[mutter] Add back coordinates to the window menu



commit 6513cbb470a145217f524f0c82a9aa5790c81b1b
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Thu May 22 08:35:11 2014 -0400

    Add back coordinates to the window menu
    
    It looks weird to have Alt+Space pop up under the cursor instead
    of the top-left corner of the window, and the Wayland request will
    pass through the coordinates as well.
    
    Add it to the compositor interface, and extend the
    _GTK_SHOW_WINDOW_MENU ClientMessage to support it as well.

 src/compositor/compositor.c          |    6 ++++--
 src/compositor/meta-plugin-manager.c |    6 ++++--
 src/compositor/meta-plugin-manager.h |    4 +++-
 src/core/core.c                      |    4 +++-
 src/core/core.h                      |    2 ++
 src/core/keybindings.c               |   11 ++++++++++-
 src/core/window-private.h            |    4 +++-
 src/core/window.c                    |   10 +++++++---
 src/meta/compositor.h                |    4 +++-
 src/meta/meta-plugin.h               |    4 +++-
 src/ui/frames.c                      |   28 +++++++++++++++++++++++++---
 src/x11/window-x11.c                 |    8 +++++++-
 12 files changed, 74 insertions(+), 17 deletions(-)
---
diff --git a/src/compositor/compositor.c b/src/compositor/compositor.c
index b5e3b8c..946ad4b 100644
--- a/src/compositor/compositor.c
+++ b/src/compositor/compositor.c
@@ -1359,7 +1359,9 @@ meta_compositor_hide_tile_preview (MetaCompositor *compositor)
 
 void
 meta_compositor_show_window_menu (MetaCompositor *compositor,
-                                  MetaWindow     *window)
+                                  MetaWindow     *window,
+                                  int             x,
+                                  int             y)
 {
-  meta_plugin_manager_show_window_menu (compositor->plugin_mgr, window);
+  meta_plugin_manager_show_window_menu (compositor->plugin_mgr, window, x, y);
 }
