From d6282716b2a64051fbb2b60705569b5f275471e3 Mon Sep 17 00:00:00 2001 From: "Jasper St. Pierre" Date: Fri, 6 Dec 2013 17:10:44 -0500 Subject: [PATCH] compositor: Simplify the unredirected window management code https://bugzilla.gnome.org/show_bug.cgi?id=720631 --- src/compositor/compositor-private.h | 4 +- src/compositor/compositor.c | 73 ++++++++++++++--------------- src/compositor/meta-window-group.c | 3 +- 3 files changed, 37 insertions(+), 43 deletions(-) diff --git a/src/compositor/compositor-private.h b/src/compositor/compositor-private.h index 2e8d85fd9..a5efd6ee8 100644 --- a/src/compositor/compositor-private.h +++ b/src/compositor/compositor-private.h @@ -46,8 +46,8 @@ struct _MetaCompScreen CoglFrameClosure *frame_closure; /* Used for unredirecting fullscreen windows */ - guint disable_unredirect_count; - MetaWindowActor *unredirected_window; + guint disable_unredirect_count; + MetaWindow *unredirected_window; /* Before we create the output window */ XserverRegion pending_input_region; diff --git a/src/compositor/compositor.c b/src/compositor/compositor.c index d2598f48b..73378903d 100644 --- a/src/compositor/compositor.c +++ b/src/compositor/compositor.c @@ -863,6 +863,30 @@ meta_shape_cow_for_window (MetaScreen *screen, } } +static void +set_unredirected_window (MetaCompScreen *info, + MetaWindow *window) +{ + if (info->unredirected_window == window) + return; + + if (info->unredirected_window != NULL) + { + MetaWindowActor *window_actor = META_WINDOW_ACTOR (meta_window_get_compositor_private (info->unredirected_window)); + meta_window_actor_set_redirected (window_actor, TRUE); + } + + info->unredirected_window = window; + + if (info->unredirected_window != NULL) + { + MetaWindowActor *window_actor = META_WINDOW_ACTOR (meta_window_get_compositor_private (info->unredirected_window)); + meta_window_actor_set_redirected (window_actor, FALSE); + } + + meta_shape_cow_for_window (info->screen, info->unredirected_window); +} + void meta_compositor_add_window (MetaCompositor *compositor, MetaWindow *window) @@ -891,19 +915,11 @@ meta_compositor_remove_window (MetaCompositor *compositor, if (!window_actor) return; - if (!meta_is_wayland_compositor ()) - { - screen = meta_window_get_screen (window); - info = meta_screen_get_compositor_data (screen); + screen = meta_window_get_screen (window); + info = meta_screen_get_compositor_data (screen); - if (window_actor == info->unredirected_window) - { - meta_window_actor_set_redirected (window_actor, TRUE); - meta_shape_cow_for_window (meta_window_get_screen (meta_window_actor_get_meta_window (info->unredirected_window)), - NULL); - info->unredirected_window = NULL; - } - } + if (info->unredirected_window == window) + set_unredirected_window (info, NULL); meta_window_actor_destroy (window_actor); } @@ -1533,7 +1549,6 @@ pre_paint_windows (MetaCompScreen *info) { GList *l; MetaWindowActor *top_window; - MetaWindowActor *expected_unredirected_window = NULL; if (info->onscreen == NULL) { @@ -1547,33 +1562,13 @@ pre_paint_windows (MetaCompScreen *info) if (info->windows == NULL) return; - if (!meta_is_wayland_compositor ()) - { - top_window = g_list_last (info->windows)->data; + top_window = g_list_last (info->windows)->data; - if (meta_window_actor_should_unredirect (top_window) && - info->disable_unredirect_count == 0) - expected_unredirected_window = top_window; - - if (info->unredirected_window != expected_unredirected_window) - { - if (info->unredirected_window != NULL) - { - meta_window_actor_set_redirected (info->unredirected_window, TRUE); - meta_shape_cow_for_window (meta_window_get_screen (meta_window_actor_get_meta_window (info->unredirected_window)), - NULL); - } - - if (expected_unredirected_window != NULL) - { - meta_shape_cow_for_window (meta_window_get_screen (meta_window_actor_get_meta_window (top_window)), - meta_window_actor_get_meta_window (top_window)); - meta_window_actor_set_redirected (top_window, FALSE); - } - - info->unredirected_window = expected_unredirected_window; - } - } + if (meta_window_actor_should_unredirect (top_window) && + info->disable_unredirect_count == 0) + set_unredirected_window (info, meta_window_actor_get_meta_window (top_window)); + else + set_unredirected_window (info, NULL); for (l = info->windows; l; l = l->next) meta_window_actor_pre_paint (l->data); diff --git a/src/compositor/meta-window-group.c b/src/compositor/meta-window-group.c index 9554571b0..a36d5961b 100644 --- a/src/compositor/meta-window-group.c +++ b/src/compositor/meta-window-group.c @@ -184,9 +184,8 @@ meta_window_group_paint (ClutterActor *actor) if (info->unredirected_window != NULL) { cairo_rectangle_int_t unredirected_rect; - MetaWindow *window = meta_window_actor_get_meta_window (info->unredirected_window); - meta_window_get_frame_rect (window, (MetaRectangle *)&unredirected_rect); + meta_window_get_frame_rect (info->unredirected_window, (MetaRectangle *)&unredirected_rect); cairo_region_subtract_rectangle (unobscured_region, &unredirected_rect); cairo_region_subtract_rectangle (clip_region, &unredirected_rect); }