xserver: Branch 'master' - 8 commits

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Thu Jul 27 08:49:07 UTC 2023


 hw/xwayland/xwayland-screen.c |    1 
 hw/xwayland/xwayland-window.c |   87 +++++++++++++++++++++++++++++-------------
 2 files changed, 63 insertions(+), 25 deletions(-)

New commits:
commit 34446a99528a9c2ee1cc5e83118e5d0c58795b31
Author: Olivier Fourdan <ofourdan at redhat.com>
Date:   Tue Jul 25 16:25:29 2023 +0200

    xwayland: Make fullscreen used a fixed size
    
    Similar to commit 94deed272 - " xwayland: Use sensible defaults for
    rootful size", mark fullscreen mode as fixed so that the actual monitor
    layout is not reflected in the single fullscreen rootful window.
    
    Without this, if "-fullscreen" is used without "-geometry", the XRandR
    configuration is taken from the compositor via wl_output/xdg-output and
    cannot be changed by the X11 clients.
    
    Signed-off-by: Olivier Fourdan <ofourdan at redhat.com>
    Reviewed-by: Michel Dänzer <mdaenzer at redhat.com>

diff --git a/hw/xwayland/xwayland-screen.c b/hw/xwayland/xwayland-screen.c
index 37ee7da0f..6b57fbe9d 100644
--- a/hw/xwayland/xwayland-screen.c
+++ b/hw/xwayland/xwayland-screen.c
@@ -799,6 +799,7 @@ xwl_screen_init(ScreenPtr pScreen, int argc, char **argv)
             use_fixed_size = 1;
         }
         else if (strcmp(argv[i], "-fullscreen") == 0) {
+            use_fixed_size = 1;
             xwl_screen->fullscreen = 1;
         }
         else if (strcmp(argv[i], "-host-grab") == 0) {
commit 881e1a569393aae3010a17079567be47c70d259e
Author: Olivier Fourdan <ofourdan at redhat.com>
Date:   Mon Jul 24 17:39:51 2023 +0200

    xwayland: Set min/max size for rootful with lidecor
    
    Enforce sensible min/max values for the window size when using libdecor.
    
    Signed-off-by: Olivier Fourdan <ofourdan at redhat.com>
    Reviewed-by: Michel Dänzer <mdaenzer at redhat.com>

diff --git a/hw/xwayland/xwayland-window.c b/hw/xwayland/xwayland-window.c
index 1766c48af..f1d6580e6 100644
--- a/hw/xwayland/xwayland-window.c
+++ b/hw/xwayland/xwayland-window.c
@@ -53,6 +53,11 @@
 
 #define DELAYED_WL_SURFACE_DESTROY 1000 /* ms */
 
+#define MAX_ROOTFUL_WIDTH 32767
+#define MAX_ROOTFUL_HEIGHT 32767
+#define MIN_ROOTFUL_WIDTH 320
+#define MIN_ROOTFUL_HEIGHT 200
+
 static DevPrivateKeyRec xwl_window_private_key;
 static DevPrivateKeyRec xwl_damage_private_key;
 static const char *xwl_surface_tag = "xwl-surface";
@@ -604,6 +609,15 @@ xwl_window_rootful_set_app_id(struct xwl_window *xwl_window)
 }
 
 #ifdef XWL_HAS_LIBDECOR
+static void
+xwl_window_libdecor_set_size_limits(struct xwl_window *xwl_window)
+{
+    libdecor_frame_set_min_content_size(xwl_window->libdecor_frame,
+                                        MIN_ROOTFUL_WIDTH, MIN_ROOTFUL_HEIGHT);
+    libdecor_frame_set_max_content_size(xwl_window->libdecor_frame,
+                                        MAX_ROOTFUL_WIDTH, MAX_ROOTFUL_HEIGHT);
+}
+
 static void
 xwl_window_update_libdecor_size(struct xwl_window *xwl_window,
                                 struct libdecor_configuration *configuration /* nullable */,
@@ -649,6 +663,9 @@ handle_libdecor_configure(struct libdecor_frame *frame,
         width = xwl_screen->width;
         height = xwl_screen->height;
     }
+    /* Clamp the size */
+    width = min(max(width, MIN_ROOTFUL_WIDTH), MAX_ROOTFUL_WIDTH);
+    height = min(max(height, MIN_ROOTFUL_HEIGHT), MAX_ROOTFUL_HEIGHT) ;
 
     if (xwl_screen->width != width || xwl_screen->height != height)
         xwl_window_libdecor_resize(xwl_window, width, height);
@@ -776,6 +793,7 @@ xwl_create_root_surface(struct xwl_window *xwl_window)
                               xwl_window->surface,
                               &libdecor_frame_iface,
                               xwl_window);
