Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/color.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@ public func nsColorToString(_ color: NSColor) -> String? {
return String(format: "#%02X%02X%02X%02X", red, green, blue, alpha)
}

@MainActor
private var colorMap = [String: String]()

@MainActor
func getAccentColor(_ id: String) -> String {
if let cachedColor = colorMap[id] {
return cachedColor
Expand Down
1 change: 1 addition & 0 deletions src/config/menu.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import Cocoa
import Fcitx

@MainActor
func restartAndReconnect(_ actionBetween: (() -> Void)? = nil) {
stop_fcitx_thread()
actionBetween?()
Expand Down
4 changes: 3 additions & 1 deletion src/controller.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ struct SyncResponse: Codable {
let capsLock = 65536
let shift = 131072

@MainActor
class FcitxInputController: IMKInputController {
var uuid: ICUUID
var appId: String
Expand All @@ -29,12 +30,13 @@ class FcitxInputController: IMKInputController {

// A registry of live FcitxInputController objects.
// Use NSHashTable to store weak references.
static var registry = NSHashTable<FcitxInputController>.weakObjects()
nonisolated(unsafe) static var registry = NSHashTable<FcitxInputController>.weakObjects()

// A new InputController is created for each server-client
// connection. We use the finest granularity here (one InputContext
// for one IMKTextInput), and pass the bundle identifier to let
// libfcitx handle the heavylifting.
@MainActor
override init(server: IMKServer!, delegate: Any!, client: Any!) {
if let client = client as? IMKTextInput {
appId = client.bundleIdentifier() ?? ""
Expand Down
2 changes: 2 additions & 0 deletions tests/testcolor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@ func testGrayScale() {
assert(nsColorToString(grayColor) == "#808080FF")
}

@MainActor
func testGetAccentColor() {
let accentColor = getAccentColor("com.apple.Notes")
assert(accentColor == "#FCB827FF")
}

@MainActor
@_cdecl("main")
func main() -> Int {
testGrayScale()
Expand Down
Loading