Support of multi-desplay setup.
This commit is contained in:
@@ -24,6 +24,9 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate {
|
|||||||
window.resignKey()
|
window.resignKey()
|
||||||
} else {
|
} else {
|
||||||
window.makeKeyAndOrderFront(nil)
|
window.makeKeyAndOrderFront(nil)
|
||||||
|
if let controller = window.contentViewController as? SearchViewController {
|
||||||
|
controller.centerWindow()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return noErr
|
return noErr
|
||||||
@@ -35,8 +38,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate {
|
|||||||
{
|
{
|
||||||
HotKeyManager.shared.registerHotKey(key: code, modifiers: mods)
|
HotKeyManager.shared.registerHotKey(key: code, modifiers: mods)
|
||||||
} else {
|
} else {
|
||||||
// NOTE: This is the default shortcut. If you want to change it, do not forget to change it in other files
|
// NOTE: This is the default shortcut. If you want to change it, do not forget to change it in other files (SettingsViewController).
|
||||||
// (SettingsViewController).
|
|
||||||
HotKeyManager.shared.registerHotKey(key: kVK_Space, modifiers: optionKey)
|
HotKeyManager.shared.registerHotKey(key: kVK_Space, modifiers: optionKey)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -69,14 +69,13 @@ $(EXEC).app: $(EXEC)
|
|||||||
|
|
||||||
all: $(EXEC).app
|
all: $(EXEC).app
|
||||||
|
|
||||||
clear:
|
|
||||||
clear
|
|
||||||
|
|
||||||
kill:
|
kill:
|
||||||
-pkill $(EXEC)
|
-pkill $(EXEC)
|
||||||
|
|
||||||
run: clear kill all
|
open: kill all
|
||||||
# @open $(EXEC).app
|
open $(EXEC).app
|
||||||
|
|
||||||
|
run: kill all
|
||||||
./$(EXEC)
|
./$(EXEC)
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
import AppKit
|
import AppKit
|
||||||
import Carbon
|
import Carbon
|
||||||
|
|
||||||
// NOTE: This is the corner radius of the backgrounView view that acts as a window frame and an NSViewController's view that clips all
|
// NOTE: This is the corner radius of the backgrounView view that acts as a window frame and an NSViewController's view that clips all elements inside of it.
|
||||||
// elements inside of it.
|
|
||||||
fileprivate let windowCornerRadius = 15.0
|
fileprivate let windowCornerRadius = 15.0
|
||||||
|
|
||||||
fileprivate let maxItems = 20
|
fileprivate let maxItems = 20
|
||||||
@@ -163,7 +162,8 @@ class SearchViewController: NSViewController, NSTextFieldDelegate, NSPopoverDele
|
|||||||
|
|
||||||
// NOTE: This needs removeObserver on deinit? Well, technically we don't care because this view controller will exist throughout
|
// NOTE: This needs removeObserver on deinit? Well, technically we don't care because this view controller will exist throughout
|
||||||
// the whole life of the program. When the program gets killed, the OS will clear this.
|
// the whole life of the program. When the program gets killed, the OS will clear this.
|
||||||
DistributedNotificationCenter.default.addObserver(self, selector: #selector(osThemeChanged(sender:)), name: NSNotification.Name(rawValue: "AppleInterfaceThemeChangedNotification"), object: nil)
|
DistributedNotificationCenter.default.addObserver(self, selector: #selector(osThemeChanged(sender:)),
|
||||||
|
name: NSNotification.Name(rawValue: "AppleInterfaceThemeChangedNotification"), object: nil)
|
||||||
|
|
||||||
// Initialize an array of programs and reusable cells.
|
// Initialize an array of programs and reusable cells.
|
||||||
for i in 0..<maxItems {
|
for i in 0..<maxItems {
|
||||||
@@ -242,11 +242,7 @@ class SearchViewController: NSViewController, NSTextFieldDelegate, NSPopoverDele
|
|||||||
|
|
||||||
keyboardEvents?.start()
|
keyboardEvents?.start()
|
||||||
|
|
||||||
if let win = view.window, let scrn = NSScreen.main {
|
centerWindow()
|
||||||
let x = (scrn.visibleFrame.size.width / 2) - (win.frame.size.width / 2)
|
|
||||||
let y = (scrn.visibleFrame.size.height * 0.9) - win.frame.size.height
|
|
||||||
view.window?.setFrameOrigin(NSPoint(x: x, y: y))
|
|
||||||
}
|
|
||||||
|
|
||||||
view.window?.makeFirstResponder(searchInput)
|
view.window?.makeFirstResponder(searchInput)
|
||||||
// searchInput should select all text whenever window appears.
|
// searchInput should select all text whenever window appears.
|
||||||
@@ -269,6 +265,14 @@ class SearchViewController: NSViewController, NSTextFieldDelegate, NSPopoverDele
|
|||||||
self.view = NSView()
|
self.view = NSView()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func centerWindow() {
|
||||||
|
if let win = view.window, let scrn = NSScreen.main {
|
||||||
|
let x = (scrn.visibleFrame.origin.x + scrn.visibleFrame.size.width / 2) - (win.frame.size.width / 2)
|
||||||
|
let y = (scrn.visibleFrame.origin.y + scrn.visibleFrame.size.height * 0.9) - win.frame.size.height
|
||||||
|
view.window?.setFrameOrigin(NSPoint(x: x, y: y))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private func reloadProgramsTableViewData() {
|
private func reloadProgramsTableViewData() {
|
||||||
if listIndex > 0 {
|
if listIndex > 0 {
|
||||||
tableViewHeightAnchor?.constant = 210
|
tableViewHeightAnchor?.constant = 210
|
||||||
|
|||||||
Reference in New Issue
Block a user