[mutter/wip/surface-content: 12/18] compositor: Simplify the unredirected window management code



commit e54b6eb7e502ae57845bc4ffbb88f45f60ecb393
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Fri Dec 6 17:10:44 2013 -0500

    compositor: Simplify the unredirected window management code

 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 2e8d85f..a5efd6e 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 10f925f..7d1654f 100644
--- a/src/compositor/compositor.c
+++ b/src/compositor/compositor.c
@@ -854,6 +854,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)
@@ -882,19 +906,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);
 }
@@ -1500,7 +1516,6 @@ pre_paint_windows (MetaCompScreen *info)
 {
   GList *l;
   MetaWindowActor *top_window;
-  MetaWindowActor *expected_unredirected_window = NULL;
 
   if (info->onscreen == NULL)
     {
@@ -1514,33 +1529,13 @@ pre_paint_windows (MetaCompScreen *info)
   if (info->windows == NULL)
     return;
 
-  if (!meta_is_wayland_compositor ())
-    {
-      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);
-            }
+  top_window = g_list_last (info->windows)->data;
 
-          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 1144554..5420605 100644
--- a/src/compositor/meta-window-group.c
+++ b/src/compositor/meta-window-group.c
@@ -170,9 +170,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);
         }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]