fix: settings window z-order on Hyprland and Linux app detach (#85)

This commit is contained in:
2026-05-25 13:21:38 -07:00
committed by GitHub
parent f7abcedd75
commit 097b619d71
18 changed files with 274 additions and 27 deletions
@@ -0,0 +1,48 @@
import type { BrowserWindow } from 'electron';
import {
ensureHyprlandWindowFloatingByTitle,
shouldAttemptHyprlandWindowPlacement,
} from './hyprland-window-placement';
type SettingsWindowLevelController = Pick<
BrowserWindow,
'getTitle' | 'isDestroyed' | 'moveTop' | 'setAlwaysOnTop'
>;
type PromoteSettingsWindowOptions = {
platform?: NodeJS.Platform;
env?: NodeJS.ProcessEnv;
ensureHyprlandWindowFloatingByTitle?: typeof ensureHyprlandWindowFloatingByTitle;
};
export function shouldPromoteSettingsWindowAboveOverlay(
platform: NodeJS.Platform = process.platform,
env: NodeJS.ProcessEnv = process.env,
): boolean {
return shouldAttemptHyprlandWindowPlacement(platform, env);
}
export function promoteSettingsWindowAboveOverlay(
window: SettingsWindowLevelController,
options: PromoteSettingsWindowOptions = {},
): boolean {
const platform = options.platform ?? process.platform;
const env = options.env ?? process.env;
if (window.isDestroyed() || !shouldPromoteSettingsWindowAboveOverlay(platform, env)) {
return false;
}
window.setAlwaysOnTop(true);
window.moveTop();
const title = window.getTitle().trim();
if (title) {
(options.ensureHyprlandWindowFloatingByTitle ?? ensureHyprlandWindowFloatingByTitle)({
title,
platform,
env,
});
}
return true;
}