mirror of
https://github.com/lwouis/alt-tab-macos.git
synced 2026-05-24 11:20:36 +00:00
fix: restore default cmd+tab shortcut when alt-tab crashes
This commit is contained in:
+15
-4
@@ -1,11 +1,22 @@
|
||||
import AppKit
|
||||
import Darwin
|
||||
|
||||
// if the app is quit/force-quit from Activity Monitor, it will receive SIGTERM and applicationWillTerminate won't be called
|
||||
// we intercept SIGTERM so we can reset the native command-tab shortcut
|
||||
signal(SIGTERM) { _ in
|
||||
// symbolic hotkeys state persist after the app is quit; we restore this shortcut before quitting
|
||||
// - if the app is quit/force-quit from Activity Monitor, it will receive SIGTERM and applicationWillTerminate won't be called
|
||||
// - if the app crashes in swift code (e.g. unexpected nil object), SIGTRAP is sent
|
||||
// we intercept these signals, and reset the native command-tab shortcut
|
||||
[SIGTERM, SIGTRAP].forEach {
|
||||
signal($0) { s in
|
||||
setNativeCommandTabEnabled(true)
|
||||
debugPrint("Exiting after receiving signal", s)
|
||||
exit(0)
|
||||
}
|
||||
}
|
||||
|
||||
// - if the app crashes in objective-c code, an NSException may be sent
|
||||
// we intercept the exception, and reset the native command-tab shortcut
|
||||
NSSetUncaughtExceptionHandler { (exception) in
|
||||
setNativeCommandTabEnabled(true)
|
||||
debugPrint("Exiting after receiving uncaught NSException", exception)
|
||||
exit(0)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user