From 41cc85c857f1528842db4cb9c173607b96a68778 Mon Sep 17 00:00:00 2001 From: Bilal Elmoussaoui Date: Wed, 14 Feb 2024 16:17:09 +0100 Subject: [PATCH] window: Move shape_region to WindowX11 Part-of: --- src/compositor/meta-window-actor-x11.c | 17 +++++++++-------- src/core/window-private.h | 4 ---- src/core/window.c | 1 - src/x11/window-x11-private.h | 4 ++++ src/x11/window-x11.c | 14 ++++++++++---- 5 files changed, 23 insertions(+), 17 deletions(-) diff --git a/src/compositor/meta-window-actor-x11.c b/src/compositor/meta-window-actor-x11.c index e2150be8d..19827af33 100644 --- a/src/compositor/meta-window-actor-x11.c +++ b/src/compositor/meta-window-actor-x11.c @@ -915,19 +915,20 @@ update_shape_region (MetaWindowActorX11 *actor_x11) { MetaWindow *window = meta_window_actor_get_meta_window (META_WINDOW_ACTOR (actor_x11)); + MetaWindowX11Private *priv = meta_window_x11_get_private (META_WINDOW_X11 (window)); MtkRegion *region = NULL; MtkRectangle client_area; get_client_area_rect (actor_x11, &client_area); - if (window->frame && window->shape_region) + if (window->frame && priv->shape_region) { - region = mtk_region_copy (window->shape_region); + region = mtk_region_copy (priv->shape_region); mtk_region_translate (region, client_area.x, client_area.y); } - else if (window->shape_region != NULL) + else if (priv->shape_region != NULL) { - region = mtk_region_ref (window->shape_region); + region = mtk_region_ref (priv->shape_region); } else { @@ -937,7 +938,7 @@ update_shape_region (MetaWindowActorX11 *actor_x11) region = mtk_region_create_rectangle (&client_area); } - if (window->shape_region || window->frame) + if (priv->shape_region || window->frame) build_and_scan_frame_mask (actor_x11, region); g_clear_pointer (&actor_x11->shape_region, mtk_region_unref); @@ -959,7 +960,7 @@ update_input_region (MetaWindowActorX11 *actor_x11) meta_window_x11_get_private (META_WINDOW_X11 (window)); g_autoptr (MtkRegion) region = NULL; - if (window->shape_region && priv->input_region) + if (priv->shape_region && priv->input_region) { MtkRectangle client_area; g_autoptr (MtkRegion) frames_input = NULL; @@ -977,13 +978,13 @@ update_input_region (MetaWindowActorX11 *actor_x11) region = g_steal_pointer (&frames_input); } - else if (window->shape_region) + else if (priv->shape_region) { MtkRectangle client_area; meta_window_get_client_area_rect (window, &client_area); - region = mtk_region_copy (window->shape_region); + region = mtk_region_copy (priv->shape_region); mtk_region_translate (region, client_area.x, client_area.y); } else if (priv->input_region) diff --git a/src/core/window-private.h b/src/core/window-private.h index aebe57d54..bd27272af 100644 --- a/src/core/window-private.h +++ b/src/core/window-private.h @@ -239,10 +239,6 @@ struct _MetaWindow /* if non-NULL, the bounds of the window frame */ MtkRegion *frame_bounds; - /* if non-NULL, the bounding shape region of the window. Relative to - * the server-side client window. */ - MtkRegion *shape_region; - /* _NET_WM_WINDOW_OPACITY rescaled to 0xFF */ guint8 opacity; diff --git a/src/core/window.c b/src/core/window.c index 4c3fb29e9..fe79b86fb 100644 --- a/src/core/window.c +++ b/src/core/window.c @@ -314,7 +314,6 @@ meta_window_finalize (GObject *object) MetaWindow *window = META_WINDOW (object); g_clear_pointer (&window->frame_bounds, mtk_region_unref); - g_clear_pointer (&window->shape_region, mtk_region_unref); if (window->transient_for) g_object_unref (window->transient_for); diff --git a/src/x11/window-x11-private.h b/src/x11/window-x11-private.h index 95f4aec2c..d8ab4dbd9 100644 --- a/src/x11/window-x11-private.h +++ b/src/x11/window-x11-private.h @@ -75,6 +75,10 @@ struct _MetaWindowX11Private /* the input shape region for picking */ MtkRegion *input_region; + /* if non-NULL, the bounding shape region of the window. Relative to + * the server-side client window. */ + MtkRegion *shape_region; + Pixmap wm_hints_pixmap; Pixmap wm_hints_mask; diff --git a/src/x11/window-x11.c b/src/x11/window-x11.c index def0d36c7..42981584c 100644 --- a/src/x11/window-x11.c +++ b/src/x11/window-x11.c @@ -2149,6 +2149,7 @@ meta_window_x11_finalize (GObject *object) MetaWindowX11 *win = META_WINDOW_X11 (object); MetaWindowX11Private *priv = meta_window_x11_get_instance_private (win); + g_clear_pointer (&priv->shape_region, mtk_region_unref); g_clear_pointer (&priv->input_region, mtk_region_unref); g_clear_pointer (&priv->opaque_region, mtk_region_unref); g_clear_pointer (&priv->wm_client_machine, g_free); @@ -2507,13 +2508,16 @@ static void meta_window_set_shape_region (MetaWindow *window, MtkRegion *region) { - if (mtk_region_equal (window->shape_region, region)) + MetaWindowX11Private *priv = + meta_window_x11_get_instance_private (META_WINDOW_X11 (window)); + + if (mtk_region_equal (priv->shape_region, region)) return; - g_clear_pointer (&window->shape_region, mtk_region_unref); + g_clear_pointer (&priv->shape_region, mtk_region_unref); if (region != NULL) - window->shape_region = mtk_region_ref (region); + priv->shape_region = mtk_region_ref (region); meta_compositor_window_shape_changed (window->display->compositor, window); } @@ -4322,6 +4326,8 @@ gboolean meta_window_x11_can_unredirect (MetaWindowX11 *window_x11) { MetaWindow *window = META_WINDOW (window_x11); + MetaWindowX11Private *priv = + meta_window_x11_get_instance_private (window_x11); if (has_requested_dont_bypass_compositor (window_x11)) return FALSE; @@ -4329,7 +4335,7 @@ meta_window_x11_can_unredirect (MetaWindowX11 *window_x11) if (window->opacity != 0xFF) return FALSE; - if (window->shape_region != NULL) + if (priv->shape_region != NULL) return FALSE; if (!window->monitor)