From ec6e0da8224a54dd7273adc2a797f149fd9795c8 Mon Sep 17 00:00:00 2001
From: Ariver <shanghai3168@gmail.com>
Date: Wed, 20 May 2026 12:51:53 +0800
Subject: [PATCH] chore: mark stable baseline as 7.6.0
---
Apptag/ApptagApp.swift | 1221 +++++++++++++++++++++++++++++++++++++++++----------------
1 files changed, 875 insertions(+), 346 deletions(-)
diff --git a/Apptag/ApptagApp.swift b/Apptag/ApptagApp.swift
index a55758d..a0487fd 100644
--- a/Apptag/ApptagApp.swift
+++ b/Apptag/ApptagApp.swift
@@ -1,91 +1,236 @@
import SwiftUI
import AppKit
import Carbon
-import ServiceManagement
// MARK: - Application Entry Point
@main
-struct ApptagApp: App {
+struct TagLauncherApp: App {
@NSApplicationDelegateAdaptor(AppDelegate.self) var appDelegate
var body: some Scene {
Settings {
PreferencesView()
}
+ .defaultSize(width: 880, height: 460)
+ .commands {
+ CommandGroup(replacing: .systemServices) { }
+ CommandGroup(replacing: .appVisibility) { }
+ }
}
}
// MARK: - App Delegate (menubar + overlay window + hotkey)
-final class AppDelegate: NSObject, NSApplicationDelegate {
- private var statusItem: NSStatusItem!
- private var overlayWindow: NSWindow?
- private var hotkeyRef: EventHotKeyRef?
- private var isInEditMode = false // Suppress auto-dismiss during editing
+final class OverlayPanel: NSPanel {
+ override var canBecomeKey: Bool { true }
+ override var canBecomeMain: Bool { true }
+}
- func applicationDidFinishLaunching(_ notification: Notification) {
- L10n.setup()
- let showDock = UserDefaults.standard.bool(forKey: "showDockIcon")
- NSApp.setActivationPolicy(showDock ? .regular : .accessory)
- setupMenuBar()
- registerHotkey()
- observeOtherWindows()
- observeEditMode()
- observeDockSetting()
- setupLaunchAtLogin()
+final class AppDelegate: NSObject, NSApplicationDelegate {
+ private static let showDockIconKey = "showDockIcon"
+ private static let statusItemAutosaveName = "com.apptag.launcher.statusItem"
+ private static let statusItemButtonIdentifier = NSUserInterfaceItemIdentifier("TagLauncherStatusItemButton")
+ private static let statusItemAccessibilityLabel = "TagLauncher"
+ private static let showAppListMenuItemIdentifier = NSUserInterfaceItemIdentifier("TagLauncherShowAppListMenuItem")
+ private static let overlayDefaultLevel = NSWindow.Level(rawValue: Int(CGWindowLevelForKey(.maximumWindow)))
+ private static let overlayTextInputLevel = NSWindow.Level.modalPanel
+
+ private var statusItem: NSStatusItem?
+ private var overlayWindow: NSWindow?
+ private var overlayKeyMonitor: Any?
+ private var quickSearchExternalMouseMonitor: Any?
+ private var settingsWindow: NSWindow? // Track Settings window to keep it above overlay
+ private var mainHotkeyRef: EventHotKeyRef?
+ private var quickSearchHotkeyRef: EventHotKeyRef?
+ private var hotkeyEventHandlerInstalled = false
+ private var isQuickSearchOpen = false
+ private var isModalInteractionActive = false
+ private var isInEditMode = false // Suppress auto-dismiss during editing
+ private var isEditingAppNote = false
+ private var isConfiguringApplicationMenu = false
+ private var lastShowDockIcon: Bool?
+
+ static func refreshChromeSettings() {
+ (NSApp.delegate as? AppDelegate)?.syncChromeSettings(force: true)
}
- /// Observe Show in Dock changes so it takes effect immediately.
- private func observeDockSetting() {
+ static func openPreferencesWindow() {
+ (NSApp.delegate as? AppDelegate)?.openPreferences()
+ }
+
+ func applicationDidFinishLaunching(_ notification: Notification) {
+ AppDefaults.register()
+ L10n.setup()
+ migrateDefaultGroupName()
+ TagDatabase.seedDefaultTags()
+ syncChromeSettings(force: true)
+ observeHotkeyStatusChanges()
+ registerConfiguredHotkeys()
+ observeOtherWindows()
+ observeSettingsClose()
+ observeEditMode()
+ observeAppNoteEditing()
+ observeQuickSearch()
+ observePreferencesRequests()
+ observeApplicationMenuChanges()
+ observeChromeSettings()
+ observeLanguageChanges()
+ setupLaunchAtLogin()
+ configureApplicationMenuWhenAvailable()
+ }
+
+ /// Dock icon click → show overlay (same as menubar "Show TagLauncher")
+ func applicationShouldHandleReopen(_ sender: NSApplication, hasVisibleWindows flag: Bool) -> Bool {
+ showOverlay()
+ return false // Suppress default "unhide all windows" behavior
+ }
+
+ func applicationWillTerminate(_ notification: Notification) {
+ TagDatabase.flushPendingCategorySchemeBackupBatch()
+ removeQuickSearchExternalMouseMonitor()
+ }
+
+ /// Ensure defaultGroupName is always the language-neutral key "Other".
+ /// Translates known old values back to "Other" so switching languages works.
+ private func migrateDefaultGroupName() {
+ let key = "defaultGroupName"
+ let stored = UserDefaults.standard.string(forKey: key)
+ // "Other" is the neutral key — nothing to do
+ if stored == nil || stored == "Other" { return }
+ // Check if the stored value is a translated version of "group.uncategorized"
+ for (code, _) in L10n.supported {
+ let loc = L10n.loadedTranslation("group.uncategorized", for: code)
+ if stored == loc {
+ UserDefaults.standard.set("Other", forKey: key)
+ return
+ }
+ }
+ // User has set a custom name — keep it
+ }
+
+ /// Observe Dock visibility changes so they take effect immediately.
+ private func observeChromeSettings() {
NotificationCenter.default.addObserver(
forName: UserDefaults.didChangeNotification,
object: nil, queue: .main
- ) { _ in
- let show = UserDefaults.standard.bool(forKey: "showDockIcon")
- NSApp.setActivationPolicy(show ? .regular : .accessory)
+ ) { [weak self] _ in
+ self?.syncChromeSettings()
}
}
- /// Enable launch at login by default; prompt user if disabled.
+ private func syncChromeSettings(force: Bool = false) {
+ let showDock = UserDefaults.standard.bool(forKey: Self.showDockIconKey)
+ let dockChanged = lastShowDockIcon != showDock
+
+ if force || dockChanged {
+ NSApp.setActivationPolicy(showDock ? .regular : .accessory)
+ lastShowDockIcon = showDock
+ }
+
+ if force {
+ setupMenuBar()
+ }
+ }
+
+ /// Keep app chrome in sync when language changes from any entry point.
+ private func observeLanguageChanges() {
+ NotificationCenter.default.addObserver(
+ forName: .appLanguageDidChange,
+ object: nil, queue: .main
+ ) { [weak self] _ in
+ self?.setupMenuBar()
+ self?.configureApplicationMenuWhenAvailable()
+ }
+ }
+
+ // MARK: - Launch at Login (LaunchAgent, zero permissions)
+
+ private static let launchAgentLabel = "com.apptag.launcher"
+ static var supportsLaunchAtLogin: Bool {
+ ProcessInfo.processInfo.environment["APP_SANDBOX_CONTAINER_ID"] == nil
+ }
+
+ private static var launchAgentURL: URL {
+ FileManager.default.homeDirectoryForCurrentUser
+ .appendingPathComponent("Library/LaunchAgents/\(launchAgentLabel).plist")
+ }
+
+ static func enableLaunchAtLogin() {
+ guard supportsLaunchAtLogin else { return }
+ let plist: [String: Any] = [
+ "Label": Self.launchAgentLabel,
+ "ProgramArguments": ["open", Bundle.main.bundlePath, "--hide"],
+ "RunAtLoad": true,
+ ]
+ let dir = Self.launchAgentURL.deletingLastPathComponent()
+ try? FileManager.default.createDirectory(at: dir, withIntermediateDirectories: true)
+ (plist as NSDictionary).write(to: Self.launchAgentURL, atomically: true)
+
+ let uid = getuid()
+ let task = Process()
+ task.launchPath = "/bin/launchctl"
+ task.arguments = ["bootstrap", "gui/\(uid)", Self.launchAgentURL.path]
+ task.launch()
+ }
+
+ static func disableLaunchAtLogin() {
+ guard supportsLaunchAtLogin else { return }
+ let uid = getuid()
+ let task = Process()
+ task.launchPath = "/bin/launchctl"
+ task.arguments = ["bootout", "gui/\(uid)/\(Self.launchAgentLabel)"]
+ task.launch()
+ try? FileManager.default.removeItem(at: Self.launchAgentURL)
+ }
+
+ /// On first launch, enable login item by default via LaunchAgent.
+ /// Does NOT require App Management permission.
private func setupLaunchAtLogin() {
+ guard Self.supportsLaunchAtLogin else {
+ if UserDefaults.standard.object(forKey: "launchAtLogin") == nil {
+ UserDefaults.standard.set(false, forKey: "launchAtLogin")
+ }
+ return
+ }
let key = "launchAtLogin"
- if UserDefaults.standard.object(forKey: key) == nil {
- // First launch: enable by default
- UserDefaults.standard.set(true, forKey: key)
- try? SMAppService.mainApp.register()
- } else if UserDefaults.standard.bool(forKey: key) {
- try? SMAppService.mainApp.register()
+ if !AppDefaults.hasStoredValue(for: key) && UserDefaults.standard.bool(forKey: key) {
+ Self.enableLaunchAtLogin()
}
}
// MARK: - Menu Bar
private func setupMenuBar() {
- // Remove old status item if re-creating (language switch, etc.)
- if let existing = statusItem {
- NSStatusBar.system.removeStatusItem(existing)
+ if statusItem == nil {
+ statusItem = NSStatusBar.system.statusItem(withLength: NSStatusItem.squareLength)
+ } else {
+ statusItem?.length = NSStatusItem.squareLength
}
- statusItem = NSStatusBar.system.statusItem(withLength: NSStatusItem.variableLength)
+ guard let statusItem else { return }
+ statusItem.autosaveName = Self.statusItemAutosaveName
+ statusItem.isVisible = true
if let button = statusItem.button {
- button.image = NSImage(
- systemSymbolName: "tag.fill",
- accessibilityDescription: "Apptag"
- )
- button.toolTip = "Apptag — Tag-based app launcher"
+ button.identifier = Self.statusItemButtonIdentifier
+ button.setAccessibilityIdentifier(Self.statusItemAutosaveName)
+ button.setAccessibilityLabel(Self.statusItemAccessibilityLabel)
+ button.image = makeMenuBarIcon()
+ button.imageScaling = .scaleProportionallyDown
+ button.imagePosition = .imageOnly
+ button.toolTip = "TagLauncher — Tag-based app launcher"
button.action = #selector(toggleOverlay)
button.target = self
}
let menu = NSMenu()
- menu.addItem(
- NSMenuItem(
- title: tr("menu.show"),
- action: #selector(toggleOverlay),
- keyEquivalent: ""
- )
+ let showItem = NSMenuItem(
+ title: showAppListMenuTitle,
+ action: #selector(toggleOverlay),
+ keyEquivalent: ""
)
+ showItem.target = self
+ menu.addItem(showItem)
menu.addItem(.separator())
// Version display
@@ -105,6 +250,7 @@
action: #selector(openPreferences),
keyEquivalent: ","
)
+ prefsItem.target = self
prefsItem.keyEquivalentModifierMask = .command
menu.addItem(prefsItem)
menu.addItem(.separator())
@@ -133,6 +279,229 @@
statusItem.menu = menu
}
+ private func makeMenuBarIcon() -> NSImage {
+ let menuBarIconSize = NSSize(width: 19, height: 19)
+ if let url = Bundle.main.url(forResource: "TagLauncherMenuBarIcon", withExtension: "svg"),
+ let image = NSImage(contentsOf: url) {
+ image.size = menuBarIconSize
+ image.isTemplate = true
+ image.accessibilityDescription = "TagLauncher"
+ return image
+ }
+
+ let image = NSImage(size: menuBarIconSize)
+ image.lockFocus()
+ defer { image.unlockFocus() }
+
+ NSGraphicsContext.current?.shouldAntialias = true
+ NSColor.black.withAlphaComponent(0.88).setStroke()
+ NSColor.black.withAlphaComponent(0.88).setFill()
+
+ let scale = image.size.width / 220.0
+ func rectFromSVG(x: CGFloat, y: CGFloat, width: CGFloat, height: CGFloat) -> NSRect {
+ NSRect(
+ x: x * scale,
+ y: (220.0 - y - height) * scale,
+ width: width * scale,
+ height: height * scale
+ )
+ }
+
+ let outline = NSBezierPath(
+ roundedRect: rectFromSVG(x: 15, y: 15, width: 190, height: 190),
+ xRadius: 44 * scale,
+ yRadius: 44 * scale
+ )
+ outline.lineWidth = 11 * scale
+ outline.stroke()
+
+ for rect in [
+ rectFromSVG(x: 49, y: 134, width: 27, height: 27),
+ rectFromSVG(x: 92, y: 134, width: 27, height: 27),
+ rectFromSVG(x: 49, y: 91, width: 27, height: 27),
+ rectFromSVG(x: 92, y: 91, width: 27, height: 27),
+ rectFromSVG(x: 49, y: 48, width: 27, height: 27),
+ rectFromSVG(x: 92, y: 48, width: 27, height: 27)
+ ] {
+ NSBezierPath(roundedRect: rect, xRadius: 8 * scale, yRadius: 8 * scale).fill()
+ }
+
+ for rect in [
+ rectFromSVG(x: 132, y: 133, width: 47, height: 28),
+ rectFromSVG(x: 132, y: 90.5, width: 47, height: 28),
+ rectFromSVG(x: 132, y: 48, width: 47, height: 28)
+ ] {
+ NSBezierPath(roundedRect: rect, xRadius: 12 * scale, yRadius: 12 * scale).fill()
+ }
+
+ image.isTemplate = true
+ image.accessibilityDescription = "TagLauncher"
+ return image
+ }
+
+ private var showAppListMenuTitle: String {
+ if LauncherHotkeyRegistrationStore.state(for: .main) == .failed {
+ return tr("menu.showShortcutUnavailable")
+ }
+ return "\(tr("menu.showAppList")) \(LauncherHotkey.main.displayString)"
+ }
+
+ private func observeApplicationMenuChanges() {
+ NotificationCenter.default.addObserver(
+ forName: NSApplication.didBecomeActiveNotification,
+ object: NSApp, queue: .main
+ ) { [weak self] _ in
+ self?.configureApplicationMenuWhenAvailable(retries: 4)
+ }
+
+ NotificationCenter.default.addObserver(
+ forName: NSMenu.didAddItemNotification,
+ object: nil, queue: .main
+ ) { [weak self] notification in
+ guard let self,
+ !self.isConfiguringApplicationMenu,
+ let menu = notification.object as? NSMenu,
+ menu === NSApp.mainMenu?.items.first?.submenu
+ else { return }
+ self.configureApplicationMenuWhenAvailable(retries: 2)
+ }
+ }
+
+ private func configureApplicationMenuWhenAvailable(retries: Int = 20) {
+ DispatchQueue.main.asyncAfter(deadline: .now() + 0.05) { [weak self] in
+ guard let self else { return }
+ guard NSApp.mainMenu?.items.first?.submenu != nil else {
+ if retries > 0 {
+ self.configureApplicationMenuWhenAvailable(retries: retries - 1)
+ }
+ return
+ }
+
+ self.configureApplicationMenu()
+ if retries > 0 && self.applicationMenuNeedsCleanup() {
+ self.configureApplicationMenuWhenAvailable(retries: retries - 1)
+ }
+ }
+ }
+
+ private func configureApplicationMenu() {
+ guard !isConfiguringApplicationMenu else { return }
+ guard let appMenu = NSApp.mainMenu?.items.first?.submenu else { return }
+
+ isConfiguringApplicationMenu = true
+ defer { isConfiguringApplicationMenu = false }
+
+ removeUnusedDefaultItems(from: appMenu)
+ configurePreferencesMenuItem(in: appMenu)
+ upsertShowAppListItem(in: appMenu)
+ normalizeSeparators(in: appMenu)
+ }
+
+ private func applicationMenuNeedsCleanup() -> Bool {
+ guard let appMenu = NSApp.mainMenu?.items.first?.submenu else { return true }
+ let hasUnusedDefaultItems = appMenu.items.contains(where: isUnusedDefaultApplicationMenuItem)
+ let hasShowAppListItem = appMenu.items.contains {
+ $0.identifier == Self.showAppListMenuItemIdentifier
+ }
+ return hasUnusedDefaultItems || !hasShowAppListItem
+ }
+
+ private func removeUnusedDefaultItems(from menu: NSMenu) {
+ for item in menu.items.reversed() where isUnusedDefaultApplicationMenuItem(item) {
+ menu.removeItem(item)
+ }
+ }
+
+ private func isUnusedDefaultApplicationMenuItem(_ item: NSMenuItem) -> Bool {
+ if let servicesMenu = NSApp.servicesMenu, item.submenu === servicesMenu {
+ return true
+ }
+ return item.action == #selector(NSApplication.hide(_:))
+ || item.action == #selector(NSApplication.hideOtherApplications(_:))
+ || item.action == #selector(NSApplication.unhideAllApplications(_:))
+ }
+
+ private func upsertShowAppListItem(in menu: NSMenu) {
+ if let existingItem = menu.items.first(where: { $0.identifier == Self.showAppListMenuItemIdentifier }) {
+ configureShowAppListItem(existingItem)
+ return
+ }
+
+ let item = NSMenuItem()
+ item.identifier = Self.showAppListMenuItemIdentifier
+ configureShowAppListItem(item)
+
+ if let settingsIndex = menu.items.firstIndex(where: { isSettingsMenuItem($0) }) {
+ menu.insertItem(item, at: settingsIndex + 1)
+ } else if let firstSeparatorIndex = menu.items.firstIndex(where: { $0.isSeparatorItem }) {
+ menu.insertItem(item, at: firstSeparatorIndex)
+ } else {
+ menu.addItem(item)
+ }
+ }
+
+ private func configureShowAppListItem(_ item: NSMenuItem) {
+ item.title = showAppListMenuTitle
+ item.action = #selector(toggleOverlay)
+ item.target = self
+ item.keyEquivalent = ""
+ item.keyEquivalentModifierMask = []
+ item.isEnabled = true
+ }
+
+ private func configurePreferencesMenuItem(in menu: NSMenu) {
+ let item: NSMenuItem
+ if let existingItem = menu.items.first(where: { isSettingsMenuItem($0) }) {
+ item = existingItem
+ } else {
+ item = NSMenuItem()
+ if let firstSeparatorIndex = menu.items.firstIndex(where: { $0.isSeparatorItem }) {
+ menu.insertItem(item, at: firstSeparatorIndex)
+ } else {
+ menu.addItem(item)
+ }
+ }
+
+ item.title = tr("menu.preferences")
+ item.action = #selector(openPreferences)
+ item.target = self
+ item.keyEquivalent = ","
+ item.keyEquivalentModifierMask = .command
+ item.isEnabled = true
+ }
+
+ private func isSettingsMenuItem(_ item: NSMenuItem) -> Bool {
+ item.action == Selector(("showSettingsWindow:"))
+ || item.action == #selector(openPreferences)
+ || item.title == tr("menu.preferences")
+ }
+
+ private func normalizeSeparators(in menu: NSMenu) {
+ var indexesToRemove: [Int] = []
+ var previousWasSeparator = false
+
+ for (index, item) in menu.items.enumerated() {
+ guard item.isSeparatorItem else {
+ previousWasSeparator = false
+ continue
+ }
+ if index == 0 || index == menu.items.count - 1 || previousWasSeparator {
+ indexesToRemove.append(index)
+ }
+ previousWasSeparator = true
+ }
+
+ for index in indexesToRemove.reversed() {
+ menu.removeItem(at: index)
+ }
+ }
+
+ private func removeMenuBarItem() {
+ guard let statusItem else { return }
+ NSStatusBar.system.removeStatusItem(statusItem)
+ self.statusItem = nil
+ }
+
// MARK: - Overlay Window
@objc private func toggleOverlay() {
@@ -143,102 +512,232 @@
}
}
- private func showOverlay() {
- if overlayWindow == nil {
- // Use the screen under the mouse cursor — works in fullscreen spaces
- let mousePoint = NSEvent.mouseLocation
- guard let screen = NSScreen.screens.first(where: {
- NSMouseInRect(mousePoint, $0.frame, false)
- }) ?? NSScreen.main ?? NSScreen.screens.first else { return }
+ private func showOverlay(initialQuickSearchSource: String? = nil) {
+ // Use the screen under the mouse cursor — works in fullscreen spaces
+ let mousePoint = NSEvent.mouseLocation
+ guard let screen = NSScreen.screens.first(where: {
+ NSMouseInRect(mousePoint, $0.frame, false)
+ }) ?? NSScreen.main ?? NSScreen.screens.first else { return }
- overlayWindow = NSWindow(
- contentRect: screen.frame,
- styleMask: [.borderless, .fullSizeContentView],
- backing: .buffered,
- defer: false
- )
- overlayWindow?.level = .floating
- overlayWindow?.collectionBehavior = [
- .canJoinAllSpaces,
- .fullScreenAuxiliary,
- .ignoresCycle
- ]
- overlayWindow?.isOpaque = false
- overlayWindow?.backgroundColor = .clear
- overlayWindow?.hasShadow = false
- overlayWindow?.titlebarAppearsTransparent = true
- overlayWindow?.titleVisibility = .hidden
- overlayWindow?.isReleasedWhenClosed = false
+ let window: NSWindow
+ if let existingWindow = overlayWindow {
+ window = existingWindow
+ } else {
+ window = makeOverlayWindow(on: screen, initialQuickSearchSource: initialQuickSearchSource)
+ overlayWindow = window
+ }
- overlayWindow?.contentView = DismissibleHostingView(
- rootView: ContentView(hideOverlay: { [weak self] in
- self?.hideOverlay()
- }),
- onBackdropTap: { [weak self] in
- self?.hideOverlay()
- }
+ window.setFrame(screen.frame, display: true)
+ window.level = isEditingAppNote ? Self.overlayTextInputLevel : Self.overlayDefaultLevel
+
+ installOverlayKeyMonitor()
+
+ if let initialQuickSearchSource {
+ NotificationCenter.default.post(
+ name: .tagLauncherQuickSearchRequested,
+ object: nil,
+ userInfo: ["source": initialQuickSearchSource]
)
}
- // Local key monitor: catch Escape while overlay is up
- NSEvent.addLocalMonitorForEvents(matching: .keyDown) { [weak self] event in
+ window.makeKeyAndOrderFront(nil)
+ window.orderFrontRegardless()
+ NotificationCenter.default.post(name: .tagLauncherOverlayDidShow, object: nil)
+ }
+
+ private func installOverlayKeyMonitor() {
+ guard overlayKeyMonitor == nil else { return }
+ overlayKeyMonitor = NSEvent.addLocalMonitorForEvents(matching: .keyDown) { [weak self] event in
+ guard let self else { return event }
if event.keyCode == 53 { // Escape
- self?.hideOverlay()
+ if self.isQuickSearchOpen {
+ NotificationCenter.default.post(name: .tagLauncherQuickSearchDismissRequested, object: nil)
+ return nil
+ }
+ self.hideOverlay()
+ return nil
+ }
+ if self.shouldOpenQuickSearch(for: event) {
+ NotificationCenter.default.post(
+ name: .tagLauncherQuickSearchRequested,
+ object: nil,
+ userInfo: ["source": QuickSearchOpenSource.mainOverlay]
+ )
return nil
}
return event
}
-
- overlayWindow?.makeKeyAndOrderFront(nil)
- NSApp.activate(ignoringOtherApps: true)
}
- private func hideOverlay() {
- guard !isInEditMode else { return }
+ private func shouldOpenQuickSearch(for event: NSEvent) -> Bool {
+ guard event.keyCode == UInt16(kVK_Space),
+ !event.isARepeat,
+ event.modifierFlags.intersection(.deviceIndependentFlagsMask).isEmpty,
+ overlayWindow?.isVisible == true,
+ !isQuickSearchOpen,
+ !isInEditMode,
+ !isEditingAppNote,
+ !isModalInteractionActive
+ else { return false }
+
+ guard let firstResponder = overlayWindow?.firstResponder else { return true }
+ if firstResponder is NSText || firstResponder is NSTextField {
+ return false
+ }
+ if let responderView = firstResponder as? NSView,
+ viewOrAncestorHandlesSpace(responderView) {
+ return false
+ }
+ return true
+ }
+
+ private func viewOrAncestorHandlesSpace(_ view: NSView) -> Bool {
+ var current: NSView? = view
+ while let candidate = current {
+ if candidate is NSButton || candidate is NSSegmentedControl || candidate is NSSlider {
+ return true
+ }
+ current = candidate.superview
+ }
+ return false
+ }
+
+ private func removeOverlayKeyMonitor() {
+ if let monitor = overlayKeyMonitor {
+ NSEvent.removeMonitor(monitor)
+ overlayKeyMonitor = nil
+ }
+ }
+
+ private func makeOverlayWindow(on screen: NSScreen, initialQuickSearchSource: String? = nil) -> NSWindow {
+ let panel = OverlayPanel(
+ contentRect: screen.frame,
+ styleMask: [.borderless, .fullSizeContentView, .nonactivatingPanel],
+ backing: .buffered,
+ defer: false
+ )
+ panel.isFloatingPanel = true
+ panel.hidesOnDeactivate = false
+ panel.collectionBehavior = [
+ .moveToActiveSpace,
+ .fullScreenAuxiliary,
+ .stationary,
+ .transient,
+ .ignoresCycle
+ ]
+ panel.isOpaque = false
+ panel.backgroundColor = .clear
+ panel.hasShadow = false
+ panel.titlebarAppearsTransparent = true
+ panel.titleVisibility = .hidden
+ panel.isReleasedWhenClosed = false
+ panel.contentView = DismissibleHostingView(
+ rootView: ContentView(
+ hideOverlay: { [weak self] in
+ self?.hideOverlay(force: true)
+ },
+ initialQuickSearchSource: initialQuickSearchSource
+ ),
+ onBackdropTap: { [weak self] in
+ self?.hideOverlay()
+ }
+ )
+ return panel
+ }
+
+ private func hideOverlay(force: Bool = false) {
+ guard force || !isInEditMode else { return }
+ TagDatabase.flushPendingCategorySchemeBackupBatch()
+ if let settingsWindow, settingsWindow.parent == overlayWindow {
+ detachSettingsWindow(settingsWindow)
+ }
overlayWindow?.orderOut(nil)
+ removeOverlayKeyMonitor()
+ removeQuickSearchExternalMouseMonitor()
+ NotificationCenter.default.post(name: .tagLauncherOverlayDidHide, object: nil)
+ if force {
+ overlayWindow = nil
+ }
}
- // MARK: - Global Hotkey (Shift+Option+Space)
+ // MARK: - Global Hotkeys
- private func registerHotkey() {
+ private func registerConfiguredHotkeys() {
+ installHotkeyEventHandlerIfNeeded()
+ registerFixedHotkey(.main)
+ registerFixedHotkey(.quickSearch)
+ }
+
+ private func registerFixedHotkey(_ kind: LauncherHotkeyKind) {
+ unregisterHotkey(for: kind)
+ let hotkey = kind.hotkey
+
var hotkeyID = EventHotKeyID()
hotkeyID.signature = OSType(0x41505447) // 'APTG'
- hotkeyID.id = 1
+ hotkeyID.id = kind.eventID
- let modifiers = UInt32(shiftKey | optionKey)
-
- var ref: EventHotKeyRef?
+ var newRef: EventHotKeyRef?
let status = RegisterEventHotKey(
- UInt32(kVK_Space),
- modifiers,
+ hotkey.keyCode,
+ hotkey.modifiers,
hotkeyID,
GetApplicationEventTarget(),
0,
- &ref
+ &newRef
)
- hotkeyRef = ref
- if status != noErr {
- print("[Apptag] Hotkey registration failed: \(status). Falling back to menu bar only.")
- return
+ if status == noErr, let newRef {
+ setHotkeyRef(newRef, for: kind)
+ LauncherHotkeyRegistrationStore.setActive(for: kind)
+ } else {
+ setHotkeyRef(nil, for: kind)
+ LauncherHotkeyRegistrationStore.setFailed(status, for: kind)
+ print("[TagLauncher] Fixed hotkey registration failed for \(kind.rawValue): \(status)")
}
+ }
+
+ private func observeHotkeyStatusChanges() {
+ NotificationCenter.default.addObserver(
+ forName: .tagLauncherHotkeyRegistrationChanged,
+ object: nil,
+ queue: .main
+ ) { [weak self] _ in
+ self?.setupMenuBar()
+ self?.configureApplicationMenuWhenAvailable(retries: 2)
+ }
+ }
+
+ private func installHotkeyEventHandlerIfNeeded() {
+ guard !hotkeyEventHandlerInstalled else { return }
+ hotkeyEventHandlerInstalled = true
var eventSpec = EventTypeSpec(
eventClass: OSType(kEventClassKeyboard),
eventKind: UInt32(kEventHotKeyPressed)
)
-
let selfPtr = Unmanaged.passUnretained(self).toOpaque()
InstallEventHandler(
GetApplicationEventTarget(),
- { (_, _, userData) -> OSStatus in
- guard let userData else { return noErr }
+ { (_, event, userData) -> OSStatus in
+ guard let event, let userData else { return noErr }
+ var hotkeyID = EventHotKeyID()
+ let status = GetEventParameter(
+ event,
+ EventParamName(kEventParamDirectObject),
+ EventParamType(typeEventHotKeyID),
+ nil,
+ MemoryLayout<EventHotKeyID>.size,
+ nil,
+ &hotkeyID
+ )
+ guard status == noErr else { return noErr }
+
let delegate = Unmanaged<AppDelegate>
.fromOpaque(userData)
.takeUnretainedValue()
DispatchQueue.main.async {
- delegate.toggleOverlay()
+ delegate.handleHotkeyEvent(id: hotkeyID.id)
}
return noErr
},
@@ -247,6 +746,40 @@
selfPtr,
nil
)
+ }
+
+ private func handleHotkeyEvent(id: UInt32) {
+ if id == LauncherHotkeyKind.quickSearch.eventID {
+ showQuickSearchFromGlobalHotkey()
+ } else {
+ toggleOverlay()
+ }
+ }
+
+ private func showQuickSearchFromGlobalHotkey() {
+ guard overlayWindow?.isVisible != true else { return }
+ showOverlay(initialQuickSearchSource: QuickSearchOpenSource.globalHidden)
+ }
+
+ private func hotkeyRef(for kind: LauncherHotkeyKind) -> EventHotKeyRef? {
+ switch kind {
+ case .main: return mainHotkeyRef
+ case .quickSearch: return quickSearchHotkeyRef
+ }
+ }
+
+ private func setHotkeyRef(_ ref: EventHotKeyRef?, for kind: LauncherHotkeyKind) {
+ switch kind {
+ case .main: mainHotkeyRef = ref
+ case .quickSearch: quickSearchHotkeyRef = ref
+ }
+ }
+
+ private func unregisterHotkey(for kind: LauncherHotkeyKind) {
+ if let ref = hotkeyRef(for: kind) {
+ UnregisterEventHotKey(ref)
+ setHotkeyRef(nil, for: kind)
+ }
}
// MARK: - Preferences
@@ -264,14 +797,107 @@
keyWindow != self.overlayWindow,
!self.isInEditMode
else { return }
+
+ // Settings/Preferences window -> float it above overlay for real-time preview.
+ if self.isSettingsWindowCandidate(keyWindow) {
+ self.prepareSettingsWindow(keyWindow)
+ return
+ }
+
self.hideOverlay()
+ }
+ }
+
+ /// Settings must always appear centered over the current overlay view and float above it.
+ private func prepareSettingsWindow(_ window: NSWindow) {
+ let settingsSize = NSSize(width: 880, height: 460)
+ window.identifier = NSUserInterfaceItemIdentifier("TagLauncherPreferencesWindow")
+ window.minSize = settingsSize
+ window.maxSize = settingsSize
+ if abs(window.frame.width - settingsSize.width) > 0.5 || abs(window.frame.height - settingsSize.height) > 0.5 {
+ window.setFrame(
+ NSRect(origin: window.frame.origin, size: settingsSize),
+ display: false
+ )
+ }
+
+ if let overlayWindow, overlayWindow.isVisible {
+ center(window, over: overlayWindow.frame)
+ attachSettingsWindow(window, to: overlayWindow)
+ window.level = overlayWindow.level
+ } else if let screen = screenUnderMouse() {
+ center(window, over: screen.visibleFrame)
+ window.level = .floating
+ detachSettingsWindow(window)
+ }
+
+ var behavior = window.collectionBehavior
+ behavior.remove(.canJoinAllSpaces)
+ behavior.formUnion([.fullScreenAuxiliary, .moveToActiveSpace])
+ window.collectionBehavior = behavior
+ window.makeKeyAndOrderFront(nil)
+ window.orderFrontRegardless()
+ settingsWindow = window
+ }
+
+ private func attachSettingsWindow(_ window: NSWindow, to overlayWindow: NSWindow) {
+ if window.parent != overlayWindow {
+ window.parent?.removeChildWindow(window)
+ overlayWindow.addChildWindow(window, ordered: .above)
+ }
+ }
+
+ private func detachSettingsWindow(_ window: NSWindow) {
+ window.parent?.removeChildWindow(window)
+ }
+
+ private func isSettingsWindowCandidate(_ window: NSWindow) -> Bool {
+ if window == settingsWindow { return true }
+ if window.identifier?.rawValue == "TagLauncherPreferencesWindow" { return true }
+ guard NSApp.windows.contains(window),
+ window != overlayWindow,
+ window.isVisible,
+ !(window is NSPanel)
+ else { return false }
+ return true
+ }
+
+ private func center(_ window: NSWindow, over rect: NSRect) {
+ let frame = window.frame
+ let origin = NSPoint(
+ x: rect.midX - frame.width / 2,
+ y: rect.midY - frame.height / 2
+ )
+ window.setFrameOrigin(origin)
+ }
+
+ private func screenUnderMouse() -> NSScreen? {
+ let mousePoint = NSEvent.mouseLocation
+ return NSScreen.screens.first(where: {
+ NSMouseInRect(mousePoint, $0.frame, false)
+ }) ?? NSScreen.main ?? NSScreen.screens.first
+ }
+
+ /// Clean up settingsWindow reference when the Settings window closes.
+ private func observeSettingsClose() {
+ NotificationCenter.default.addObserver(
+ forName: NSWindow.willCloseNotification,
+ object: nil,
+ queue: .main
+ ) { [weak self] notification in
+ guard let self,
+ let closingWindow = notification.object as? NSWindow,
+ closingWindow == self.settingsWindow
+ else { return }
+ self.detachSettingsWindow(closingWindow)
+ self.settingsWindow = nil
}
}
/// Track whether the overlay is in edit mode to suppress auto-dismiss.
private func observeEditMode() {
NotificationCenter.default.addObserver(
- forName: .apptagEditModeChanged,
+ forName: .tagLauncherEditModeChanged,
object: nil,
queue: .main
) { [weak self] notification in
@@ -279,16 +905,121 @@
}
}
+ /// Lower the overlay while editing app notes so IME candidate windows are not hidden behind it.
+ private func observeAppNoteEditing() {
+ NotificationCenter.default.addObserver(
+ forName: .tagLauncherAppNoteEditingChanged,
+ object: nil,
+ queue: .main
+ ) { [weak self] notification in
+ guard let self else { return }
+ self.isEditingAppNote = (notification.userInfo?["active"] as? Bool) ?? false
+ self.updateOverlayLevelForTextInput()
+ }
+ }
+
+ private func observeQuickSearch() {
+ NotificationCenter.default.addObserver(
+ forName: .tagLauncherQuickSearchVisibilityChanged,
+ object: nil,
+ queue: .main
+ ) { [weak self] notification in
+ guard let self else { return }
+ self.isQuickSearchOpen = (notification.userInfo?["active"] as? Bool) ?? false
+ if self.isQuickSearchOpen {
+ self.installQuickSearchExternalMouseMonitor()
+ } else {
+ self.removeQuickSearchExternalMouseMonitor()
+ }
+ }
+
+ NotificationCenter.default.addObserver(
+ forName: .tagLauncherModalInteractionChanged,
+ object: nil,
+ queue: .main
+ ) { [weak self] notification in
+ self?.isModalInteractionActive = (notification.userInfo?["active"] as? Bool) ?? false
+ }
+
+ NotificationCenter.default.addObserver(
+ forName: NSApplication.didResignActiveNotification,
+ object: NSApp,
+ queue: .main
+ ) { [weak self] _ in
+ guard self?.isQuickSearchOpen == true else { return }
+ NotificationCenter.default.post(name: .tagLauncherQuickSearchDismissRequested, object: nil)
+ }
+ }
+
+ private func installQuickSearchExternalMouseMonitor() {
+ guard quickSearchExternalMouseMonitor == nil else { return }
+ quickSearchExternalMouseMonitor = NSEvent.addGlobalMonitorForEvents(
+ matching: [.leftMouseDown, .rightMouseDown, .otherMouseDown]
+ ) { [weak self] _ in
+ DispatchQueue.main.async {
+ guard self?.isQuickSearchOpen == true else { return }
+ NotificationCenter.default.post(name: .tagLauncherQuickSearchDismissRequested, object: nil)
+ }
+ }
+ }
+
+ private func removeQuickSearchExternalMouseMonitor() {
+ if let quickSearchExternalMouseMonitor {
+ NSEvent.removeMonitor(quickSearchExternalMouseMonitor)
+ self.quickSearchExternalMouseMonitor = nil
+ }
+ }
+
+ private func updateOverlayLevelForTextInput() {
+ guard let overlayWindow else { return }
+ overlayWindow.level = isEditingAppNote ? Self.overlayTextInputLevel : Self.overlayDefaultLevel
+ if let settingsWindow, settingsWindow.parent == overlayWindow {
+ settingsWindow.level = overlayWindow.level
+ }
+ }
+
+ /// The overlay buttons live inside SwiftUI; use an app-level notification like edit mode does.
+ private func observePreferencesRequests() {
+ NotificationCenter.default.addObserver(
+ forName: .tagLauncherOpenPreferencesRequested,
+ object: nil,
+ queue: .main
+ ) { [weak self] _ in
+ self?.openPreferences()
+ }
+ }
+
@objc private func openPreferences() {
- hideOverlay()
- NSApp.sendAction(Selector(("showSettingsWindow:")), to: nil, from: nil)
+ TagDatabase.flushPendingCategorySchemeBackupBatch()
+ // Don't hide overlay — keep it visible for real-time setting preview.
+ if let overlayWindow, overlayWindow.isVisible {
+ overlayWindow.makeKeyAndOrderFront(nil)
+ overlayWindow.orderFrontRegardless()
+ }
+ NSApp.activate(ignoringOtherApps: true)
+
+ if let settingsWindow {
+ prepareSettingsWindow(settingsWindow)
+ return
+ }
+
+ let settingsSize = NSSize(width: 880, height: 460)
+ let window = NSWindow(
+ contentRect: NSRect(origin: .zero, size: settingsSize),
+ styleMask: [.titled, .closable],
+ backing: .buffered,
+ defer: false
+ )
+ window.title = tr("menu.preferences").replacingOccurrences(of: "…", with: "")
+ window.contentView = NSHostingView(rootView: PreferencesView())
+ window.isReleasedWhenClosed = false
+ settingsWindow = window
+ prepareSettingsWindow(window)
}
@objc private func switchLanguage(_ sender: NSMenuItem) {
guard let code = sender.representedObject as? String else { return }
L10n.switchTo(code)
- // Rebuild menu to update checkmarks
- setupMenuBar()
}
}
@@ -296,15 +1027,25 @@
final class DismissibleHostingView<Content: View>: NSHostingView<Content> {
private let onBackdropTap: () -> Void
+ private var suppressBackdropDismiss = false
+ private var modalInteractionObserver: NSObjectProtocol?
@MainActor required init(rootView: Content) {
self.onBackdropTap = {}
super.init(rootView: rootView)
+ observeModalInteractionChanges()
}
init(rootView: Content, onBackdropTap: @escaping () -> Void) {
self.onBackdropTap = onBackdropTap
super.init(rootView: rootView)
+ observeModalInteractionChanges()
+ }
+
+ deinit {
+ if let modalInteractionObserver {
+ NotificationCenter.default.removeObserver(modalInteractionObserver)
+ }
}
@available(*, unavailable)
@@ -317,7 +1058,15 @@
return
}
if hit == self {
+ if suppressBackdropDismiss {
+ super.mouseDown(with: event)
+ return
+ }
onBackdropTap()
+ return
+ }
+ if let floatingButton = findFloatingIconButton(at: event.locationInWindow, in: self) {
+ floatingButton.mouseDown(with: event)
return
}
// Recursively search hit subtree for TextFieldContainer or NSTextField.
@@ -332,12 +1081,17 @@
tf.mouseDown(with: event)
return
}
- // Forward to any other NSControl we find
- if let control = findNSControl(in: hit) {
- control.mouseDown(with: event)
- return
- }
super.mouseDown(with: event)
+ }
+
+ private func observeModalInteractionChanges() {
+ modalInteractionObserver = NotificationCenter.default.addObserver(
+ forName: .tagLauncherModalInteractionChanged,
+ object: nil,
+ queue: .main
+ ) { [weak self] notification in
+ self?.suppressBackdropDismiss = (notification.userInfo?["active"] as? Bool) ?? false
+ }
}
private func findTextFieldContainer(in view: NSView) -> TextFieldContainer? {
@@ -356,243 +1110,18 @@
return nil
}
- private func findNSControl(in view: NSView) -> NSControl? {
- if let control = view as? NSControl { return control }
- for sub in view.subviews {
- if let found = findNSControl(in: sub) { return found }
+ private func findFloatingIconButton(at windowPoint: NSPoint, in view: NSView) -> FloatingIconButtonView? {
+ for subview in view.subviews.reversed() where !subview.isHidden {
+ if let found = findFloatingIconButton(at: windowPoint, in: subview) {
+ return found
+ }
+ }
+ guard let floatingButton = view as? FloatingIconButtonView else { return nil }
+ let localPoint = floatingButton.convert(windowPoint, from: nil)
+ if floatingButton.bounds.contains(localPoint) {
+ return floatingButton
}
return nil
}
-}
-// MARK: - Preferences View
-
-struct PreferencesView: View {
- @AppStorage("tagFontSize") private var tagFontSize: Double = 18
- @AppStorage("iconSize") private var iconSize: Double = 56
- @AppStorage("tagPosition") private var tagPosition = "left"
- @AppStorage("defaultGroupName") private var defaultGroupName = "Other"
- @AppStorage("displayMode") private var displayMode = "flat"
- @AppStorage("hideAppNames") private var hideAppNames = false
- @AppStorage("showDockIcon") private var showDockIcon = false
- @AppStorage("launchAtLogin") private var launchAtLogin = true
-
- @State private var allApps: [AppInfo] = []
- @State private var tagColors: [String: Int] = [:]
-
- private func scanApps() {
- DispatchQueue.global(qos: .userInitiated).async {
- var apps = AppIndexer.scan()
- let store = TagDatabase.migrateFromFinderIfNeeded(apps: apps)
- apps = TagEditor.annotate(apps: apps)
- let colors = store.tags.mapValues { $0.color }
- DispatchQueue.main.async {
- allApps = apps
- tagColors = colors
- }
- }
- }
-
- private func exportTags() {
- let panel = NSSavePanel()
- panel.title = "Export Tags"
- panel.nameFieldStringValue = "Apptag-tags.json"
- panel.allowedContentTypes = [.json]
- panel.begin { response in
- guard response == .OK, let url = panel.url else { return }
- do {
- try TagDatabase.exportTo(url)
- } catch {
- fputs("[Apptag] Export failed: \(error)\n", stderr)
- }
- }
- }
-
- private func importTags() {
- let panel = NSOpenPanel()
- panel.title = "Import Tags"
- panel.allowedContentTypes = [.json]
- panel.allowsMultipleSelection = false
- panel.begin { response in
- guard response == .OK, let url = panel.url else { return }
- do {
- _ = try TagDatabase.importFrom(url)
- scanApps()
- } catch {
- fputs("[Apptag] Import failed: \(error)\n", stderr)
- // Show alert on failure
- let alert = NSAlert()
- alert.messageText = "Import Failed"
- alert.informativeText = error.localizedDescription
- alert.alertStyle = .warning
- alert.runModal()
- }
- }
- }
-
- private var appVersion: String {
- Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String ?? "?"
- }
- private var buildVersion: String {
- Bundle.main.infoDictionary?["CFBundleVersion"] as? String ?? "?"
- }
-
- var body: some View {
- TabView {
- // Tab 1: General
- Form {
- Section {
- Toggle("Launch at login", isOn: $launchAtLogin)
- .onChange(of: launchAtLogin) { _, enabled in
- if enabled {
- try? SMAppService.mainApp.register()
- } else {
- try? SMAppService.mainApp.unregister()
- }
- }
- }
-
- Section {
- LabeledContent("App list style:") {
- Picker("", selection: $displayMode) {
- Text("Flat").tag("flat")
- Text("Container").tag("container")
- }
- .pickerStyle(.segmented)
- .frame(width: 210)
- }
- Text("\"Flat\" shows apps directly. \"Container\" wraps each tag group in a rounded box.")
- .font(.caption)
- .foregroundStyle(.secondary)
- }
-
- Section {
- LabeledContent("Tag position:") {
- Picker("", selection: $tagPosition) {
- Text("Left").tag("left")
- Text("Right").tag("right")
- Text("Top").tag("top")
- }
- .pickerStyle(.segmented)
- .frame(width: 210)
- }
- Text("Where the tag navigation bar appears. Left/Right puts tags in a sidebar.")
- .font(.caption)
- .foregroundStyle(.secondary)
- }
-
- Section {
- LabeledContent("Tag font size:") {
- Picker("", selection: $tagFontSize) {
- ForEach([16.0, 18.0, 20.0, 22.0, 24.0, 26.0], id: \.self) { size in
- Text("\(Int(size))").tag(size)
- }
- }
- .pickerStyle(.segmented)
- .frame(width: 280)
- }
- Text("Adjust the size of group-name labels in the overlay.")
- .font(.caption)
- .foregroundStyle(.secondary)
- }
-
- Section {
- LabeledContent("Icon size:") {
- Picker("", selection: $iconSize) {
- ForEach([40.0, 48.0, 56.0, 64.0, 72.0, 80.0], id: \.self) { size in
- Text("\(Int(size))").tag(size)
- }
- }
- .pickerStyle(.segmented)
- .frame(width: 280)
- }
- Text("Icon display size. Grid columns adjust automatically.")
- .font(.caption)
- .foregroundStyle(.secondary)
- }
-
- Section {
- Toggle("Show in Dock", isOn: $showDockIcon)
- }
-
- Section {
- Toggle("Hide app names", isOn: $hideAppNames)
- }
- }
- .tabItem { Label("General", systemImage: "gearshape") }
- .padding()
-
- // Tab 2: Tags
- VStack(spacing: 0) {
- TagEditorView(
- tagColors: $tagColors,
- excludedTagNames: ["Mac自带", defaultGroupName],
- onRefresh: { scanApps() }
- )
- }
- .tabItem { Label("Tags", systemImage: "tag.fill") }
- .onAppear { scanApps() }
-
- // Tab 3: Data
- Form {
- Section {
- HStack {
- Button("Re-index Now") {
- NotificationCenter.default.post(name: .apptagReindex, object: nil)
- }
- .buttonStyle(.borderedProminent)
-
- Text("Re-scan all app directories and refresh the tag database.")
- .font(.caption)
- .foregroundStyle(.secondary)
- }
- } header: {
- Text("Index Management")
- }
-
- Section {
- HStack(spacing: 12) {
- Button("Export Tags…") { exportTags() }
- .buttonStyle(.bordered)
- Button("Import Tags…") { importTags() }
- .buttonStyle(.bordered)
- }
- Text("Export saves your tag assignments to a JSON file. Import replaces the current database with one from a file.")
- .font(.caption)
- .foregroundStyle(.secondary)
- } header: {
- Text("Backup & Restore")
- }
- }
- .tabItem { Label("Data", systemImage: "externaldrive.fill") }
- .padding()
-
- // Tab 3: About
- Form {
- Section {
- HStack {
- if let icon = NSImage(named: NSImage.applicationIconName) {
- Image(nsImage: icon)
- .resizable()
- .frame(width: 64, height: 64)
- }
- VStack(alignment: .leading, spacing: 4) {
- Text("Apptag")
- .font(.title2)
- .fontWeight(.semibold)
- Text("Tag-based app launcher")
- .font(.body)
- .foregroundStyle(.secondary)
- Text("Version \(appVersion) (Build \(buildVersion))")
- .font(.callout)
- .foregroundStyle(.tertiary)
- }
- }
- }
- }
- .tabItem { Label("About", systemImage: "info.circle") }
- .padding()
- }
- .frame(minWidth: 660, idealWidth: 660, minHeight: 380, idealHeight: 380)
- }
}
--
Gitblit v1.9.3