xserver: Branch 'master' - 4 commits

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Apr 24 09:44:51 UTC 2024


 hw/xwayland/xwayland-drm-lease.c |   17 +++++++++++------
 hw/xwayland/xwayland-output.c    |   25 ++++++++++++++++++++++---
 hw/xwayland/xwayland-output.h    |    4 ++++
 3 files changed, 37 insertions(+), 9 deletions(-)

New commits:
commit 49b8f131f7b1df2f3c4a3bde010d67e0b448246c
Author: Olivier Fourdan <ofourdan at redhat.com>
Date:   Wed Apr 17 15:47:32 2024 +0200

    xwayland: Use the connector name for XRANDR leases
    
    Use the connector name as basis for the Xwayland output name in XRANDR,
    similar to what we do for regular outputs, instead of the generic
    "XWAYLAND<n>" name which changes every time the output is leased.
    
    Prefix the actual name with "lease-" to distinguish from duplicate names
    from the regular outputs.
    
    v2: avoid duplicate names (Simon)
    v3: Move the check for duplicates to xwl_output_set_name() (Simon)
    
    Signed-off-by: Olivier Fourdan <ofourdan at redhat.com>
    Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1492>

diff --git a/hw/xwayland/xwayland-drm-lease.c b/hw/xwayland/xwayland-drm-lease.c
index 51c92872e..4f9004d8c 100644
--- a/hw/xwayland/xwayland-drm-lease.c
+++ b/hw/xwayland/xwayland-drm-lease.c
@@ -189,7 +189,11 @@ lease_connector_handle_name(void *data,
                             struct wp_drm_lease_connector_v1 *wp_drm_lease_connector_v1,
                             const char *name)
 {
-    /* This space is deliberately left blank */
+    struct xwl_output *xwl_output = data;
+    char rr_output_name[MAX_OUTPUT_NAME] = { 0 };
+
+    snprintf(rr_output_name, MAX_OUTPUT_NAME, "lease-%s", name);
+    xwl_output_set_name(xwl_output, rr_output_name);
 }
 
 static void
