From b93c72315d2e57fd8d5c3cf1d46b049271781bfa Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Tue, 2 Aug 2011 01:12:04 +0200 Subject: [PATCH] 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 9ce271b43..f002df498 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 28e753cd7..dd50170ec 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 b620c6cc4..b349c6fb6 100644 --- a/src/core/display.c +++ b/src/core/display.c @@ -1962,6 +1962,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 aa2bf29c2..88e571f96 100644 --- a/src/core/keybindings.c +++ b/src/core/keybindings.c @@ -3135,6 +3135,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 6aca9a6bc..9a78d4567 100644 --- a/src/core/window-private.h +++ b/src/core/window-private.h @@ -580,6 +580,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 88dc14aee..ae84d9d9e 100644 --- a/src/core/window.c +++ b/src/core/window.c @@ -8043,6 +8043,7 @@ menu_callback (MetaWindowMenu *menu, void meta_window_show_menu (MetaWindow *window, + MetaDevice *device, int root_x, int root_y, int button, @@ -8173,7 +8174,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 238063fa8..558134394 100644 --- a/src/ui/frames.c +++ b/src/ui/frames.c @@ -1519,6 +1519,7 @@ meta_frame_titlebar_event (MetaUIFrame *frame, case META_ACTION_TITLEBAR_MENU: meta_core_show_window_menu (display, frame->xwindow, + gdk_x11_device_get_id (pointer), event->x_root, event->y_root, event->button, @@ -1711,6 +1712,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 b3cad3255..f6ed9cad8 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 c6e8dde4d..6ac096d07 100644 --- a/src/ui/menu.h +++ b/src/ui/menu.h @@ -25,6 +25,7 @@ #define META_MENU_H #include +#include #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 7dc4ed057..0fa7a5ec8 100644 --- a/src/ui/ui.c +++ b/src/ui/ui.c @@ -538,12 +538,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 f8becc334..9143247ff 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 +#include #include #include #include @@ -132,6 +133,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,