mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-07 05:31:22 +00:00
GUAC-862: Simplify keydown logic. Restore workaround for Chrome meta bug.
This commit is contained in:
@@ -457,7 +457,7 @@ Guacamole.Keyboard = function(element) {
|
|||||||
"KanjiMode": [0xFF21],
|
"KanjiMode": [0xFF21],
|
||||||
"Katakana": [0xFF26],
|
"Katakana": [0xFF26],
|
||||||
"Left": [0xFF51],
|
"Left": [0xFF51],
|
||||||
"Meta": [0xFFE7],
|
"Meta": [0xFFE7, 0xFFE7, 0xFFE8],
|
||||||
"ModeChange": [0xFF7E],
|
"ModeChange": [0xFF7E],
|
||||||
"NumLock": [0xFF7F],
|
"NumLock": [0xFF7F],
|
||||||
"PageDown": [0xFF55],
|
"PageDown": [0xFF55],
|
||||||
@@ -905,45 +905,53 @@ Guacamole.Keyboard = function(element) {
|
|||||||
// Keydown event
|
// Keydown event
|
||||||
if (first instanceof KeydownEvent) {
|
if (first instanceof KeydownEvent) {
|
||||||
|
|
||||||
|
var keysym = null;
|
||||||
|
var accepted_events = [];
|
||||||
|
|
||||||
// If event itself is reliable, no need to wait for other events
|
// If event itself is reliable, no need to wait for other events
|
||||||
var keysym = first.keysym;
|
|
||||||
if (first.reliable) {
|
if (first.reliable) {
|
||||||
|
keysym = first.keysym;
|
||||||
if (keysym) {
|
accepted_events = eventLog.splice(0, 1);
|
||||||
release_simulated_altgr(keysym);
|
|
||||||
first.defaultPrevented = !press_key(keysym);
|
|
||||||
recentKeysym[first.keyCode] = keysym;
|
|
||||||
}
|
|
||||||
|
|
||||||
return eventLog.shift();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// If keydown is immediately followed by a keypress, use the indicated character
|
// If keydown is immediately followed by a keypress, use the indicated character
|
||||||
var next = eventLog[1];
|
else if (eventLog[1] instanceof KeypressEvent) {
|
||||||
if (next && next instanceof KeypressEvent) {
|
keysym = eventLog[1].keysym;
|
||||||
|
accepted_events = eventLog.splice(0, 2);
|
||||||
keysym = next.keysym;
|
|
||||||
if (keysym) {
|
|
||||||
release_simulated_altgr(keysym);
|
|
||||||
first.defaultPrevented = next.defaultPrevented = !press_key(keysym);
|
|
||||||
recentKeysym[first.keyCode] = keysym;
|
|
||||||
}
|
|
||||||
|
|
||||||
return eventLog.shift();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// If there is a keyup already, the event must be handled now
|
// If there is a keyup already, the event must be handled now
|
||||||
else if (indexof_keyup(first) !== -1) {
|
else if (indexof_keyup(first) !== -1) {
|
||||||
if (keysym) {
|
keysym = first.keysym;
|
||||||
first.defaultPrevented = !press_key(keysym);
|
accepted_events = eventLog.splice(0, 1);
|
||||||
recentKeysym[first.keyCode] = keysym;
|
|
||||||
}
|
|
||||||
return eventLog.shift();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
// Fire a key press if valid events were found
|
||||||
|
if (accepted_events.length > 0) {
|
||||||
|
|
||||||
|
if (keysym) {
|
||||||
|
|
||||||
|
// Fire event
|
||||||
|
release_simulated_altgr(keysym);
|
||||||
|
var defaultPrevented = !press_key(keysym);
|
||||||
|
recentKeysym[first.keyCode] = keysym;
|
||||||
|
|
||||||
|
// If a key is pressed while meta is held down, the keyup will
|
||||||
|
// never be sent in Chrome, so send it now. (bug #108404)
|
||||||
|
if (guac_keyboard.modifiers.meta && keysym !== 0xFFE7 && keysym !== 0xFFE8)
|
||||||
|
release_key(keysym);
|
||||||
|
|
||||||
|
// Record whether default was prevented
|
||||||
|
for (var i=0; i<accepted_events.length; i++)
|
||||||
|
accepted_events[i].defaultPrevented = defaultPrevented;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return first;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
} // end if keydown
|
||||||
|
|
||||||
// Keyup event
|
// Keyup event
|
||||||
else if (first instanceof KeyupEvent) {
|
else if (first instanceof KeyupEvent) {
|
||||||
@@ -956,7 +964,7 @@ Guacamole.Keyboard = function(element) {
|
|||||||
|
|
||||||
return eventLog.shift();
|
return eventLog.shift();
|
||||||
|
|
||||||
}
|
} // end if keyup
|
||||||
|
|
||||||
// Ignore any other type of event (keypress by itself is invalid)
|
// Ignore any other type of event (keypress by itself is invalid)
|
||||||
else
|
else
|
||||||
|
Reference in New Issue
Block a user