fix(desktop): skip auxiliary macOS snapshot windows #12978
MergedYoruSamaOG(GitHub profile, opens in a new tab)merged 8 commits into
main fromrefs/pull/12978/headmerged by juliusmarminge View on GitHubgithub-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:M
- apps/desktop/src/snapShot/ActiveWindow.ts line 142OutdatedResolvedby YoruSamaOG(GitHub profile, opens in a new tab)@@ -102,4 +124,19 @@102124 async function macActiveWindow(): Promise<ActiveWindow | undefined> {103125 const output = (await runMacLookup()).trim();104126 if (!output) return undefined;105- const window = decodeMacActiveWindow(output);127+ const lookup = decodeMacActiveWindowLookup(output);128+ const visible = lookup.windows.filter(129+ (window) => window.alpha > 0 && window.bounds.width > 0 && window.bounds.height > 0,130+ );131+ const largest = visible.reduce<(typeof visible)[number] | undefined>(132+ (current, window) =>133+ !current ||134+ window.bounds.width * window.bounds.height > current.bounds.width * current.bounds.height135+ ? window136+ : current,137+ undefined,138+ );139+ const isAuxiliaryStrip = (window: (typeof visible)[number]) =>140+ largest !== undefined &&141+ window !== largest &&142+ ((window.bounds.width >= largest.bounds.width * MAC_AUXILIARY_STRIP_LONG_EDGE_RATIO &&
juliusmarminge added labelsmacroscope-review
- apps/desktop/src/snapShot/ActiveWindow.ts lines 97 to 97OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -68,16 +84,14 @@6884 for (let i = 0; i < count; i++) {6985 const w = ObjC.castRefToObject($.CFArrayGetValueAtIndex(list, i));7086 if (w.objectForKey("kCGWindowOwnerPID").js !== pid) continue;87+ if (!ownerName) {88+ ownerName = String(ObjC.unwrap(w.objectForKey("kCGWindowOwnerName")) || "");89+ }7190 if (w.objectForKey("kCGWindowLayer").js !== 0) continue;7291 const b = ObjC.deepUnwrap(w.objectForKey("kCGWindowBounds"));73- return JSON.stringify({92+ windows.push({7493 id: w.objectForKey("kCGWindowNumber").js,7594 title: String(ObjC.unwrap(w.objectForKey("kCGWindowName")) || ""),7695 bounds: { x: b.X, y: b.Y, width: b.Width, height: b.Height },77- owner: {78- name: String(app.localizedName.js || ObjC.unwrap(w.objectForKey("kCGWindowOwnerName")) || ""),79- processId: pid,80- path: String(app.bundleURL.path.js || ""),81- bundleId: String(app.bundleIdentifier.js || ""),82- },96+ alpha: w.objectForKey("kCGWindowAlpha").js,8397 });
- apps/desktop/src/snapShot/ActiveWindow.ts lines 141 to 143OutdatedResolvedby coderabbitai[bot](GitHub profile, opens in a new tab)@@ -104,2 +124,20 @@104124 if (!output) return undefined;105- const window = decodeMacActiveWindow(output);125+ const lookup = decodeMacActiveWindowLookup(output);126+ const visible = lookup.windows.filter(127+ (window) => window.alpha > 0 && window.bounds.width > 0 && window.bounds.height > 0,128+ );129+ const largest = visible.reduce<(typeof visible)[number] | undefined>(130+ (current, window) =>131+ !current ||132+ window.bounds.width * window.bounds.height > current.bounds.width * current.bounds.height133+ ? window134+ : current,135+ undefined,136+ );137+ const isAuxiliaryStrip = (window: (typeof visible)[number]) =>138+ largest !== undefined &&139+ window !== largest &&140+ window.title.trim() === "" &&141+ ((window.bounds.x === largest.bounds.x &&142+ window.bounds.width === largest.bounds.width &&143+ window.bounds.height < largest.bounds.height) ||
maria-rcks closed this
maria-rcks reopened this
juliusmarminge assignedjuliusmarminge
juliusmarminge merged thisb4cebe8
juliusmarminge closed this
Sign in to join this conversation.
macroscopeapp[bot](GitHub profile, opens in a new tab) reviewed