fix(overlay): correct Hyprland fullscreen overlay alignment on Linux (#107)

This commit is contained in:
2026-06-01 02:12:16 -07:00
committed by GitHub
parent f1e260e996
commit 76f99e6518
15 changed files with 501 additions and 23 deletions
@@ -7,11 +7,56 @@ type ScreenDipConverter = {
) => Electron.Rectangle;
};
type ContentBoundsWindow = {
isDestroyed: () => boolean;
getBounds: () => Electron.Rectangle;
getContentBounds: () => Electron.Rectangle;
};
function resolveContentAlignedBounds(
geometry: WindowGeometry,
window?: ContentBoundsWindow | null,
): WindowGeometry {
if (!window || window.isDestroyed()) {
return geometry;
}
let outer: Electron.Rectangle;
let content: Electron.Rectangle;
try {
outer = window.getBounds();
content = window.getContentBounds();
} catch {
return geometry;
}
const leftInset = content.x - outer.x;
const topInset = content.y - outer.y;
const rightInset = outer.x + outer.width - (content.x + content.width);
const bottomInset = outer.y + outer.height - (content.y + content.height);
const insets = [leftInset, topInset, rightInset, bottomInset];
if (insets.some((inset) => !Number.isFinite(inset) || inset < 0)) {
return geometry;
}
return {
x: geometry.x - leftInset,
y: geometry.y - topInset,
width: geometry.width + leftInset + rightInset,
height: geometry.height + topInset + bottomInset,
};
}
export function normalizeOverlayWindowBoundsForPlatform(
geometry: WindowGeometry,
platform: NodeJS.Platform,
screen: ScreenDipConverter | null,
window?: ContentBoundsWindow | null,
): WindowGeometry {
if (platform === 'linux') {
return resolveContentAlignedBounds(geometry, window);
}
if (platform !== 'win32' || !screen) {
return geometry;
}