Re: [PATCH spice-gtk] widget: Use deprecated function to ungrab device

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

Yep, fixed it:)

I would prefer to revert both grabbing and ungrabbing to the deprecated functions until a suitable

gdk_seat_ungrab function will be available but maybe a comment explaining why seat_ungrab is

not in use (just to avoid that someone will change it again) will be be enough.

Anyways, Ack.

Snir.


On 03/16/2017 12:42 PM, Pavel Grunt wrote:
Avoid broken grab (alt+tab not working), regression since
  ef7a6fa1798c8e53c0b77330b398a78181cf90e5

Currently it is not possible to ungrab just keyboard/mouse
using GdkSeat functions:
  https://bugzilla.gnome.org/show_bug.cgi?id=780133
Use deprecated gdk_device_ungrab to do it
---
  src/spice-widget.c | 49 +++++++++++++++++++++++++++++--------------------
  1 file changed, 29 insertions(+), 20 deletions(-)

diff --git a/src/spice-widget.c b/src/spice-widget.c
index 9a7ea56..c7db2a8 100644
--- a/src/spice-widget.c
+++ b/src/spice-widget.c
@@ -890,6 +890,19 @@ static void try_keyboard_grab(SpiceDisplay *display)
      }
  }
+static void ungrab_keyboard(G_GNUC_UNUSED SpiceDisplay *display)
+{
+    G_GNUC_BEGIN_IGNORE_DEPRECATIONS
+#if GTK_CHECK_VERSION(3, 20, 0)
+    /* we want to ungrab just the keyboard - it is possible using deprecated gdk_device_ungrab */
+    GdkDevice *keyboard = gdk_seat_get_keyboard(spice_display_get_default_seat(display));
+    gdk_device_ungrab(keyboard, GDK_CURRENT_TIME);
+#else
+    gdk_keyboard_ungrab(GDK_CURRENT_TIME);
+#endif
+    G_GNUC_END_IGNORE_DEPRECATIONS
+}
+
  static void try_keyboard_ungrab(SpiceDisplay *display)
  {
      SpiceDisplayPrivate *d = display->priv;
@@ -899,11 +912,7 @@ 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
+    ungrab_keyboard(display);
  #ifdef G_OS_WIN32
      // do not use g_clear_pointer as Windows API have different linkage
      if (d->keyboard_hook) {
@@ -1161,6 +1170,19 @@ static void mouse_wrap(SpiceDisplay *display, GdkEventMotion *motion)
} +static void ungrab_pointer(G_GNUC_UNUSED SpiceDisplay *display)
+{
+    G_GNUC_BEGIN_IGNORE_DEPRECATIONS
+#if GTK_CHECK_VERSION(3, 20, 0)
+    /* we want to ungrab just the pointer - it is possible using deprecated gdk_device_ungrab */
+    GdkDevice *pointer = gdk_seat_get_pointer(spice_display_get_default_seat(display));
+    gdk_device_ungrab(pointer, GDK_CURRENT_TIME);
+#else
+    gdk_pointer_ungrab(GDK_CURRENT_TIME);
+#endif
+    G_GNUC_END_IGNORE_DEPRECATIONS
+}
+
  static void try_mouse_ungrab(SpiceDisplay *display)
  {
      SpiceDisplayPrivate *d = display->priv;
@@ -1171,13 +1193,7 @@ static void try_mouse_ungrab(SpiceDisplay *display)
      if (!d->mouse_grab_active)
          return;
- G_GNUC_BEGIN_IGNORE_DEPRECATIONS
-#if GTK_CHECK_VERSION(3, 20, 0)
-    gdk_seat_ungrab(spice_display_get_default_seat(display));
-#else
-    gdk_pointer_ungrab(GDK_CURRENT_TIME);
-#endif
-    G_GNUC_END_IGNORE_DEPRECATIONS
+    ungrab_pointer(display);
      gtk_grab_remove(GTK_WIDGET(display));
  #ifdef G_OS_WIN32
      ClipCursor(NULL);
@@ -2044,14 +2060,7 @@ static gboolean button_event(GtkWidget *widget, GdkEventButton *button)
             FIXME: should be multiple widget grab, but how?
             or should know the position of the other widgets?
          */
-        /* FIXME: gdk_pointer_ungrab() is deprecated */
-        G_GNUC_BEGIN_IGNORE_DEPRECATIONS
-#if GTK_CHECK_VERSION(3, 20, 0)
-        gdk_seat_ungrab(spice_display_get_default_seat(display));
-#else
-        gdk_pointer_ungrab(GDK_CURRENT_TIME);
-#endif
-        G_GNUC_END_IGNORE_DEPRECATIONS
+        ungrab_pointer(display);
      }
if (!d->inputs)

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]