[mutter] Actually implement opening the app menu



commit 31db32e8262d53a8bcb853c1fbf19df92b63845c
Author: Florian Müllner <fmuellner gnome org>
Date:   Fri May 23 23:14:51 2014 +0200

    Actually implement opening the app menu
    
    The last commit added support for the "appmenu" button in decorations,
    but didn't actually implement it. Add a new MetaWindowMenuType parameter
    to the show_window_menu () functions and use it to ask the compositor
    to display the app menu when the new button is activated.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=730752

 src/compositor/compositor.c          |   11 ++++++-----
 src/compositor/meta-plugin-manager.c |   11 ++++++-----
 src/compositor/meta-plugin-manager.h |   10 ++++++----
 src/core/core.c                      |   13 +++++++------
 src/core/core.h                      |   12 ++++++------
 src/core/keybindings.c               |    2 +-
 src/core/window-private.h            |    7 ++++---
 src/core/window.c                    |   10 ++++++----
 src/meta/common.h                    |   13 +++++++++++++
 src/meta/compositor.h                |    9 +++++----
 src/meta/meta-plugin.h               |    9 +++++----
 src/ui/frames.c                      |   14 +++++++++++---
 src/wayland/meta-wayland-surface.c   |    2 +-
 src/x11/window-x11.c                 |    2 +-
 14 files changed, 78 insertions(+), 47 deletions(-)
---
diff --git a/src/compositor/compositor.c b/src/compositor/compositor.c
index 946ad4b..901dd1e 100644
--- a/src/compositor/compositor.c
+++ b/src/compositor/compositor.c
@@ -1358,10 +1358,11 @@ meta_compositor_hide_tile_preview (MetaCompositor *compositor)
 }
 
 void
-meta_compositor_show_window_menu (MetaCompositor *compositor,
-                                  MetaWindow     *window,
-                                  int             x,
-                                  int             y)
+meta_compositor_show_window_menu (MetaCompositor     *compositor,
+                                  MetaWindow         *window,
+                                  MetaWindowMenuType  menu,
+                                  int                 x,
+                                  int                 y)
 {
-  meta_plugin_manager_show_window_menu (compositor->plugin_mgr, window, x, y);
+  meta_plugin_manager_show_window_menu (compositor->plugin_mgr, window, menu, x, y);
 }
diff --git a/src/compositor/meta-plugin-manager.c b/src/compositor/meta-plugin-manager.c
index 49873c7..c3c9b72 100644
--- a/src/compositor/meta-plugin-manager.c
+++ b/src/compositor/meta-plugin-manager.c
@@ -358,10 +358,11 @@ meta_plugin_manager_hide_tile_preview (MetaPluginManager *plugin_mgr)
 }
 
 void
-meta_plugin_manager_show_window_menu (MetaPluginManager *plugin_mgr,
-                                      MetaWindow        *window,
-                                      int                x,
-                                      int                y)
+meta_plugin_manager_show_window_menu (MetaPluginManager  *plugin_mgr,
+                                      MetaWindow         *window,
+                                      MetaWindowMenuType  menu,
+                                      int                 x,
+                                      int                 y)
 {
   MetaPlugin *plugin = plugin_mgr->plugin;
   MetaPluginClass *klass = META_PLUGIN_GET_CLASS (plugin);
@@ -371,5 +372,5 @@ meta_plugin_manager_show_window_menu (MetaPluginManager *plugin_mgr,
     return;
 
   if (klass->show_window_menu)
-    klass->show_window_menu (plugin, window, x, y);
+    klass->show_window_menu (plugin, window, menu, x, y);
 }
diff --git a/src/compositor/meta-plugin-manager.h b/src/compositor/meta-plugin-manager.h
index 471eb5c..da5a726 100644
--- a/src/compositor/meta-plugin-manager.h
+++ b/src/compositor/meta-plugin-manager.h
@@ -81,9 +81,11 @@ gboolean meta_plugin_manager_show_tile_preview (MetaPluginManager *mgr,
                                                 int                tile_monitor_number);
 gboolean meta_plugin_manager_hide_tile_preview (MetaPluginManager *mgr);
 
-void meta_plugin_manager_show_window_menu (MetaPluginManager *mgr,
-                                           MetaWindow        *window,
-                                           int                x,
-                                           int                y);
+void meta_plugin_manager_show_window_menu (MetaPluginManager  *mgr,
+                                           MetaWindow         *window,
+                                           MetaWindowMenuType  menu,
+                                           int                 x,
+                                           int                 y);
+
 
 #endif
diff --git a/src/core/core.c b/src/core/core.c
index 23580e4..6eed661 100644
--- a/src/core/core.c
+++ b/src/core/core.c
@@ -374,11 +374,12 @@ 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)
+meta_core_show_window_menu (Display            *xdisplay,
+                            Window              frame_xwindow,
+                            MetaWindowMenuType  menu,
+                            int                 root_x,
+                            int                 root_y,
+                            guint32             timestamp)
 {
   MetaWindow *window = get_window (xdisplay, frame_xwindow);
 
@@ -386,7 +387,7 @@ meta_core_show_window_menu (Display *xdisplay,
     meta_window_raise (window);
   meta_window_focus (window, timestamp);
 
-  meta_window_show_menu (window, root_x, root_y);
+  meta_window_show_menu (window, menu, root_x, root_y);
 }
 
 const char*
diff --git a/src/core/core.h b/src/core/core.h
index d722ec2..c6df0e0 100644
--- a/src/core/core.h
+++ b/src/core/core.h
@@ -132,12 +132,12 @@ const char* meta_core_get_workspace_name_with_index (Display *xdisplay,
                                                      Window xroot,
                                                      int    index);
 
-void meta_core_show_window_menu (Display *xdisplay,
-                                 Window   frame_xwindow,
-                                 int      root_x,
-                                 int      root_y,
-                                 guint32  timestamp);
-
+void meta_core_show_window_menu (Display            *xdisplay,
+                                 Window              frame_xwindow,
+                                 MetaWindowMenuType  menu,
+                                 int                 root_x,
+                                 int                 root_y,
+                                 guint32             timestamp);
 
 gboolean   meta_core_begin_grab_op (Display    *xdisplay,
                                     Window      frame_xwindow,
diff --git a/src/core/keybindings.c b/src/core/keybindings.c
index 44cb4e4..e9687c1 100644
--- a/src/core/keybindings.c
+++ b/src/core/keybindings.c
@@ -2751,7 +2751,7 @@ handle_activate_window_menu (MetaDisplay     *display,
         x += child_rect.width;
 
       y = frame_rect.y + child_rect.y;
-      meta_window_show_menu (display->focus_window, x, y);
+      meta_window_show_menu (display->focus_window, META_WINDOW_MENU_WM, x, y);
     }
 }
 
diff --git a/src/core/window-private.h b/src/core/window-private.h
index b68d44a..5d6ce40 100644
--- a/src/core/window-private.h
+++ b/src/core/window-private.h
@@ -605,9 +605,10 @@ void     meta_window_set_focused_internal (MetaWindow *window,
 
 void     meta_window_current_workspace_changed (MetaWindow *window);
 
-void meta_window_show_menu (MetaWindow *window,
-                            int         x,
-                            int         y);
+void meta_window_show_menu (MetaWindow         *window,
+                            MetaWindowMenuType  menu,
+                            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 47442a1..1a1fca7 100644
--- a/src/core/window.c
+++ b/src/core/window.c
@@ -5314,12 +5314,13 @@ meta_window_recalc_features (MetaWindow *window)
 }
 
 void
-meta_window_show_menu (MetaWindow *window,
-                       int         x,
-                       int         y)
+meta_window_show_menu (MetaWindow         *window,
+                       MetaWindowMenuType  menu,
+                       int                 x,
+                       int                 y)
 {
   g_return_if_fail (!window->override_redirect);
-  meta_compositor_show_window_menu (window->display->compositor, window, x, y);
+  meta_compositor_show_window_menu (window->display->compositor, window, menu, x, y);
 }
 
 void
@@ -7980,6 +7981,7 @@ 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_MENU_WM,
                              event->button.x,
                              event->button.y);
       return TRUE;
diff --git a/src/meta/common.h b/src/meta/common.h
index f413936..411ac37 100644
--- a/src/meta/common.h
+++ b/src/meta/common.h
@@ -388,6 +388,19 @@ struct _MetaButtonLayout
 };
 
 /**
+ * MetaWindowMenuType:
+ * @META_WINDOW_MENU_WM: the window manager menu
+ * @META_WINDOW_MENU_APP: the (fallback) app menu
+ *
+ * Menu the compositor should display for a given window
+ */
+typedef enum
+{
+  META_WINDOW_MENU_WM,
+  META_WINDOW_MENU_APP
+} MetaWindowMenuType;
+
+/**
  * MetaFrameBorders:
  * @visible: inner visible portion of frame border
  * @invisible: outer invisible portion of frame border
diff --git a/src/meta/compositor.h b/src/meta/compositor.h
index 8520931..792602e 100644
--- a/src/meta/compositor.h
+++ b/src/meta/compositor.h
@@ -122,9 +122,10 @@ void meta_compositor_show_tile_preview (MetaCompositor *compositor,
                                         MetaRectangle  *tile_rect,
                                         int             tile_monitor_number);
 void meta_compositor_hide_tile_preview (MetaCompositor *compositor);
-void meta_compositor_show_window_menu (MetaCompositor *compositor,
-                                       MetaWindow     *window,
-                                       int             x,
-                                       int             y);
+void meta_compositor_show_window_menu (MetaCompositor     *compositor,
+                                       MetaWindow         *window,
+                                      MetaWindowMenuType  menu,
+                                       int                 x,
+                                       int                 y);
 
 #endif /* META_COMPOSITOR_H */
