From 4d681ac116b78d23d173522165ec28c2d0153e2f Mon Sep 17 00:00:00 2001 From: igor Date: Sun, 16 Mar 2025 15:40:47 -0700 Subject: [PATCH] Support of multi-desplay setup. --- src/AppDelegate.swift | 6 ++++-- src/Makefile | 9 ++++----- src/SearchViewController.swift | 20 ++++++++++++-------- 3 files changed, 20 insertions(+), 15 deletions(-) diff --git a/src/AppDelegate.swift b/src/AppDelegate.swift index 7fb14f1..3da7939 100644 --- a/src/AppDelegate.swift +++ b/src/AppDelegate.swift @@ -24,6 +24,9 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate { window.resignKey() } else { window.makeKeyAndOrderFront(nil) + if let controller = window.contentViewController as? SearchViewController { + controller.centerWindow() + } } } return noErr @@ -35,8 +38,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate { { HotKeyManager.shared.registerHotKey(key: code, modifiers: mods) } else { - // NOTE: This is the default shortcut. If you want to change it, do not forget to change it in other files - // (SettingsViewController). + // NOTE: This is the default shortcut. If you want to change it, do not forget to change it in other files (SettingsViewController). HotKeyManager.shared.registerHotKey(key: kVK_Space, modifiers: optionKey) } } diff --git a/src/Makefile b/src/Makefile index 9652f7d..2b89265 100644 --- a/src/Makefile +++ b/src/Makefile @@ -69,14 +69,13 @@ $(EXEC).app: $(EXEC) all: $(EXEC).app -clear: - clear - kill: -pkill $(EXEC) -run: clear kill all -# @open $(EXEC).app +open: kill all + open $(EXEC).app + +run: kill all ./$(EXEC) clean: diff --git a/src/SearchViewController.swift b/src/SearchViewController.swift index 53ebb1c..2ef9b98 100644 --- a/src/SearchViewController.swift +++ b/src/SearchViewController.swift @@ -1,8 +1,7 @@ import AppKit 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 -// elements inside of it. +// 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. fileprivate let windowCornerRadius = 15.0 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 // 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. for i in 0.. 0 { tableViewHeightAnchor?.constant = 210