novnc / noVNC

VNC client web application
https://novnc.com
Other
11.48k stars 2.28k forks source link

The System steals keyboard events for certain system keyboard shortcuts, e.g. Cmd+Shift+4 #1799

Open namper opened 1 year ago

namper commented 1 year ago

Describe the bug The system steals keyboard events for certain system keyboard shortcuts, e.g. Cmd+Shift+4. Unfortunately, this isn't considered a focus loss, so the server doesn't realize it has lost a few keyboard events and can end up in a confused state.

To Reproduce Steps to reproduce the behavior: Press CMD+SHIFT+4 Take screenshot Click on server and see that server is confused as you can't click but can only drag.

Expected behavior noVNC should catch focus loss and reset keyboard state.

Screenshots cced1247-88f4-4ddf-945b-1c314fb2ba51

Client (please complete the following information):

Server (please complete the following information):

Additional context Here is this exact problem solved by tigervnc https://github.com/TigerVNC/tigervnc/commit/4f6d4895c3420e5ac301a916bced4a0065a19183

CendioOssman commented 1 year ago

Unfortunately, we don't have access to the low-level events like TigerVNC has, so we can't apply the same workaround.

Likely this needs to be fixed in the browsers so that they send keyup events when this happens.

Have you reported the issue to the different browsers?

namper commented 1 year ago

Thanks for reply. I am aware we can't access the low level API hack that TigerVNC is doing. Unfortunately, this bug is also reproducible on Safari & Mozilla. What would you advise as potential interim solution, for example detecting that Command and Shift is pressed and scheduling Command & Shift key down events to server.

Versions: Safari: 16.5 Firefox: 107.0.1

namper commented 1 year ago

I found similar issues attempted fix by KasmVNC's fork of noVNC will test this solution. https://github.com/kasmtech/noVNC/commit/2b7e3321ae81cff99510738c2ecee1bcd2853d9b

CendioOssman commented 1 year ago

Trying to perfectly detect every possible troublesome shortcut would be a maintenance nightmare. So what Kasm has done is probably a more feasible mitigation of the issue.

It's important that the issue get reported to all the browsers, though, so a proper solution can be available long term.

namper commented 1 year ago

Raised bug to chromium https://bugs.chromium.org/p/chromium/issues/detail?id=1474894#c3

CendioOssman commented 1 year ago

Many thanks. I don't suppose you could also inform Firefox and Safari (WebKit) of this issue?

namper commented 1 year ago

Many thanks. I don't suppose you could also inform Firefox and Safari (WebKit) of this issue?

Likewise. Raised to all 3 of them.

WebKit: https://bugs.webkit.org/show_bug.cgi?id=260866 Mozila: https://bugzilla.mozilla.org/show_bug.cgi?id=1850583 Chromium: https://bugs.chromium.org/p/chromium/issues/detail?id=1474894#c3

freebrowser1 commented 3 months ago

Weird. I tried it on Brave (a sanitized Chrome clone, Cr 125) on macOS 14.5 Sonoma and connected to two VNC servers one with noVNC 1.3.0 and the other with 1.5.0, but the screenshot shortcut cmd+shift+4 did work normally and was not swallowed by the browser or noVNC. These servers run TigerVNC. The same applies to Safari.

namper commented 3 months ago

Weird.

I tried it on Brave (a sanitized Chrome clone, Cr 125) on macOS 14.5 Sonoma and connected to two VNC servers one with noVNC 1.3.0 and the other with 1.5.0, but the screenshot shortcut cmd+shift+4 did work normally and was not swallowed by the browser or noVNC. These servers run TigerVNC.

The same applies to Safari.

Screenshot will work fine but keyup event will be swallowed. What was version of Chrome and Safari that you tried with ?

freebrowser1 commented 3 months ago

Screenshot will work fine but keyup event will be swallowed. What was version of Chrome and Safari that you tried with ? Chrome (Brave) v.125 and Safari 14 (?) the one supplied with macOS 14.5.