[mutter] Move the resizepopup to a compositor-side feature



commit 2dd1f37820507384d04e714ae9de337f71f66b34
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Mon Dec 29 17:20:07 2014 -0800

    Move the resizepopup to a compositor-side feature
    
    This is the last big feature that requires X11 on Wayland, so let's just
    trash it and make GNOME Shell reimplement it.

 src/Makefile.am              |    2 -
 src/core/display-private.h   |    6 +
 src/core/display.c           |   27 +++++
 src/ui/resizepopup.c         |  238 ------------------------------------------
 src/ui/resizepopup.h         |   47 --------
 src/x11/window-x11-private.h |    3 +-
 src/x11/window-x11.c         |   40 ++++---
 7 files changed, 58 insertions(+), 305 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index 94d2b22..17bfb34 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -198,8 +198,6 @@ libmutter_la_SOURCES =                              \
        ui/ui.h                                 \
        ui/frames.c                             \
        ui/frames.h                             \
-       ui/resizepopup.c                        \
-       ui/resizepopup.h                        \
        ui/theme.c                              \
        meta/theme.h                            \
        ui/theme-private.h                      \
diff --git a/src/core/display-private.h b/src/core/display-private.h
index a4c7959..07d4e2e 100644
--- a/src/core/display-private.h
+++ b/src/core/display-private.h
@@ -478,6 +478,12 @@ gboolean meta_display_show_restart_message (MetaDisplay *display,
                                             const char  *message);
 gboolean meta_display_request_restart      (MetaDisplay *display);
 
+gboolean meta_display_show_resize_popup (MetaDisplay *display,
+                                         gboolean show,
+                                         MetaRectangle *rect,
+                                         int display_w,
+                                         int display_h);
+
 void meta_restart_init (void);
 void meta_restart_finish (void);
 
diff --git a/src/core/display.c b/src/core/display.c
index d796963..936100a 100644
--- a/src/core/display.c
+++ b/src/core/display.c
@@ -122,6 +122,7 @@ enum
   GRAB_OP_END,
   SHOW_RESTART_MESSAGE,
   RESTART,
+  SHOW_RESIZE_POPUP,
   LAST_SIGNAL
 };
 
@@ -329,6 +330,16 @@ meta_display_class_init (MetaDisplayClass *klass)
                   NULL, NULL,
                   G_TYPE_BOOLEAN, 0);
 
