From 4d5a86327a1c2ec4f8a9ac6202373e629c4cc2a0 Mon Sep 17 00:00:00 2001 From: Olivier Fourdan Date: Fri, 6 Dec 2019 16:01:35 +0100 Subject: [PATCH] window/x11: Add `always_update_shape()` vfunc To address the black shadows that sometimes show during resize with Xwayland, we need to update the window shape regardless of the frozen status of the window actor. However, plain Xorg does not need this, as resized windows do not clear to black, so add a new vfunc to window/x11 to indicate whether or not the backing windowing system (either plain X11 or Xwayland) would require the shape to be always updated. https://gitlab.gnome.org/GNOME/mutter/merge_requests/942 --- src/wayland/meta-window-xwayland.c | 16 ++++++++++++++++ src/x11/window-x11-private.h | 1 + src/x11/window-x11.c | 15 +++++++++++++++ src/x11/window-x11.h | 1 + 4 files changed, 33 insertions(+) diff --git a/src/wayland/meta-window-xwayland.c b/src/wayland/meta-window-xwayland.c index 5b1c4198e..0c77ca5d7 100644 --- a/src/wayland/meta-window-xwayland.c +++ b/src/wayland/meta-window-xwayland.c @@ -219,6 +219,21 @@ meta_window_xwayland_thaw_commits (MetaWindow *window) apply_allow_commits_x11_property (xwayland_window, TRUE); } +static gboolean +meta_window_xwayland_always_update_shape (MetaWindow *window) +{ + /* + * On Xwayland, resizing a window will clear the corresponding Wayland + * buffer to plain solid black. + * + * Therefore, to address the black shadows which sometimes show during + * resize with Xwayland, we need to always update the window shape + * regardless of the actual frozen state of the window actor. + */ + + return TRUE; +} + static void meta_window_xwayland_get_property (GObject *object, guint prop_id, @@ -270,6 +285,7 @@ meta_window_xwayland_class_init (MetaWindowXwaylandClass *klass) window_x11_class->freeze_commits = meta_window_xwayland_freeze_commits; window_x11_class->thaw_commits = meta_window_xwayland_thaw_commits; + window_x11_class->always_update_shape = meta_window_xwayland_always_update_shape; gobject_class->get_property = meta_window_xwayland_get_property; gobject_class->set_property = meta_window_xwayland_set_property; diff --git a/src/x11/window-x11-private.h b/src/x11/window-x11-private.h index 621609e3e..906d44546 100644 --- a/src/x11/window-x11-private.h +++ b/src/x11/window-x11-private.h @@ -36,6 +36,7 @@ struct _MetaWindowX11Class void (*freeze_commits) (MetaWindow *window); void (*thaw_commits) (MetaWindow *window); + gboolean (*always_update_shape) (MetaWindow *window); }; struct _MetaWindowX11 diff --git a/src/x11/window-x11.c b/src/x11/window-x11.c index 93cfa8e0d..87067955b 100644 --- a/src/x11/window-x11.c +++ b/src/x11/window-x11.c @@ -2014,6 +2014,12 @@ meta_window_x11_unmap (MetaWindow *window) window->unmaps_pending ++; } +static gboolean +meta_window_x11_impl_always_update_shape (MetaWindow *window) +{ + return FALSE; +} + static void meta_window_x11_class_init (MetaWindowX11Class *klass) { @@ -2047,6 +2053,7 @@ meta_window_x11_class_init (MetaWindowX11Class *klass) klass->freeze_commits = meta_window_x11_impl_freeze_commits; klass->thaw_commits = meta_window_x11_impl_thaw_commits; + klass->always_update_shape = meta_window_x11_impl_always_update_shape; } void @@ -4051,3 +4058,11 @@ meta_window_x11_should_thaw_after_paint (MetaWindow *window) return priv->thaw_after_paint; } + +gboolean +meta_window_x11_always_update_shape (MetaWindow *window) +{ + MetaWindowX11 *window_x11 = META_WINDOW_X11 (window); + + return META_WINDOW_X11_GET_CLASS (window_x11)->always_update_shape (window); +} diff --git a/src/x11/window-x11.h b/src/x11/window-x11.h index 7864135bb..256bca568 100644 --- a/src/x11/window-x11.h +++ b/src/x11/window-x11.h @@ -87,5 +87,6 @@ void meta_window_x11_thaw_commits (MetaWindow *window); void meta_window_x11_set_thaw_after_paint (MetaWindow *window, gboolean thaw_after_paint); gboolean meta_window_x11_should_thaw_after_paint (MetaWindow *window); +gboolean meta_window_x11_always_update_shape (MetaWindow *window); #endif