summaryrefslogtreecommitdiff
path: root/gtk
diff options
context:
space:
mode:
authorMarc-André Lureau <marcandre.lureau@redhat.com>2012-01-15 16:56:25 +0100
committerMarc-André Lureau <marcandre.lureau@redhat.com>2012-01-15 16:56:31 +0100
commitf905850dc4657a146f7ba090247777d718c6aa2e (patch)
treed36a983125e55fc63acfbc3cf88b694dcb8ca7b2 /gtk
parentedee7467bf9d0d8ed09a4477f0372d8f3981d8f1 (diff)
Warn if windows keyboard hook failed
Diffstat (limited to 'gtk')
-rw-r--r--gtk/spice-widget.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/gtk/spice-widget.c b/gtk/spice-widget.c
index 362f313..a3ca4fc 100644
--- a/gtk/spice-widget.c
+++ b/gtk/spice-widget.c
@@ -488,8 +488,10 @@ static void try_keyboard_grab(SpiceDisplay *display)
gtk_widget_grab_focus(widget);
#ifdef WIN32
- d->keyboard_hook = SetWindowsHookEx(WH_KEYBOARD_LL, keyboard_hook_cb,
- GetModuleHandle(NULL), 0);
+ 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
status = gdk_keyboard_grab(gtk_widget_get_window(widget), FALSE,
GDK_CURRENT_TIME);
@@ -513,8 +515,10 @@ static void try_keyboard_ungrab(SpiceDisplay *display)
SPICE_DEBUG("ungrab keyboard");
gdk_keyboard_ungrab(GDK_CURRENT_TIME);
#ifdef WIN32
- UnhookWindowsHookEx(d->keyboard_hook);
- d->keyboard_hook = 0;
+ if (d->keyboard_hook != NULL) {
+ UnhookWindowsHookEx(d->keyboard_hook);
+ d->keyboard_hook = NULL;
+ }
#endif
d->keyboard_grab_active = false;
g_signal_emit(widget, signals[SPICE_DISPLAY_KEYBOARD_GRAB], 0, false);