Skip to content

Commit 8e0cfbd

Browse files
author
Jaden
committed
drawers: restore focus to previous window on dismiss
When a drawer (launcher, session, sidebar, dashboard) is opened, the HyprlandFocusGrab takes keyboard focus away from the active window. On dismiss, focus was not restored, causing Hyprland to fall back to focusing whatever window is under the mouse cursor. This stores the active window address when the focus grab activates and dispatches focuswindow to restore it when the grab deactivates.
1 parent 25515fd commit 8e0cfbd

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

modules/drawers/Drawers.qml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,20 @@ Variants {
9191
HyprlandFocusGrab {
9292
id: focusGrab
9393

94+
property string previousWindowAddress: ""
95+
9496
active: (visibilities.launcher && Config.launcher.enabled) || (visibilities.session && Config.session.enabled) || (visibilities.sidebar && Config.sidebar.enabled) || (!Config.dashboard.showOnHover && visibilities.dashboard && Config.dashboard.enabled) || (panels.popouts.currentName.startsWith("traymenu") && (panels.popouts.current as StackView)?.depth > 1)
9597
windows: [win]
98+
99+
onActiveChanged: {
100+
if (active) {
101+
previousWindowAddress = Hypr.activeToplevel?.lastIpcObject.address ?? "";
102+
} else if (previousWindowAddress) {
103+
Hypr.dispatch(`focuswindow address:0x${previousWindowAddress}`);
104+
previousWindowAddress = "";
105+
}
106+
}
107+
96108
onCleared: {
97109
visibilities.launcher = false;
98110
visibilities.session = false;

0 commit comments

Comments
 (0)