Skip to content

Reset modifier button's state when connection is completed #10743

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: 4.19
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions systemvm/agent/noVNC/app/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -1147,6 +1147,7 @@ const UI = {
msg = _("Connected (unencrypted) to ") + UI.desktopName;
}
UI.showStatus(msg);
UI.resetModifierKeysState();
UI.updateVisualState('connected');

// Do this last because it can only be used on rendered elements
Expand Down Expand Up @@ -1783,6 +1784,35 @@ const UI = {
selectbox.options.add(optn);
},

// Function to reset all modifier key states when reconnecting
resetModifierKeysState() {
// Reset the UI buttons for special keys
const modifierButtons = [
'noVNC_toggle_ctrl_button',
'noVNC_toggle_shift_button',
'noVNC_toggle_alt_button',
'noVNC_toggle_windows_button'
];

for (let id of modifierButtons) {
const btn = document.getElementById(id);
if (btn && btn.classList.contains("noVNC_selected")) {
btn.classList.remove("noVNC_selected");

// Also send the key-up event if needed
if (id === 'noVNC_toggle_ctrl_button') {
UI.sendKey(KeyTable.XK_Control_L, "ControlLeft", false);
} else if (id === 'noVNC_toggle_shift_button') {
UI.sendKey(KeyTable.XK_Shift_L, "ShiftLeft", false);
} else if (id === 'noVNC_toggle_alt_button') {
UI.sendKey(KeyTable.XK_Alt_L, "AltLeft", false);
} else if (id === 'noVNC_toggle_windows_button') {
UI.sendKey(KeyTable.XK_Super_L, "MetaLeft", false);
}
}
}
},

/* ------^-------
* /MISC
* ==============
Expand Down