EPOD Window Bar: a window strip above the macOS Dock
EPOD Window Bar is a macOS agent app. It shows a thin strip above the Dock with one tab per window of the frontmost application. One click raises the window. Build from source with XcodeGen and Xcode. Signing uses Config.xcconfig (ad-hoc by default; a local Local.xcconfig can set a team ID). The app needs Accessibility and Screen Recording permissions, and runs in a reduced mode without Screen Recording. See README.md and docs/ for details.
This commit is contained in:
52
Sources/Strip/StripPositioner.swift
Normal file
52
Sources/Strip/StripPositioner.swift
Normal file
@@ -0,0 +1,52 @@
|
||||
import AppKit
|
||||
|
||||
// StripPositioner finds the Dock screen and computes the strip frame.
|
||||
// See spec section 7.8. The core math takes plain values so a unit test can
|
||||
// check the logic without a real screen.
|
||||
enum StripPositioner {
|
||||
|
||||
// ScreenFrames holds the two frames of one screen.
|
||||
struct ScreenFrames: Equatable {
|
||||
let frame: CGRect
|
||||
let visibleFrame: CGRect
|
||||
}
|
||||
|
||||
// dockScreenIndex returns the index of the Dock screen. The Dock screen has
|
||||
// a visibleFrame.minY above the frame.minY. macOS reserves this space for
|
||||
// the Dock at the bottom. If no screen matches, the function returns the
|
||||
// main index.
|
||||
static func dockScreenIndex(screens: [ScreenFrames], mainIndex: Int) -> Int {
|
||||
for (index, screen) in screens.enumerated() {
|
||||
if screen.visibleFrame.minY > screen.frame.minY {
|
||||
return index
|
||||
}
|
||||
}
|
||||
return mainIndex
|
||||
}
|
||||
|
||||
// stripFrame returns the strip frame for a visible frame and a height.
|
||||
// The strip sits at the bottom of the visible frame, full width.
|
||||
static func stripFrame(visibleFrame: CGRect, height: CGFloat) -> CGRect {
|
||||
return CGRect(x: visibleFrame.minX,
|
||||
y: visibleFrame.minY,
|
||||
width: visibleFrame.width,
|
||||
height: height)
|
||||
}
|
||||
|
||||
// dockScreen returns the Dock NSScreen. The function uses the same rule as
|
||||
// dockScreenIndex. If no screen matches, the function returns the main
|
||||
// screen, or the first screen.
|
||||
static func dockScreen(_ screens: [NSScreen], main: NSScreen?) -> NSScreen? {
|
||||
for screen in screens {
|
||||
if screen.visibleFrame.minY > screen.frame.minY {
|
||||
return screen
|
||||
}
|
||||
}
|
||||
return main ?? screens.first
|
||||
}
|
||||
|
||||
// stripFrame returns the strip frame for an NSScreen and a height.
|
||||
static func stripFrame(for screen: NSScreen, height: CGFloat) -> NSRect {
|
||||
return stripFrame(visibleFrame: screen.visibleFrame, height: height)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user