Blame SOURCES/x11-release-all-pressed-keys-when-window-is-unmapped.patch

0c7016
From 4db610f292aca3ae4ed0bb59ed1972202a1c6b27 Mon Sep 17 00:00:00 2001
0c7016
From: Vic Lee <llyzs@163.com>
0c7016
Date: Wed, 11 Apr 2012 12:37:47 +0800
0c7016
Subject: [PATCH 1/2] x11: release all pressed keys when window is unmapped.
0c7016
0c7016
https://github.com/FreeRDP/FreeRDP/pull/547
0c7016
0c7016
Backported by Ondrej Holy <oholy@redhat.com>.
0c7016
---
0c7016
 client/X11/xf_event.c    |  2 ++
0c7016
 client/X11/xf_keyboard.c | 22 ++++++++++++++++++++++
0c7016
 client/X11/xf_keyboard.h |  1 +
0c7016
 3 files changed, 25 insertions(+)
0c7016
0c7016
diff --git a/client/X11/xf_event.c b/client/X11/xf_event.c
0c7016
index b5c381f..cbcfc65 100644
0c7016
--- a/client/X11/xf_event.c
0c7016
+++ b/client/X11/xf_event.c
0c7016
@@ -507,6 +507,8 @@ boolean xf_event_UnmapNotify(xfInfo* xfi, XEvent* event, boolean app)
0c7016
 	rdpWindow* window;
0c7016
 	rdpRail* rail = ((rdpContext*) xfi->context)->rail;
0c7016
 
0c7016
+	xf_kbd_release_all_keypress(xfi);
0c7016
+
0c7016
 	if (app != true)
0c7016
 		return true;
0c7016
 
0c7016
diff --git a/client/X11/xf_keyboard.c b/client/X11/xf_keyboard.c
0c7016
index cb82fa4..e94b362 100644
0c7016
--- a/client/X11/xf_keyboard.c
0c7016
+++ b/client/X11/xf_keyboard.c
0c7016
@@ -50,6 +50,28 @@ void xf_kbd_unset_keypress(xfInfo* xfi, uint8 keycode)
0c7016
 		return;
0c7016
 }
0c7016
 
0c7016
+void xf_kbd_release_all_keypress(xfInfo* xfi)
0c7016
+{
0c7016
+	int keycode;
0c7016
+	uint16 flags;
0c7016
+	uint8 rdp_scancode;
0c7016
+	boolean extended;
0c7016
+
0c7016
+	for (keycode = 0; keycode < sizeof(xfi->pressed_keys) / sizeof(xfi->pressed_keys[0]); keycode++)
0c7016
+	{
0c7016
+		if (xfi->pressed_keys[keycode] != NoSymbol)
0c7016
+		{
0c7016
+			rdp_scancode = freerdp_kbd_get_scancode_by_keycode(keycode, &extended);
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
+			xfi->pressed_keys[keycode] = NoSymbol;
0c7016
+		}
0c7016
+	}
0c7016
+}
0c7016
+
0c7016
 boolean xf_kbd_key_pressed(xfInfo* xfi, KeySym keysym)
0c7016
 {
0c7016
 	KeyCode keycode = XKeysymToKeycode(xfi->display, keysym);
0c7016
diff --git a/client/X11/xf_keyboard.h b/client/X11/xf_keyboard.h
0c7016
index 92e08fc..e316f07 100644
0c7016
--- a/client/X11/xf_keyboard.h
0c7016
+++ b/client/X11/xf_keyboard.h
0c7016
@@ -28,6 +28,7 @@
0c7016
 void xf_kbd_init(xfInfo* xfi);
0c7016
 void xf_kbd_set_keypress(xfInfo* xfi, uint8 keycode, KeySym keysym);
0c7016
 void xf_kbd_unset_keypress(xfInfo* xfi, uint8 keycode);
0c7016
+void xf_kbd_release_all_keypress(xfInfo* xfi);
0c7016
 boolean xf_kbd_key_pressed(xfInfo* xfi, KeySym keysym);
0c7016
 void xf_kbd_send_key(xfInfo* xfi, boolean down, uint8 keycode);
0c7016
 int xf_kbd_read_keyboard_state(xfInfo* xfi);
0c7016
-- 
0c7016
2.9.3
0c7016