summaryrefslogtreecommitdiff
path: root/ui/gtk.c
diff options
context:
space:
mode:
authorDaniel P. Berrange <berrange@redhat.com>2013-02-25 15:20:37 +0000
committerAnthony Liguori <aliguori@us.ibm.com>2013-02-26 13:29:51 -0600
commit2a05485d72504ed92ce91dffd1f5867974c47ff0 (patch)
treea7d6462b02bf09f8e34857e814a5c5fdc3de26fa /ui/gtk.c
parent655199da197d2c3407d4bc937c9d3d3ac4551764 (diff)
downloadqemu-2a05485d72504ed92ce91dffd1f5867974c47ff0.tar.gz
qemu-2a05485d72504ed92ce91dffd1f5867974c47ff0.tar.bz2
qemu-2a05485d72504ed92ce91dffd1f5867974c47ff0.zip
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>
Diffstat (limited to 'ui/gtk.c')
-rw-r--r--ui/gtk.c76
1 files changed, 65 insertions, 11 deletions
diff --git a/ui/gtk.c b/ui/gtk.c
index 3826bea97c..19d554d35b 100644
--- a/ui/gtk.c
+++ b/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);