compositor: Simplify the unredirected window management code

https://bugzilla.gnome.org/show_bug.cgi?id=720631
This commit is contained in:
Jasper St. Pierre 2013-12-06 17:10:44 -05:00
parent e3b64912b6
commit fa7a5782c6
3 changed files with 37 additions and 43 deletions

View File

@ -47,7 +47,7 @@ struct _MetaCompScreen
/* Used for unredirecting fullscreen windows */ /* Used for unredirecting fullscreen windows */
guint disable_unredirect_count; guint disable_unredirect_count;
MetaWindowActor *unredirected_window; MetaWindow *unredirected_window;
gint switch_workspace_in_progress; gint switch_workspace_in_progress;

View File

@ -805,6 +805,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 void
meta_compositor_add_window (MetaCompositor *compositor, meta_compositor_add_window (MetaCompositor *compositor,
MetaWindow *window) MetaWindow *window)
@ -833,19 +857,11 @@ meta_compositor_remove_window (MetaCompositor *compositor,
if (!window_actor) if (!window_actor)
return; return;
if (!meta_is_wayland_compositor ())
{
screen = meta_window_get_screen (window); screen = meta_window_get_screen (window);
info = meta_screen_get_compositor_data (screen); info = meta_screen_get_compositor_data (screen);
if (window_actor == info->unredirected_window) if (info->unredirected_window == window)
{ set_unredirected_window (info, NULL);
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;
}
}
meta_window_actor_destroy (window_actor); meta_window_actor_destroy (window_actor);
} }
@ -1451,7 +1467,6 @@ pre_paint_windows (MetaCompScreen *info)
{ {
GList *l; GList *l;
MetaWindowActor *top_window; MetaWindowActor *top_window;
MetaWindowActor *expected_unredirected_window = NULL;
if (info->onscreen == NULL) if (info->onscreen == NULL)
{ {
@ -1465,33 +1480,13 @@ pre_paint_windows (MetaCompScreen *info)
if (info->windows == NULL) if (info->windows == NULL)
return; 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) && if (meta_window_actor_should_unredirect (top_window) &&
info->disable_unredirect_count == 0) info->disable_unredirect_count == 0)
expected_unredirected_window = top_window; set_unredirected_window (info, meta_window_actor_get_meta_window (top_window));
else
if (info->unredirected_window != expected_unredirected_window) set_unredirected_window (info, NULL);
{
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;
}
}
for (l = info->windows; l; l = l->next) for (l = info->windows; l; l = l->next)
meta_window_actor_pre_paint (l->data); meta_window_actor_pre_paint (l->data);

View File

@ -170,9 +170,8 @@ meta_window_group_paint (ClutterActor *actor)
if (info->unredirected_window != NULL) if (info->unredirected_window != NULL)
{ {
cairo_rectangle_int_t unredirected_rect; 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 (unobscured_region, &unredirected_rect);
cairo_region_subtract_rectangle (clip_region, &unredirected_rect); cairo_region_subtract_rectangle (clip_region, &unredirected_rect);
} }