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
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ set(F5M_TARGET "${CMAKE_OSX_ARCHITECTURES}-apple-macos${CMAKE_OSX_DEPLOYMENT_TAR
add_compile_options(-target "${F5M_TARGET}")
add_link_options(-target "${F5M_TARGET}")

set(CMAKE_Swift_LANGUAGE_VERSION 6)
# Disallow InitializeSwift to execute link_directories which adds Xcode paths to rpath.
set(SWIFT_LIBRARY_SEARCH_PATHS "")
include(InitializeSwift)
Expand Down
3 changes: 2 additions & 1 deletion src/config/about.swift
Original file line number Diff line number Diff line change
Expand Up @@ -294,8 +294,9 @@ struct AboutView: View {
// It's necessary to disable not only for cleaning up.
// Without this, if user cancels sudo prompt and try again, UI will hang.
disableInputMethod()
let userDataParam = removeUserData ? "true" : "false"
DispatchQueue.global().async {
if !sudo("uninstall", removeUserData ? "true" : "false", uninstallLog) {
if !sudo("uninstall", userDataParam, uninstallLog) {
DispatchQueue.main.async {
uninstalling = false
uninstallFailed = true
Expand Down
2 changes: 2 additions & 0 deletions src/config/menu.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ func restartAndReconnect(_ actionBetween: (() -> Void)? = nil) {
}

// Don't call it synchronously in SwiftUI as it will make IM temporarily unavailable in focused client.
@MainActor
func restartProcess() {
NSApp.terminate(nil)
}
Expand Down Expand Up @@ -41,6 +42,7 @@ extension FcitxInputController {
openWindow("plugin", PluginManager.self)
}

@MainActor
@objc func restart(_: Any? = nil) {
restartProcess()
}
Expand Down
3 changes: 3 additions & 0 deletions src/config/optionviews.swift
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,7 @@ struct UnsupportedOptionView: OptionView {
}
}

@MainActor
func buildViewImpl(label: String, option: any Option) -> any OptionView {
if let option = option as? BooleanOption {
return BooleanOptionView(label: label, model: option)
Expand Down Expand Up @@ -506,6 +507,7 @@ func buildViewImpl(label: String, option: any Option) -> any OptionView {
}
}

@MainActor
func buildViewImpl(config: Config) -> any OptionView {
switch config.kind {
case .group(let children):
Expand All @@ -515,6 +517,7 @@ func buildViewImpl(config: Config) -> any OptionView {
}
}

@MainActor
func buildView(config: Config) -> AnyView {
AnyView(buildViewImpl(config: config))
}
8 changes: 7 additions & 1 deletion src/config/plugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import SwiftUI
import SwiftyJSON
import UniformTypeIdentifiers

@MainActor
struct Plugin: Identifiable, Hashable {
let id: String
let category: String
Expand All @@ -13,12 +14,14 @@ struct Plugin: Identifiable, Hashable {
var dependencies: [String] = []
}

private var pluginMap = officialPlugins.reduce(into: [String: Plugin]()) { result, plugin in
private let pluginMap = officialPlugins.reduce(into: [String: Plugin]()) { result, plugin in
result[plugin.id] = plugin
}

// fcitx5 doesn't unload addons from memory, so once loaded, we have to restart process to use an updated version.
@MainActor
private var inMemoryPlugins = [String]()
@MainActor
private var needsRestart = false

private func getInstalledPlugins() -> [Plugin] {
Expand Down Expand Up @@ -46,6 +49,7 @@ private func getAutoAddIms(_ plugin: String) -> [String] {
return json["input_methods"].arrayValue.map { $0.stringValue }
}

@MainActor
class PluginVM: ObservableObject {
@Published private(set) var installedPlugins = [Plugin]()
@Published private(set) var availablePlugins = [Plugin]()
Expand Down Expand Up @@ -233,6 +237,8 @@ struct PluginView: View {
pluginVM.dataAvailable.removeAll()

var countedPlugins = Set<String>()

@MainActor
func helper(_ plugin: String) {
if countedPlugins.contains(plugin) {
return
Expand Down
2 changes: 2 additions & 0 deletions src/config/ui.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ extension View {
}
}

@MainActor
func footer(reset: @escaping () -> Void, apply: @escaping () -> Void, close: @escaping () -> Void)
-> some View
{
Expand Down Expand Up @@ -143,6 +144,7 @@ struct SelectFileButton<Label>: View where Label: View {
}
}

@MainActor
func selectApplication(_ openPanel: NSOpenPanel, onFinish: @escaping (String) -> Void) {
openPanel.allowsMultipleSelection = false
openPanel.canChooseDirectories = false
Expand Down
Loading