window: Move opaque_region to WindowX11

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3584>
This commit is contained in:
Bilal Elmoussaoui 2024-02-14 16:10:18 +01:00 committed by Marge Bot
parent bf5f597141
commit 606197de46
6 changed files with 16 additions and 11 deletions

View File

@ -39,7 +39,7 @@
#include "x11/window-x11.h" #include "x11/window-x11.h"
#include "x11/meta-sync-counter.h" #include "x11/meta-sync-counter.h"
#include "x11/meta-x11-display-private.h" #include "x11/meta-x11-display-private.h"
#include "x11/window-x11.h" #include "x11/window-x11-private.h"
enum enum
{ {
@ -1018,13 +1018,15 @@ update_opaque_region (MetaWindowActorX11 *actor_x11)
{ {
MetaWindow *window = MetaWindow *window =
meta_window_actor_get_meta_window (META_WINDOW_ACTOR (actor_x11)); meta_window_actor_get_meta_window (META_WINDOW_ACTOR (actor_x11));
MetaWindowX11Private *priv =
meta_window_x11_get_private (META_WINDOW_X11 (window));
gboolean is_maybe_transparent; gboolean is_maybe_transparent;
g_autoptr (MtkRegion) opaque_region = NULL; g_autoptr (MtkRegion) opaque_region = NULL;
MetaSurfaceActor *surface; MetaSurfaceActor *surface;
is_maybe_transparent = is_actor_maybe_transparent (actor_x11); is_maybe_transparent = is_actor_maybe_transparent (actor_x11);
if (is_maybe_transparent && if (is_maybe_transparent &&
(window->opaque_region || (priv->opaque_region ||
(window->frame && window->frame->opaque_region))) (window->frame && window->frame->opaque_region)))
{ {
MtkRectangle client_area; MtkRectangle client_area;
@ -1037,7 +1039,7 @@ update_opaque_region (MetaWindowActorX11 *actor_x11)
if (opaque_region && meta_window_x11_has_alpha_channel (window)) if (opaque_region && meta_window_x11_has_alpha_channel (window))
mtk_region_subtract_rectangle (opaque_region, &client_area); mtk_region_subtract_rectangle (opaque_region, &client_area);
if (window->opaque_region) if (priv->opaque_region)
{ {
g_autoptr (MtkRegion) client_opaque_region = NULL; g_autoptr (MtkRegion) client_opaque_region = NULL;
@ -1051,7 +1053,7 @@ update_opaque_region (MetaWindowActorX11 *actor_x11)
* to be undefined, and considered a client bug. In mutter's * to be undefined, and considered a client bug. In mutter's
* case, graphical glitches will occur. * case, graphical glitches will occur.
*/ */
client_opaque_region = mtk_region_copy (window->opaque_region); client_opaque_region = mtk_region_copy (priv->opaque_region);
mtk_region_translate (client_opaque_region, mtk_region_translate (client_opaque_region,
client_area.x, client_area.y); client_area.x, client_area.y);

View File

@ -243,9 +243,6 @@ struct _MetaWindow
* the server-side client window. */ * the server-side client window. */
MtkRegion *shape_region; MtkRegion *shape_region;
/* if non-NULL, the opaque region _NET_WM_OPAQUE_REGION */
MtkRegion *opaque_region;
/* the input shape region for picking */ /* the input shape region for picking */
MtkRegion *input_region; MtkRegion *input_region;

View File

@ -315,7 +315,6 @@ meta_window_finalize (GObject *object)
g_clear_pointer (&window->frame_bounds, mtk_region_unref); g_clear_pointer (&window->frame_bounds, mtk_region_unref);
g_clear_pointer (&window->shape_region, mtk_region_unref); g_clear_pointer (&window->shape_region, mtk_region_unref);
g_clear_pointer (&window->opaque_region, mtk_region_unref);
g_clear_pointer (&window->input_region, mtk_region_unref); g_clear_pointer (&window->input_region, mtk_region_unref);
if (window->transient_for) if (window->transient_for)

View File

@ -629,13 +629,16 @@ static void
meta_window_set_opaque_region (MetaWindow *window, meta_window_set_opaque_region (MetaWindow *window,
MtkRegion *region) MtkRegion *region)
{ {
if (mtk_region_equal (window->opaque_region, region)) MetaWindowX11Private *priv =
meta_window_x11_get_private (META_WINDOW_X11 (window));
if (mtk_region_equal (priv->opaque_region, region))
return; return;
g_clear_pointer (&window->opaque_region, mtk_region_unref); g_clear_pointer (&priv->opaque_region, mtk_region_unref);
if (region != NULL) if (region != NULL)
window->opaque_region = mtk_region_ref (region); priv->opaque_region = mtk_region_ref (region);
meta_compositor_window_shape_changed (window->display->compositor, window); meta_compositor_window_shape_changed (window->display->compositor, window);
} }

View File

@ -69,6 +69,9 @@ struct _MetaWindowX11Private
* relative to the frame. */ * relative to the frame. */
MtkRectangle client_rect; MtkRectangle client_rect;
/* if non-NULL, the opaque region _NET_WM_OPAQUE_REGION */
MtkRegion *opaque_region;
Pixmap wm_hints_pixmap; Pixmap wm_hints_pixmap;
Pixmap wm_hints_mask; Pixmap wm_hints_mask;

View File

@ -2149,6 +2149,7 @@ meta_window_x11_finalize (GObject *object)
MetaWindowX11 *win = META_WINDOW_X11 (object); MetaWindowX11 *win = META_WINDOW_X11 (object);
MetaWindowX11Private *priv = meta_window_x11_get_instance_private (win); MetaWindowX11Private *priv = meta_window_x11_get_instance_private (win);
g_clear_pointer (&priv->opaque_region, mtk_region_unref);
g_clear_pointer (&priv->wm_client_machine, g_free); g_clear_pointer (&priv->wm_client_machine, g_free);
g_clear_pointer (&priv->sm_client_id, g_free); g_clear_pointer (&priv->sm_client_id, g_free);