diff --git a/src/compositor/meta-plugin-manager.c b/src/compositor/meta-plugin-manager.c
index 076f315..49873c7 100644
--- a/src/compositor/meta-plugin-manager.c
+++ b/src/compositor/meta-plugin-manager.c
@@ -359,7 +359,9 @@ meta_plugin_manager_hide_tile_preview (MetaPluginManager *plugin_mgr)
 
 void
 meta_plugin_manager_show_window_menu (MetaPluginManager *plugin_mgr,
-                                      MetaWindow        *window)
+                                      MetaWindow        *window,
+                                      int                x,
+                                      int                y)
 {
   MetaPlugin *plugin = plugin_mgr->plugin;
   MetaPluginClass *klass = META_PLUGIN_GET_CLASS (plugin);
@@ -369,5 +371,5 @@ meta_plugin_manager_show_window_menu (MetaPluginManager *plugin_mgr,
     return;
 
   if (klass->show_window_menu)
-    klass->show_window_menu (plugin, window);
+    klass->show_window_menu (plugin, window, x, y);
 }
diff --git a/src/compositor/meta-plugin-manager.h b/src/compositor/meta-plugin-manager.h
index 224f353..471eb5c 100644
--- a/src/compositor/meta-plugin-manager.h
+++ b/src/compositor/meta-plugin-manager.h
@@ -82,6 +82,8 @@ gboolean meta_plugin_manager_show_tile_preview (MetaPluginManager *mgr,
 gboolean meta_plugin_manager_hide_tile_preview (MetaPluginManager *mgr);
 
 void meta_plugin_manager_show_window_menu (MetaPluginManager *mgr,
-                                           MetaWindow        *window);
+                                           MetaWindow        *window,
+                                           int                x,
+                                           int                y);
 
 #endif
diff --git a/src/core/core.c b/src/core/core.c
index 40c0b61..69c2582 100644
--- a/src/core/core.c
+++ b/src/core/core.c
@@ -374,6 +374,8 @@ meta_core_change_workspace (Display *xdisplay,
 void
 meta_core_show_window_menu (Display *xdisplay,
                             Window   frame_xwindow,
+                            int      root_x,
+                            int      root_y,
                             guint32  timestamp)
 {
   MetaWindow *window = get_window (xdisplay, frame_xwindow);
@@ -382,7 +384,7 @@ meta_core_show_window_menu (Display *xdisplay,
     meta_window_raise (window);
   meta_window_focus (window, timestamp);
 
-  meta_window_show_menu (window);
+  meta_window_show_menu (window, root_x, root_y);
 }
 
 const char*
diff --git a/src/core/core.h b/src/core/core.h
index 6490e0a..d722ec2 100644
--- a/src/core/core.h
+++ b/src/core/core.h
@@ -134,6 +134,8 @@ const char* meta_core_get_workspace_name_with_index (Display *xdisplay,
 
 void meta_core_show_window_menu (Display *xdisplay,
                                  Window   frame_xwindow,
+                                 int      root_x,
+                                 int      root_y,
                                  guint32  timestamp);
 
 
diff --git a/src/core/keybindings.c b/src/core/keybindings.c
index 4d908f9..25a4000 100644
--- a/src/core/keybindings.c
+++ b/src/core/keybindings.c
@@ -2726,7 +2726,16 @@ handle_activate_window_menu (MetaDisplay     *display,
                              gpointer         dummy)
 {
   if (display->focus_window)
-    meta_window_show_menu (display->focus_window);
+    {
+      int x, y;
+
+      meta_window_get_position (display->focus_window, &x, &y);
+
+      if (meta_ui_get_direction() == META_UI_DIRECTION_RTL)
+        x += display->focus_window->rect.width;
+
+      meta_window_show_menu (display->focus_window, x, y);
+    }
 }
 
 static void
diff --git a/src/core/window-private.h b/src/core/window-private.h
index eb3d482..18d5f72 100644
--- a/src/core/window-private.h
+++ b/src/core/window-private.h
@@ -605,7 +605,9 @@ void     meta_window_set_focused_internal (MetaWindow *window,
 
 void     meta_window_current_workspace_changed (MetaWindow *window);
 
-void meta_window_show_menu (MetaWindow *window);
+void meta_window_show_menu (MetaWindow *window,
+                            int         x,
+                            int         y);
 
 gboolean meta_window_handle_mouse_grab_op_event  (MetaWindow         *window,
                                                   const ClutterEvent *event);
diff --git a/src/core/window.c b/src/core/window.c
index 53880e4..3acc7d7 100644
--- a/src/core/window.c
+++ b/src/core/window.c
@@ -5313,10 +5313,12 @@ meta_window_recalc_features (MetaWindow *window)
 }
 
 void
-meta_window_show_menu (MetaWindow *window)
+meta_window_show_menu (MetaWindow *window,
+                       int         x,
+                       int         y)
 {
   g_return_if_fail (!window->override_redirect);
-  meta_compositor_show_window_menu (window->display->compositor, window);
+  meta_compositor_show_window_menu (window->display->compositor, window, x, y);
 }
 
 void
@@ -7976,7 +7978,9 @@ meta_window_handle_ungrabbed_event (MetaWindow         *window,
     {
       if (meta_prefs_get_raise_on_click ())
         meta_window_raise (window);
-      meta_window_show_menu (window);
+      meta_window_show_menu (window,
+                             event->button.x,
+                             event->button.y);
       return TRUE;
     }
   else if (fully_modified && (int) event->button.button == 1)
diff --git a/src/meta/compositor.h b/src/meta/compositor.h
index b5d7a54..8520931 100644
--- a/src/meta/compositor.h
+++ b/src/meta/compositor.h
@@ -123,6 +123,8 @@ void meta_compositor_show_tile_preview (MetaCompositor *compositor,
                                         int             tile_monitor_number);
 void meta_compositor_hide_tile_preview (MetaCompositor *compositor);
 void meta_compositor_show_window_menu (MetaCompositor *compositor,
-                                       MetaWindow     *window);
+                                       MetaWindow     *window,
+                                       int             x,
+                                       int             y);
 
 #endif /* META_COMPOSITOR_H */
diff --git a/src/meta/meta-plugin.h b/src/meta/meta-plugin.h
index a2666d0..88d6a18 100644
--- a/src/meta/meta-plugin.h
+++ b/src/meta/meta-plugin.h
@@ -165,7 +165,9 @@ struct _MetaPluginClass
   void (*hide_tile_preview) (MetaPlugin      *plugin);
 
   void (*show_window_menu)  (MetaPlugin      *plugin,
-                             MetaWindow      *window);
+                             MetaWindow      *window,
+                             int              x,
+                             int              y);
 
   /**
    * MetaPluginClass::kill_window_effects:
diff --git a/src/ui/frames.c b/src/ui/frames.c
index fd223d7..01f8bfa 100644
--- a/src/ui/frames.c
+++ b/src/ui/frames.c
@@ -1101,6 +1101,8 @@ meta_frame_titlebar_event (MetaUIFrame    *frame,
     case G_DESKTOP_TITLEBAR_ACTION_MENU:
       meta_core_show_window_menu (display,
                                   frame->xwindow,
+                                  event->x_root,
+                                  event->y_root,
                                   event->time);
       break;
     }
@@ -1210,9 +1212,29 @@ meta_frames_button_press_event (GtkWidget      *widget,
       redraw_control (frames, frame, control);
 
       if (control == META_FRAME_CONTROL_MENU)
-        meta_core_show_window_menu (display,
-                                    frame->xwindow,
-                                    event->time);
+        {
+          MetaFrameGeometry fgeom;
+          GdkRectangle *rect;
+          int dx, dy;
+
+          meta_frames_calc_geometry (frames, frame, &fgeom);
+
+          rect = control_rect (META_FRAME_CONTROL_MENU, &fgeom);
+
+          /* get delta to convert to root coords */
+          dx = event->x_root - event->x;
+          dy = event->y_root - event->y;
+
+          /* Align to the right end of the menu rectangle if RTL */
+          if (meta_ui_get_direction() == META_UI_DIRECTION_RTL)
+            dx += rect->width;
+
+          meta_core_show_window_menu (display,
+                                      frame->xwindow,
+                                      rect->x + dx,
+                                      rect->y + rect->height + dy,
+                                      event->time);
+        }
     }
   else if (event->button == 1 &&
            (control == META_FRAME_CONTROL_RESIZE_SE ||
diff --git a/src/x11/window-x11.c b/src/x11/window-x11.c
index 54654fd..e5db696 100644
--- a/src/x11/window-x11.c
+++ b/src/x11/window-x11.c
@@ -2729,7 +2729,13 @@ meta_window_x11_client_message (MetaWindow *window,
   else if (event->xclient.message_type ==
            display->atom__GTK_SHOW_WINDOW_MENU)
     {
-      meta_window_show_menu (window);
+      gulong x, y;
+
+      /* l[0] is device_id, which we don't use */
+      x = event->xclient.data.l[1];
+      y = event->xclient.data.l[2];
+
+      meta_window_show_menu (window, x, y);
     }
 
   return FALSE;


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