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

#if defined(WIN32) #if defined(WIN32)
MSG *msg = (MSG*)event; 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; UINT vKey;
bool isExtended; bool isExtended;
int keyCode; int keyCode;
// by seeing the two key events directly after each other with a very // by seeing the two key events directly after each other with a very
// short time between them (<50ms) and supress the Ctrl event. // short time between them (<50ms) and supress the Ctrl event.
if (self->altGrArmed) { 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) { if (keyCode == SCAN_FAKE) {


// We can't get a release in the middle of an AltGr sequence, so // We can't get a release in the middle of an AltGr sequence, so
// abort that detection // 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) { if (keyCode == SCAN_FAKE) {
vlog.debug("Ignoring fake key release (virtual key 0x%02x)", vKey); vlog.debug("Ignoring fake key release (virtual key 0x%02x)", vKey);
self->altGrArmed = false; self->altGrArmed = false;
self->handleKeyPress(0x1d, XK_Control_L); 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 #endif


void Viewport::initContextMenu() void Viewport::initContextMenu()

+ 1
- 0
vncviewer/Viewport.h View File



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


void pushLEDState(); void pushLEDState();

Loading…
Cancel
Save