1
0
Fork 0

x11/window: Compare input shape to client rect when undecorating

When a window with an input shape on its decoration window becomes
undecorated and meta_window_x11_update_input_region() gets called via
notify::decorated, the buffer_rect of the window has not been updated
yet while the decorated property has. This would lead to us comparing
the input shape of the client window to the buffer_rect which still
includes the decoration window. This would fail to detect the common
case when the client window has no input shape set, leading to the input
region being set to the size of the client window rather than NULL. If
the window is then resized later, the input shape would remain at the
previous size.

This was not a problem before 6bd920b35, because then we were (wrongly)
always comparing to the client_rect.

Fix this by choosing the correct rect for comparison depending on
whether the window is decorated.

Fixes: 6bd920b35 ("x11/window: Use correct bounding rect to determine NULL input region")
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3451
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3720>
This commit is contained in:
Sebastian Keller 2024-04-23 20:45:36 +02:00 committed by Marge Bot
parent 1c7ed16d05
commit 1f1538be76

View file

@ -2400,6 +2400,7 @@ meta_window_x11_update_input_region (MetaWindow *window)
g_autoptr (MtkRegion) region = NULL; g_autoptr (MtkRegion) region = NULL;
MetaWindowX11 *window_x11 = META_WINDOW_X11 (window); MetaWindowX11 *window_x11 = META_WINDOW_X11 (window);
MetaWindowX11Private *priv = meta_window_x11_get_instance_private (window_x11); MetaWindowX11Private *priv = meta_window_x11_get_instance_private (window_x11);
MtkRectangle bounding_rect = { 0 };
Window xwindow; Window xwindow;
if (window->decorated) if (window->decorated)
@ -2411,10 +2412,14 @@ meta_window_x11_update_input_region (MetaWindow *window)
return; return;
} }
xwindow = window->frame->xwindow; xwindow = window->frame->xwindow;
bounding_rect.width = window->buffer_rect.width;
bounding_rect.height = window->buffer_rect.height;
} }
else else
{ {
xwindow = priv->xwindow; xwindow = priv->xwindow;
bounding_rect.width = priv->client_rect.width;
bounding_rect.height = priv->client_rect.height;
} }
if (META_X11_DISPLAY_HAS_SHAPE (x11_display)) if (META_X11_DISPLAY_HAS_SHAPE (x11_display))
@ -2458,8 +2463,8 @@ meta_window_x11_update_input_region (MetaWindow *window)
else if (n_rects == 1 && else if (n_rects == 1 &&
(rects[0].x == 0 && (rects[0].x == 0 &&
rects[0].y == 0 && rects[0].y == 0 &&
rects[0].width == window->buffer_rect.width && rects[0].width == bounding_rect.width &&
rects[0].height == window->buffer_rect.height)) rects[0].height == bounding_rect.height))
{ {
/* This is the bounding region case. Keep the /* This is the bounding region case. Keep the
* region as NULL. */ * region as NULL. */
@ -2476,13 +2481,6 @@ meta_window_x11_update_input_region (MetaWindow *window)
if (region != NULL) if (region != NULL)
{ {
MtkRectangle bounding_rect;
bounding_rect.x = 0;
bounding_rect.y = 0;
bounding_rect.width = window->buffer_rect.width;
bounding_rect.height = window->buffer_rect.height;
/* The shape we get back from the client may have coordinates /* The shape we get back from the client may have coordinates
* outside of the frame. The X SHAPE Extension requires that * outside of the frame. The X SHAPE Extension requires that
* the overall shape the client provides never exceeds the * the overall shape the client provides never exceeds the