xserver: Branch 'xwayland-22.1' - 3 commits

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed May 25 08:22:35 UTC 2022


 hw/xwayland/xwayland-drm-lease.c |    3 ++-
 hw/xwayland/xwayland-output.c    |   26 ++++++++++++++++++++++++++
 randr/rrcrtc.c                   |   27 ++++++++++++++++++++++++---
 3 files changed, 52 insertions(+), 4 deletions(-)

New commits:
commit cae60591d2f2e82732fd8e116cd109ab6c568fd5
Author: Olivier Fourdan <ofourdan at redhat.com>
Date:   Mon Apr 4 14:28:15 2022 +0200

    xwayland/output: Set the "RANDR Emulation" property
    
    Xwayland does not change the actual XRANDR setup for real, it just
    emulates the resolution changes using viewports in Wayland.
    
    With a single output, if an X11 applications tries to change the CRTC
    back to the native mode, RRCrtcSet() will simply ignore the request as
    no actual change is induced by this.
    
    Set the property "RANDR Emulation" on all Xwayland outputs to make sure
    the optimizations in RRCrtcSet() get skipped and Xwayland can receive
    and act upon the client request.
    
    Also make sure we do not allow that property to be changed by X11
    clients.
    
    v2: Prevent X11 clients from changing the property value
        (Pekka Paalanen <pekka.paalanen at collabora.com>)
    
    Signed-off-by: Olivier Fourdan <ofourdan at redhat.com>
    Reviewed-by: Hans de Goede <hdegoede at redhat.com>
    Closes: https://gitlab.freedesktop.org/xorg/xserver/-/issues/1305
    (cherry picked from commit 7b7170ecd636ae1110622e2430549f79598750ca)

diff --git a/hw/xwayland/xwayland-output.c b/hw/xwayland/xwayland-output.c
index d2fa4e0bb..3ad8adc8b 100644
--- a/hw/xwayland/xwayland-output.c
+++ b/hw/xwayland/xwayland-output.c
@@ -720,6 +720,27 @@ static const struct zxdg_output_v1_listener xdg_output_listener = {
     xdg_output_handle_description,
 };
 
+#define XRANDR_EMULATION_PROP "RANDR Emulation"
+static Atom
+get_rand_emulation_property(void)
+{
+    const char *emulStr = XRANDR_EMULATION_PROP;
+
+    return MakeAtom(emulStr, strlen(emulStr), TRUE);
+}
+
+static void
+xwl_output_set_emulated(struct xwl_output *xwl_output)
+{
+    int32_t val = TRUE;
+
+    RRChangeOutputProperty(xwl_output->randr_output,
+                           get_rand_emulation_property(),
+                           XA_INTEGER,
+                           32, PropModeReplace, 1,
+                           &val, FALSE, FALSE);
+}
+
 struct xwl_output *
 xwl_output_create(struct xwl_screen *xwl_screen, uint32_t id)
 {
@@ -758,6 +779,7 @@ xwl_output_create(struct xwl_screen *xwl_screen, uint32_t id)
         ErrorF("Failed creating RandR Output\n");
         goto err;
     }
+    xwl_output_set_emulated(xwl_output);
 
     RRCrtcGammaSetSize(xwl_output->randr_crtc, 256);
     RROutputSetCrtcs(xwl_output->randr_output, &xwl_output->randr_crtc, 1);
@@ -896,6 +918,10 @@ xwl_randr_output_set_property(ScreenPtr pScreen,
                               Atom property,
                               RRPropertyValuePtr value)
 {
+    /* RANDR Emulation property is read-only. */
+    if (get_rand_emulation_property() == property)
+        return FALSE;
+
     return TRUE;
 }
 
commit 8ddac82f214a17382eb0824c4c8b875a81253441
Author: Olivier Fourdan <ofourdan at redhat.com>
Date:   Mon Apr 4 14:22:20 2022 +0200

    randr: Add "RANDR Emulation" property
    
    When RANDR is emulated as with Xwayland, the actual output configuration
    does not change as RANDR is emulated using viewports.
    
    As a result, changes to the CRTC may be skipped, resulting in the
    configuration being (wrongly) assumed to be unchanged.
    
    Add a new output property "RANDR Emulation" that the DDX can set to
    force RRCrtcSet() to reconfigure the CRTC regardless of the change.
    
    Signed-off-by: Olivier Fourdan <ofourdan at redhat.com>
    Reviewed-by: Hans de Goede <hdegoede at redhat.com>
    (cherry picked from commit 0904421f57a6e3c1889cda145ec318c7071a3ee0)

diff --git a/randr/rrcrtc.c b/randr/rrcrtc.c
index 3a9b620ab..e64f03131 100644
--- a/randr/rrcrtc.c
+++ b/randr/rrcrtc.c
@@ -717,6 +717,25 @@ rrCheckPixmapBounding(ScreenPtr pScreen,
     return TRUE;
 }
 
+#define XRANDR_EMULATION_PROP "RANDR Emulation"
+static Bool
+rrCheckEmulated(RROutputPtr output)
+{
+    const char *emulStr = XRANDR_EMULATION_PROP;
+    Atom emulProp;
+    RRPropertyValuePtr val;
+
+    emulProp = MakeAtom(emulStr, strlen(emulStr), FALSE);
+    if (emulProp == None)
+        return FALSE;
+
+    val = RRGetOutputProperty(output, emulProp, TRUE);
+    if (val && val->data)
+        return !!val->data;
+
+    return FALSE;
+}
+
 /*
  * Request that the Crtc be reconfigured
  */
@@ -736,9 +755,11 @@ RRCrtcSet(RRCrtcPtr crtc,
 
     crtcChanged = FALSE;
     for (o = 0; o < numOutputs; o++) {
-        if (outputs[o] && outputs[o]->crtc != crtc) {
-            crtcChanged = TRUE;
-            break;
+        if (outputs[o]) {
+            if (rrCheckEmulated(outputs[o]) || (outputs[o]->crtc != crtc)) {
+                crtcChanged = TRUE;
+                break;
+            }
         }
     }
 
commit 7de3d8573e0f91105baec598337904d75c76e34b
Author: Weng Xuetian <wengxt at gmail.com>
Date:   Sat Apr 16 01:40:45 2022 -0700

    xwayland: Fix invalid pointer access in drm_lease_device_handle_released.
    
    drm_lease_device_handle_released uses the wrong pointer type in the
    callback. This will cause crash when compositor removes drm lease device
    object.
    
    Fixes: 089e7f98f - Xwayland: implement drm-lease-v1
    
    Reviewed-by: Olivier Fourdan <ofourdan at redhat.com>
    Signed-off-by: Weng Xuetian <wengxt at gmail.com>
    (cherry picked from commit 479c8aae8e6e6059f77be8de79726e7f6eac61a9)

diff --git a/hw/xwayland/xwayland-drm-lease.c b/hw/xwayland/xwayland-drm-lease.c
index 656e6a62d..8bbb27e70 100644
--- a/hw/xwayland/xwayland-drm-lease.c
+++ b/hw/xwayland/xwayland-drm-lease.c
@@ -386,7 +386,8 @@ static void
 drm_lease_device_handle_released(void *data,
                                  struct wp_drm_lease_device_v1 *wp_drm_lease_device_v1)
 {
-    xwl_screen_destroy_drm_lease_device(data, wp_drm_lease_device_v1);
+    struct xwl_drm_lease_device *lease_device = data;
+    xwl_screen_destroy_drm_lease_device(lease_device->xwl_screen, wp_drm_lease_device_v1);
 }
 
 static void


More information about the xorg-commit mailing list