Sophie

Sophie

distrib > Mageia > 7 > i586 > by-pkgid > 5b285d6e912ad995943d1c0ee298d7cc > files > 21

x11-server-1.20.9-1.mga7.src.rpm

From c5d9cb5f4bc4f703b66fc524a76247c742490b30 Mon Sep 17 00:00:00 2001
From: Roman Gilg <subdiff@gmail.com>
Date: Fri, 3 Jan 2020 17:55:28 +0100
Subject: [PATCH xserver 18/24] xwayland: Check emulation on client toplevel
 resize

When a reparented window is resized directly check the emulation instead of
doing this only when the window manager parent window is resized, what might
never happen.

For that to work we need to make sure that we compare the current size of the
client toplevel when looking for an emulated mode.

Changes by Hans de Goede:
- Remove xwl_window x, y, width and height members as those are no longer used.
- Add check for xwl_window_from_window() returning NULL.

Signed-off-by: Roman Gilg <subdiff@gmail.com>
Acked-by: Olivier Fourdan <ofourdan@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
(cherry picked from commit 6d98f840da6dfcf2a69e03a1b3fa0bf602ba1f27)
---
 hw/xwayland/xwayland.c | 27 +++++++++++----------------
 hw/xwayland/xwayland.h |  1 -
 2 files changed, 11 insertions(+), 17 deletions(-)

diff --git a/hw/xwayland/xwayland.c b/hw/xwayland/xwayland.c
index d70d729ae..14227a327 100644
--- a/hw/xwayland/xwayland.c
+++ b/hw/xwayland/xwayland.c
@@ -609,6 +609,7 @@ xwl_window_should_enable_viewport(struct xwl_window *xwl_window,
     struct xwl_output *xwl_output;
     ClientPtr owner;
     WindowPtr window;
+    DrawablePtr drawable;
 
     if (!xwl_screen_has_resolution_change_emulation(xwl_screen))
         return FALSE;
@@ -618,6 +619,7 @@ xwl_window_should_enable_viewport(struct xwl_window *xwl_window,
         return FALSE;
 
     owner = wClient(window);
+    drawable = &window->drawable;
 
     /* 1. Test if the window matches the emulated mode on one of the outputs
      * This path gets hit by most games / libs (e.g. SDL, SFML, OGRE)
@@ -627,10 +629,10 @@ xwl_window_should_enable_viewport(struct xwl_window *xwl_window,
         if (!emulated_mode)
             continue;
 
-        if (xwl_window->x == xwl_output->x &&
-            xwl_window->y == xwl_output->y &&
-            xwl_window->width  == emulated_mode->width &&
-            xwl_window->height == emulated_mode->height) {
+        if (drawable->x == xwl_output->x &&
+            drawable->y == xwl_output->y &&
+            drawable->width  == emulated_mode->width &&
+            drawable->height == emulated_mode->height) {
 
             *emulated_mode_ret = emulated_mode;
             *xwl_output_ret = xwl_output;
@@ -646,9 +648,9 @@ xwl_window_should_enable_viewport(struct xwl_window *xwl_window,
     emulated_mode = xwl_output_get_emulated_mode_for_client(xwl_output, owner);
     if (xwl_output && xwl_window->window->overrideRedirect &&
         emulated_mode && emulated_mode->from_vidmode &&
-        xwl_window->x == 0 && xwl_window->y == 0 &&
-        xwl_window->width  == xwl_screen->width &&
-        xwl_window->height == xwl_screen->height) {
+        drawable->x == 0 && drawable->y == 0 &&
+        drawable->width  == xwl_screen->width &&
+        drawable->height == xwl_screen->height) {
 
         *emulated_mode_ret = emulated_mode;
         *xwl_output_ret = xwl_output;
@@ -768,8 +770,6 @@ ensure_surface_for_window(WindowPtr window)
 
     xwl_window->xwl_screen = xwl_screen;
     xwl_window->window = window;
-    xwl_window->width = window->drawable.width;
-    xwl_window->height = window->drawable.height;
     xwl_window->surface = wl_compositor_create_surface(xwl_screen->compositor);
     if (xwl_window->surface == NULL) {
         ErrorF("wl_display_create_surface failed\n");
@@ -997,20 +997,15 @@ xwl_resize_window(WindowPtr window,
     struct xwl_window *xwl_window;
 
     xwl_screen = xwl_screen_get(screen);
-    xwl_window = xwl_window_get(window);
+    xwl_window = xwl_window_from_window(window);
 
     screen->ResizeWindow = xwl_screen->ResizeWindow;
     (*screen->ResizeWindow) (window, x, y, width, height, sib);
     xwl_screen->ResizeWindow = screen->ResizeWindow;
     screen->ResizeWindow = xwl_resize_window;
 
-    if (xwl_window) {
-        xwl_window->x = x;
-        xwl_window->y = y;
-        xwl_window->width = width;
-        xwl_window->height = height;
+    if (xwl_window && xwl_window_is_toplevel(window))
         xwl_window_check_resolution_change_emulation(xwl_window);
-    }
 }
 
 static void
diff --git a/hw/xwayland/xwayland.h b/hw/xwayland/xwayland.h
index 126af8823..01aef27d2 100644
--- a/hw/xwayland/xwayland.h
+++ b/hw/xwayland/xwayland.h
@@ -184,7 +184,6 @@ struct xwl_window {
     struct xwl_screen *xwl_screen;
     struct wl_surface *surface;
     struct wp_viewport *viewport;
-    int32_t x, y, width, height;
     float scale_x, scale_y;
     struct wl_shell_surface *shell_surface;
     WindowPtr window;
-- 
2.25.2