diff options
author | Daniel P. Berrange <berrange@redhat.com> | 2013-02-25 15:20:36 +0000 |
---|---|---|
committer | Anthony Liguori <aliguori@us.ibm.com> | 2013-02-26 13:29:51 -0600 |
commit | 655199da197d2c3407d4bc937c9d3d3ac4551764 (patch) | |
tree | b6424c0c5c02ab5c9cab6d346a50c4099d4115d1 /ui | |
parent | 66962f14378d0adf2e7d0fcfac66e2248b09bb4d (diff) |
Conditionalize use of gdk_keyboard_grab / gdk_keyboard_ungrab
On GTK3 there is support for multiple keyboard devices, so
rather than using gdk_keyboard_grab / gdk_keyboard_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-4-git-send-email-berrange@redhat.com
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'ui')
-rw-r--r-- | ui/gtk.c | 41 |
1 files changed, 40 insertions, 1 deletions
@@ -758,14 +758,53 @@ static void gd_menu_zoom_fit(GtkMenuItem *item, void *opaque) static void gd_grab_keyboard(GtkDisplayState *s) { - gdk_keyboard_grab(gtk_widget_get_window(GTK_WIDGET(s->drawing_area)), +#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_KEYBOARD) { + gdk_device_grab(dev, + gtk_widget_get_window(s->drawing_area), + GDK_OWNERSHIP_NONE, + FALSE, + GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK, + NULL, + GDK_CURRENT_TIME); + } + tmp = tmp->next; + } + g_list_free(devices); +#else + gdk_keyboard_grab(gtk_widget_get_window(s->drawing_area), FALSE, GDK_CURRENT_TIME); +#endif } static void gd_ungrab_keyboard(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_KEYBOARD) { + gdk_device_ungrab(dev, + GDK_CURRENT_TIME); + } + tmp = tmp->next; + } + g_list_free(devices); +#else gdk_keyboard_ungrab(GDK_CURRENT_TIME); +#endif } static void gd_menu_grab_input(GtkMenuItem *item, void *opaque) |