From 161118122e0c2b6c70d72e0f599f6c024277d94e Mon Sep 17 00:00:00 2001 From: bbedward Date: Tue, 30 Jun 2026 10:04:44 -0400 Subject: [PATCH] launcher: fix hyprland focus on context menu fixes #2714 --- .../DankLauncherV2/DankLauncherV2ModalConnected.qml | 4 +++- .../DankLauncherV2/DankLauncherV2ModalSpotlight.qml | 4 +++- .../DankLauncherV2ModalStandalone.qml | 4 +++- .../Modals/DankLauncherV2/LauncherContextMenu.qml | 13 ++++++++++++- 4 files changed, 21 insertions(+), 4 deletions(-) diff --git a/quickshell/Modals/DankLauncherV2/DankLauncherV2ModalConnected.qml b/quickshell/Modals/DankLauncherV2/DankLauncherV2ModalConnected.qml index fc11d6607..a7a2813d0 100644 --- a/quickshell/Modals/DankLauncherV2/DankLauncherV2ModalConnected.qml +++ b/quickshell/Modals/DankLauncherV2/DankLauncherV2ModalConnected.qml @@ -530,7 +530,9 @@ Item { HyprlandFocusGrab { id: focusGrab - windows: [contentWindow] + readonly property var contextMenuWindow: root.spotlightContent?.activeContextMenu?.contextWindow ?? null + readonly property bool contextMenuActive: root.spotlightContent?.activeContextMenu?.renderActive ?? false + windows: contextMenuActive && contextMenuWindow ? [contentWindow, contextMenuWindow] : [contentWindow] active: root.useHyprlandFocusGrab && root.spotlightOpen onCleared: { diff --git a/quickshell/Modals/DankLauncherV2/DankLauncherV2ModalSpotlight.qml b/quickshell/Modals/DankLauncherV2/DankLauncherV2ModalSpotlight.qml index c69b4510d..7211d521e 100644 --- a/quickshell/Modals/DankLauncherV2/DankLauncherV2ModalSpotlight.qml +++ b/quickshell/Modals/DankLauncherV2/DankLauncherV2ModalSpotlight.qml @@ -228,7 +228,9 @@ Item { HyprlandFocusGrab { id: focusGrab - windows: [launcherWindow] + readonly property var contextMenuWindow: root.spotlightContent?.activeContextMenu?.contextWindow ?? null + readonly property bool contextMenuActive: root.spotlightContent?.activeContextMenu?.renderActive ?? false + windows: contextMenuActive && contextMenuWindow ? [launcherWindow, contextMenuWindow] : [launcherWindow] active: root.useHyprlandFocusGrab && root.keyboardActive onCleared: { if (spotlightOpen) diff --git a/quickshell/Modals/DankLauncherV2/DankLauncherV2ModalStandalone.qml b/quickshell/Modals/DankLauncherV2/DankLauncherV2ModalStandalone.qml index 62eb79ddd..fbb76cbc4 100644 --- a/quickshell/Modals/DankLauncherV2/DankLauncherV2ModalStandalone.qml +++ b/quickshell/Modals/DankLauncherV2/DankLauncherV2ModalStandalone.qml @@ -259,7 +259,9 @@ Item { HyprlandFocusGrab { id: focusGrab - windows: [launcherWindow] + readonly property var contextMenuWindow: root.spotlightContent?.activeContextMenu?.contextWindow ?? null + readonly property bool contextMenuActive: root.spotlightContent?.activeContextMenu?.renderActive ?? false + windows: contextMenuActive && contextMenuWindow ? [launcherWindow, contextMenuWindow] : [launcherWindow] active: root.useHyprlandFocusGrab && root.keyboardActive onCleared: { diff --git a/quickshell/Modals/DankLauncherV2/LauncherContextMenu.qml b/quickshell/Modals/DankLauncherV2/LauncherContextMenu.qml index 73d12b163..8ee197bc1 100644 --- a/quickshell/Modals/DankLauncherV2/LauncherContextMenu.qml +++ b/quickshell/Modals/DankLauncherV2/LauncherContextMenu.qml @@ -25,6 +25,7 @@ Item { property real anchorY: 0 property bool openState: false property bool renderActive: false + readonly property alias contextWindow: menuWindow readonly property bool blurActive: renderActive && openState && BlurService.enabled && Theme.connectedSurfaceBlurEnabled readonly property real minMenuWidth: 180 @@ -446,7 +447,17 @@ Item { WlrLayershell.namespace: "dms:launcher-context-menu" WlrLayershell.layer: WlrLayershell.Overlay WlrLayershell.exclusiveZone: -1 - WlrLayershell.keyboardFocus: PopoutManager.screenshotActive ? WlrKeyboardFocus.None : (root.renderActive ? WlrKeyboardFocus.Exclusive : WlrKeyboardFocus.None) + // Hyprland steals the launcher's focus grab on exclusive focus; keep keys on the + // launcher window, which forwards them to the menu via handleKey(). + WlrLayershell.keyboardFocus: { + if (PopoutManager.screenshotActive) + return WlrKeyboardFocus.None; + if (!root.renderActive) + return WlrKeyboardFocus.None; + if (CompositorService.useHyprlandFocusGrab) + return WlrKeyboardFocus.None; + return WlrKeyboardFocus.Exclusive; + } anchors { top: true