+        xwl_window_libdecor_set_size_limits(xwl_window);
         libdecor_frame_map(xwl_window->libdecor_frame);
     }
     else
@@ -808,7 +826,6 @@ xwl_create_root_surface(struct xwl_window *xwl_window)
 
     xwl_window_rootful_update_title(xwl_window);
     xwl_window_rootful_set_app_id(xwl_window);
-
     wl_surface_commit(xwl_window->surface);
 
     region = wl_compositor_create_region(xwl_screen->compositor);
commit f19fe9d260cfc3e4e2991393bf9339caba8b7a5a
Author: Olivier Fourdan <ofourdan at redhat.com>
Date:   Wed Jul 26 09:36:17 2023 +0200

    xwayland: Use update size from libdecor configure handler
    
    This is to avoid repeating the same code in two places.
    
    This is essentially a cosmetic change, not a functional change.
    
    Signed-off-by: Olivier Fourdan <ofourdan at redhat.com>
    Reviewed-by: Michel Dänzer <mdaenzer at redhat.com>

diff --git a/hw/xwayland/xwayland-window.c b/hw/xwayland/xwayland-window.c
index 985b0f14a..1766c48af 100644
--- a/hw/xwayland/xwayland-window.c
+++ b/hw/xwayland/xwayland-window.c
@@ -643,7 +643,6 @@ handle_libdecor_configure(struct libdecor_frame *frame,
 {
     struct xwl_window *xwl_window = data;
     struct xwl_screen *xwl_screen = xwl_window->xwl_screen;
-    struct libdecor_state *state;
     int width, height;
 
     if (!libdecor_configuration_get_content_size(configuration, frame, &width, &height)) {
@@ -654,9 +653,8 @@ handle_libdecor_configure(struct libdecor_frame *frame,
     if (xwl_screen->width != width || xwl_screen->height != height)
         xwl_window_libdecor_resize(xwl_window, width, height);
 
-    state = libdecor_state_new(xwl_screen->width, xwl_screen->height);
-    libdecor_frame_commit(frame, state, configuration);
-    libdecor_state_free(state);
+    xwl_window_update_libdecor_size(xwl_window, configuration,
+                                    xwl_screen->width, xwl_screen->height);
 }
 
 static void
commit c180eca8ef71e42a9bea23ae276c24d97caf4577
Author: Olivier Fourdan <ofourdan at redhat.com>
Date:   Wed Jul 26 09:34:18 2023 +0200

    xwayland: Add configuration to libdecor update size
    
    Allow passing an optional libdecor configuration pointer to
    xwl_window_update_libdecor_size() so that we can reuse it from more than
    one place and avoid duplicating that code.
    
    No functional change.
    
    Signed-off-by: Olivier Fourdan <ofourdan at redhat.com>
    Reviewed-by: Michel Dänzer <mdaenzer at redhat.com>

diff --git a/hw/xwayland/xwayland-window.c b/hw/xwayland/xwayland-window.c
index 0951e47cd..985b0f14a 100644
--- a/hw/xwayland/xwayland-window.c
+++ b/hw/xwayland/xwayland-window.c
@@ -605,13 +605,15 @@ xwl_window_rootful_set_app_id(struct xwl_window *xwl_window)
 
 #ifdef XWL_HAS_LIBDECOR
 static void
-xwl_window_update_libdecor_size(struct xwl_window *xwl_window, int width, int height)
+xwl_window_update_libdecor_size(struct xwl_window *xwl_window,
+                                struct libdecor_configuration *configuration /* nullable */,
+                                int width, int height)
 {
     struct libdecor_state *state;
 
     if (xwl_window->libdecor_frame) {
 	state = libdecor_state_new(width, height);
-	libdecor_frame_commit(xwl_window->libdecor_frame, state, NULL);
+	libdecor_frame_commit(xwl_window->libdecor_frame, state, configuration);
 	libdecor_state_free(state);
     }
 }
@@ -1226,7 +1228,7 @@ xwl_resize_window(WindowPtr window,
             xwl_window_check_resolution_change_emulation(xwl_window);
 #ifdef XWL_HAS_LIBDECOR
         if (window == screen->root)
-            xwl_window_update_libdecor_size(xwl_window, width, height);
+            xwl_window_update_libdecor_size(xwl_window, NULL, width, height);
 #endif
     }
 }
commit 6d00c2bc1077c9e1e870303b1b49ec694089fc4e
Author: Olivier Fourdan <ofourdan at redhat.com>
Date:   Mon Jul 24 17:03:56 2023 +0200

    xwayland: attach new buffer from libdecor handlers
    
    The configure handler in libdecor is triggered any time a new
    configuration is received.
    
    According to the documentation from libdecor, an application should
    respond to that event by creating a suitable libdecor_state, and apply
    it using libdecor_frame_commit().
    
    So we ought to attach a new buffer matching the new size and commit
    the Wayland surface.
    
    The actual content of the window does not need to be explicitly
    repainted, that occurs through the call to SetRootClip():
    
      xwl_output_set_mode_fixed()
      -> update_screen_size()
         -> SetRootClip()
            -> miHandleValidateExposures()
               -> miWindowExposures()
                  -> miPaintWindow()
    
    This fixes an issue with mutter where maximizing a window and then
    switching to another window would sometimes resize the Xwayland window
    back to its pre-maximized size, or with Weston where the Xwayland window
    would initially show up black until the pointer moves to the window.
    
    Signed-off-by: Olivier Fourdan <ofourdan at redhat.com>
    Reviewed-by: Michel Dänzer <mdaenzer at redhat.com>

diff --git a/hw/xwayland/xwayland-window.c b/hw/xwayland/xwayland-window.c
index 72c832e4e..0951e47cd 100644
--- a/hw/xwayland/xwayland-window.c
+++ b/hw/xwayland/xwayland-window.c
@@ -629,6 +629,9 @@ xwl_window_libdecor_resize(struct xwl_window *xwl_window, int width, int height)
 
     mode = xwl_output_find_mode(xwl_output, width, height);
     xwl_output_set_mode_fixed(xwl_output, mode);
+
+    xwl_window_attach_buffer(xwl_window);
+    wl_surface_commit(xwl_window->surface);
 }
 
 static void
@@ -652,8 +655,6 @@ handle_libdecor_configure(struct libdecor_frame *frame,
     state = libdecor_state_new(xwl_screen->width, xwl_screen->height);
     libdecor_frame_commit(frame, state, configuration);
     libdecor_state_free(state);
-
-    wl_surface_commit(xwl_window->surface);
 }
 
 static void
commit e37539e1e2d38127fc7ae600da543b0ac341ec14
Author: Olivier Fourdan <ofourdan at redhat.com>
Date:   Tue Jul 25 18:38:24 2023 +0200

    xwayland: Move the libdecor resize to its own function
    
    This moves the code which updates the XRandR modes and sets the root
    window size to its own function.
    
    This preparation work for the next commit, no functional change.
    
    Signed-off-by: Olivier Fourdan <ofourdan at redhat.com>
    Reviewed-by: Michel Dänzer <mdaenzer at redhat.com>

diff --git a/hw/xwayland/xwayland-window.c b/hw/xwayland/xwayland-window.c
index 85d917161..72c832e4e 100644
--- a/hw/xwayland/xwayland-window.c
+++ b/hw/xwayland/xwayland-window.c
@@ -616,6 +616,21 @@ xwl_window_update_libdecor_size(struct xwl_window *xwl_window, int width, int he
     }
 }
 
