Skip to content

Commit

Permalink
feat: add window display delay as a preference
Browse files Browse the repository at this point in the history
  • Loading branch information
Louis Pontoise committed Oct 16, 2019
1 parent f864a25 commit e52326b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
3 changes: 3 additions & 0 deletions alt-tab-macos/logic/Preferences.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ struct PreferencesDecodable: Decodable {
let metaModifierFlagInt: UInt?
let highlightColorString : String?
let thumbnailQuality : UInt?
let windowDisplayDelay: Int?
}

func fileLines(_ url: URL) throws -> Int {
Expand Down Expand Up @@ -79,6 +80,8 @@ class Preferences: Decodable {
static let thumbnailQuality = NSImageInterpolation.init(rawValue: decoded?.thumbnailQuality ?? 3) ?? .high
// NSEvent.ModifierFlags (e.g. control=262144, command=1048576, shift=131072, option=524288)
static let metaModifierFlag = NSEvent.ModifierFlags(rawValue: decoded?.metaModifierFlagInt ?? 262144)
// delay (in ms) before the window is displayed after the shortcut is pressed
static let windowDisplayDelay = DispatchTimeInterval.milliseconds(decoded?.windowDisplayDelay ?? 200)
// color for the currently selected cell
static let highlightColor = NSColor.white
// derived properties
Expand Down
3 changes: 2 additions & 1 deletion alt-tab-macos/resources/preferences.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@
"metaKey": 59,
"metaModifierFlagInt": 262144,
"highlightColorString": "white",
"thumbnailQuality": 4
"thumbnailQuality": 4,
"windowDisplayDelay": 200
}
2 changes: 1 addition & 1 deletion alt-tab-macos/ui/Application.swift
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ class Application: NSApplication, NSApplicationDelegate, NSWindowDelegate, NSCol
Application.shared.unhideWithoutActivation()
}
workItems.append(workItem)
DispatchQueue.main.asyncAfter(deadline: .now() + 0.2, execute: workItem)
DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + Preferences.windowDisplayDelay, execute: workItem)
} else {
highlightThumbnail(step)
}
Expand Down

0 comments on commit e52326b

Please sign in to comment.