diff --git a/src/meta/meta-plugin.h b/src/meta/meta-plugin.h
index 88d6a18..6cf8b41 100644
--- a/src/meta/meta-plugin.h
+++ b/src/meta/meta-plugin.h
@@ -164,10 +164,11 @@ struct _MetaPluginClass
                              int              tile_monitor_number);
   void (*hide_tile_preview) (MetaPlugin      *plugin);
 
-  void (*show_window_menu)  (MetaPlugin      *plugin,
-                             MetaWindow      *window,
-                             int              x,
-                             int              y);
+  void (*show_window_menu)  (MetaPlugin         *plugin,
+                             MetaWindow         *window,
+                             MetaWindowMenuType  menu,
+                             int                 x,
+                             int                 y);
 
   /**
    * MetaPluginClass::kill_window_effects:
diff --git a/src/ui/frames.c b/src/ui/frames.c
index 36d477e..9de29f4 100644
--- a/src/ui/frames.c
+++ b/src/ui/frames.c
@@ -1101,6 +1101,7 @@ meta_frame_titlebar_event (MetaUIFrame    *frame,
     case G_DESKTOP_TITLEBAR_ACTION_MENU:
       meta_core_show_window_menu (display,
                                   frame->xwindow,
+                                  META_WINDOW_MENU_WM,
                                   event->x_root,
                                   event->y_root,
                                   event->time);
@@ -1202,7 +1203,8 @@ meta_frames_button_press_event (GtkWidget      *widget,
        control == META_FRAME_CONTROL_UNABOVE ||
        control == META_FRAME_CONTROL_STICK ||
        control == META_FRAME_CONTROL_UNSTICK ||
-       control == META_FRAME_CONTROL_MENU))
+       control == META_FRAME_CONTROL_MENU ||
+       control == META_FRAME_CONTROL_APPMENU))
     {
       frames->grab_xwindow = frame->xwindow;
 
@@ -1211,15 +1213,17 @@ meta_frames_button_press_event (GtkWidget      *widget,
       frame->prelit_control = control;
       redraw_control (frames, frame, control);
 
-      if (control == META_FRAME_CONTROL_MENU)
+      if (control == META_FRAME_CONTROL_MENU ||
+          control == META_FRAME_CONTROL_APPMENU)
         {
           MetaFrameGeometry fgeom;
           GdkRectangle *rect;
+          MetaWindowMenuType menu;
           int dx, dy;
 
           meta_frames_calc_geometry (frames, frame, &fgeom);
 
-          rect = control_rect (META_FRAME_CONTROL_MENU, &fgeom);
+          rect = control_rect (control, &fgeom);
 
           /* get delta to convert to root coords */
           dx = event->x_root - event->x;
@@ -1229,8 +1233,12 @@ meta_frames_button_press_event (GtkWidget      *widget,
           if (meta_ui_get_direction() == META_UI_DIRECTION_RTL)
             dx += rect->width;
 
+          menu = control == META_FRAME_CONTROL_MENU ? META_WINDOW_MENU_WM
+                                                    : META_WINDOW_MENU_APP;
+
           meta_core_show_window_menu (display,
                                       frame->xwindow,
+                                      menu,
                                       rect->x + dx,
                                       rect->y + rect->height + dy,
                                       event->time);
diff --git a/src/wayland/meta-wayland-surface.c b/src/wayland/meta-wayland-surface.c
index c2abdd4..2ab26df 100644
--- a/src/wayland/meta-wayland-surface.c
+++ b/src/wayland/meta-wayland-surface.c
@@ -784,7 +784,7 @@ xdg_surface_show_window_menu (struct wl_client *client,
   if (!meta_wayland_seat_can_grab_surface (seat, surface, serial))
     return;
 
-  meta_window_show_menu (surface->window, x, y);
+  meta_window_show_menu (surface->window, META_WINDOW_MENU_WM, x, y);
 }
 
 static gboolean
diff --git a/src/x11/window-x11.c b/src/x11/window-x11.c
index 2ddff3d..957bfa1 100644
--- a/src/x11/window-x11.c
+++ b/src/x11/window-x11.c
@@ -2723,7 +2723,7 @@ meta_window_x11_client_message (MetaWindow *window,
       x = event->xclient.data.l[1];
       y = event->xclient.data.l[2];
 
-      meta_window_show_menu (window, x, y);
+      meta_window_show_menu (window, META_WINDOW_MENU_WM, x, y);
     }
 
   return FALSE;


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