refactor: moved local constant to a preference
This commit is contained in:
1 parent
c2c10f5bdd
commit
77bb69c132
2 files changed
+3
-4
No files matched your search
@@ -16,6 +16,7 @@ class Preferences {
|
||||
static var rawValues = [String: String]()
|
||||
static var thumbnailMaxWidth: CGFloat = 200
|
||||
static var thumbnailMaxHeight: CGFloat = 200
|
||||
static var minimumWindowSize: CGFloat = 200
|
||||
static var fontColor: NSColor = .white
|
||||
static var windowMaterial: NSVisualEffectView.Material = .dark
|
||||
static var windowPadding: CGFloat = 23
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
import Cocoa
|
||||
import Foundation
|
||||
|
||||
let minimumWindowSize: CGFloat = 200
|
||||
|
||||
class OpenWindow {
|
||||
var target: AXUIElement?
|
||||
var ownerPid: pid_t?
|
||||
@@ -50,7 +48,7 @@ func axWindows(_ cgOwnerPid: pid_t) -> [AXUIElement] {
|
||||
return windows.filter {
|
||||
// workaround: some apps like chrome use a window to implement the search popover
|
||||
let windowBounds = AXValueGetValue($0, kAXSizeAttribute, NSSize(), AXValueType.cgSize)!
|
||||
let isReasonablyBig = windowBounds.width > minimumWindowSize && windowBounds.height > minimumWindowSize
|
||||
let isReasonablyBig = windowBounds.width > Preferences.minimumWindowSize && windowBounds.height > Preferences.minimumWindowSize
|
||||
return isReasonablyBig
|
||||
}
|
||||
}
|
||||
@@ -64,7 +62,7 @@ func cgWindows() -> [NSDictionary] {
|
||||
let isWindowNotMenubarOrOthers = $0[kCGWindowLayer] as? Int == 0
|
||||
let windowBounds = CGRect(dictionaryRepresentation: $0[kCGWindowBounds] as! NSDictionary)!
|
||||
// workaround: some apps like chrome use a window to implement the search popover
|
||||
let isReasonablyBig = windowBounds.width > minimumWindowSize && windowBounds.height > minimumWindowSize
|
||||
let isReasonablyBig = windowBounds.width > Preferences.minimumWindowSize && windowBounds.height > Preferences.minimumWindowSize
|
||||
return isWindowNotMenubarOrOthers && isReasonablyBig
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user