bbennett-ks commented on code in PR #1164:
URL: https://github.com/apache/guacamole-client/pull/1164#discussion_r2829182643
##########
guacamole-common-js/src/main/webapp/modules/Keyboard.js:
##########
@@ -1379,6 +1508,62 @@ Guacamole.Keyboard = function Keyboard(element) {
}, true);
+ /**
+ * Handles non-keyboard events, resynchronizing lock states
+ * based on modifier flags.
+ *
+ * @private
+ * @param {!Event} e
+ * The event to handle.
+ */
+ var handleModifierSync = function handleModifierSync(e) {
+
+ // Only intercept if handler set
+ if (!guac_keyboard.onkeydown && !guac_keyboard.onkeyup) return;
+
+ // Ignore events which have already been handled
+ if (!markEvent(e)) return;
+
+ // Only sync if modifier state is available
+ if (!e.getModifierState) return;
+
+ // Resync lock states based modifier flags
+ var modifierState =
Guacamole.Keyboard.ModifierState.fromKeyboardEvent(e);
+
+ updateToggleModifierState('capsLock', [
+ capsLockKeysym
+ ], {
+ modifiers: modifierState,
+ keysym: null,
+ eventType: e.type
+ });
+
+ updateToggleModifierState('numLock', [
+ numLockKeysym
+ ], {
+ modifiers: modifierState,
+ keysym: null,
+ eventType: e.type
+ });
+
+ updateToggleModifierState('scrollLock', [
+ scrollLockKeysym
+ ], {
+ modifiers: modifierState,
+ keysym: null,
+ eventType: e.type
+ });
+
+ };
+
+ // Resync lock states on mouse/touch events which may reflect lock
flags
+ element.addEventListener("mousedown", handleModifierSync, true);
+ element.addEventListener("mouseup", handleModifierSync, true);
+ element.addEventListener("pointerdown", handleModifierSync, true);
+ element.addEventListener("pointerup", handleModifierSync, true);
+ element.addEventListener("touchstart", handleModifierSync, true);
+ element.addEventListener("touchend", handleModifierSync, true);
Review Comment:
I better understand the architecture, now. While more a little more complex,
architecturally cleaner. I also did a little refactoring to make more
compatible with @sschiffli 's
https://github.com/apache/guacamole-client/pull/1155.
@mike-jumper I'll leave it for you to resolve this if this redesign works
for you.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]