[Spice-devel] [PATCH spice-gtk v2 4/5] gtk: Avoid deprecated gdk_keyboard_grab

Pavel Grunt pgrunt at redhat.com
Mon Dec 19 16:26:35 UTC 2016


---
 src/spice-widget.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/src/spice-widget.c b/src/spice-widget.c
index bc705f8..791f5b0 100644
--- a/src/spice-widget.c
+++ b/src/spice-widget.c
@@ -120,6 +120,9 @@ static void size_allocate(GtkWidget *widget, GtkAllocation *conf, gpointer data)
 static gboolean draw_event(GtkWidget *widget, cairo_t *cr, gpointer data);
 static void update_size_request(SpiceDisplay *display);
 static GdkDevice *spice_display_get_pointer(SpiceDisplay *display);
+#if GTK_CHECK_VERSION(3, 20, 0)
+static GdkSeat *spice_display_get_default_seat(SpiceDisplay *display);
+#endif
 
 /* ---------------------------------------------------------------- */
 
@@ -850,8 +853,19 @@ static void try_keyboard_grab(SpiceDisplay *display)
                                             GetModuleHandle(NULL), 0);
     g_warn_if_fail(d->keyboard_hook != NULL);
 #endif
+#if GTK_CHECK_VERSION(3, 20, 0)
+    status = gdk_seat_grab(spice_display_get_default_seat(display),
+                           gtk_widget_get_window(widget),
+                           GDK_SEAT_CAPABILITY_KEYBOARD,
+                           FALSE,
+                           NULL,
+                           NULL,
+                           NULL,
+                           NULL);
+#else
     status = gdk_keyboard_grab(gtk_widget_get_window(widget), FALSE,
                                GDK_CURRENT_TIME);
+#endif
     if (status != GDK_GRAB_SUCCESS) {
         g_warning("keyboard grab failed %u", status);
         d->keyboard_grab_active = false;
@@ -870,7 +884,11 @@ static void try_keyboard_ungrab(SpiceDisplay *display)
         return;
 
     SPICE_DEBUG("ungrab keyboard");
+#if GTK_CHECK_VERSION(3, 20, 0)
+    gdk_seat_ungrab(spice_display_get_default_seat(display));
+#else
     gdk_keyboard_ungrab(GDK_CURRENT_TIME);
+#endif
 #ifdef G_OS_WIN32
     // do not use g_clear_pointer as Windows API have different linkage
     if (d->keyboard_hook) {
-- 
2.11.0



More information about the Spice-devel mailing list