Fixed handling of AltGr from Windows' touch keyboard
We need to test this always in order to catch Ctrl+AltGr, and to
handle release of the key properly. Hopefully there isn't any other
case where VK_MENU is sent without a scan code.
diff --git a/vncviewer/Viewport.cxx b/vncviewer/Viewport.cxx
index 165560c..18ed69e 100644
--- a/vncviewer/Viewport.cxx
+++ b/vncviewer/Viewport.cxx
@@ -936,6 +936,13 @@
keyCode = ((msg->lParam >> 16) & 0xff);
+ // Windows' touch keyboard doesn't set a scan code for the Alt
+ // portion of the AltGr sequence, so we need to help it out
+ if (!isExtended && (keyCode == 0x00) && (vKey == VK_MENU)) {
+ isExtended = true;
+ keyCode = 0x38;
+ }
+
// Windows doesn't have a proper AltGr, but handles it using fake
// Ctrl+Alt. However the remote end might not be Windows, so we need
// to merge those in to a single AltGr event. We detect this case
@@ -945,13 +952,6 @@
self->altGrArmed = false;
Fl::remove_timeout(handleAltGrTimeout);
- // Windows' touch keyboard doesn't set a scan code for the Alt
- // portion of the AltGr sequence, so we need to help it out
- if (!isExtended && (keyCode == 0x00)) {
- isExtended = true;
- keyCode = 0x38;
- }
-
if (isExtended && (keyCode == 0x38) && (vKey == VK_MENU) &&
((msg->time - self->altGrCtrlTime) < 50)) {
// Alt seen, so this is an AltGr sequence
@@ -1047,6 +1047,12 @@
keyCode = ((msg->lParam >> 16) & 0xff);
+ // Touch keyboard AltGr (see above)
+ if (!isExtended && (keyCode == 0x00) && (vKey == VK_MENU)) {
+ isExtended = true;
+ keyCode = 0x38;
+ }
+
// We can't get a release in the middle of an AltGr sequence, so
// abort that detection
if (self->altGrArmed) {