Skip to content

[BUG] Launcher dismissal doesn't restore focus to previously focused window #1322

@1letme

Description

@1letme

Description

When opening the launcher (e.g. via super+d) and then closing it (via Esc or super+d again), the previously focused window loses focus. Instead, the window under the mouse cursor gets focused.

This is problematic when your keyboard focus is on a different window than where the mouse is — after dismissing the launcher, focus jumps to the wrong window. It's especially annoying with groups, where you want to launch an app into the focused group but it ends up on a different window/workspace because focus shifted to wherever the mouse was.

Steps to Reproduce

  1. Focus a window (e.g. click on it or alt-tab to it)
  2. Move the mouse cursor over a different window (don't click)
  3. Open the launcher (super+d)
  4. Close the launcher (Esc or super+d)
  5. Observe: focus is now on the window under the mouse, not the previously focused window

Root Cause

In modules/drawers/Drawers.qml, the layer shell keyboard focus is set based on launcher visibility:

WlrLayershell.keyboardFocus: visibilities.launcher || visibilities.session ? WlrKeyboardFocus.OnDemand : WlrKeyboardFocus.None

When the launcher closes, keyboard focus becomes None, and Hyprland's default behavior focuses the window under the cursor. No previous focus tracking or restoration is implemented.

Expected Behavior

After dismissing the launcher, focus should return to the window that was focused before the launcher was opened.

Suggested Fix

  1. Store the active window address (via Hyprland IPC) before the launcher opens
  2. Restore focus to that window (e.g. hyprctl dispatch focuswindow address:...) when the launcher closes

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions