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(hud): refuse an empty size from the renderer

EtienneLescot98411d6f839c
diff --git a/electron/windows.test.ts b/electron/windows.test.ts
index de7e2d8e6..685195e19 100644
--- a/electron/windows.test.ts
+++ b/electron/windows.test.ts
@@ -129,4 +129,13 @@ describe("HUD drag at 125 % scaling (#1004)", () => {
// One row of slack: the work area Electron reports is enclosed in DIP (825.6 -> 826).
expect(barBottom).toBeLessThanOrEqual(WORK_AREA_BOTTOM_PX + 1);
});
+
+ it("ignores an empty size instead of carrying it into the next move", () => {
+ const win = openHud();
+ const { width, height } = win.pixels;
+ send("hud-overlay-set-size", 0, 0, null);
+ drag(4, 2, 0);
+ expect(Math.abs(win.pixels.width - width)).toBeLessThanOrEqual(1);
+ expect(Math.abs(win.pixels.height - height)).toBeLessThanOrEqual(1);
+ });
});
diff --git a/electron/windows.ts b/electron/windows.ts
index fafac9a46..8273b5b9b 100644
--- a/electron/windows.ts
+++ b/electron/windows.ts
@@ -317,11 +317,15 @@ ipcMain.on("hud-overlay-drag-end", () => {
// snaps anyway — tweening the window across 10 frames just meant 10 frames of the
// bar sitting at an offset that didn't match the content it was drawn with.
ipcMain.on("hud-overlay-set-size", (_event, width: number, height: number, content: unknown) => {
+ // An empty size is refused too: it would be stored as the HUD's own size and re-applied by
+ // every later move.
if (
!hudOverlayWindow ||
hudOverlayWindow.isDestroyed() ||
!Number.isFinite(width) ||
- !Number.isFinite(height)
+ !Number.isFinite(height) ||
+ width <= 0 ||
+ height <= 0
) {
return;
}