From 30b3f926cbafe58e699a1e8893d96817ded21f3d Mon Sep 17 00:00:00 2001 From: Pierre Ossman Date: Mon, 13 Nov 2017 09:07:59 +0100 Subject: [PATCH] Handle right shift better on Windows The shift buttons are a bit buggy on Windows unfortunately, but we can do slightly better than we're doing today. --- vncviewer/Viewport.cxx | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/vncviewer/Viewport.cxx b/vncviewer/Viewport.cxx index 960a085c..12624d9c 100644 --- a/vncviewer/Viewport.cxx +++ b/vncviewer/Viewport.cxx @@ -922,6 +922,11 @@ int Viewport::handleSystemEvent(void *event, void *data) vlog.error(_("No symbol for virtual key 0x%02x"), (int)vKey); } + // Windows sends the same vKey for both shifts, so we need to look + // at the scan code to tell them apart + if ((keySym == XK_Shift_L) && (keyCode == 0x36)) + keySym = XK_Shift_R; + self->handleKeyPress(keyCode, keySym); return 1; @@ -953,6 +958,15 @@ int Viewport::handleSystemEvent(void *event, void *data) self->handleKeyRelease(keyCode); + // Windows has a rather nasty bug where it won't send key release + // events for a Shift button if the other Shift is still pressed + if ((keyCode == 0x2a) || (keyCode == 0x36)) { + if (self->downKeySym.count(0x2a)) + self->handleKeyRelease(0x2a); + if (self->downKeySym.count(0x36)) + self->handleKeyRelease(0x36); + } + return 1; } #elif defined(__APPLE__) -- 2.39.5