fix: restore default cmd+tab shortcut when alt-tab crashes
This commit is contained in:
1 parent
4371eb7c39
commit
2c47b4e585
1 file changed
+15
-4
+15
-4
@@ -1,11 +1,22 @@
|
|||||||
import AppKit
|
import AppKit
|
||||||
import Darwin
|
import Darwin
|
||||||
|
|
||||||
// if the app is quit/force-quit from Activity Monitor, it will receive SIGTERM and applicationWillTerminate won't be called
|
// - 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
|
// - if the app crashes in swift code (e.g. unexpected nil object), SIGTRAP is sent
|
||||||
signal(SIGTERM) { _ in
|
// we intercept these signals, and reset the native command-tab shortcut
|
||||||
// symbolic hotkeys state persist after the app is quit; we restore this shortcut before quitting
|
[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)
|
setNativeCommandTabEnabled(true)
|
||||||
|
debugPrint("Exiting after receiving uncaught NSException", exception)
|
||||||
exit(0)
|
exit(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user