fix: filter auxiliary windows and remove thumbnail requirement from source list

- Swift helper: filter out untitled auxiliary windows from multi-window apps (e.g. Arc sidebar/tab-bar chrome)
- Swift helper: increase minimum window size from 1x1 to 50x50
- Remove .filter(source => Boolean(source.thumbnail)) that hid valid sources
- Remove hasUsableSourceThumbnail filter in fallback path
- Recompile prebundled openscreen-window-list binary
This commit is contained in:
webadderall
2026-03-30 15:16:28 +11:00
parent 0a30df9872
commit 27a2be2d3b
3 changed files with 32 additions and 5 deletions
-2
View File
@@ -2950,7 +2950,6 @@ export function registerIpcHandlers(
sourceType: 'window' as const,
}
})
.filter((source) => Boolean(source.thumbnail))
return [...screenSources, ...mergedWindowSources]
} catch (error) {
@@ -2958,7 +2957,6 @@ export function registerIpcHandlers(
const windowSources = electronSources
.filter((source) => source.id.startsWith('window:'))
.filter((source) => hasUsableSourceThumbnail(source.thumbnail))
.filter((source) => {
const normalizedName = normalizeDesktopSourceName(source.name)
if (!normalizedName) {
@@ -49,7 +49,14 @@ group.enter()
Task {
do {
let shareableContent = try await SCShareableContent.excludingDesktopWindows(false, onScreenWindowsOnly: true)
let entries = shareableContent.windows.compactMap { window -> WindowListEntry? in
struct RawWindowEntry {
let entry: WindowListEntry
let hasRawTitle: Bool
let bundleId: String?
}
let rawEntries = shareableContent.windows.compactMap { window -> RawWindowEntry? in
let appName = normalize(window.owningApplication?.applicationName)
let windowTitle = normalize(window.title)
let bundleId = normalize(window.owningApplication?.bundleIdentifier)
@@ -59,7 +66,7 @@ Task {
return nil
}
guard frame.width > 1, frame.height > 1 else {
guard frame.width >= 50, frame.height >= 50 else {
return nil
}
@@ -87,7 +94,7 @@ Task {
resolvedName = resolvedWindowTitle
}
return WindowListEntry(
let entry = WindowListEntry(
id: "window:\(window.windowID):0",
name: resolvedName,
display_id: matchedDisplay.map { String($0.displayID) } ?? "",
@@ -99,7 +106,29 @@ Task {
width: Double(frame.width),
height: Double(frame.height)
)
return RawWindowEntry(entry: entry, hasRawTitle: windowTitle != nil, bundleId: bundleId)
}
// For apps with multiple windows, drop auxiliary windows that lack a
// distinct title (e.g. Arc's sidebar/tab-bar chrome). If ALL windows
// from an app lack titles, keep them all.
var titledCountByBundle: [String: Int] = [:]
for raw in rawEntries {
if let bid = raw.bundleId, raw.hasRawTitle {
titledCountByBundle[bid, default: 0] += 1
}
}
let entries = rawEntries
.filter { raw in
guard let bid = raw.bundleId else { return true }
if let titled = titledCountByBundle[bid], titled > 0 {
return raw.hasRawTitle
}
return true
}
.map { $0.entry }
.sorted { lhs, rhs in
let lhsApp = lhs.appName ?? lhs.name
let rhsApp = rhs.appName ?? rhs.name