[mutter] window: Simplify resize_popup handling



commit 7726001d43953612c9688587a1e016a74338e3c2
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Tue Apr 29 15:35:34 2014 -0400

    window: Simplify resize_popup handling

 src/core/display-private.h |    1 -
 src/core/display.c         |    2 -
 src/core/window-private.h  |    4 +-
 src/core/window.c          |   79 ++++++++++++++++++-------------------------
 4 files changed, 35 insertions(+), 51 deletions(-)
---
diff --git a/src/core/display-private.h b/src/core/display-private.h
index a99fc7e..708a8ec 100644
--- a/src/core/display-private.h
+++ b/src/core/display-private.h
@@ -203,7 +203,6 @@ struct _MetaDisplay
   MetaRectangle grab_initial_window_pos;
   int         grab_initial_x, grab_initial_y;  /* These are only relevant for */
   gboolean    grab_threshold_movement_reached; /* raise_on_click == FALSE.    */
-  MetaResizePopup *grab_resize_popup;
   GTimeVal    grab_last_moveresize_time;
   MetaEdgeResistanceData *grab_edge_resistance_data;
   unsigned int grab_last_user_action_was_snap;
diff --git a/src/core/display.c b/src/core/display.c
index adbec2c..1c6b9c0 100644
--- a/src/core/display.c
+++ b/src/core/display.c
@@ -41,7 +41,6 @@
 #include <meta/errors.h>
 #include "keybindings-private.h"
 #include <meta/prefs.h>
-#include "resizepopup.h"
 #include "workspace-private.h"
 #include "bell.h"
 #include <meta/compositor.h>
@@ -557,7 +556,6 @@ meta_display_open (void)
 
   the_display->grab_op = META_GRAB_OP_NONE;
   the_display->grab_window = NULL;
-  the_display->grab_resize_popup = NULL;
   the_display->grab_tile_mode = META_TILE_NONE;
   the_display->grab_tile_monitor_number = -1;
 
diff --git a/src/core/window-private.h b/src/core/window-private.h
index a7e86a2..fe4abf7 100644
--- a/src/core/window-private.h
+++ b/src/core/window-private.h
@@ -462,6 +462,8 @@ struct _MetaWindow
 
   /* Bypass compositor hints */
   guint bypass_compositor;
+
+  MetaResizePopup *grab_resize_popup;
 };
 
 struct _MetaWindowClass
@@ -650,8 +652,6 @@ gboolean meta_window_same_application (MetaWindow *window,
 #define META_WINDOW_IN_GROUP_TAB_CHAIN(w, g) \
   (((w)->input || (w)->take_focus) && (!g || meta_window_get_group(w)==g))
 
-void meta_window_refresh_resize_popup (MetaWindow *window);
-
 void meta_window_free_delete_dialog (MetaWindow *window);
 
 void meta_window_create_sync_request_alarm  (MetaWindow *window);
diff --git a/src/core/window.c b/src/core/window.c
index abe38e6..a10845e 100644
--- a/src/core/window.c
+++ b/src/core/window.c
@@ -4141,6 +4141,23 @@ meta_window_update_monitor (MetaWindow *window)
     }
 }
 
+static void
+meta_window_refresh_resize_popup (MetaWindow *window)
+{
+  MetaRectangle rect;
+
+  meta_window_get_client_root_coords (window, &rect);
+
+  meta_ui_resize_popup_set (window->grab_resize_popup,
+                            rect,
+                            window->size_hints.base_width,
+                            window->size_hints.base_height,
+                            window->size_hints.width_inc,
+                            window->size_hints.height_inc);
+
+  meta_ui_resize_popup_set_showing (window->grab_resize_popup, TRUE);
+}
+
 void
 meta_window_move_resize_internal (MetaWindow          *window,
                                   MetaMoveResizeFlags  flags,
@@ -4317,7 +4334,8 @@ meta_window_move_resize_internal (MetaWindow          *window,
       meta_topic (META_DEBUG_GEOMETRY, "Size/position not modified\n");
     }
 
-  meta_window_refresh_resize_popup (window);
+  if (window->grab_resize_popup)
+    meta_window_refresh_resize_popup (window);
 
   meta_window_update_monitor (window);
 
@@ -7331,42 +7349,6 @@ meta_window_is_client_decorated (MetaWindow *window)
     }
 }
 
-void
-meta_window_refresh_resize_popup (MetaWindow *window)
-{
-  if (!meta_grab_op_is_resizing (window->display->grab_op))
-    return;
-
-  if (window->display->grab_window != window)
-    return;
-
-  if (window->display->grab_resize_popup == NULL)
-    {
-      if (window->size_hints.width_inc > 1 ||
-          window->size_hints.height_inc > 1)
-        window->display->grab_resize_popup =
-          meta_ui_resize_popup_new (window->display->xdisplay,
-                                    window->screen->number);
-    }
-
-  if (window->display->grab_resize_popup != NULL)
-    {
-      MetaRectangle rect;
-
-      meta_window_get_client_root_coords (window, &rect);
-
-      meta_ui_resize_popup_set (window->display->grab_resize_popup,
-                                rect,
-                                window->size_hints.base_width,
-                                window->size_hints.base_height,
-                                window->size_hints.width_inc,
-                                window->size_hints.height_inc);
-
-      meta_ui_resize_popup_set_showing (window->display->grab_resize_popup,
-                                        TRUE);
-    }
-}
-
 /**
  * meta_window_foreach_transient:
  * @window: a #MetaWindow
@@ -8921,24 +8903,29 @@ void
 meta_window_grab_op_began (MetaWindow *window,
                            MetaGrabOp  op)
 {
-  if (meta_grab_op_is_resizing (op) &&
-      window->sync_request_counter != None)
-    meta_window_create_sync_request_alarm (window);
+  if (meta_grab_op_is_resizing (op))
+    {
+      if (window->sync_request_counter != None)
+        meta_window_create_sync_request_alarm (window);
 
-  meta_window_refresh_resize_popup (window);
+      if (window->size_hints.width_inc > 1 || window->size_hints.height_inc > 1)
+        {
+          window->grab_resize_popup = meta_ui_resize_popup_new (window->display->xdisplay,
+                                                                window->screen->number);
+          meta_window_refresh_resize_popup (window);
+        }
+    }
 }
 
 void
 meta_window_grab_op_ended (MetaWindow *window,
                            MetaGrabOp  op)
 {
-  MetaDisplay *display = window->display;
-
   window->shaken_loose = FALSE;
 
-  if (display->grab_resize_popup)
+  if (window->grab_resize_popup)
     {
-      meta_ui_resize_popup_free (display->grab_resize_popup);
-      display->grab_resize_popup = NULL;
+      meta_ui_resize_popup_free (window->grab_resize_popup);
+      window->grab_resize_popup = NULL;
     }
 }


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