fix(overlay): keep Hyprland recovery dialogs above overlays (#245)

This commit is contained in:
sudacode authored and GitHub committed 2026-09-11 01:52:01 -07:00
1 parent 0c37c665a2
commit 6d69a56574
4 files changed
+161 -4

No files matched your search

+52 -4
View File
@@ -3,14 +3,17 @@ import { execFileSync } from 'node:child_process';
export interface HyprlandPlacementClient {
address?: string;
at?: [number, number];
class?: string;
floating?: boolean;
hidden?: boolean;
initialClass?: string;
initialTitle?: string;
mapped?: boolean;
pid?: number;
pinned?: boolean;
size?: [number, number];
title?: string;
workspace?: { id: number };
}
export interface HyprlandPlacementBounds {
@@ -25,7 +28,11 @@ export interface HyprlandPlacementDispatchOptions {
promote?: boolean;
}
type ExecFileSync = typeof execFileSync;
type ExecFileSync = (
file: string,
args: string[],
options: NonNullable<Parameters<typeof execFileSync>[2]>,
) => ReturnType<typeof execFileSync>;
export type HyprlandConfigProvider = 'hyprlang' | 'lua';
export function shouldAttemptHyprlandWindowPlacement(
@@ -154,6 +161,33 @@ function luaWindowDispatch(name: string, windowAddress: string, fields: string[]
];
}
// Compositor recovery dialogs must remain clickable even when an overlay still owns input.
function buildHyprlandDialogPromotionDispatches(
clients: HyprlandPlacementClient[],
placedClient: HyprlandPlacementClient,
configProvider: HyprlandConfigProvider,
): string[][] {
if (typeof placedClient.workspace?.id !== 'number') return [];
return clients.flatMap((client) => {
if (
!client.address ||
client.address === placedClient.address ||
client.mapped === false ||
client.hidden === true ||
client.workspace?.id !== placedClient.workspace?.id ||
(client.class !== 'hyprland-dialog' && client.initialClass !== 'hyprland-dialog')
) {
return [];
}
const windowAddress = `address:${client.address}`;
return [
configProvider === 'lua'
? luaWindowDispatch('alter_zorder', windowAddress, ['mode = "top"'])
: ['dispatch', 'alterzorder', `top,${windowAddress}`],
];
});
}
function luaWindowSetProp(windowAddress: string, prop: string, value: string): string[] {
return luaWindowDispatch('set_prop', windowAddress, [
`prop = ${luaString(prop)}`,
@@ -331,12 +365,16 @@ export function ensureHyprlandWindowFloatingByTitleWithStatus(options: {
configProvider,
promote: options.promote,
});
if (options.promote !== false) {
dispatches.push(...buildHyprlandDialogPromotionDispatches(clients, client, configProvider));
}
for (const args of dispatches) {
run('hyprctl', args, { stdio: 'ignore' });
}
if (shouldVerifyBounds) {
try {
const refreshedClient = findHyprlandWindowForPlacement(readHyprlandPlacementClients(run), {
const refreshedClients = readHyprlandPlacementClients(run);
const refreshedClient = findHyprlandWindowForPlacement(refreshedClients, {
pid: options.pid ?? process.pid,
title: options.title,
});
@@ -345,10 +383,20 @@ export function ensureHyprlandWindowFloatingByTitleWithStatus(options: {
targetBounds &&
clientMatchesPlacementBounds(refreshedClient, targetBounds) === false
) {
for (const args of buildHyprlandPlacementDispatches(refreshedClient, targetBounds, {
const retryDispatches = buildHyprlandPlacementDispatches(refreshedClient, targetBounds, {
configProvider,
promote: options.promote,
})) {
});
if (options.promote !== false) {
retryDispatches.push(
...buildHyprlandDialogPromotionDispatches(
refreshedClients,
refreshedClient,
configProvider,
),
);
}
for (const args of retryDispatches) {
run('hyprctl', args, { stdio: 'ignore' });
}
}