Skip to content

Screenshots, hung out to dry. A tiny native macOS app that hangs every screenshot on a line at the top of your screen.

Swift

The shortcut and Show line work over full screen apps

Alejandro Bujána3f1815d2353
diff --git a/Sources/Tendedero/AppDelegate.swift b/Sources/Tendedero/AppDelegate.swift
index 017b3e1..86f2ff3 100644
--- a/Sources/Tendedero/AppDelegate.swift
+++ b/Sources/Tendedero/AppDelegate.swift
@@ -45,6 +45,9 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSMenuDelegate {
private var wanted = false
/// Set when you open the line on purpose, so it stays up while empty.
private var keepOpen = false
+ /// Opened on purpose with the shortcut or the menu, which counts over a
+ /// full screen app too, until the line tucks away.
+ private var openedOnPurpose = false
// What brings the line down, from the menu bar's "Bring the line down".
// Out of the box, the first two are on and the third off.
@@ -104,6 +107,8 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSMenuDelegate {
for name in [NSWorkspace.activeSpaceDidChangeNotification, NSWorkspace.didActivateApplicationNotification] {
workspace.addObserver(forName: name, object: nil, queue: .main) { [weak self] _ in
MainActor.assumeIsolated {
+ // Opened on purpose counts for the Space it was opened on.
+ if name == NSWorkspace.activeSpaceDidChangeNotification { self?.openedOnPurpose = false }
self?.refresh()
DispatchQueue.main.asyncAfter(deadline: .now() + 0.8) { self?.refresh() }
}
@@ -342,10 +347,10 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSMenuDelegate {
}
/// Decides whether the panel is ordered in at all: something to show,
- /// and no full screen app on that screen.
+ /// and no full screen app on that screen unless you asked for the line.
private func refresh() {
- let blocked = panel.screen.map(FullScreen.blocksLine(on:))
- ?? LinePanel.screenUnderPointer().map(FullScreen.blocksLine(on:)) ?? false
+ let blocked = !openedOnPurpose && (panel.screen.map(FullScreen.blocksLine(on:))
+ ?? LinePanel.screenUnderPointer().map(FullScreen.blocksLine(on:)) ?? false)
if wanted && !blocked {
present()
} else {
@@ -403,6 +408,11 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSMenuDelegate {
pinned = false
peekUntil = .distantPast
panel.ignoresMouseEvents = true
+ // Over a full screen app the line goes once it is put away.
+ if openedOnPurpose {
+ openedOnPurpose = false
+ refresh()
+ }
}
}
@@ -417,6 +427,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSMenuDelegate {
} else {
keepOpen = true
wanted = true
+ openedOnPurpose = true
panel.placeOnScreen()
updateCapacity()
refresh()