Skip to content

Commit 36befc2

Browse files
committed
fix(picker): activate app and cleanup observer before showing
- Call NSApp.activate(ignoringOtherApps: true) to ensure picker shows - Remove old observer before adding new one to prevent duplicates
1 parent 6ba13b6 commit 36befc2

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

swift-bridge/Sources/ScreenCaptureKitBridge/ContentSharingPicker.swift

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,16 @@ public func showContentSharingPicker(
158158
let configBox: Box<SCContentSharingPickerConfiguration> = unretained(config)
159159

160160
DispatchQueue.main.async {
161+
// Activate the app to ensure picker can show
162+
NSApp.activate(ignoringOtherApps: true)
163+
161164
let picker = SCContentSharingPicker.shared
162165

166+
// Remove old observer if any
167+
if let old = currentObserver {
168+
picker.remove(old)
169+
}
170+
163171
let observer = PickerObserver(callback: callback, userData: userData)
164172
currentObserver = observer
165173

@@ -181,8 +189,16 @@ public func showContentSharingPickerWithResult(
181189
let configBox: Box<SCContentSharingPickerConfiguration> = unretained(config)
182190

183191
DispatchQueue.main.async {
192+
// Activate the app to ensure picker can show
193+
NSApp.activate(ignoringOtherApps: true)
194+
184195
let picker = SCContentSharingPicker.shared
185196

197+
// Remove old observer if any
198+
if let old = currentObserver {
199+
picker.remove(old)
200+
}
201+
186202
let observer = PickerObserverWithResult(callback: callback, userData: userData)
187203
currentObserver = observer
188204

0 commit comments

Comments
 (0)