-
-
Notifications
You must be signed in to change notification settings - Fork 330
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
Keyboard inputs are ignored despite all OS permissions being granted #284
Comments
I replied to the author:
|
Hi, sorry for the naming latest macos incorrectly, its Catalina. I have latest Catalina. And AltTab was working after I got the latest macos update for a few AltTab updates, then it stopped. It has both needed permissions. I tried checking and unchecking them and restarting AltTab. It starts properly, I can open it from menubar icon and access preferences. When preferences windows in open, and I try option+tab, it just behaves as tab, it goes to next option on preferences window. It does not pick option+tab key combination no more. When I click "show" the windows selection appears but it looks like it does not pick keyboard in any way. Command+tab does not work, nor do arrows or tab button (it does not switch between apps or selects them via keyboard, only mouse works). Pressing tab or arrow keys, takes effect on the app behind open AltTAb, somehow AltTab does not gain keyboard input. Macos's useless command+tab still works :) |
When the app boots, it checks permissions. The check is pretty clear and has never bugged for anyone. Also you clicked "Show" and saw the working UI, and even can interact with the mouse. So you have both the Accessibility permission needed to: intercept keyboard inputs + read windows events + focus/minimize/etc windows; and the Screen Recording permission needed to: get screenshots of windows. Now despite having permissions, the keyboard inputs are not intercepted. I'm afraid I don't see where to go from here. I see only 2 explanations:
https://github.com/lwouis/alt-tab-macos/blob/master/src/logic/events/KeyboardEvents.swift#L16 Never happened before. Why would that fail with the permission granted?
https://github.com/lwouis/alt-tab-macos/blob/master/src/logic/events/KeyboardEvents.swift#L46 Again I don't see how that would be happening. I made a special build that logs every line in that function: private func keyboardHandler(proxy: CGEventTapProxy, type: CGEventType, cgEvent: CGEvent, userInfo: UnsafeMutableRawPointer?) -> Unmanaged<CGEvent>? {
os_log("keyboardHandler1")
if type == .keyDown || type == .keyUp || type == .flagsChanged {
os_log("keyboardHandler2")
if let event_ = NSEvent(cgEvent: cgEvent),
// workaround: NSEvent.characters is not safe outside of the main thread; this is not documented by Apple
// see https://github.com/Kentzo/ShortcutRecorder/issues/114#issuecomment-606465340
let event = NSEvent.keyEvent(with: event_.type, location: event_.locationInWindow, modifierFlags: event_.modifierFlags,
timestamp: event_.timestamp, windowNumber: event_.windowNumber, context: nil, characters: "",
charactersIgnoringModifiers: "", isARepeat: type == .flagsChanged ? false : event_.isARepeat, keyCode: event_.keyCode) {
os_log("keyboardHandler3")
let appWasBeingUsed = App.app.appIsBeingUsed
os_log("keyboardHandler4")
App.shortcutMonitor.handle(event, withTarget: nil)
os_log("keyboardHandler5")
if appWasBeingUsed || App.app.appIsBeingUsed {
return nil // focused app won't receive the event
}
}
} else if type == .tapDisabledByUserInput || type == .tapDisabledByTimeout {
os_log("keyboardHandler6")
CGEvent.tapEnable(tap: eventTap!, enable: true)
}
os_log("keyboardHandler7")
return Unmanaged.passRetained(cgEvent) // focused app will receive the event
} Could you please open Console.app, search AltTab in the top right search field, and run that build? Then could you please press a normal key like |
@HelloAstroWolf that's all there is, really? I'm surprised :o It should print when you hit normal keys, and when you hit Here it looks like only the |
Removed all permissions. Uninstalled it using brew. Restart. Installed using brew. Works. Looks like macos needs frequent restarts? |
@HelloAstroWolf that looks like a bug in macOS. I noticed bug during recent work on #127 where I would remove permissions while AltTab is open, and it would still be able to work. It was not always happening, so inconsistent as well. These permissions are a very low-quality work from Apple. See links I shared in #127 to see the kind of poor consideration they put into the APIs, and the bad consequence on end-user UX. I'll close this ticket as I think the issue was on macOS side |
This issue was opened by a bot after a user submitted feedback through the in-app form.
From: m.terzic@gmail.com
Message:
Debug profile
The text was updated successfully, but these errors were encountered: