Skip to content

Commit d16bd22

Browse files
committed
Reset modifier button's state when connection is completed
1 parent 53d3d19 commit d16bd22

File tree

1 file changed

+30
-0
lines changed
  • systemvm/agent/noVNC/app

1 file changed

+30
-0
lines changed

systemvm/agent/noVNC/app/ui.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1147,6 +1147,7 @@ const UI = {
11471147
msg = _("Connected (unencrypted) to ") + UI.desktopName;
11481148
}
11491149
UI.showStatus(msg);
1150+
UI.resetModifierKeysState();
11501151
UI.updateVisualState('connected');
11511152

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

1787+
// Function to reset all modifier key states when reconnecting
1788+
resetModifierKeysState() {
1789+
// Reset the UI buttons for special keys
1790+
const modifierButtons = [
1791+
'noVNC_toggle_ctrl_button',
1792+
'noVNC_toggle_shift_button',
1793+
'noVNC_toggle_alt_button',
1794+
'noVNC_toggle_windows_button'
1795+
];
1796+
1797+
for (let id of modifierButtons) {
1798+
const btn = document.getElementById(id);
1799+
if (btn && btn.classList.contains("noVNC_selected")) {
1800+
btn.classList.remove("noVNC_selected");
1801+
1802+
// Also send the key-up event if needed
1803+
if (id === 'noVNC_toggle_ctrl_button') {
1804+
UI.sendKey(KeyTable.XK_Control_L, "ControlLeft", false);
1805+
} else if (id === 'noVNC_toggle_shift_button') {
1806+
UI.sendKey(KeyTable.XK_Shift_L, "ShiftLeft", false);
1807+
} else if (id === 'noVNC_toggle_alt_button') {
1808+
UI.sendKey(KeyTable.XK_Alt_L, "AltLeft", false);
1809+
} else if (id === 'noVNC_toggle_windows_button') {
1810+
UI.sendKey(KeyTable.XK_Super_L, "MetaLeft", false);
1811+
}
1812+
}
1813+
}
1814+
},
1815+
17861816
/* ------^-------
17871817
* /MISC
17881818
* ==============

0 commit comments

Comments
 (0)