xserver: Branch 'master' - 10 commits

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Thu Jan 11 08:48:37 UTC 2024


 hw/xwayland/man/Xwayland.man  |   12 ++++
 hw/xwayland/xwayland-output.c |  115 +++++++++++++++++++++++++++++-------------
 hw/xwayland/xwayland-output.h |    4 +
 hw/xwayland/xwayland-screen.c |    4 +
 hw/xwayland/xwayland-screen.h |    1 
 hw/xwayland/xwayland-window.c |    5 +
 hw/xwayland/xwayland.c        |    5 +
 7 files changed, 109 insertions(+), 37 deletions(-)

New commits:
commit 4805d901c3064c4bd8570826c3e95cb8d1af2196
Author: Olivier Fourdan <ofourdan at redhat.com>
Date:   Mon Dec 4 16:31:14 2023 +0100

    xwayland: Add the output name for fullscreen rootful
    
    This adds a new command line option "-output" to specify on which output
    Xwayland should be starting fullscreen when rootful.
    
    That allows to run multiple instances of Xwayland rootful fullscreen on
    multiple outputs.
    
    Signed-off-by: Olivier Fourdan <ofourdan at redhat.com>
    Acked-by: Michel Dänzer <mdaenzer at redhat.com>

diff --git a/hw/xwayland/man/Xwayland.man b/hw/xwayland/man/Xwayland.man
index 26b554be8..62ace369a 100644
--- a/hw/xwayland/man/Xwayland.man
+++ b/hw/xwayland/man/Xwayland.man
@@ -124,6 +124,16 @@ support touch input.
 Force additional non-native modes to be exposed when viewporter is not
 supported by the Wayland compositor.
 .TP 8
+.B \-output \fIname\fP
+Specifies on which output \fIXwayland\fP fullscreen rootful should be placed.
+The name must match the name of an existing Wayland output (output names can
+be found using wayland-info).
+
+If no matching output can be found, the Wayland compositor will decide on which
+output the fullscreen rootful \fIXwayland\fP window will be placed.
+
+This option has no effect if \fIXwayland\fP is not running fullscreen rootful.
+.TP 8
 .B \-rootless
 Run \fIXwayland\fP rootless, so that X clients integrate seamlessly with
 Wayland clients in a Wayland desktop. That requires the Wayland server
@@ -159,4 +169,4 @@ the name of the display of the Wayland server.
 .B XWAYLAND_NO_GLAMOR
 disable glamor and DRI3 support in \fIXwayland\fP, for testing purposes.
 .SH "SEE ALSO"
-General information: \fIX\fP(@miscmansuffix@)
+General information: \fIX\fP(@miscmansuffix@), \fIwayland-info\fP(@miscmansuffix@)
diff --git a/hw/xwayland/xwayland-screen.c b/hw/xwayland/xwayland-screen.c
index 099207855..22afd4e94 100644
--- a/hw/xwayland/xwayland-screen.c
+++ b/hw/xwayland/xwayland-screen.c
@@ -253,6 +253,7 @@ xwl_close_screen(ScreenPtr screen)
     wl_display_disconnect(xwl_screen->display);
 
     screen->CloseScreen = xwl_screen->CloseScreen;
+
     free(xwl_screen);
 
     return screen->CloseScreen(screen);
@@ -846,6 +847,9 @@ xwl_screen_init(ScreenPtr pScreen, int argc, char **argv)
             use_fixed_size = 1;
             xwl_screen->fullscreen = 1;
         }
