Skip to content

Record your screen, ship a demo. Free and open-source, GPU-accelerated, no watermarks, no subscriptions. Windows, macOS, Linux. Actively maintained.

fix(windows): put the bar back on top when the source picker closes

EtienneLescotd6286825cc4a
diff --git a/electron/windows.test.ts b/electron/windows.test.ts
index 28b73e8e4..62840cee4 100644
--- a/electron/windows.test.ts
+++ b/electron/windows.test.ts
@@ -62,7 +62,10 @@ const electron = vi.hoisted(() => {
}
// 1920x1032 px of work area, enclosed in DIP the way Chromium reports it.
- const display = { workArea: { x: 0, y: 0, width: 1536, height: 826 } };
+ const display = {
+ workArea: { x: 0, y: 0, width: 1536, height: 826 },
+ workAreaSize: { width: 1536, height: 826 },
+ };
const handlers = new Map<string, (event: unknown, ...args: unknown[]) => void>();
return { scale, FakeWindow, display, handlers };
});
@@ -83,6 +86,7 @@ vi.mock("electron", () => ({
const REAL_PLATFORM = process.platform;
let createHudOverlayWindow: typeof import("./windows").createHudOverlayWindow;
+let createSourceSelectorWindow: typeof import("./windows").createSourceSelectorWindow;
beforeAll(async () => {
// windows.ts decides at import whether to clamp the bar or, on Linux, the whole window,
@@ -92,7 +96,7 @@ beforeAll(async () => {
value: () => "10.0.26100",
configurable: true,
});
- ({ createHudOverlayWindow } = await import("./windows"));
+ ({ createHudOverlayWindow, createSourceSelectorWindow } = await import("./windows"));
});
afterAll(() => {
@@ -167,4 +171,16 @@ describe("HUD topmost on Windows (#1193)", () => {
step();
expect(win.topmost).toBe(true);
});
+
+ it("is put back once Windows took it and the source picker closes", () => {
+ const hud = openHud();
+ const picker = createSourceSelectorWindow() as unknown as InstanceType<
+ typeof electron.FakeWindow
+ >;
+ hud.topmost = false;
+ for (const [event, listener] of picker.on.mock.calls) {
+ if (event === "closed") listener();
+ }
+ expect(hud.topmost).toBe(true);
+ });
});
diff --git a/electron/windows.ts b/electron/windows.ts
index a062e0110..e972caf2a 100644
--- a/electron/windows.ts
+++ b/electron/windows.ts
@@ -692,6 +692,10 @@ export function createSourceSelectorWindow(): BrowserWindow {
// desktop regardless of where the HUD was opened.
followAcrossSpaces(win);
keepAlwaysOnTop(win);
+ // The picker may close with another app in front, which gives the HUD no event of its own.
+ win.on("closed", () => {
+ if (hudOverlayWindow) reassertAlwaysOnTop(hudOverlayWindow);
+ });
if (VITE_DEV_SERVER_URL) {
win.loadURL(VITE_DEV_SERVER_URL + "?windowType=source-selector");