diff --git a/quickshell/Common/TrayMenuManager.qml b/quickshell/Common/TrayMenuManager.qml index 30539259..7e61e1c2 100644 --- a/quickshell/Common/TrayMenuManager.qml +++ b/quickshell/Common/TrayMenuManager.qml @@ -6,49 +6,27 @@ import QtQuick Singleton { id: root - property var activeOverflowMenus: ({}) - property var activeTrayMenus: ({}) + property var activeTrayBars: ({}) - function registerOverflowMenu(screenName, menuOpenBinding) { + function register(screenName, trayBar) { + if (!screenName || !trayBar) return + activeTrayBars[screenName] = trayBar + } + + function unregister(screenName) { if (!screenName) return - activeOverflowMenus[screenName] = menuOpenBinding - } - - function unregisterOverflowMenu(screenName) { - if (!screenName) return - delete activeOverflowMenus[screenName] - } - - function registerTrayMenu(screenName, closeCallback) { - if (!screenName) return - activeTrayMenus[screenName] = closeCallback - } - - function unregisterTrayMenu(screenName) { - if (!screenName) return - delete activeTrayMenus[screenName] - } - - function closeOverflowMenus() { - for (const screenName in activeOverflowMenus) { - const menuBinding = activeOverflowMenus[screenName] - if (menuBinding && menuBinding.close) { - menuBinding.close() - } - } - } - - function closeTrayMenus() { - for (const screenName in activeTrayMenus) { - const closeCallback = activeTrayMenus[screenName] - if (closeCallback) { - closeCallback() - } - } + delete activeTrayBars[screenName] } function closeAllMenus() { - closeOverflowMenus() - closeTrayMenus() + for (const screenName in activeTrayBars) { + const trayBar = activeTrayBars[screenName] + if (!trayBar) continue + + trayBar.menuOpen = false + if (trayBar.currentTrayMenu) { + trayBar.currentTrayMenu.showMenu = false + } + } } } diff --git a/quickshell/Modals/Common/DankModal.qml b/quickshell/Modals/Common/DankModal.qml index 084c0496..d2588024 100644 --- a/quickshell/Modals/Common/DankModal.qml +++ b/quickshell/Modals/Common/DankModal.qml @@ -88,7 +88,10 @@ PanelWindow { } } WlrLayershell.exclusiveZone: -1 - WlrLayershell.keyboardFocus: shouldHaveFocus ? WlrKeyboardFocus.Exclusive : WlrKeyboardFocus.None + WlrLayershell.keyboardFocus: { + if (!shouldHaveFocus) return WlrKeyboardFocus.None + return CompositorService.isHyprland ? WlrKeyboardFocus.OnDemand : WlrKeyboardFocus.Exclusive + } onVisibleChanged: { if (root.visible) { opened() diff --git a/quickshell/Modules/AppDrawer/AppDrawerPopout.qml b/quickshell/Modules/AppDrawer/AppDrawerPopout.qml index 4c24b136..39e663df 100644 --- a/quickshell/Modules/AppDrawer/AppDrawerPopout.qml +++ b/quickshell/Modules/AppDrawer/AppDrawerPopout.qml @@ -17,9 +17,6 @@ DankPopout { property var triggerScreen: null - // Setting to Exclusive, so virtual keyboards can send input to app drawer - WlrLayershell.keyboardFocus: shouldBeVisible ? WlrKeyboardFocus.Exclusive : WlrKeyboardFocus.None - function show() { open() } diff --git a/quickshell/Modules/DankBar/Widgets/SystemTrayBar.qml b/quickshell/Modules/DankBar/Widgets/SystemTrayBar.qml index d64004e6..105e8fea 100644 --- a/quickshell/Modules/DankBar/Widgets/SystemTrayBar.qml +++ b/quickshell/Modules/DankBar/Widgets/SystemTrayBar.qml @@ -49,21 +49,16 @@ Item { visible: allTrayItems.length > 0 property bool menuOpen: false - property bool overflowWasOpenBeforeTrayMenu: false + property var currentTrayMenu: null Component.onCompleted: { - if (parentScreen) { - TrayMenuManager.registerOverflowMenu(parentScreen.name, { - close: () => { root.menuOpen = false } - }) - } + if (!parentScreen) return + TrayMenuManager.register(parentScreen.name, root) } Component.onDestruction: { - if (parentScreen) { - TrayMenuManager.unregisterOverflowMenu(parentScreen.name) - TrayMenuManager.unregisterTrayMenu(parentScreen.name) - } + if (!parentScreen) return + TrayMenuManager.unregister(parentScreen.name) } Rectangle { @@ -186,7 +181,7 @@ Item { if (!delegateRoot.trayItem.hasMenu) return - root.overflowWasOpenBeforeTrayMenu = root.menuOpen + root.menuOpen = false root.showForTrayItem(delegateRoot.trayItem, visualContent, parentScreen, root.isAtBottom, root.isVertical, root.axis) } } @@ -319,7 +314,7 @@ Item { if (!delegateRoot.trayItem.hasMenu) return - root.overflowWasOpenBeforeTrayMenu = root.menuOpen + root.menuOpen = false root.showForTrayItem(delegateRoot.trayItem, visualContent, parentScreen, root.isAtBottom, root.isVertical, root.axis) } } @@ -722,7 +717,6 @@ Item { if (!trayItem.hasMenu) return - root.overflowWasOpenBeforeTrayMenu = true root.menuOpen = false root.showForTrayItem(trayItem, parent, parentScreen, root.isAtBottom, root.isVertical, root.axis) } @@ -784,7 +778,6 @@ Item { } function closeWithAction() { - root.overflowWasOpenBeforeTrayMenu = false close() } @@ -1329,39 +1322,19 @@ Item { } } - property var currentTrayMenu: null - - Connections { - target: currentTrayMenu - enabled: currentTrayMenu !== null - function onShowMenuChanged() { - if (parentWindow && typeof parentWindow.systemTrayMenuOpen !== "undefined") { - parentWindow.systemTrayMenuOpen = currentTrayMenu.showMenu - } - } - } - function showForTrayItem(item, anchor, screen, atBottom, vertical, axisObj) { - if (parentWindow && typeof parentWindow.systemTrayMenuOpen !== "undefined") { - parentWindow.systemTrayMenuOpen = true - } + if (!screen) return if (currentTrayMenu) { - root.overflowWasOpenBeforeTrayMenu = false currentTrayMenu.showMenu = false currentTrayMenu.destroy() currentTrayMenu = null } currentTrayMenu = trayMenuComponent.createObject(null) - if (currentTrayMenu && screen) { - currentTrayMenu.showForTrayItem(item, anchor, screen, atBottom, vertical ?? false, axisObj) - TrayMenuManager.registerTrayMenu(screen.name, () => { - if (currentTrayMenu) { - currentTrayMenu.close() - } - }) - } + if (!currentTrayMenu) return + + currentTrayMenu.showForTrayItem(item, anchor, screen, atBottom, vertical ?? false, axisObj) } } diff --git a/quickshell/Modules/DankDash/DankDashPopout.qml b/quickshell/Modules/DankDash/DankDashPopout.qml index 47d5ff80..fc11cea1 100644 --- a/quickshell/Modules/DankDash/DankDashPopout.qml +++ b/quickshell/Modules/DankDash/DankDashPopout.qml @@ -18,7 +18,6 @@ DankPopout { property var triggerScreen: null property int currentTabIndex: 0 - keyboardFocusMode: WlrKeyboardFocus.Exclusive function setTriggerPosition(x, y, width, section, screen) { triggerSection = section diff --git a/quickshell/Modules/HyprWorkspaces/HyprlandOverview.qml b/quickshell/Modules/HyprWorkspaces/HyprlandOverview.qml index ceb6ce85..977f0fca 100644 --- a/quickshell/Modules/HyprWorkspaces/HyprlandOverview.qml +++ b/quickshell/Modules/HyprWorkspaces/HyprlandOverview.qml @@ -35,7 +35,7 @@ Scope { WlrLayershell.namespace: "dms:workspace-overview" WlrLayershell.layer: WlrLayer.Overlay WlrLayershell.exclusiveZone: -1 - WlrLayershell.keyboardFocus: WlrKeyboardFocus.Exclusive + WlrLayershell.keyboardFocus: overviewScope.overviewOpen ? WlrKeyboardFocus.OnDemand : WlrKeyboardFocus.None anchors { top: true diff --git a/quickshell/Modules/Plugins/PluginPopout.qml b/quickshell/Modules/Plugins/PluginPopout.qml index ec97f1b2..74e76d13 100644 --- a/quickshell/Modules/Plugins/PluginPopout.qml +++ b/quickshell/Modules/Plugins/PluginPopout.qml @@ -8,8 +8,6 @@ DankPopout { layerNamespace: "dms-plugin:" + layerNamespacePlugin - WlrLayershell.keyboardFocus: shouldBeVisible ? WlrKeyboardFocus.Exclusive : WlrKeyboardFocus.None - property var triggerScreen: null property Component pluginContent: null property real contentWidth: 400 diff --git a/quickshell/Widgets/DankPopout.qml b/quickshell/Widgets/DankPopout.qml index f1e70ec7..de4d98a0 100644 --- a/quickshell/Widgets/DankPopout.qml +++ b/quickshell/Widgets/DankPopout.qml @@ -28,7 +28,6 @@ PanelWindow { property list animationEnterCurve: Theme.expressiveCurves.expressiveDefaultSpatial property list animationExitCurve: Theme.expressiveCurves.emphasized property bool shouldBeVisible: false - property int keyboardFocusMode: WlrKeyboardFocus.Exclusive visible: false @@ -97,7 +96,10 @@ PanelWindow { } } WlrLayershell.exclusiveZone: -1 - WlrLayershell.keyboardFocus: shouldBeVisible ? keyboardFocusMode : WlrKeyboardFocus.None + WlrLayershell.keyboardFocus: { + if (!shouldBeVisible) return WlrKeyboardFocus.None + return CompositorService.isHyprland ? WlrKeyboardFocus.OnDemand : WlrKeyboardFocus.Exclusive + } anchors { top: true