Skip to content

Instantly share code, notes, and snippets.

@PowderedToastMan
Created January 14, 2014 18:34
Show Gist options
  • Save PowderedToastMan/8423275 to your computer and use it in GitHub Desktop.
Save PowderedToastMan/8423275 to your computer and use it in GitHub Desktop.
Totally disable the Windows key in freerdp. This is to works around a long standing issue where it appears the Window key is "stuck" causing explorer and run windows to pop open, accidental screen locks, and all sorts of unintended Windows actions. This only changes the freerdp under X11. WARNING: MASSIVE HACK!!!
diff --git a/client/X11/xf_keyboard.c b/client/X11/xf_keyboard.c
index e6427e1..81e95bb 100644
--- a/client/X11/xf_keyboard.c
+++ b/client/X11/xf_keyboard.c
@@ -100,6 +100,15 @@ void xf_kbd_send_key(xfContext* xfc, BOOL down, BYTE keycode)
input = xfc->instance->input;
rdp_scancode = freerdp_keyboard_get_rdp_scancode_from_x11_keycode(keycode);
+ /*
+ * Giant hack to disable Windows keys
+ * http://social.technet.microsoft.com/Forums/en-US/cbaae74e-8311-4a46-a842-31dcdd6878dc/windows-key-stuck
+ */
+ freerdp_input_send_keyboard_event_ex(input, FALSE, RDP_SCANCODE_LWIN);
+ freerdp_input_send_keyboard_event_ex(input, FALSE, RDP_SCANCODE_RWIN);
+ if (rdp_scancode == RDP_SCANCODE_LWIN || rdp_scancode == RDP_SCANCODE_RWIN)
+ return;
+
if (rdp_scancode == RDP_SCANCODE_UNKNOWN)
{
fprintf(stderr, "Unknown key with X keycode 0x%02x\n", keycode);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment