Skip to content

Commit 6f11bf3

Browse files
committed
surface-actor-x11: Move window related unredirect logic to MetaWindowX11
Better to have the relevant object figure out whether it is a good position to be unredirectable other than the actor, which should be responsible for being composited. Original Mutter commit: https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/798/diffs?commit_id=5dad87cfb9058a0be96d9ec1a530e09a6d418a6e
1 parent daa2a8a commit 6f11bf3

File tree

9 files changed

+100
-70
lines changed

9 files changed

+100
-70
lines changed

src/compositor/meta-surface-actor-x11.c

Lines changed: 4 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -254,33 +254,14 @@ meta_surface_actor_x11_is_opaque (MetaSurfaceActor *actor)
254254
gboolean
255255
meta_surface_actor_x11_should_unredirect (MetaSurfaceActorX11 *self)
256256
{
257-
MetaWindow *window = self->window;
258-
259-
if (meta_window_requested_dont_bypass_compositor (window))
260-
return FALSE;
261-
262-
if (window->opacity != 0xFF)
263-
return FALSE;
264-
265-
if (window->shape_region != NULL)
266-
return FALSE;
267-
268-
if (!meta_window_is_monitor_sized (window))
269-
return FALSE;
270-
271-
if (meta_window_requested_bypass_compositor (window))
272-
return TRUE;
273-
274257
if (!meta_surface_actor_x11_is_opaque (META_SURFACE_ACTOR (self)))
275258
return FALSE;
276259

277-
if (meta_window_is_override_redirect (window))
278-
return TRUE;
279-
280-
if (self->does_full_damage && meta_prefs_get_unredirect_fullscreen_windows ())
281-
return TRUE;
260+
if (!self->does_full_damage &&
261+
!meta_window_is_override_redirect (self->window))
262+
return FALSE;
282263

283-
return FALSE;
264+
return TRUE;
284265
}
285266

286267
static void

src/compositor/meta-window-actor-x11.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
#include "meta/meta-window-actor.h"
4040
#include "meta/meta-x11-errors.h"
4141
#include "meta/window.h"
42+
#include "x11/window-x11.h"
4243
#include "x11/meta-x11-display-private.h"
4344
#include "x11/window-x11.h"
4445

