Skip to content
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

Grabbing keyboard input on MacOS #162

Open
proteins247 opened this issue Feb 6, 2019 · 5 comments
Open

Grabbing keyboard input on MacOS #162

proteins247 opened this issue Feb 6, 2019 · 5 comments

Comments

@proteins247
Copy link

proteins247 commented Feb 6, 2019

I've searched around grabbing keyboard input (#26) and I read it can be toggled by Ctrl+Alt+Shift+G or by adding "/grabkeyboard always" to the launch options in the .exe file.

But I'm using MacOS, and I can't enable grabbing keyboard input. Is this feature unsupported for MacOS?

@dcommander
Copy link
Member

Keyboard grabbing isn't implemented in the Mac TurboVNC Viewer (note that it doesn't appear in any of the menus or the command-line usage) because there isn't a strong need for it on Mac clients. Although I try to ensure that the TurboVNC Viewer works with Windows and Mac VNC servers, its primary use is as a client application for the TurboVNC Server, and the TurboVNC Server only works on Linux, FreeBSD, and Solaris/x86. As such, the primary purpose of the keyboard grabbing feature is to send special window manager keystrokes (Alt-Tab, Alt-Esc, etc.) to the server. Since macOS doesn't intercept those keystrokes, sending them to the TurboVNC Server already works with Mac clients without the need for keyboard grabbing.

If there is a particular use case that you feel would justify keyboard grabbing on Mac clients, then please let me know. AFAICT, the only real purpose for such a feature would be to send Mac-specific window manager keystrokes (Command-Tab, etc.) to a Mac VNC server, and whereas I'll implement anything for money, that particular configuration (Mac-to-Mac) isn't a strategic priority for TurboVNC.

@proteins247
Copy link
Author

Here's an example where keyboard grabbing would be useful:

  1. Ctrl+1/2/3 in the file browser to change the view mode (MacOS grabs it for workspace switching)

Additionally, I am interested in sending Cmd to the session (and then within linux remap it to alt (e.g. https://unix.stackexchange.com/questions/86933/swap-alt-and-super)) so that I can hit usual Alt+Key combinations.

I understand if these are not priorities. thanks

@dcommander
Copy link
Member

The feature is technically feasible. It would just require funding for my labor.

@proteins247
Copy link
Author

I see.

Reporting on a failed workaround: I use Emacs, and common shortcuts include Alt-F (forward one word) and Alt-W (copy). I realized that it's possible, once connected to a Linux desktop, to use xmodmap to rebind Command (seen as Super) to Alt. But pressing Cmd-F and Cmd-W activates TurboVNC shortcuts full-screen and close connection respectively. In MacOS Preferences, it's possible to rebind application shortcuts. I tried this with "Full Screen" and "Close Connection," binding them to Ctrl+option+cmd+KEY (so that activating these shortcuts is difficult), but it appears that TurboVNC doesn't respond to these rebindings. The application menu shows the new combinations next to the menu items, but the combinations don't work. Instead, the old shortcuts remain active.

@dcommander
Copy link
Member

I'm not surprised that that doesn't work, since the accelerator keys for the Mac menu are hard-coded. I could use the remapped shortcut keys if there were a way to get that information through Java, but I don't know if such is possible.

I certainly understand the desire to send Ctrl+1/2/3 to the server, although I consider that to be a softer requirement than sending Alt-Tab, since Ctrl+1/2/3 is window-manager-specific. As far as remapping the Command/Super key to the Alt key, that's a personal preference hack, so I don't feel particularly guilty that it doesn't work. Linux software is not generally designed to use the Super key for that purpose.

dcommander added a commit that referenced this issue Jul 19, 2023
Referring to #345, some users need to use Super/Meta key combinations
with Emacs, and since the Command key on macOS maps to the Super/Meta
key on remote Un*x systems, some of those key combinations are hijacked
by the Mac menu accelerators before they can be sent to the VNC server.
This commit introduces a new parameter (MacHotkeys) that can be used to
disable the Mac menu accelerators.  This parameter is currently
undocumented because it is an incomplete solution to a
rarely-encountered problem.  (The complete solution would be to
implement keyboard grabbing on macOS.  Refer to #162.)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants