Browse Source

Cancel AltGr timeout on mouse events as well

We have a timer after Ctrl is pressed in order to see if an Alt will
come right after. Ctrl + Alt is what windows sends for AltGr.
If a key other than Alt was pressed we knew that we could cancel this
timer, this commit extends that to mouse events too.

Since this detection breaks the true order of events we want to make
a decision as fast as possible.
tags/v1.10.90
Samuel Mannehed 4 years ago
parent
commit
d71135b02b
2 changed files with 33 additions and 16 deletions
  1. 32
    16
      vncviewer/Viewport.cxx
  2. 1
    0
      vncviewer/Viewport.h

+ 32
- 16
vncviewer/Viewport.cxx View File

@@ -939,7 +939,22 @@ int Viewport::handleSystemEvent(void *event, void *data)
#if defined(WIN32)
MSG *msg = (MSG*)event;

if ((msg->message == WM_KEYDOWN) || (msg->message == WM_SYSKEYDOWN)) {
if ((msg->message == WM_MOUSEMOVE) ||
(msg->message == WM_LBUTTONDOWN) ||
(msg->message == WM_LBUTTONUP) ||
(msg->message == WM_RBUTTONDOWN) ||
(msg->message == WM_RBUTTONUP) ||
(msg->message == WM_MBUTTONDOWN) ||
(msg->message == WM_MBUTTONUP) ||
(msg->message == WM_MOUSEWHEEL) ||
(msg->message == WM_MOUSEHWHEEL)) {
// We can't get a mouse event in the middle of an AltGr sequence, so
// abort that detection
if (self->altGrArmed)
self->resolveAltGrDetection(false);

return 0; // We didn't really consume the mouse event
} else if ((msg->message == WM_KEYDOWN) || (msg->message == WM_SYSKEYDOWN)) {
UINT vKey;
bool isExtended;
int keyCode;
@@ -963,16 +978,11 @@ int Viewport::handleSystemEvent(void *event, void *data)
// by seeing the two key events directly after each other with a very
// short time between them (<50ms) and supress the Ctrl event.
if (self->altGrArmed) {
self->altGrArmed = false;
Fl::remove_timeout(handleAltGrTimeout);

if (isExtended && (keyCode == 0x38) && (vKey == VK_MENU) &&
((msg->time - self->altGrCtrlTime) < 50)) {
// Alt seen, so this is an AltGr sequence
} else {
// Not Alt, so fire the queued up Ctrl event
self->handleKeyPress(0x1d, XK_Control_L);
}
bool altPressed = isExtended &&
(keyCode == 0x38) &&
(vKey == VK_MENU) &&
((msg->time - self->altGrCtrlTime) < 50);
self->resolveAltGrDetection(altPressed);
}

if (keyCode == SCAN_FAKE) {
@@ -1069,11 +1079,8 @@ int Viewport::handleSystemEvent(void *event, void *data)

// We can't get a release in the middle of an AltGr sequence, so
// abort that detection
if (self->altGrArmed) {
self->altGrArmed = false;
Fl::remove_timeout(handleAltGrTimeout);
self->handleKeyPress(0x1d, XK_Control_L);
}
if (self->altGrArmed)
self->resolveAltGrDetection(false);

if (keyCode == SCAN_FAKE) {
vlog.debug("Ignoring fake key release (virtual key 0x%02x)", vKey);
@@ -1197,6 +1204,15 @@ void Viewport::handleAltGrTimeout(void *data)
self->altGrArmed = false;
self->handleKeyPress(0x1d, XK_Control_L);
}

void Viewport::resolveAltGrDetection(bool isAltGrSequence)
{
altGrArmed = false;
Fl::remove_timeout(handleAltGrTimeout);
// when it's not an AltGr sequence we can't supress the Ctrl anymore
if (!isAltGrSequence)
handleKeyPress(0x1d, XK_Control_L);
}
#endif

void Viewport::initContextMenu()

+ 1
- 0
vncviewer/Viewport.h View File

@@ -91,6 +91,7 @@ private:

#ifdef WIN32
static void handleAltGrTimeout(void *data);
void resolveAltGrDetection(bool isAltGrSequence);
#endif

void pushLEDState();

Loading…
Cancel
Save