Conditionalize use of gdk_pointer_grab / gdk_pointer_ungrab
On GTK3 there is support for multiple pointer devices, so rather than using gdk_pointer_grab / gdk_pointer_ungrab we should iterate over all devices, grabbing each one in turn Signed-off-by: Daniel P. Berrange <berrange@redhat.com> Message-id: 1361805646-6425-5-git-send-email-berrange@redhat.com Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
This commit is contained in:
parent
655199da19
commit
2a05485d72
76
ui/gtk.c
76
ui/gtk.c
@ -807,25 +807,79 @@ static void gd_ungrab_keyboard(GtkDisplayState *s)
|
||||
#endif
|
||||
}
|
||||
|
||||
static void gd_grab_pointer(GtkDisplayState *s)
|
||||
{
|
||||
#if GTK_CHECK_VERSION(3, 0, 0)
|
||||
GdkDisplay *display = gtk_widget_get_display(s->drawing_area);
|
||||
GdkDeviceManager *mgr = gdk_display_get_device_manager(display);
|
||||
GList *devices = gdk_device_manager_list_devices(mgr,
|
||||
GDK_DEVICE_TYPE_MASTER);
|
||||
GList *tmp = devices;
|
||||
while (tmp) {
|
||||
GdkDevice *dev = tmp->data;
|
||||
if (gdk_device_get_source(dev) == GDK_SOURCE_MOUSE) {
|
||||
gdk_device_grab(dev,
|
||||
gtk_widget_get_window(s->drawing_area),
|
||||
GDK_OWNERSHIP_NONE,
|
||||
FALSE, /* All events to come to our
|
||||
window directly */
|
||||
GDK_POINTER_MOTION_MASK |
|
||||
GDK_BUTTON_PRESS_MASK |
|
||||
GDK_BUTTON_RELEASE_MASK |
|
||||
GDK_BUTTON_MOTION_MASK |
|
||||
GDK_SCROLL_MASK,
|
||||
s->null_cursor,
|
||||
GDK_CURRENT_TIME);
|
||||
}
|
||||
tmp = tmp->next;
|
||||
}
|
||||
g_list_free(devices);
|
||||
#else
|
||||
gdk_pointer_grab(gtk_widget_get_window(s->drawing_area),
|
||||
FALSE, /* All events to come to our window directly */
|
||||
GDK_POINTER_MOTION_MASK |
|
||||
GDK_BUTTON_PRESS_MASK |
|
||||
GDK_BUTTON_RELEASE_MASK |
|
||||
GDK_BUTTON_MOTION_MASK |
|
||||
GDK_SCROLL_MASK,
|
||||
NULL, /* Allow cursor to move over entire desktop */
|
||||
s->null_cursor,
|
||||
GDK_CURRENT_TIME);
|
||||
#endif
|
||||
}
|
||||
|
||||
static void gd_ungrab_pointer(GtkDisplayState *s)
|
||||
{
|
||||
#if GTK_CHECK_VERSION(3, 0, 0)
|
||||
GdkDisplay *display = gtk_widget_get_display(s->drawing_area);
|
||||
GdkDeviceManager *mgr = gdk_display_get_device_manager(display);
|
||||
GList *devices = gdk_device_manager_list_devices(mgr,
|
||||
GDK_DEVICE_TYPE_MASTER);
|
||||
GList *tmp = devices;
|
||||
while (tmp) {
|
||||
GdkDevice *dev = tmp->data;
|
||||
if (gdk_device_get_source(dev) == GDK_SOURCE_MOUSE) {
|
||||
gdk_device_ungrab(dev,
|
||||
GDK_CURRENT_TIME);
|
||||
}
|
||||
tmp = tmp->next;
|
||||
}
|
||||
g_list_free(devices);
|
||||
#else
|
||||
gdk_pointer_ungrab(GDK_CURRENT_TIME);
|
||||
#endif
|
||||
}
|
||||
|
||||
static void gd_menu_grab_input(GtkMenuItem *item, void *opaque)
|
||||
{
|
||||
GtkDisplayState *s = opaque;
|
||||
|
||||
if (gd_is_grab_active(s)) {
|
||||
gd_grab_keyboard(s);
|
||||
gdk_pointer_grab(gtk_widget_get_window(GTK_WIDGET(s->drawing_area)),
|
||||
FALSE, /* All events to come to our window directly */
|
||||
GDK_POINTER_MOTION_MASK |
|
||||
GDK_BUTTON_PRESS_MASK |
|
||||
GDK_BUTTON_RELEASE_MASK |
|
||||
GDK_BUTTON_MOTION_MASK |
|
||||
GDK_SCROLL_MASK,
|
||||
NULL, /* Allow cursor to move over entire desktop */
|
||||
s->null_cursor,
|
||||
GDK_CURRENT_TIME);
|
||||
gd_grab_pointer(s);
|
||||
} else {
|
||||
gd_ungrab_keyboard(s);
|
||||
gdk_pointer_ungrab(GDK_CURRENT_TIME);
|
||||
gd_ungrab_pointer(s);
|
||||
}
|
||||
|
||||
gd_update_caption(s);
|
||||
|
Loading…
Reference in New Issue
Block a user