mike-jumper commented on code in PR #1155:
URL: https://github.com/apache/guacamole-client/pull/1155#discussion_r2814111063
##########
guacamole-common-js/src/main/webapp/modules/Keyboard.js:
##########
@@ -926,6 +987,39 @@ Guacamole.Keyboard = function Keyboard(element) {
};
+ /**
+ * Handles a mouse event to resolve deferred Meta key events. When a Meta
+ * key is pressed, it is deferred to determine if it's being used as a
+ * modifier or as a standalone key. A mouse click with Meta held provides
+ * the context needed to resolve this, enabling Cmd+Click functionality.
+ *
+ * @param {Guacamole.Mouse.Event} mouseEvent
+ * The mouse event that occurred.
+ */
+ this.handleMouseEvent = function(mouseEvent) {
Review Comment:
I think we should consider renaming this. To me, "handle" implies that the
entirety of event processing is dealt with here, but this is specific to
updating the keyboard state with any changes that are visible only within the
mouse event.
I'd suggest something like `updateModifierState()`, `syncModifierState()`,
etc.
##########
guacamole-common-js/src/main/webapp/modules/Mouse.js:
##########
@@ -510,6 +510,81 @@ Guacamole.Mouse.State.Buttons = {
};
+/**
+ * The state of all supported keyboard modifiers. This is the same structure
+ * used for keyboard modifier state tracking.
+ * @constructor
+ */
+Guacamole.Mouse.ModifierState = function() {
+
+ /**
+ * Whether shift is currently pressed.
+ *
+ * @type {!boolean}
+ */
+ this.shift = false;
+
+ /**
+ * Whether ctrl is currently pressed.
+ *
+ * @type {!boolean}
+ */
+ this.ctrl = false;
+
+ /**
+ * Whether alt is currently pressed.
+ *
+ * @type {!boolean}
+ */
+ this.alt = false;
+
+ /**
+ * Whether meta (apple key) is currently pressed.
+ *
+ * @type {!boolean}
+ */
+ this.meta = false;
+
+ /**
+ * Whether hyper (windows key) is currently pressed.
+ *
+ * @type {!boolean}
+ */
+ this.hyper = false;
+
+};
+
+/**
+ * Returns the modifier state applicable to the mouse event given.
+ *
+ * @param {!MouseEvent} e
+ * The mouse event to read.
+ *
+ * @returns {!Guacamole.Mouse.ModifierState}
+ * The current state of keyboard modifiers.
+ */
+Guacamole.Mouse.ModifierState.fromMouseEvent = function(e) {
Review Comment:
Rather than duplicate `Guacamole.Keyboard.ModifierState`, maybe we should
add `Guacamole.Keyboard.ModifierState.fromMouseEvent()`?
--
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]