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

Swallows shotcut keys on MacOSX. #833

Open
wl2776 opened this issue Dec 23, 2024 · 4 comments
Open

Swallows shotcut keys on MacOSX. #833

wl2776 opened this issue Dec 23, 2024 · 4 comments
Assignees
Labels
need-more-info Extra information or replay is needed os-macos This issue only exists on macOS

Comments

@wl2776
Copy link
Contributor

wl2776 commented Dec 23, 2024

On MacOSX I have configured a hotkey Ctrl-<backtick> (the key above Control on the embedded keyboard or the key below Esc on Windows kbd) to run an AppleScript in the Automator application. That script launches the Terminal application or brings it to front if it is already running.

The issue: when SourceGit's window has focus, this shortcut does not work, Terminal window doesn't appear. Also, I don't see a rotating gear icon in the menu bar indicating that the Automator is performing its action.

When another application has focus (Visual Studio Code, or Safari or Calendar, ...), the rotating gear shows, then the terminal window shows up, when I press Ctrl+backtick.

Probably, the issue is that on first usage of the shortcut, these applications request permissions to access other applications' data. SourceGit doesn't ask for these permissions.

Details:
HW: Macbook Pro M1, Apple silicon (ARM chip).
OS: MacOSX Sonoma 14.7.1
Sourcegit is installed from released package, downloaded from Github

Unfortunately, I have limited capabilities to track down this issue on Macbook, because I cannot build it from sources.

@love-linger
Copy link
Collaborator

love-linger commented Dec 23, 2024

SourceGit does not use this hotkey. And I can use Ctrl+<backtick> to trigger PixPin (a screenshot app, it use Ctrl+<backtick> to switch captured screenshots) while focusing on SourceGit

@love-linger love-linger self-assigned this Dec 24, 2024
@love-linger love-linger added os-macos This issue only exists on macOS need-more-info Extra information or replay is needed labels Dec 25, 2024
@wl2776
Copy link
Contributor Author

wl2776 commented Jan 5, 2025

I believe, the issue is somewhere in the Launcher.OnKeyDown method.

Could you check it?

To reproduce

  1. Open Automator or Shortcuts
  2. Create new action opening Terminal application (stock Terminal.app, not iTerm2 or any other terminals)
  3. Bind that action to some hotkey.

@love-linger
Copy link
Collaborator

I believe, the issue is somewhere in the Launcher.OnKeyDown method.

image

  • At line 113, SourceGit just cleans the _unhandledModifiers
  • From line 116 to 120, the code is only works on Windows and Linux platforms.
  • From line 123 to 215, the code requires key on macOS, not Ctrl
  • From line 216 to 230, SourceGit will not handle the key <backtick>
  • At line 232, we just fallback to the Window.OnKeyDown
  • After the line 235, if this key down event has not been handled, SourceGit just records the key modifiers, and leave this event unhandled.

BTW. as I said above, on my MacBook Pro (M3 Max), I can confirm the Ctrl+<backtick> works (will trigger another app) no matter which control was focused in SourceGit

@wl2776
Copy link
Contributor Author

wl2776 commented Jan 6, 2025

Thank you for this detailed analysis.

on my MacBook Pro (M3 Max), I can confirm the Ctrl+<backtick> works (will trigger another app)

Do you mean that you have tried Automator.app or Shortcuts.app? I thought there could be several methods to install global shortcut handler in MacOS. Unfortunately, I have zero experience in programming for MacOS and cannot be sure.

On my macbook (M1 Pro, macos Sonoma 14.7.2) I have two more programs, that handle Ctrl-backtick shortcut: Far2l and Visual Studio Code. When Far2l has focus, it handles Ctrl-backtick and prevents the Automator from opening Terminal. When VSCode has focus, it doesn't do anything, and Terminal opens.

I thought you could run SourceGit under debugger and see how it works on MacOS

Unfortunately, I have very limited capabilities to debug the code. My macbook is a corporate PC, controlled by the cybersecurity department and I am not allowed to install arbitrary software on it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
need-more-info Extra information or replay is needed os-macos This issue only exists on macOS
Projects
None yet
Development

No branches or pull requests

2 participants