+        else if (strcmp(argv[i], "-output") == 0) {
+            xwl_screen->output_name = argv[i + 1];
+        }
         else if (strcmp(argv[i], "-host-grab") == 0) {
             xwl_screen->host_grab = 1;
             xwl_screen->has_grab = 1;
diff --git a/hw/xwayland/xwayland.c b/hw/xwayland/xwayland.c
index 6ec573674..2aa9893a1 100644
--- a/hw/xwayland/xwayland.c
+++ b/hw/xwayland/xwayland.c
@@ -94,6 +94,7 @@ ddxUseMsg(void)
     ErrorF("-fullscreen            run fullscreen when rootful\n");
     ErrorF("-geometry WxH          set Xwayland window size when rootful\n");
     ErrorF("-host-grab             disable host keyboard shortcuts when rootful\n");
+    ErrorF("-output                specify which output to use for fullscreen when rootful\n");
     ErrorF("-wm fd                 create X client for wm on given fd\n");
     ErrorF("-initfd fd             add given fd as a listen socket for initialization clients\n");
     ErrorF("-listenfd fd           add given fd as a listen socket\n");
@@ -262,6 +263,10 @@ ddxProcessArgument(int argc, char *argv[], int i)
     else if (strcmp(argv[i], "-enable-ei-portal") == 0) {
         return 1;
     }
+    else if (strcmp(argv[i], "-output") == 0) {
+        CHECK_FOR_REQUIRED_ARGUMENTS(1);
+        return 2;
+    }
 
     return 0;
 }
commit 87ca6dcb43a179838784d5fede94824b2b7f3a3a
Author: Olivier Fourdan <ofourdan at redhat.com>
Date:   Mon Dec 4 16:28:31 2023 +0100

    xwayland: Check for the screen output name for fullscreen
    
    When putting the (root) window fullscreen, first search for an output
    with the specified name, if any.
    
    Signed-off-by: Olivier Fourdan <ofourdan at redhat.com>
    Acked-by: Michel Dänzer <mdaenzer at redhat.com>

diff --git a/hw/xwayland/xwayland-window.c b/hw/xwayland/xwayland-window.c
index a6a4cf8f5..aaeeace68 100644
--- a/hw/xwayland/xwayland-window.c
+++ b/hw/xwayland/xwayland-window.c
@@ -319,8 +319,11 @@ xwl_window_get_output(struct xwl_window *xwl_window)
     struct xwl_screen *xwl_screen = xwl_window->xwl_screen;
     struct xwl_output *xwl_output;
 
-    xwl_output = xwl_output_from_wl_output(xwl_screen, xwl_window->wl_output);
+    xwl_output = xwl_output_get_output_from_name(xwl_screen, xwl_screen->output_name);
+    if (xwl_output)
+        return xwl_output;
 
+    xwl_output = xwl_output_from_wl_output(xwl_screen, xwl_window->wl_output);
     if (xwl_output)
         return xwl_output;
 
commit 2e317e0242852f6476ecfeb364c6b823969c59e2
Author: Olivier Fourdan <ofourdan at redhat.com>
Date:   Mon Dec 4 16:43:53 2023 +0100

    xwayland: Check for fullscreen on output name change
    
    At startup, the names of the Wayland outputs are not yet known,
    therefore we cannot rely on those when running fullscreen rootful.
    
    Make sure to check the fullscreen state once the Wayland output name
    changes.
    
    Signed-off-by: Olivier Fourdan <ofourdan at redhat.com>
    Acked-by: Michel Dänzer <mdaenzer at redhat.com>

diff --git a/hw/xwayland/xwayland-output.c b/hw/xwayland/xwayland-output.c
index 8f063169e..25559d0e1 100644
--- a/hw/xwayland/xwayland-output.c
+++ b/hw/xwayland/xwayland-output.c
@@ -681,6 +681,8 @@ apply_output_change(struct xwl_output *xwl_output)
 static void
 xwl_output_set_name(struct xwl_output *xwl_output, const char *name)
 {
+    struct xwl_screen *xwl_screen = xwl_output->xwl_screen;
+
     if (xwl_output->randr_output == NULL)
         return; /* rootful */
 
@@ -692,6 +694,9 @@ xwl_output_set_name(struct xwl_output *xwl_output, const char *name)
 
     snprintf(xwl_output->randr_output->name, MAX_OUTPUT_NAME, "%s", name);
     xwl_output->randr_output->nameLength = strlen(xwl_output->randr_output->name);
+
+    if (xwl_screen->output_name && strcmp(name, xwl_screen->output_name) == 0)
+        maybe_update_fullscreen_state(xwl_output);
 }
 
 static void
commit 01e31f5d95c88bb554cdb5afeb32af8b1dc1df0c
Author: Olivier Fourdan <ofourdan at redhat.com>
Date:   Mon Dec 4 16:24:06 2023 +0100

    xwayland: Add an output name for fullscreen
    
    Add a output name to the xwl_screen.
    
    This is preparation work for fullscreen rootful on a specific output,
    no functional change.
    
    Signed-off-by: Olivier Fourdan <ofourdan at redhat.com>
    Acked-by: Michel Dänzer <mdaenzer at redhat.com>

diff --git a/hw/xwayland/xwayland-screen.h b/hw/xwayland/xwayland-screen.h
index 9eaac16db..92688a7e0 100644
--- a/hw/xwayland/xwayland-screen.h
+++ b/hw/xwayland/xwayland-screen.h
@@ -145,6 +145,7 @@ struct xwl_screen {
     int libdecor_fd;
     struct libdecor *libdecor_context;
 #endif
+    const char *output_name;
 };
 
 /* Apps which use randr/vidmode to change the mode when going fullscreen,
commit d99e98ad68bf696bf508237e11c088429a154a66
Author: Olivier Fourdan <ofourdan at redhat.com>
Date:   Mon Dec 4 16:26:14 2023 +0100

    xwayland: Add a function to search for xwl_output by name
    
    Add a convenient function to search for an xwl_output based on its
    XRandR name.
    
    Signed-off-by: Olivier Fourdan <ofourdan at redhat.com>
    Acked-by: Michel Dänzer <mdaenzer at redhat.com>

diff --git a/hw/xwayland/xwayland-output.c b/hw/xwayland/xwayland-output.c
index 6699bdb8f..8f063169e 100644
--- a/hw/xwayland/xwayland-output.c
+++ b/hw/xwayland/xwayland-output.c
@@ -838,6 +838,27 @@ xwl_output_from_wl_output(struct xwl_screen *xwl_screen,
     return NULL;
 }
 
+
+struct xwl_output *
+xwl_output_get_output_from_name(struct xwl_screen *xwl_screen, const char *name)
+{
+    struct xwl_output *xwl_output;
+
+    if (name == NULL)
+        return NULL;
+
+    xorg_list_for_each_entry(xwl_output, &xwl_screen->output_list, link) {
+        if (xwl_output->randr_output == NULL)
+            continue;
+
+        if (strcmp(xwl_output->randr_output->name, name) == 0) {
+            return xwl_output;
+        }
+    }
+
+    return NULL;
+}
+
 struct xwl_output *
 xwl_output_create(struct xwl_screen *xwl_screen, uint32_t id,
                   Bool connected, uint32_t version)
diff --git a/hw/xwayland/xwayland-output.h b/hw/xwayland/xwayland-output.h
index fd3179db0..24b118dfd 100644
--- a/hw/xwayland/xwayland-output.h
+++ b/hw/xwayland/xwayland-output.h
@@ -86,6 +86,8 @@ void xwl_output_set_mode_fixed(struct xwl_output *xwl_output,
 
 struct xwl_output *xwl_output_from_wl_output(struct xwl_screen *xwl_screen,
                                              struct wl_output* wl_output);
+struct xwl_output *xwl_output_get_output_from_name(struct xwl_screen *xwl_screen,
+                                                   const char *name);
 
 struct xwl_output *xwl_output_create(struct xwl_screen *xwl_screen,
                                      uint32_t id, Bool connected,
commit 0fede76cc387252347d6e098e59e9708ed623140
Author: Olivier Fourdan <ofourdan at redhat.com>
Date:   Mon Dec 11 16:49:16 2023 +0100

    xwayland: Do not update the outputs when rootful
    
    When running rootful, we do not need to apply the output changes, these
    are there just to track the names and show up as disconnected in XRandR.
    
    Signed-off-by: Olivier Fourdan <ofourdan at redhat.com>
    Acked-by: Michel Dänzer <mdaenzer at redhat.com>

diff --git a/hw/xwayland/xwayland-output.c b/hw/xwayland/xwayland-output.c
index 60a997d76..6699bdb8f 100644
--- a/hw/xwayland/xwayland-output.c
+++ b/hw/xwayland/xwayland-output.c
@@ -698,8 +698,12 @@ static void
 output_handle_done(void *data, struct wl_output *wl_output)
 {
     struct xwl_output *xwl_output = data;
+    struct xwl_screen *xwl_screen = xwl_output->xwl_screen;
 
     xwl_output->wl_output_done = TRUE;
+    if (xwl_screen->fixed_output)
+        return;
+
     /* Apply the changes from wl_output only if both "done" events are received,
      * if xdg-output is not supported or if xdg-output version is high enough.
      */