+static void
+xwl_window_libdecor_resize(struct xwl_window *xwl_window, int width, int height)
+{
+    struct xwl_screen *xwl_screen = xwl_window->xwl_screen;
+    struct xwl_output *xwl_output;
+    RRModePtr mode;
+
+    xwl_output = xwl_screen_get_fixed_or_first_output(xwl_screen);
+    if (!xwl_randr_add_modes_fixed(xwl_output, width, height))
+        return;
+
+    mode = xwl_output_find_mode(xwl_output, width, height);
+    xwl_output_set_mode_fixed(xwl_output, mode);
+}
+
 static void
 handle_libdecor_configure(struct libdecor_frame *frame,
                           struct libdecor_configuration *configuration,
@@ -623,9 +638,7 @@ handle_libdecor_configure(struct libdecor_frame *frame,
 {
     struct xwl_window *xwl_window = data;
     struct xwl_screen *xwl_screen = xwl_window->xwl_screen;
-    struct xwl_output *xwl_output;
     struct libdecor_state *state;
-    RRModePtr mode;
     int width, height;
 
     if (!libdecor_configuration_get_content_size(configuration, frame, &width, &height)) {
@@ -633,13 +646,8 @@ handle_libdecor_configure(struct libdecor_frame *frame,
         height = xwl_screen->height;
     }
 
-    if (xwl_screen->width != width || xwl_screen->height != height) {
-        xwl_output = xwl_screen_get_fixed_or_first_output(xwl_screen);
-        if (xwl_randr_add_modes_fixed(xwl_output, width, height)) {
-            mode = xwl_output_find_mode(xwl_output, width, height);
-            xwl_output_set_mode_fixed(xwl_output, mode);
-        }
-    }
+    if (xwl_screen->width != width || xwl_screen->height != height)
+        xwl_window_libdecor_resize(xwl_window, width, height);
 
     state = libdecor_state_new(xwl_screen->width, xwl_screen->height);
     libdecor_frame_commit(frame, state, configuration);
commit cda004c2a9d7ae585e9284c1989333297fbaeede
Author: Olivier Fourdan <ofourdan at redhat.com>
Date:   Thu Jul 27 08:49:19 2023 +0200

    xwayland: Use the screen width/height for libdecor state
    
    The configure handler for libdecor, namely handle_libdecor_configure(),
    is where both the content and the decorations get resized (when needed).
    
    If for any reason, the actual size of the Xwayland screen fails to be
    updated, we would still appy the expected size rather than the actual
    one for the libdecor state.
    
    To avoid this, use the actual xwl_screen width/height for the libdecor
    state.
    
    Signed-off-by: Olivier Fourdan <ofourdan at redhat.com>
    Reviewed-by: Michel Dänzer <mdaenzer at redhat.com>

diff --git a/hw/xwayland/xwayland-window.c b/hw/xwayland/xwayland-window.c
index 5707e3bfe..85d917161 100644
--- a/hw/xwayland/xwayland-window.c
+++ b/hw/xwayland/xwayland-window.c
@@ -641,7 +641,7 @@ handle_libdecor_configure(struct libdecor_frame *frame,
         }
     }
 
-    state = libdecor_state_new(width, height);
+    state = libdecor_state_new(xwl_screen->width, xwl_screen->height);
     libdecor_frame_commit(frame, state, configuration);
     libdecor_state_free(state);
 
commit 8bbd908d1d8512825983322ab7a0eadcf6571131
Author: Olivier Fourdan <ofourdan at redhat.com>
Date:   Mon Jul 24 16:39:03 2023 +0200

    xwayland: Move attach buffer out of post damage
    
    For libdecor, we will have to attach a new buffer and commit from two
    different handlers (libdecor configure and commit).
    
    Having xwl_window_attach_buffer() separate from xwl_window_post_damage()
    is to allow for that.
    
    This commit should not introduce any functional change.
    
    Signed-off-by: Olivier Fourdan <ofourdan at redhat.com>
    Reviewed-by: Michel Dänzer <mdaenzer at redhat.com>

diff --git a/hw/xwayland/xwayland-window.c b/hw/xwayland/xwayland-window.c
index a58a4439a..5707e3bfe 100644
--- a/hw/xwayland/xwayland-window.c
+++ b/hw/xwayland/xwayland-window.c
@@ -57,6 +57,8 @@ static DevPrivateKeyRec xwl_window_private_key;
 static DevPrivateKeyRec xwl_damage_private_key;
 static const char *xwl_surface_tag = "xwl-surface";
 
+static Bool xwl_window_attach_buffer(struct xwl_window *);
+
 struct xwl_window *
 xwl_window_get(WindowPtr window)
 {
@@ -1312,8 +1314,8 @@ xwl_destroy_window(WindowPtr window)
     return ret;
 }
 
-void
-xwl_window_post_damage(struct xwl_window *xwl_window)
+static Bool
+xwl_window_attach_buffer(struct xwl_window *xwl_window)
 {
     struct xwl_screen *xwl_screen = xwl_window->xwl_screen;
     RegionPtr region;
@@ -1322,8 +1324,6 @@ xwl_window_post_damage(struct xwl_window *xwl_window)
     PixmapPtr pixmap;
     int i;
 
-    assert(!xwl_window->frame_callback);
-
     region = DamageRegion(window_get_damage(xwl_window->window));
     pixmap = xwl_window_buffers_get_pixmap(xwl_window, region);
 
@@ -1336,14 +1336,14 @@ xwl_window_post_damage(struct xwl_window *xwl_window)
 
     if (!buffer) {
         ErrorF("Error getting buffer\n");
-        return;
+        return FALSE;
     }
 
 #ifdef XWL_HAS_GLAMOR
     if (xwl_screen->glamor) {
         if (!xwl_glamor_post_damage(xwl_window, pixmap, region)) {
             ErrorF("glamor: Failed to post damage\n");
-            return;
+            return FALSE;
         }
     }
 #endif
@@ -1370,6 +1370,17 @@ xwl_window_post_damage(struct xwl_window *xwl_window)
         }
     }
 
+    return TRUE;
+}
+
+void
+xwl_window_post_damage(struct xwl_window *xwl_window)
+{
+    assert(!xwl_window->frame_callback);
+
+    if (!xwl_window_attach_buffer(xwl_window))
+        return;
+
     xwl_window_create_frame_callback(xwl_window);
     DamageEmpty(window_get_damage(xwl_window->window));
 }


More information about the xorg-commit mailing list