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>
This commit is contained in:
Roman Gilg 2020-01-03 17:55:28 +01:00 committed by Hans de Goede
parent 060f10062e
commit 6d98f840da
2 changed files with 11 additions and 17 deletions

View File

@ -276,6 +276,7 @@ xwl_window_should_enable_viewport(struct xwl_window *xwl_window,
struct xwl_output *xwl_output; struct xwl_output *xwl_output;
ClientPtr owner; ClientPtr owner;
WindowPtr window; WindowPtr window;
DrawablePtr drawable;
if (!xwl_screen_has_resolution_change_emulation(xwl_screen)) if (!xwl_screen_has_resolution_change_emulation(xwl_screen))
return FALSE; return FALSE;
@ -285,6 +286,7 @@ xwl_window_should_enable_viewport(struct xwl_window *xwl_window,
return FALSE; return FALSE;
owner = wClient(window); owner = wClient(window);
drawable = &window->drawable;
/* 1. Test if the window matches the emulated mode on one of the outputs /* 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) * 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) if (!emulated_mode)
continue; continue;
if (xwl_window->x == xwl_output->x && if (drawable->x == xwl_output->x &&
xwl_window->y == xwl_output->y && drawable->y == xwl_output->y &&
xwl_window->width == emulated_mode->width && drawable->width == emulated_mode->width &&
xwl_window->height == emulated_mode->height) { drawable->height == emulated_mode->height) {
*emulated_mode_ret = emulated_mode; *emulated_mode_ret = emulated_mode;
*xwl_output_ret = xwl_output; *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); emulated_mode = xwl_output_get_emulated_mode_for_client(xwl_output, owner);
if (xwl_output && xwl_window->window->overrideRedirect && if (xwl_output && xwl_window->window->overrideRedirect &&
emulated_mode && emulated_mode->from_vidmode && emulated_mode && emulated_mode->from_vidmode &&
xwl_window->x == 0 && xwl_window->y == 0 && drawable->x == 0 && drawable->y == 0 &&
xwl_window->width == xwl_screen->width && drawable->width == xwl_screen->width &&
xwl_window->height == xwl_screen->height) { drawable->height == xwl_screen->height) {
*emulated_mode_ret = emulated_mode; *emulated_mode_ret = emulated_mode;
*xwl_output_ret = xwl_output; *xwl_output_ret = xwl_output;
@ -451,8 +453,6 @@ ensure_surface_for_window(WindowPtr window)
xwl_window->xwl_screen = xwl_screen; xwl_window->xwl_screen = xwl_screen;
xwl_window->window = window; 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); xwl_window->surface = wl_compositor_create_surface(xwl_screen->compositor);
if (xwl_window->surface == NULL) { if (xwl_window->surface == NULL) {
ErrorF("wl_display_create_surface failed\n"); ErrorF("wl_display_create_surface failed\n");
@ -682,20 +682,15 @@ xwl_resize_window(WindowPtr window,
struct xwl_window *xwl_window; struct xwl_window *xwl_window;
xwl_screen = xwl_screen_get(screen); 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 = xwl_screen->ResizeWindow;
(*screen->ResizeWindow) (window, x, y, width, height, sib); (*screen->ResizeWindow) (window, x, y, width, height, sib);
xwl_screen->ResizeWindow = screen->ResizeWindow; xwl_screen->ResizeWindow = screen->ResizeWindow;
screen->ResizeWindow = xwl_resize_window; screen->ResizeWindow = xwl_resize_window;
if (xwl_window) { if (xwl_window && xwl_window_is_toplevel(window))
xwl_window->x = x;
xwl_window->y = y;
xwl_window->width = width;
xwl_window->height = height;
xwl_window_check_resolution_change_emulation(xwl_window); xwl_window_check_resolution_change_emulation(xwl_window);
}
} }
static void static void

View File

@ -40,7 +40,6 @@ struct xwl_window {
struct xwl_screen *xwl_screen; struct xwl_screen *xwl_screen;
struct wl_surface *surface; struct wl_surface *surface;
struct wp_viewport *viewport; struct wp_viewport *viewport;
int32_t x, y, width, height;
float scale_x, scale_y; float scale_x, scale_y;
struct wl_shell_surface *shell_surface; struct wl_shell_surface *shell_surface;
WindowPtr window; WindowPtr window;