+  display_signals[SHOW_RESIZE_POPUP] =
+    g_signal_new ("show-resize-popup",
+                  G_TYPE_FROM_CLASS (klass),
+                  G_SIGNAL_RUN_LAST,
+                  0,
+                  g_signal_accumulator_true_handled,
+                  NULL, NULL,
+                  G_TYPE_BOOLEAN, 4,
+                  G_TYPE_BOOLEAN, META_TYPE_RECTANGLE, G_TYPE_INT, G_TYPE_INT);
+
   g_object_class_install_property (object_class,
                                    PROP_FOCUS_WINDOW,
                                    g_param_spec_object ("focus-window",
@@ -3018,6 +3029,22 @@ meta_display_request_restart (MetaDisplay *display)
   return result;
 }
 
+gboolean
+meta_display_show_resize_popup (MetaDisplay *display,
+                                gboolean show,
+                                MetaRectangle *rect,
+                                int display_w,
+                                int display_h)
+{
+  gboolean result = FALSE;
+
+  g_signal_emit (display,
+                 display_signals[SHOW_RESIZE_POPUP], 0,
+                 show, rect, display_w, display_h, &result);
+
+  return result;
+}
+
 /**
  * meta_display_is_pointer_emulating_sequence:
  * @display: the display
diff --git a/src/x11/window-x11-private.h b/src/x11/window-x11-private.h
index d909a0c..6234173 100644
--- a/src/x11/window-x11-private.h
+++ b/src/x11/window-x11-private.h
@@ -25,7 +25,6 @@
 
 #include "window-private.h"
 #include "x11/iconcache.h"
-#include "ui/resizepopup.h"
 
 G_BEGIN_DECLS
 
@@ -56,7 +55,7 @@ struct _MetaWindowX11Private
   /* Requested geometry */
   int border_width;
 
-  MetaResizePopup *grab_resize_popup;
+  gboolean showing_resize_popup;
 
   /* These are in server coordinates. If we have a frame, it's
    * relative to the frame. */
diff --git a/src/x11/window-x11.c b/src/x11/window-x11.c
index 321360e..fefef3b 100644
--- a/src/x11/window-x11.c
+++ b/src/x11/window-x11.c
@@ -44,7 +44,6 @@
 #include "window-private.h"
 #include "window-props.h"
 #include "xprops.h"
-#include "resizepopup.h"
 #include "session.h"
 #include "workspace-private.h"
 
@@ -831,18 +830,28 @@ meta_window_refresh_resize_popup (MetaWindow *window)
 {
   MetaWindowX11 *window_x11 = META_WINDOW_X11 (window);
   MetaWindowX11Private *priv = meta_window_x11_get_instance_private (window_x11);
-  MetaRectangle rect;
 
-  meta_window_get_client_root_coords (window, &rect);
+  if (priv->showing_resize_popup)
+    {
+      MetaRectangle rect;
+      int display_w, display_h;
+
+      meta_window_get_client_root_coords (window, &rect);
+
+      display_w = (rect.width - window->size_hints.base_width);
+      if (window->size_hints.width_inc > 0)
+        display_w /= window->size_hints.width_inc;
 
-  meta_ui_resize_popup_set (priv->grab_resize_popup,
-                            rect,
-                            window->size_hints.base_width,
-                            window->size_hints.base_height,
-                            window->size_hints.width_inc,
-                            window->size_hints.height_inc);
+      display_h = (rect.height - window->size_hints.base_height);
+      if (window->size_hints.height_inc > 0)
+        display_h /= window->size_hints.height_inc;
 
-  meta_ui_resize_popup_set_showing (priv->grab_resize_popup, TRUE);
+      meta_display_show_resize_popup (window->display, TRUE, &rect, display_w, display_h);
+    }
+  else
+    {
+      meta_display_show_resize_popup (window->display, FALSE, NULL, 0, 0);
+    }
 }
 
 static void
@@ -859,8 +868,7 @@ meta_window_x11_grab_op_began (MetaWindow *window,
 
       if (window->size_hints.width_inc > 1 || window->size_hints.height_inc > 1)
         {
-          priv->grab_resize_popup = meta_ui_resize_popup_new (window->display->xdisplay,
-                                                              window->screen->number);
+          priv->showing_resize_popup = TRUE;
           meta_window_refresh_resize_popup (window);
         }
     }
@@ -875,10 +883,10 @@ meta_window_x11_grab_op_ended (MetaWindow *window,
   MetaWindowX11 *window_x11 = META_WINDOW_X11 (window);
   MetaWindowX11Private *priv = meta_window_x11_get_instance_private (window_x11);
 
-  if (priv->grab_resize_popup)
+  if (priv->showing_resize_popup)
     {
-      meta_ui_resize_popup_free (priv->grab_resize_popup);
-      priv->grab_resize_popup = NULL;
+      priv->showing_resize_popup = FALSE;
+      meta_window_refresh_resize_popup (window);
     }
 
   META_WINDOW_CLASS (meta_window_x11_parent_class)->grab_op_ended (window, op);
@@ -1264,7 +1272,7 @@ meta_window_x11_move_resize_internal (MetaWindow                *window,
   if (need_configure_notify)
     send_configure_notify (window);
 
-  if (priv->grab_resize_popup)
+  if (priv->showing_resize_popup)
     meta_window_refresh_resize_popup (window);
 
   if (frame_shape_changed)


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