[mutter/wip/multitouchr: 58/73] ui: Add a MetaDevice arg to meta_window_menu_popup()



commit 827999aa8281558e9b44077baff39822167e2378
Author: Carlos Garnacho <carlosg gnome org>
Date:   Tue Aug 2 01:12:04 2011 +0200

    ui: Add a MetaDevice arg to meta_window_menu_popup()
    
    This will be the device popping up the menu, gtk_menu_popup()
    uses the current GTK+ event device, and that might not even be
    filled up with mutter event bypassing.

 src/core/core.c           |    5 ++++-
 src/core/core.h           |    1 +
 src/core/display.c        |    1 +
 src/core/keybindings.c    |    1 +
 src/core/window-private.h |    1 +
 src/core/window.c         |    3 ++-
 src/ui/frames.c           |    2 ++
 src/ui/menu.c             |   24 +++++++++++++++++-------
 src/ui/menu.h             |    2 ++
 src/ui/ui.c               |    3 ++-
 src/ui/ui.h               |    2 ++
 11 files changed, 35 insertions(+), 10 deletions(-)
---
diff --git a/src/core/core.c b/src/core/core.c
index 2bb91e0..a64d251 100644
--- a/src/core/core.c
+++ b/src/core/core.c
@@ -512,12 +512,14 @@ meta_core_get_active_workspace (Screen *xscreen)
 void
 meta_core_show_window_menu (Display *xdisplay,
                             Window   frame_xwindow,
+                            int      device_id,
                             int      root_x,
                             int      root_y,
                             int      button,
                             guint32  timestamp)
 {
   MetaWindow *window = get_window (xdisplay, frame_xwindow);
+  MetaDevice *device;
 
   /* There is already a menu popped up,
    * most likely from another device
@@ -529,7 +531,8 @@ 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, button, timestamp);
+  device = meta_device_map_lookup (window->display->device_map, device_id);
+  meta_window_show_menu (window, device, root_x, root_y, button, timestamp);
 }
 
 void
diff --git a/src/core/core.h b/src/core/core.h
index 28e753c..dd50170 100644
--- a/src/core/core.h
+++ b/src/core/core.h
@@ -165,6 +165,7 @@ const char* meta_core_get_workspace_name_with_index (Display *xdisplay,
 
 void meta_core_show_window_menu (Display *xdisplay,
                                  Window   frame_xwindow,
+                                 int      device_id,
                                  int      root_x,
                                  int      root_y,
                                  int      button,
diff --git a/src/core/display.c b/src/core/display.c
index bd859d0..4d10beb 100644
--- a/src/core/display.c
+++ b/src/core/display.c
@@ -2198,6 +2198,7 @@ event_callback (XEvent   *event,
                   if (meta_prefs_get_raise_on_click ())
                     meta_window_raise (window);
                   meta_window_show_menu (window,
+                                         device,
                                          ev_root_x,
                                          ev_root_y,
                                          n_button,
diff --git a/src/core/keybindings.c b/src/core/keybindings.c
index b39f1d8..2d599f9 100644
--- a/src/core/keybindings.c
+++ b/src/core/keybindings.c
@@ -3138,6 +3138,7 @@ handle_activate_window_menu (MetaDisplay    *display,
       evtime = meta_input_event_get_time (display, event);
 
       meta_window_show_menu (focus_info->focus_window,
+                             meta_device_get_paired_device (device),
                              x, y,
                              0,
                              evtime);
diff --git a/src/core/window-private.h b/src/core/window-private.h
index 5809ff8..6b530d3 100644
--- a/src/core/window-private.h
+++ b/src/core/window-private.h
@@ -585,6 +585,7 @@ void     meta_window_set_current_workspace_hint (MetaWindow *window);
 unsigned long meta_window_get_net_wm_desktop (MetaWindow *window);
 
 void meta_window_show_menu (MetaWindow *window,
+                            MetaDevice *device,
                             int         root_x,
                             int         root_y,
                             int         button,
diff --git a/src/core/window.c b/src/core/window.c
index ab4aa69..faaf8e0 100644
--- a/src/core/window.c
+++ b/src/core/window.c
@@ -8394,6 +8394,7 @@ menu_callback (MetaWindowMenu *menu,
 
 void
 meta_window_show_menu (MetaWindow *window,
+                       MetaDevice *device,
                        int         root_x,
                        int         root_y,
                        int         button,
@@ -8518,7 +8519,7 @@ meta_window_show_menu (MetaWindow *window,
 
   meta_verbose ("Popping up window menu for %s\n", window->desc);
 
-  meta_ui_window_menu_popup (menu, root_x, root_y, button, timestamp);
+  meta_ui_window_menu_popup (menu, device, root_x, root_y, button, timestamp);
 }
 
 void
diff --git a/src/ui/frames.c b/src/ui/frames.c
index 7fc85ff..7162555 100644
--- a/src/ui/frames.c
+++ b/src/ui/frames.c
@@ -1143,6 +1143,7 @@ meta_frame_titlebar_event (MetaUIFrame    *frame,
     case G_DESKTOP_TITLEBAR_ACTION_MENU:
       meta_core_show_window_menu (display,
                                   frame->xwindow,
+                                  gdk_x11_device_get_id (pointer),
                                   event->x_root,
                                   event->y_root,
                                   event->button,
@@ -1330,6 +1331,7 @@ meta_frames_button_press_event (GtkWidget      *widget,
 
           meta_core_show_window_menu (display,
                                       frame->xwindow,
+                                      device_id,
                                       rect->x + dx,
                                       rect->y + rect->height + dy,
                                       event->button,
diff --git a/src/ui/menu.c b/src/ui/menu.c
index 5c0dd16..5509e26 100644
--- a/src/ui/menu.c
+++ b/src/ui/menu.c
@@ -498,13 +498,17 @@ meta_window_menu_new   (MetaFrames         *frames,
 
 void
 meta_window_menu_popup (MetaWindowMenu     *menu,
+                        MetaDevice         *device,
                         int                 root_x,
                         int                 root_y,
                         int                 button,
                         guint32             timestamp)
 {
+  GdkDeviceManager *device_manager;
+  GdkDevice *gdkdevice;
+  GdkDisplay *display;
   GdkPoint *pt;
-  
+
   pt = g_new (GdkPoint, 1);
 
   g_object_set_data_full (G_OBJECT (menu->menu),
@@ -514,12 +518,18 @@ meta_window_menu_popup (MetaWindowMenu     *menu,
 
   pt->x = root_x;
   pt->y = root_y;
-  
-  gtk_menu_popup (GTK_MENU (menu->menu),
-                  NULL, NULL,
-                  popup_position_func, pt,
-                  button,
-                  timestamp);
+
+  display = gtk_widget_get_display (menu->menu);
+  device_manager = gdk_display_get_device_manager (display);
+  gdkdevice = gdk_x11_device_manager_lookup (device_manager,
+                                             meta_device_get_id (device));
+
+  gtk_menu_popup_for_device (GTK_MENU (menu->menu),
+                             gdkdevice,
+                             NULL, NULL,
+                             popup_position_func, pt, NULL,
+                             button,
+                             timestamp);
 
   if (!gtk_widget_get_visible (menu->menu))
     meta_warning ("GtkMenu failed to grab the pointer\n");
diff --git a/src/ui/menu.h b/src/ui/menu.h
index c6e8dde..6ac096d 100644
--- a/src/ui/menu.h
+++ b/src/ui/menu.h
@@ -25,6 +25,7 @@
 #define META_MENU_H
 
 #include <gtk/gtk.h>
+#include <meta/device.h>
 #include "frames.h"
 
 /* Stock icons */
@@ -52,6 +53,7 @@ MetaWindowMenu* meta_window_menu_new      (MetaFrames         *frames,
                                            MetaWindowMenuFunc  func,
                                            gpointer            data);
 void            meta_window_menu_popup    (MetaWindowMenu     *menu,
+                                           MetaDevice         *device,
                                            int                 root_x,
                                            int                 root_y,
                                            int                 button,
diff --git a/src/ui/ui.c b/src/ui/ui.c
index b74a8f8..4646404 100644
--- a/src/ui/ui.c
+++ b/src/ui/ui.c
@@ -542,12 +542,13 @@ meta_ui_window_menu_new  (MetaUI             *ui,
 
 void
 meta_ui_window_menu_popup (MetaWindowMenu     *menu,
+                           MetaDevice         *device,
                            int                 root_x,
                            int                 root_y,
                            int                 button,
                            guint32             timestamp)
 {
-  meta_window_menu_popup (menu, root_x, root_y, button, timestamp);
+  meta_window_menu_popup (menu, device, root_x, root_y, button, timestamp);
 }
 
 void
diff --git a/src/ui/ui.h b/src/ui/ui.h
index 4a510b5..246c095 100644
--- a/src/ui/ui.h
+++ b/src/ui/ui.h
@@ -26,6 +26,7 @@
 
 /* Don't include gtk.h or gdk.h here */
 #include <meta/common.h>
+#include <meta/device.h>
 #include <X11/Xlib.h>
 #include <X11/Xutil.h>
 #include <cairo.h>
@@ -131,6 +132,7 @@ MetaWindowMenu* meta_ui_window_menu_new   (MetaUI             *ui,
                                            MetaWindowMenuFunc  func,
                                            gpointer            data);
 void            meta_ui_window_menu_popup (MetaWindowMenu     *menu,
+                                           MetaDevice         *device,
                                            int                 root_x,
                                            int                 root_y,
                                            int                 button,



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