@@ -347,7 +351,7 @@ drm_lease_device_handle_connector(void *data,
     struct xwl_drm_lease_device *lease_device = data;
     struct xwl_screen *xwl_screen = lease_device->xwl_screen;
     struct xwl_output *xwl_output;
-    char name[256];
+    char name[MAX_OUTPUT_NAME] = { 0 };
 
     xwl_output = calloc(1, sizeof *xwl_output);
     if (xwl_output == NULL) {
@@ -355,9 +359,6 @@ drm_lease_device_handle_connector(void *data,
         return;
     }
 
-    snprintf(name, sizeof name, "XWAYLAND%d",
-             xwl_screen_get_next_output_serial(xwl_screen));
-
     xwl_output->lease_device = lease_device;
     xwl_output->xwl_screen = xwl_screen;
     xwl_output->lease_connector = connector;
@@ -368,7 +369,11 @@ drm_lease_device_handle_connector(void *data,
     }
     RRCrtcSetRotations(xwl_output->randr_crtc, ALL_ROTATIONS);
     xwl_output->randr_output = RROutputCreate(xwl_screen->screen,
-                                              name, strlen(name), xwl_output);
+                                              name, MAX_OUTPUT_NAME, xwl_output);
+    snprintf(name, MAX_OUTPUT_NAME, "XWAYLAND%d",
+             xwl_screen_get_next_output_serial(xwl_screen));
+    xwl_output_set_name(xwl_output, name);
+
     if (!xwl_output->randr_output) {
         ErrorF("Failed creating RandR Output\n");
         goto err;
commit d36f66f15d367c86cb93605caa2a6520a2fcde46
Author: Olivier Fourdan <ofourdan at redhat.com>
Date:   Tue Apr 23 11:04:13 2024 +0200

    xwayland: Check for duplicate output names
    
    Even though the name provided by either xdg-output or wl_output are
    guaranteed to be unique, that might not be the case with output names
    between different protocols, such as the one offered for DRM lease.
    
    To avoid running into name conflicts, check that no other existing
    output of the same name exists prior to changing the output name.
    
    Signed-off-by: Olivier Fourdan <ofourdan at redhat.com>
    Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1492>

diff --git a/hw/xwayland/xwayland-output.c b/hw/xwayland/xwayland-output.c
index 2690fa0e3..7c8ebd49a 100644
--- a/hw/xwayland/xwayland-output.c
+++ b/hw/xwayland/xwayland-output.c
@@ -687,6 +687,9 @@ void
 xwl_output_set_name(struct xwl_output *xwl_output, const char *name)
 {
     struct xwl_screen *xwl_screen = xwl_output->xwl_screen;
+    rrScrPrivPtr pScrPriv;
+    RRLeasePtr lease;
+    int i;
 
     if (xwl_output->randr_output == NULL)
         return; /* rootful */
@@ -697,6 +700,24 @@ xwl_output_set_name(struct xwl_output *xwl_output, const char *name)
         return;
     }
 
+    /* Check for duplicate names to be safe */
+    pScrPriv = rrGetScrPriv(xwl_screen->screen);
+    for (i = 0; i < pScrPriv->numOutputs; i++) {
+        if (!strcmp(name, pScrPriv->outputs[i]->name)) {
+            ErrorF("An output named '%s' already exists", name);
+            return;
+        }
+    }
+    /* And leases' names as well */
+    xorg_list_for_each_entry(lease, &pScrPriv->leases, list) {
+        for (i = 0; i < lease->numOutputs; i++) {
+            if (!strcmp(name, pScrPriv->outputs[i]->name)) {
+                ErrorF("A lease output named '%s' already exists", name);
+                return;
+            }
+        }
+    }
+
     snprintf(xwl_output->randr_output->name, MAX_OUTPUT_NAME, "%s", name);
     xwl_output->randr_output->nameLength = strlen(xwl_output->randr_output->name);
 
commit 0cb4ec4dbd2ef8d94c05bd907bb3b53bdefba5f9
Author: Olivier Fourdan <ofourdan at redhat.com>
Date:   Wed Apr 17 15:40:05 2024 +0200

    xwayland: Make xwl_output_set_name() public
    
    No functional change, this is preparation work for the next commit.
    
    Signed-off-by: Olivier Fourdan <ofourdan at redhat.com>
    Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1492>

diff --git a/hw/xwayland/xwayland-output.c b/hw/xwayland/xwayland-output.c
index 95f5d983b..2690fa0e3 100644
--- a/hw/xwayland/xwayland-output.c
+++ b/hw/xwayland/xwayland-output.c
@@ -683,7 +683,7 @@ apply_output_change(struct xwl_output *xwl_output)
     maybe_update_fullscreen_state(xwl_output);
 }
 
-static void
+void
 xwl_output_set_name(struct xwl_output *xwl_output, const char *name)
 {
     struct xwl_screen *xwl_screen = xwl_output->xwl_screen;
diff --git a/hw/xwayland/xwayland-output.h b/hw/xwayland/xwayland-output.h
index 773296026..5e070f90d 100644
--- a/hw/xwayland/xwayland-output.h
+++ b/hw/xwayland/xwayland-output.h
@@ -80,6 +80,8 @@ struct xwl_emulated_mode {
 
 Bool xwl_screen_init_output(struct xwl_screen *xwl_screen);
 
+void xwl_output_set_name(struct xwl_output *xwl_output, const char *name);
+
 Bool xwl_screen_init_randr_fixed(struct xwl_screen *xwl_screen);
 
 void
commit 12265aaa1c71df104f98619b0dec96aa3ba7a48d
Author: Olivier Fourdan <ofourdan at redhat.com>
Date:   Wed Apr 17 15:36:06 2024 +0200

    xwayland: Define MAX_OUTPUT_NAME in the header
    
    So that other parts of the Xwayland code can use it.
    
    Signed-off-by: Olivier Fourdan <ofourdan at redhat.com>
    Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1492>

diff --git a/hw/xwayland/xwayland-output.c b/hw/xwayland/xwayland-output.c
index 7449ba193..95f5d983b 100644
--- a/hw/xwayland/xwayland-output.c
+++ b/hw/xwayland/xwayland-output.c
@@ -39,8 +39,6 @@
 
 #include "xdg-output-unstable-v1-client-protocol.h"
 
-#define MAX_OUTPUT_NAME 256
-
 static void xwl_output_get_xdg_output(struct xwl_output *xwl_output);
 
 static Rotation
diff --git a/hw/xwayland/xwayland-output.h b/hw/xwayland/xwayland-output.h
index 0e5ee6b55..773296026 100644
--- a/hw/xwayland/xwayland-output.h
+++ b/hw/xwayland/xwayland-output.h
@@ -43,6 +43,8 @@
                        RR_Reflect_X  | \
                        RR_Reflect_Y)
 
+#define MAX_OUTPUT_NAME 256
+
 struct xwl_output {
     struct xorg_list link;
     struct xwl_screen *xwl_screen;


More information about the xorg-commit mailing list