@@ -544,12 +545,18 @@ has_shadow (MetaWindowActorX11 *actor_x11)
544545
gboolean
545546
meta_window_actor_x11_should_unredirect (MetaWindowActorX11 *actor_x11)
546547
{
548+
MetaWindow *window =
549+
meta_window_actor_get_meta_window (META_WINDOW_ACTOR (actor_x11));
550+
MetaWindowX11 *window_x11 = META_WINDOW_X11 (window);
547551
MetaSurfaceActor *surface;
548552
MetaSurfaceActorX11 *surface_x11;
549553

550554
if (meta_window_actor_is_destroyed (META_WINDOW_ACTOR (actor_x11)))
551555
return FALSE;
552556

557+
if (!meta_window_x11_can_unredirect (window_x11))
558+
return FALSE;
559+
553560
surface = meta_window_actor_get_surface (META_WINDOW_ACTOR (actor_x11));
554561
if (!surface)
555562
return FALSE;

src/core/window-private.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,6 @@ typedef enum
6565

6666
#define NUMBER_OF_QUEUES 3
6767

68-
typedef enum
69-
{
70-
_NET_WM_BYPASS_COMPOSITOR_HINT_AUTO = 0,
71-
_NET_WM_BYPASS_COMPOSITOR_HINT_ON = 1,
72-
_NET_WM_BYPASS_COMPOSITOR_HINT_OFF = 2,
73-
} MetaBypassCompositorHintValue;
74-
7568
typedef enum
7669
{
7770
META_MOVE_RESIZE_CONFIGURE_REQUEST = 1 << 0,
@@ -550,9 +543,6 @@ struct _MetaWindow
550543

551544
// MetaWindow *tile_match;
552545

553-
/* Bypass compositor hints */
554-
guint bypass_compositor;
555-
556546
struct {
557547
MetaPlacementRule *rule;
558548
MetaPlacementState state;

src/core/window.c

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3165,30 +3165,6 @@ meta_window_is_on_primary_monitor (MetaWindow *window)
31653165
return window->monitor->is_primary;
31663166
}
31673167

3168-
/**
3169-
* meta_window_requested_bypass_compositor:
3170-
* @window: a #MetaWindow
3171-
*
3172-
* Return value: %TRUE if the window requested to bypass the compositor
3173-
*/
3174-
gboolean
3175-
meta_window_requested_bypass_compositor (MetaWindow *window)
3176-
{
3177-
return window->bypass_compositor == _NET_WM_BYPASS_COMPOSITOR_HINT_ON;
3178-
}
3179-
3180-
/**
3181-
* meta_window_requested_dont_bypass_compositor:
3182-
* @window: a #MetaWindow
3183-
*
3184-
* Return value: %TRUE if the window requested to opt out of unredirecting
3185-
*/
3186-
gboolean
3187-
meta_window_requested_dont_bypass_compositor (MetaWindow *window)
3188-
{
3189-
return window->bypass_compositor == _NET_WM_BYPASS_COMPOSITOR_HINT_OFF;
3190-
}
3191-
31923168
static void
31933169
get_default_tile_fractions (MetaTileMode for_mode,
31943170
double *hfraction,

src/meta/window.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -283,12 +283,6 @@ gboolean meta_window_is_monitor_sized (MetaWindow *window);
283283
META_EXPORT
284284
gboolean meta_window_is_on_primary_monitor (MetaWindow *window);
285285

286-
META_EXPORT
287-
gboolean meta_window_requested_bypass_compositor (MetaWindow *window);
288-
289-
META_EXPORT
290-
gboolean meta_window_requested_dont_bypass_compositor (MetaWindow *window);
291-
292286
META_EXPORT
293287
gboolean meta_window_get_icon_geometry (MetaWindow *window,
294288
MetaRectangle *rect);

src/x11/window-props.c

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1847,23 +1847,28 @@ reload_bypass_compositor (MetaWindow *window,
18471847
MetaPropValue *value,
18481848
gboolean initial)
18491849
{
1850-
int requested_value = 0;
1851-
int current_value = window->bypass_compositor;
1850+
MetaWindowX11 *window_x11 = META_WINDOW_X11 (window);
1851+
MetaWindowX11Private *priv = meta_window_x11_get_private (window_x11);
1852+
MetaBypassCompositorHint requested_value;
1853+
MetaBypassCompositorHint current_value;
18521854

18531855
if (value->type != META_PROP_VALUE_INVALID)
1854-
requested_value = (int) value->v.cardinal;
1856+
requested_value = (MetaBypassCompositorHint) value->v.cardinal;
1857+
else
1858+
requested_value = META_BYPASS_COMPOSITOR_HINT_AUTO;
18551859

1860+
current_value = priv->bypass_compositor;
18561861
if (requested_value == current_value)
18571862
return;
18581863

1859-
if (requested_value == _NET_WM_BYPASS_COMPOSITOR_HINT_ON)
1864+
if (requested_value == META_BYPASS_COMPOSITOR_HINT_ON)
18601865
meta_verbose ("Request to bypass compositor for window %s.\n", window->desc);
1861-
else if (requested_value == _NET_WM_BYPASS_COMPOSITOR_HINT_OFF)
1866+
else if (requested_value == META_BYPASS_COMPOSITOR_HINT_OFF)
18621867
meta_verbose ("Request to don't bypass compositor for window %s.\n", window->desc);
1863-
else if (requested_value != _NET_WM_BYPASS_COMPOSITOR_HINT_AUTO)
1868+
else if (requested_value != META_BYPASS_COMPOSITOR_HINT_AUTO)
18641869
return;
18651870

1866-
window->bypass_compositor = requested_value;
1871+
priv->bypass_compositor = requested_value;
18671872
}
18681873

18691874
static void

src/x11/window-x11-private.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,16 @@
2929

3030
G_BEGIN_DECLS
3131

32+
/*
33+
* Mirrors _NET_WM_BYPASS_COMPOSITOR preference values.
34+
*/
35+
typedef enum _MetaBypassCompositorHint
36+
{
37+
META_BYPASS_COMPOSITOR_HINT_AUTO = 0,
38+
META_BYPASS_COMPOSITOR_HINT_ON = 1,
39+
META_BYPASS_COMPOSITOR_HINT_OFF = 2,
40+
} MetaBypassCompositorHint;
41+
3242
typedef struct _MetaWindowX11Private MetaWindowX11Private;
3343

3444
struct _MetaWindowX11Private
@@ -64,10 +74,16 @@ struct _MetaWindowX11Private
6474

6575
/* Freeze/thaw on resize (for Xwayland) */
6676
gboolean thaw_after_paint;
77+
78+
/* Bypass compositor hints */
79+
MetaBypassCompositorHint bypass_compositor;
6780
};
6881

6982
MetaWindowX11Private * meta_window_x11_get_private (MetaWindowX11 *window_x11);
7083

84+
void meta_window_x11_set_bypass_compositor_hint (MetaWindowX11 *window_x11,
85+
MetaBypassCompositorHint requested_value);
86+
7187
G_END_DECLS
7288

7389
#endif

src/x11/window-x11.c

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4146,3 +4146,62 @@ meta_window_x11_get_client_rect (MetaWindowX11 *window_x11)
41464146

41474147
return priv->client_rect;
41484148
}
4149+
4150+
static gboolean
4151+
has_requested_bypass_compositor (MetaWindowX11 *window_x11)
4152+
{
4153+
MetaWindowX11Private *priv = meta_window_x11_get_instance_private (window_x11);
4154+
4155+
return priv->bypass_compositor == META_BYPASS_COMPOSITOR_HINT_ON;
4156+
}
4157+
4158+
static gboolean
4159+
has_requested_dont_bypass_compositor (MetaWindowX11 *window_x11)
4160+
{
4161+
MetaWindowX11Private *priv = meta_window_x11_get_instance_private (window_x11);
4162+
4163+
return priv->bypass_compositor == META_BYPASS_COMPOSITOR_HINT_OFF;
4164+
}
4165+
4166+
gboolean
4167+
meta_window_x11_can_unredirect (MetaWindowX11 *window_x11)
4168+
{
4169+
MetaWindow *window = META_WINDOW (window_x11);
4170+
4171+
if (has_requested_dont_bypass_compositor (window_x11))
4172+
return FALSE;
4173+
4174+
if (window->opacity != 0xFF)
4175+
return FALSE;
4176+
4177+
if (window->shape_region != NULL)
4178+
return FALSE;
4179+
4180+
if (!window->monitor)
4181+
return FALSE;
4182+
4183+
if (window->fullscreen)
4184+
return TRUE;
4185+
4186+
if (meta_window_is_screen_sized (window))
4187+
return TRUE;
4188+
4189+
if (has_requested_bypass_compositor (window_x11))
4190+
return TRUE;
4191+
4192+
if (window->override_redirect)
4193+
{
4194+
MetaRectangle window_rect;
4195+
MetaRectangle logical_monitor_layout;
4196+
MetaLogicalMonitor *logical_monitor = window->monitor;
4197+
4198+
meta_window_get_frame_rect (window, &window_rect);
4199+
logical_monitor_layout =
4200+
meta_logical_monitor_get_layout (logical_monitor);
4201+
4202+
if (meta_rectangle_equal (&window_rect, &logical_monitor_layout))
4203+
return TRUE;
4204+
}
4205+
4206+
return FALSE;
4207+
}

src/x11/window-x11.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,4 +97,6 @@ void meta_window_x11_surface_rect_to_client_rect (MetaWindow *window,
9797
MetaRectangle *client_rect);
9898

9999
MetaRectangle meta_window_x11_get_client_rect (MetaWindowX11 *window_x11);
100+
101+
gboolean meta_window_x11_can_unredirect (MetaWindowX11 *window_x11);
100102
#endif

0 commit comments

Comments
 (0)