@@ -761,8 +765,13 @@ static void
 xdg_output_handle_done(void *data, struct zxdg_output_v1 *xdg_output)
 {
     struct xwl_output *xwl_output = data;
+    struct xwl_screen *xwl_screen = xwl_output->xwl_screen;
 
     xwl_output->xdg_output_done = TRUE;
+
+    if (xwl_screen->fixed_output)
+        return;
+
     if (xwl_output->wl_output_done &&
         zxdg_output_v1_get_version(xdg_output) < 3)
         apply_output_change(xwl_output);
commit 060f1f1154aa094219e541cc3621245b9c2440f6
Author: Olivier Fourdan <ofourdan at redhat.com>
Date:   Mon Dec 4 16:16:16 2023 +0100

    xwayland: Always create the XrandR CRTCs
    
    When running rootful, Xwayland would simply skip the creation of the CRTC
    for the "real" outputs.
    
    Instead, create the CRTC regardless of all outputs in rootful mode, but
    mark them as disconnected when running rootful.
    
    Signed-off-by: Olivier Fourdan <ofourdan at redhat.com>
    Acked-by: Michel Dänzer <mdaenzer at redhat.com>

diff --git a/hw/xwayland/xwayland-output.c b/hw/xwayland/xwayland-output.c
index 923745144..60a997d76 100644
--- a/hw/xwayland/xwayland-output.c
+++ b/hw/xwayland/xwayland-output.c
@@ -831,7 +831,7 @@ xwl_output_from_wl_output(struct xwl_screen *xwl_screen,
 
 struct xwl_output *
 xwl_output_create(struct xwl_screen *xwl_screen, uint32_t id,
-                  Bool with_xrandr, uint32_t version)
+                  Bool connected, uint32_t version)
 {
     struct xwl_output *xwl_output;
     char name[MAX_OUTPUT_NAME] = { 0 };
@@ -854,31 +854,31 @@ xwl_output_create(struct xwl_screen *xwl_screen, uint32_t id,
 
     xwl_output->xwl_screen = xwl_screen;
 
-    if (with_xrandr) {
-        xwl_output->randr_crtc = RRCrtcCreate(xwl_screen->screen, xwl_output);
-        if (!xwl_output->randr_crtc) {
-            ErrorF("Failed creating RandR CRTC\n");
-            goto err;
-        }
-        RRCrtcSetRotations (xwl_output->randr_crtc, ALL_ROTATIONS);
+    xwl_output->randr_crtc = RRCrtcCreate(xwl_screen->screen, xwl_output);
+    if (!xwl_output->randr_crtc) {
+        ErrorF("Failed creating RandR CRTC\n");
+        goto err;
+    }
+    RRCrtcSetRotations (xwl_output->randr_crtc, ALL_ROTATIONS);
 
-        /* Allocate MAX_OUTPUT_NAME data for the output name, all filled with zeros */
-        xwl_output->randr_output = RROutputCreate(xwl_screen->screen, name,
-                                                  MAX_OUTPUT_NAME, xwl_output);
-        if (!xwl_output->randr_output) {
-            ErrorF("Failed creating RandR Output\n");
-            goto err;
-        }
-        /* Set the default output name to a sensible value */
-        snprintf(name, MAX_OUTPUT_NAME, "XWAYLAND%d",
-                 xwl_screen_get_next_output_serial(xwl_screen));
-        xwl_output_set_name(xwl_output, name);
-        xwl_output_set_emulated(xwl_output);
-
-        RRCrtcGammaSetSize(xwl_output->randr_crtc, 256);
-        RROutputSetCrtcs(xwl_output->randr_output, &xwl_output->randr_crtc, 1);
-        RROutputSetConnection(xwl_output->randr_output, RR_Connected);
+    /* Allocate MAX_OUTPUT_NAME data for the output name, all filled with zeros */
+    xwl_output->randr_output = RROutputCreate(xwl_screen->screen, name,
+                                              MAX_OUTPUT_NAME, xwl_output);
+    if (!xwl_output->randr_output) {
+        ErrorF("Failed creating RandR Output\n");
+        goto err;
     }
+    /* Set the default output name to a sensible value */
+    snprintf(name, MAX_OUTPUT_NAME, "XWAYLAND%d",
+             xwl_screen_get_next_output_serial(xwl_screen));
+    xwl_output_set_name(xwl_output, name);
+    xwl_output_set_emulated(xwl_output);
+
+    RRCrtcGammaSetSize(xwl_output->randr_crtc, 256);
+    RROutputSetCrtcs(xwl_output->randr_output, &xwl_output->randr_crtc, 1);
+    RROutputSetConnection(xwl_output->randr_output,
+                          connected ? RR_Connected : RR_Disconnected);
+
     /* We want the output to be in the list as soon as created so we can
      * use it when binding to the xdg-output protocol...
      */
diff --git a/hw/xwayland/xwayland-output.h b/hw/xwayland/xwayland-output.h
index bcdf25bec..fd3179db0 100644
--- a/hw/xwayland/xwayland-output.h
+++ b/hw/xwayland/xwayland-output.h
@@ -88,7 +88,7 @@ struct xwl_output *xwl_output_from_wl_output(struct xwl_screen *xwl_screen,
                                              struct wl_output* wl_output);
 
 struct xwl_output *xwl_output_create(struct xwl_screen *xwl_screen,
-                                     uint32_t id, Bool with_xrandr,
+                                     uint32_t id, Bool connected,
                                      uint32_t version);
 
 void xwl_output_destroy(struct xwl_output *xwl_output);
commit f0124485e10848a8b6e8e5834bef2c2da3fb8e37
Author: Olivier Fourdan <ofourdan at redhat.com>
Date:   Mon Dec 4 16:12:08 2023 +0100

    xwayland: Use the output serial for the fixed output
    
    The fixed output is called "XWAYLAND0", yet if the compositor does not
    support Wayland output names, the "real" output names may collide with
    the fixed output name.
    
    Use the same output serial as with the (default) real output names to
    avoid reusing the same names.
    
    Signed-off-by: Olivier Fourdan <ofourdan at redhat.com>
    Acked-by: Michel Dänzer <mdaenzer at redhat.com>

diff --git a/hw/xwayland/xwayland-output.c b/hw/xwayland/xwayland-output.c
index 890dd7418..923745144 100644
--- a/hw/xwayland/xwayland-output.c
+++ b/hw/xwayland/xwayland-output.c
@@ -1174,6 +1174,7 @@ Bool
 xwl_screen_init_randr_fixed(struct xwl_screen *xwl_screen)
 {
     struct xwl_output *xwl_output;
+    char name[MAX_OUTPUT_NAME] = { 0 };
     rrScrPrivPtr rp;
     RRModePtr mode;
 
@@ -1192,7 +1193,10 @@ xwl_screen_init_randr_fixed(struct xwl_screen *xwl_screen)
     rp->rrGetInfo = xwl_randr_get_info;
     rp->rrSetConfig = xwl_randr_set_config_fixed;
 
-    xwl_output->randr_output = RROutputCreate(xwl_screen->screen, "XWAYLAND0", 9, NULL);
+    snprintf(name, MAX_OUTPUT_NAME, "XWAYLAND%d",
+             xwl_screen_get_next_output_serial(xwl_screen));
+    xwl_output->randr_output = RROutputCreate(xwl_screen->screen, name,
+                                              strlen(name), NULL);
     if (!xwl_output->randr_output) {
         ErrorF("Failed to create RandR output\n");
         goto err;
commit a6bbc9663d33abe1868315a947310f90fb853a5b
Author: Olivier Fourdan <ofourdan at redhat.com>
Date:   Tue Dec 5 09:57:57 2023 +0100

    xwayland: Use simpler initialization syntax
    
    Use the simpler form `{ 0 }` instead of `{ '\0', }` for the
    initialization of the output name buffer.
    
    No functional change.
    
    Signed-off-by: Olivier Fourdan <ofourdan at redhat.com>
    Acked-by: Michel Dänzer <mdaenzer at redhat.com>

diff --git a/hw/xwayland/xwayland-output.c b/hw/xwayland/xwayland-output.c
index c9ff5087d..890dd7418 100644
--- a/hw/xwayland/xwayland-output.c
+++ b/hw/xwayland/xwayland-output.c
@@ -834,7 +834,7 @@ xwl_output_create(struct xwl_screen *xwl_screen, uint32_t id,
                   Bool with_xrandr, uint32_t version)
 {
     struct xwl_output *xwl_output;
-    char name[MAX_OUTPUT_NAME] = { '\0', };
+    char name[MAX_OUTPUT_NAME] = { 0 };
 
     xwl_output = calloc(1, sizeof *xwl_output);
     if (xwl_output == NULL) {
commit e1e3bef7f86020d2c157648966c1f65153019dd8
Author: Olivier Fourdan <ofourdan at redhat.com>
Date:   Mon Dec 4 16:10:07 2023 +0100

    xwayland: Use a helper function for fullscreen update
    
    Move the code which may update the fullscreen state of the rootful
    window to a dedicated helper function.
    
    No functional change.
    
    Signed-off-by: Olivier Fourdan <ofourdan at redhat.com>
    Acked-by: Michel Dänzer <mdaenzer at redhat.com>

diff --git a/hw/xwayland/xwayland-output.c b/hw/xwayland/xwayland-output.c
index cf99c6e84..c9ff5087d 100644
--- a/hw/xwayland/xwayland-output.c
+++ b/hw/xwayland/xwayland-output.c
@@ -598,10 +598,24 @@ xwl_output_set_emulated_mode(struct xwl_output *xwl_output, ClientPtr client,
 }
 
 static void
-apply_output_change(struct xwl_output *xwl_output)
+maybe_update_fullscreen_state(struct xwl_output *xwl_output)
 {
     struct xwl_screen *xwl_screen = xwl_output->xwl_screen;
     struct xwl_window *xwl_window;
+
+    if (xwl_screen->fullscreen) {
+        /* The root window may not yet be created */
+        if (xwl_screen->screen->root) {
+            xwl_window = xwl_window_get(xwl_screen->screen->root);
+            xwl_window_rootful_update_fullscreen(xwl_window, xwl_output);
+        }
+    }
+}
+
+static void
+apply_output_change(struct xwl_output *xwl_output)
+{
+    struct xwl_screen *xwl_screen = xwl_output->xwl_screen;
     struct xwl_output *it;
     int mode_width, mode_height, count;
     int width = 0, height = 0, has_this_output = 0;
@@ -661,13 +675,7 @@ apply_output_change(struct xwl_output *xwl_output)
         RRTellChanged(xwl_screen->screen);
 
     /* If running rootful and fullscreen, make sure to match the new setup */
-    if (xwl_screen->fullscreen) {
-        /* The root window may not yet be created */
-        if (xwl_screen->screen->root) {
-            xwl_window = xwl_window_get(xwl_screen->screen->root);
-            xwl_window_rootful_update_fullscreen(xwl_window, xwl_output);
-        }
-    }
+    maybe_update_fullscreen_state(xwl_output);
 }
 
 static void


More information about the xorg-commit mailing list