feat: play alert sound for unavailable thumbnail shortcuts
This commit is contained in:
1 parent
b62c422959
commit
fd84a9a5fc
3 files changed
+32
-8
No files matched your search
@@ -125,9 +125,16 @@ class Application: NSObject {
|
||||
}
|
||||
}
|
||||
|
||||
func canBeQuit() -> Bool {
|
||||
return runningApplication.bundleIdentifier != "com.apple.finder" || Preferences.finderShowsQuitMenuItem
|
||||
}
|
||||
|
||||
func quit() {
|
||||
// only let power users quit Finder if they opt-in
|
||||
if runningApplication.bundleIdentifier == "com.apple.finder" && !Preferences.finderShowsQuitMenuItem { return }
|
||||
if !canBeQuit() {
|
||||
NSSound.beep()
|
||||
return
|
||||
}
|
||||
if alreadyRequestedToQuit {
|
||||
runningApplication.forceTerminate()
|
||||
} else {
|
||||
|
||||
+21
-4
@@ -101,8 +101,15 @@ class Window {
|
||||
}
|
||||
}
|
||||
|
||||
func canBeClosed() -> Bool {
|
||||
return !isWindowlessApp
|
||||
}
|
||||
|
||||
func close() {
|
||||
if isWindowlessApp { return }
|
||||
if !canBeClosed() {
|
||||
NSSound.beep()
|
||||
return
|
||||
}
|
||||
BackgroundWork.accessibilityCommandsQueue.asyncWithCap { [weak self] in
|
||||
guard let self = self else { return }
|
||||
if self.isFullscreen {
|
||||
@@ -114,8 +121,15 @@ class Window {
|
||||
}
|
||||
}
|
||||
|
||||
func canBeMinDeminOrFullscreened() -> Bool {
|
||||
return !isWindowlessApp && !isTabbed
|
||||
}
|
||||
|
||||
func minDemin() {
|
||||
if isWindowlessApp { return }
|
||||
if !canBeMinDeminOrFullscreened() {
|
||||
NSSound.beep()
|
||||
return
|
||||
}
|
||||
BackgroundWork.accessibilityCommandsQueue.asyncWithCap { [weak self] in
|
||||
guard let self = self else { return }
|
||||
if self.isFullscreen {
|
||||
@@ -132,7 +146,10 @@ class Window {
|
||||
}
|
||||
|
||||
func toggleFullscreen() {
|
||||
if isWindowlessApp { return }
|
||||
if canBeMinDeminOrFullscreened() {
|
||||
NSSound.beep()
|
||||
return
|
||||
}
|
||||
BackgroundWork.accessibilityCommandsQueue.asyncWithCap { [weak self] in
|
||||
guard let self = self else { return }
|
||||
self.axUiElement.setAttribute(kAXFullscreenAttribute, !self.isFullscreen)
|
||||
@@ -164,7 +181,7 @@ class Window {
|
||||
}
|
||||
}
|
||||
|
||||
// The following function was ported from https://github.com/Hammerspoon/hammerspoon/issues/370#issuecomment-545545468
|
||||
/// The following function was ported from https://github.com/Hammerspoon/hammerspoon/issues/370#issuecomment-545545468
|
||||
func makeKeyWindow(_ psn: ProcessSerialNumber) -> Void {
|
||||
var psn_ = psn
|
||||
var bytes1 = [UInt8](repeating: 0, count: 0xf8)
|
||||
|
||||
@@ -78,9 +78,9 @@ class ThumbnailView: NSStackView {
|
||||
var yOffset = CGFloat(2 + ThumbnailView.windowsControlSize)
|
||||
[quitIcon, closeIcon, minimizeIcon, maximizeIcon].forEach { icon in
|
||||
icon.isHidden = !shouldShow ||
|
||||
((window_?.isWindowlessApp ?? true) && icon.type != .quit) ||
|
||||
(icon.type == .quit && window_?.application.runningApplication.bundleIdentifier == "com.apple.finder" && !Preferences.finderShowsQuitMenuItem) ||
|
||||
((icon.type == .miniaturize || icon.type == .fullscreen) && (window_?.isTabbed ?? true))
|
||||
(icon.type == .quit && !(window_?.application.canBeQuit() ?? true)) ||
|
||||
(icon.type == .close && !(window_?.canBeClosed() ?? true)) ||
|
||||
((icon.type == .miniaturize || icon.type == .fullscreen) && !(window_?.canBeMinDeminOrFullscreened() ?? true))
|
||||
if !icon.isHidden {
|
||||
icon.setFrameOrigin(NSPoint(
|
||||
x: xOffset,
|
||||
|
||||
Reference in new issue
Block a user