[Spice-devel] [spice-gtk] Set windows hook only when keyboard is grabbed
Snir Sheriber
ssheribe at redhat.com
Mon May 15 16:02:59 UTC 2017
The keyboard events hook should be set only if keyboard is
grabbed otherwise the hook won't behave as expected, e.g alt-tab
may cause duplicate event in the windows manager and not releasing
the alt after key was released
---
src/spice-widget.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/src/spice-widget.c b/src/spice-widget.c
index 8203d55..e889bba 100644
--- a/src/spice-widget.c
+++ b/src/spice-widget.c
@@ -862,12 +862,6 @@ static void try_keyboard_grab(SpiceDisplay *display)
DISPLAY_DEBUG(display, "grab keyboard");
gtk_widget_grab_focus(widget);
-#ifdef G_OS_WIN32
- if (d->keyboard_hook == NULL)
- d->keyboard_hook = SetWindowsHookEx(WH_KEYBOARD_LL, keyboard_hook_cb,
- 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),
@@ -885,6 +879,12 @@ static void try_keyboard_grab(SpiceDisplay *display)
g_warning("keyboard grab failed %u", status);
d->keyboard_grab_active = false;
} else {
+#ifdef G_OS_WIN32
+ if (d->keyboard_hook == NULL)
+ d->keyboard_hook = SetWindowsHookEx(WH_KEYBOARD_LL, keyboard_hook_cb,
+ GetModuleHandle(NULL), 0);
+ g_warn_if_fail(d->keyboard_hook != NULL);
+#endif
d->keyboard_grab_active = true;
g_signal_emit(widget, signals[SPICE_DISPLAY_KEYBOARD_GRAB], 0, true);
}
--
2.9.3
More information about the Spice-devel
mailing list