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.
This commit is contained in:
Carlos Garnacho 2011-08-02 01:12:04 +02:00
parent f84637d31e
commit b93c72315d
11 changed files with 35 additions and 10 deletions

View File

@ -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

View File

@ -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,

View File

@ -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,

View File

@ -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);

View File

@ -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,

View File

@ -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

View File

@ -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,

View File

@ -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");

View File

@ -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,

View File

@ -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

View File

@ -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>
@ -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,