From 6d98f840da6dfcf2a69e03a1b3fa0bf602ba1f27 Mon Sep 17 00:00:00 2001 From: Roman Gilg Date: Fri, 3 Jan 2020 17:55:28 +0100 Subject: [PATCH] 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 Acked-by: Olivier Fourdan Signed-off-by: Hans de Goede --- hw/xwayland/xwayland-window.c | 27 +++++++++++---------------- hw/xwayland/xwayland-window.h | 1 - 2 files changed, 11 insertions(+), 17 deletions(-) diff --git a/hw/xwayland/xwayland-window.c b/hw/xwayland/xwayland-window.c index f2d5891ca..d787637e8 100644 --- a/hw/xwayland/xwayland-window.c +++ b/hw/xwayland/xwayland-window.c @@ -276,6 +276,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; @@ -285,6 +286,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) @@ -294,10 +296,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; @@ -313,9 +315,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; @@ -451,8 +453,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"); @@ -682,20 +682,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-window.h b/hw/xwayland/xwayland-window.h index 526e08fb7..550edb28c 100644 --- a/hw/xwayland/xwayland-window.h +++ b/hw/xwayland/xwayland-window.h @@ -40,7 +40,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;