Commit 02d78631 authored by Roman Gilg's avatar Roman Gilg
Browse files

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.
Signed-off-by: Roman Gilg's avatarRoman Gilg <subdiff@gmail.com>
parent 829d56b7
Pipeline #93638 passed with stages
in 6 minutes and 45 seconds
......@@ -256,23 +256,28 @@ xwl_screen_client_is_window_manager(struct xwl_screen *xwl_screen,
return FALSE;
}
static ClientPtr
xwl_window_get_none_wm_owner(WindowPtr window, struct xwl_window *xwl_window)
static WindowPtr
xwl_window_get_none_wm_next_window(WindowPtr window, struct xwl_window *xwl_window)
{
ClientPtr client = wClient(window);
assert(window);
/* If the toplevel window is owned by the window-manager, then the
* actual client toplevel window has been reparented to some window-manager
* decoration/wrapper windows. In that case recurse by checking the client of the
* first *and only* child of the decoration/wrapper window.
*/
if (xwl_screen_client_is_window_manager(xwl_window->xwl_screen, client)) {
if (xwl_screen_client_is_window_manager(xwl_window->xwl_screen, wClient(window))) {
if (window->firstChild && window->firstChild == window->lastChild)
return xwl_window_get_none_wm_owner(window->firstChild, xwl_window);
return xwl_window_get_none_wm_next_window(window->firstChild, xwl_window);
else
return NULL; /* Should never happen, skip resolution emulation */
}
return client;
return window;
}
static WindowPtr
xwl_window_get_none_wm_window(struct xwl_window *xwl_window)
{
return xwl_window_get_none_wm_next_window(xwl_window->window, xwl_window);
}
static Bool
......@@ -284,14 +289,19 @@ xwl_window_should_enable_viewport(struct xwl_window *xwl_window,
struct xwl_emulated_mode *emulated_mode;
struct xwl_output *xwl_output;
ClientPtr owner;
WindowPtr window;
DrawablePtr drawable;
if (!xwl_screen_has_resolution_change_emulation(xwl_screen))
return FALSE;
owner = xwl_window_get_none_wm_owner(xwl_window->window, xwl_window);
if (!owner)
window = xwl_window_get_none_wm_window(xwl_window);
if (!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)
*/
......@@ -300,10 +310,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;
......@@ -319,9 +329,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;
......@@ -360,8 +370,9 @@ xwl_window_is_toplevel(WindowPtr window)
if (window_get_damage(window))
return TRUE;
/* Normal toplevel client windows, reparented to decoration window */
return (window->parent && window_get_damage(window->parent));
/* Normal toplevel client windows, reparented to a window-manger window */
return window->parent
&& xwl_screen_client_is_window_manager(xwl_screen, wClient(window->parent));
}
static void
......@@ -676,8 +687,10 @@ xwl_resize_window(WindowPtr window,
xwl_window->y = y;
xwl_window->width = width;
xwl_window->height = height;
xwl_window_check_resolution_change_emulation(xwl_window);
}
if (xwl_window_is_toplevel(window))
xwl_window_check_resolution_change_emulation(xwl_window_from_window(window));
}
static void
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment