From b2a06ec5ebc86c0241e635782ae5a032ab5aad0a Mon Sep 17 00:00:00 2001
From: Ariver <shanghai3168@gmail.com>
Date: Thu, 02 Jul 2026 02:43:51 +0800
Subject: [PATCH] Prepare TagLauncher 8.3.2 App Store candidate

---
 src/Apptag/AppGridCollectionView.swift |   33 ++++++++++++++++++++++++---------
 1 files changed, 24 insertions(+), 9 deletions(-)

diff --git a/src/Apptag/AppGridCollectionView.swift b/src/Apptag/AppGridCollectionView.swift
index 8807590..5b7bab6 100644
--- a/src/Apptag/AppGridCollectionView.swift
+++ b/src/Apptag/AppGridCollectionView.swift
@@ -48,6 +48,7 @@
 struct AppGridCollectionView: NSViewRepresentable {
     let groups: [TagGroup]
     let tagColors: [String: Int]
+    let tagCustomColors: [String: TagCustomColor]
     let displayMode: String
     let iconSize: CGFloat
     let showNames: Bool
@@ -89,6 +90,7 @@
         context.coordinator.update(
             groups: groups,
             tagColors: tagColors,
+            tagCustomColors: tagCustomColors,
             displayMode: displayMode,
             iconSize: iconSize,
             showNames: showNames,
@@ -122,6 +124,7 @@
     final class Coordinator: NSObject, NSCollectionViewDataSource, NSCollectionViewDelegate {
         var groups: [TagGroup] = []
         var tagColors: [String: Int] = [:]
+        var tagCustomColors: [String: TagCustomColor] = [:]
         var displayMode = AppDefaults.displayMode
         var iconSize: CGFloat = AppDefaults.iconSize
         var showNames = true
@@ -164,6 +167,7 @@
         func update(
             groups: [TagGroup],
             tagColors: [String: Int],
+            tagCustomColors: [String: TagCustomColor],
             displayMode: String,
             iconSize: CGFloat,
             showNames: Bool,
@@ -193,6 +197,7 @@
         ) {
             self.groups = groups
             self.tagColors = tagColors
+            self.tagCustomColors = tagCustomColors
             self.displayMode = displayMode
             self.iconSize = iconSize
             self.showNames = showNames
@@ -225,6 +230,7 @@
 
             let nextSignature = Self.signature(
                 tagColors: tagColors,
+                tagCustomColors: tagCustomColors,
                 displayMode: displayMode,
                 iconSize: iconSize,
                 showNames: showNames,
@@ -401,6 +407,7 @@
 
         private static func signature(
             tagColors: [String: Int],
+            tagCustomColors: [String: TagCustomColor],
             displayMode: String,
             iconSize: CGFloat,
             showNames: Bool,
@@ -413,6 +420,10 @@
                 .sorted { $0.key < $1.key }
                 .map { "\($0.key)=\($0.value)" }
                 .joined(separator: ",")
+            let customColorPart = tagCustomColors
+                .sorted { $0.key < $1.key }
+                .map { "\($0.key)=\($0.value.signature)" }
+                .joined(separator: ",")
             return [
                 displayMode,
                 "\(Int(iconSize.rounded()))",
@@ -421,8 +432,16 @@
                 showUncommonAppBubbles ? "uncommon" : "allbubbles",
                 "bottom=\(Int(bottomContentPadding.rounded()))",
                 colorPart,
+                customColorPart,
                 "rev=\(contentRevision)"
             ].joined(separator: "|")
+        }
+
+        func tagColor(for groupName: String) -> NSColor {
+            TagColor.nsColor(
+                for: tagColors[groupName] ?? 0,
+                customColor: tagCustomColors[groupName]
+            )
         }
 
         private static func clampedUsageTipIndex(_ index: Int, tips: [AppGridUsageTip]) -> Int {
@@ -745,7 +764,7 @@
             ]
         ) { [weak self] event in
             guard let self,
-                  self.window != nil,
+                  event.window === self.window,
                   self.handleUsageTipsMouseEvent(
                     event,
                     triggerButtons: event.type == .leftMouseDown
@@ -759,9 +778,7 @@
         if event.window === window {
             return convert(event.locationInWindow, from: nil)
         }
-        guard let window else { return .zero }
-        let windowPoint = window.convertPoint(fromScreen: NSEvent.mouseLocation)
-        return convert(windowPoint, from: nil)
+        return .zero
     }
 
     private func removeUsageTipsMouseMonitor() {
@@ -1237,9 +1254,7 @@
         if event.window === window {
             return convert(event.locationInWindow, from: nil)
         }
-        guard let window else { return .zero }
-        let windowPoint = window.convertPoint(fromScreen: NSEvent.mouseLocation)
-        return convert(windowPoint, from: nil)
+        return .zero
     }
 
     private func setPointerInside(_ inside: Bool) {
@@ -2325,7 +2340,7 @@
     override func draw(_ dirtyRect: NSRect) {
         guard let coordinator, let group else { return }
         let displayStyle = coordinator.displayStyle
-        let tagColor = TagColor.nsColor(for: coordinator.tagColors[group.name] ?? 0)
+        let tagColor = coordinator.tagColor(for: group.name)
         let isNavigationHighlighted = coordinator.highlightedGroupName == group.name
         let isColorlessActive = coordinator.isColorlessContainerMode
             && (isHovered || isNavigationHighlighted)
@@ -2571,7 +2586,7 @@
         let shouldShadow = coordinator.displayStyle.usesCardSurface
             && ((coordinator.isColoredContainerMode && (isHovered || isNavigationHighlighted)) || isColorlessActive)
         if coordinator.appGridTheme.usesDarkGlass && coordinator.displayStyle.usesCardSurface {
-            let tagColor = TagColor.nsColor(for: coordinator.tagColors[group?.name ?? ""] ?? 0)
+            let tagColor = coordinator.tagColor(for: group?.name ?? "")
             let active = isHovered || isNavigationHighlighted
             layer?.shadowColor = active
                 ? tagColor.withAlphaComponent(0.82).cgColor

--
Gitblit v1.9.3