fix(overlay): Linux X11/XWayland stacking, stale pause state, multi-copy selector (#101)

This commit is contained in:
2026-05-31 20:59:18 -07:00
committed by GitHub
parent b46b8dfa41
commit e1ea464bc9
103 changed files with 6314 additions and 353 deletions
@@ -0,0 +1,53 @@
export type LinuxOverlayShapeRect = {
x: number;
y: number;
width: number;
height: number;
};
export type LinuxOverlayShapeWindow = {
isDestroyed: () => boolean;
getBounds?: () => LinuxOverlayShapeRect;
setShape?: (rects: LinuxOverlayShapeRect[]) => void;
};
function toPositivePixel(value: number): number | null {
if (!Number.isFinite(value) || value <= 0) {
return null;
}
return Math.max(1, Math.round(value));
}
export function buildFullWindowShapeRect(
bounds: LinuxOverlayShapeRect,
): LinuxOverlayShapeRect | null {
const width = toPositivePixel(bounds.width);
const height = toPositivePixel(bounds.height);
if (width === null || height === null) {
return null;
}
return {
x: 0,
y: 0,
width,
height,
};
}
export function restoreLinuxOverlayWindowShape(window: LinuxOverlayShapeWindow | null): boolean {
if (!window || window.isDestroyed()) {
return false;
}
if (typeof window.setShape !== 'function' || typeof window.getBounds !== 'function') {
return false;
}
const rect = buildFullWindowShapeRect(window.getBounds());
if (!rect) {
return false;
}
window.setShape([rect]);
return true;
}