Skip to content

Commit

Permalink
Fix enabledKeyboardInputSourcesChanged
Browse files Browse the repository at this point in the history
  • Loading branch information
tekezo committed Jan 25, 2025
1 parent 98650f2 commit b4a8a14
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,8 @@ extension TISInputSource {
var inputModeID: String? {
getProperty(kTISPropertyInputModeID) as? String
}

var localizedName: String? {
getProperty(kTISPropertyLocalizedName) as? String
}
}
11 changes: 4 additions & 7 deletions src/ShowyEdge/swift/WorkspaceData.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,20 +50,17 @@ public class WorkspaceData: NSObject, ObservableObject {
private func enabledKeyboardInputSourcesChanged() {
Task { @MainActor in
guard
let inputSourceList = TISCreateInputSourceList(nil, false)?.takeUnretainedValue()
let inputSourceList = TISCreateInputSourceList(nil, false)?.takeRetainedValue()
as? [TISInputSource]
else { return }

var newInputSourceNames: [String: String] = [:]

for inputSource in inputSourceList {
if let id = TISGetInputSourceProperty(inputSource, kTISPropertyInputSourceID),
let name = TISGetInputSourceProperty(inputSource, kTISPropertyLocalizedName)
if let id = inputSource.inputSourceID,
let name = inputSource.localizedName
{
let inputSourceID = String(unsafeBitCast(id, to: CFString.self))
let localizedName = String(unsafeBitCast(name, to: CFString.self))

newInputSourceNames[inputSourceID] = localizedName
newInputSourceNames[id] = name
}
}

Expand Down

0 comments on commit b4a8a14

Please sign in to comment.