0c7016
From 1d12ad20cbd07b0aeb49ac9544de451c9f43f04c Mon Sep 17 00:00:00 2001
0c7016
From: Seray Rosh <seray.rosh@web.de>
0c7016
Date: Fri, 27 Feb 2015 16:02:40 +0100
0c7016
Subject: [PATCH 2/2] release keys when xfreerdp is unfocused to prevent stuck
0c7016
 keys
0c7016
0c7016
https://github.com/FreeRDP/FreeRDP/issues/2104
0c7016
https://github.com/FreeRDP/FreeRDP/pull/2430
0c7016
0c7016
Backported by Ondrej Holy <oholy@redhat.com>.
0c7016
---
0c7016
 client/X11/xf_event.c    | 2 ++
0c7016
 client/X11/xf_keyboard.c | 5 +++++
0c7016
 2 files changed, 7 insertions(+)
0c7016
0c7016
diff --git a/client/X11/xf_event.c b/client/X11/xf_event.c
0c7016
index cbcfc65..1475214 100644
0c7016
--- a/client/X11/xf_event.c
0c7016
+++ b/client/X11/xf_event.c
0c7016
@@ -356,6 +356,8 @@ boolean xf_event_FocusOut(xfInfo* xfi, XEvent* event, boolean app)
0c7016
 	if (event->xfocus.mode == NotifyWhileGrabbed)
0c7016
 		XUngrabKeyboard(xfi->display, CurrentTime);
0c7016
 
0c7016
+	xf_kbd_release_all_keypress(xfi);
0c7016
+
0c7016
 	if (app)
0c7016
 		xf_rail_send_activate(xfi, event->xany.window, false);
0c7016
 
0c7016
diff --git a/client/X11/xf_keyboard.c b/client/X11/xf_keyboard.c
0c7016
index e94b362..fb14015 100644
0c7016
--- a/client/X11/xf_keyboard.c
0c7016
+++ b/client/X11/xf_keyboard.c
0c7016
@@ -63,6 +63,11 @@ void xf_kbd_release_all_keypress(xfInfo* xfi)
0c7016
 		{
0c7016
 			rdp_scancode = freerdp_kbd_get_scancode_by_keycode(keycode, &extended);
0c7016
 
0c7016
+			// release tab before releasing the windows key.
0c7016
+			// this stops the start menu from opening on unfocus event.
0c7016
+			if (rdp_scancode == 0x5B && extended) /* Left Windows Key */
0c7016
+				xfi->instance->input->KeyboardEvent(xfi->instance->input, KBD_FLAGS_RELEASE, 0x0F); /* Tab up */
0c7016
+
0c7016
 			flags = KBD_FLAGS_RELEASE;
0c7016
 			flags |= (extended) ? KBD_FLAGS_EXTENDED : 0;
0c7016
 			xfi->instance->input->KeyboardEvent(xfi->instance->input, flags, rdp_scancode);
0c7016
-- 
0c7016
2.9.3
0c7016