[gnome-shell/wip/focus-management: 5/8] global: Clean up the code that actually sets the shape on the stage



commit ca8136f6b0f69aa8282067069c5058efdd37af7e
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Sat May 18 18:51:58 2013 -0400

    global: Clean up the code that actually sets the shape on the stage
    
    Instead of having "dummy" setters that do work, split out the parts
    that do work into their own function.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=700735

 src/shell-global.c |   42 ++++++++++++++++++++----------------------
 1 files changed, 20 insertions(+), 22 deletions(-)
---
diff --git a/src/shell-global.c b/src/shell-global.c
index 3221b53..1561fe0 100644
--- a/src/shell-global.c
+++ b/src/shell-global.c
@@ -594,6 +594,19 @@ focus_actor_changed (ClutterStage *stage,
   sync_stage_window_focus (global);
 }
 
+static void
+sync_input_region (ShellGlobal *global)
+{
+  MetaScreen *screen = global->meta_screen;
+
+  if (global->gtk_grab_active)
+    meta_empty_stage_input_region (screen);
+  else if (global->input_mode == SHELL_STAGE_INPUT_MODE_FULLSCREEN || !global->input_region)
+    meta_set_stage_input_region (screen, None);
+  else
+    meta_set_stage_input_region (screen, global->input_region);
+}
+
 /**
  * shell_global_set_stage_input_mode:
  * @global: the #ShellGlobal
@@ -613,24 +626,12 @@ void
 shell_global_set_stage_input_mode (ShellGlobal         *global,
                                    ShellStageInputMode  mode)
 {
-  MetaScreen *screen;
-
-  g_return_if_fail (SHELL_IS_GLOBAL (global));
-
-  screen = meta_plugin_get_screen (global->plugin);
-
-  if (global->gtk_grab_active)
-    meta_empty_stage_input_region (screen);
-  else if (mode == SHELL_STAGE_INPUT_MODE_FULLSCREEN || !global->input_region)
-    meta_set_stage_input_region (screen, None);
-  else
-    meta_set_stage_input_region (screen, global->input_region);
+  if (mode == global->input_mode)
+    return;
 
-  if (mode != global->input_mode)
-    {
-      global->input_mode = mode;
-      g_object_notify (G_OBJECT (global), "stage-input-mode");
-    }
+  global->input_mode = mode;
+  sync_input_region (global);
+  g_object_notify (G_OBJECT (global), "stage-input-mode");
 }
 
 /**
@@ -756,10 +757,7 @@ shell_global_set_stage_input_region (ShellGlobal *global,
   global->input_region = XFixesCreateRegion (global->xdisplay, rects, nrects);
   g_free (rects);
 
-  /* set_stage_input_mode() will figure out whether or not we
-   * should actually change the input region right now.
-   */
-  shell_global_set_stage_input_mode (global, global->input_mode);
+  sync_input_region (global);
 }
 
 /**
@@ -1279,7 +1277,7 @@ grab_notify (GtkWidget *widget, gboolean was_grabbed, gpointer user_data)
   global->gtk_grab_active = !was_grabbed;
 
   /* Update for the new setting of gtk_grab_active */
-  shell_global_set_stage_input_mode (global, global->input_mode);
+  sync_input_region (global);
 }
 
 /**


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