From 9ac52f034081d7b32cf2c3729137ab78eae885aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Sat, 17 Aug 2019 09:46:55 +0200 Subject: [PATCH] compositor/x11: Move unredirect logic to helper It makes it clearer what is required for unredirecting a window. https://gitlab.gnome.org/GNOME/mutter/merge_requests/734 --- src/compositor/meta-compositor-x11.c | 39 +++++++++++++++++----------- 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/src/compositor/meta-compositor-x11.c b/src/compositor/meta-compositor-x11.c index 4f99c35f5..b31ec451c 100644 --- a/src/compositor/meta-compositor-x11.c +++ b/src/compositor/meta-compositor-x11.c @@ -229,27 +229,36 @@ set_unredirected_window (MetaCompositorX11 *compositor_x11, } } +static void +maybe_unredirect_top_window (MetaCompositorX11 *compositor_x11) +{ + MetaCompositor *compositor = META_COMPOSITOR (compositor_x11); + MetaWindow *window_to_unredirect = NULL; + MetaWindowActor *window_actor; + + if (meta_compositor_is_unredirect_inhibited (compositor)) + goto out; + + window_actor = meta_compositor_get_top_window_actor (compositor); + if (!window_actor) + goto out; + + if (!meta_window_actor_should_unredirect (window_actor)) + goto out; + + window_to_unredirect = meta_window_actor_get_meta_window (window_actor); + +out: + set_unredirected_window (compositor_x11, window_to_unredirect); +} + static void meta_compositor_x11_pre_paint (MetaCompositor *compositor) { MetaCompositorX11 *compositor_x11 = META_COMPOSITOR_X11 (compositor); - MetaWindowActor *top_window_actor; MetaCompositorClass *parent_class; - top_window_actor = meta_compositor_get_top_window_actor (compositor); - if (!meta_compositor_is_unredirect_inhibited (compositor) && - top_window_actor && - meta_window_actor_should_unredirect (top_window_actor)) - { - MetaWindow *top_window; - - top_window = meta_window_actor_get_meta_window (top_window_actor); - set_unredirected_window (compositor_x11, top_window); - } - else - { - set_unredirected_window (compositor_x11, NULL); - } + maybe_unredirect_top_window (compositor_x11); parent_class = META_COMPOSITOR_CLASS (meta_compositor_x11_parent_class); parent_class->pre_paint (compositor);