diff --git a/components/StyledPanelWindow.qml b/components/StyledPanelWindow.qml index 0426201..45562dd 100644 --- a/components/StyledPanelWindow.qml +++ b/components/StyledPanelWindow.qml @@ -1,15 +1,36 @@ import qs.config import QtQuick import Quickshell +import Quickshell.Hyprland import Quickshell.Wayland PanelWindow { id: window - required property string name property alias background: background + required property string name + property bool canFocus: true + property bool focused: false WlrLayershell.namespace: `lux-${name}` + WlrLayershell.layer: WlrLayer.Top + WlrLayershell.keyboardFocus: window.visible ? WlrKeyboardFocus.OnDemand : WlrKeyboardFocus.None + + onVisibleChanged: { + if (!canFocus) + return; + focused = visible; + } + HyprlandFocusGrab { + active: window.focused + windows: [window] + onCleared: { + if (!window.canFocus) + return; + window.focused = false; + } + } + color: "transparent" Rectangle { diff --git a/modules/configuration/Configuration.qml b/modules/configuration/Configuration.qml index e6e9400..7a13d2c 100644 --- a/modules/configuration/Configuration.qml +++ b/modules/configuration/Configuration.qml @@ -4,8 +4,6 @@ import qs.services import QtQuick import QtQuick.Controls import QtQuick.Layouts -import Quickshell.Hyprland -import Quickshell.Wayland StyledPanelWindow { id: window @@ -17,15 +15,8 @@ StyledPanelWindow { implicitHeight: 400 background.color: Styling.theme.base200 - WlrLayershell.layer: WlrLayer.Top - WlrLayershell.keyboardFocus: window.visible ? WlrKeyboardFocus.OnDemand : WlrKeyboardFocus.None - - HyprlandFocusGrab { - active: Visibility.configuration - windows: [window] - onCleared: { - Visibility.configuration = false; - } + onFocusedChanged: { + Visibility.configuration = focused; } StyledTabBar { diff --git a/modules/launcher/Launcher.qml b/modules/launcher/Launcher.qml index 2ee10b0..4c51b54 100644 --- a/modules/launcher/Launcher.qml +++ b/modules/launcher/Launcher.qml @@ -6,8 +6,6 @@ import qs.components import qs.services import QtQuick import QtQuick.Layouts -import Quickshell.Hyprland -import Quickshell.Wayland import Quickshell.Widgets StyledPanelWindow { @@ -20,21 +18,11 @@ StyledPanelWindow { list.currentIndex = 0; search.clear(); } + Visibility.launcher = focused; } implicitWidth: rect.width implicitHeight: rect.height - WlrLayershell.layer: WlrLayer.Top - WlrLayershell.keyboardFocus: window.visible ? WlrKeyboardFocus.OnDemand : WlrKeyboardFocus.None - - HyprlandFocusGrab { - active: Visibility.launcher - windows: [window] - onCleared: { - Visibility.launcher = false; - } - } - WrapperItem { id: rect diff --git a/modules/pomodoro/Pomodoro.qml b/modules/pomodoro/Pomodoro.qml index eaa2d95..627520d 100644 --- a/modules/pomodoro/Pomodoro.qml +++ b/modules/pomodoro/Pomodoro.qml @@ -6,8 +6,6 @@ import qs.services import qs.widgets import QtQuick import QtQuick.Layouts -import Quickshell.Hyprland -import Quickshell.Wayland import Quickshell.Widgets StyledPanelWindow { @@ -18,8 +16,9 @@ StyledPanelWindow { implicitWidth: rect.width implicitHeight: rect.height - WlrLayershell.layer: WlrLayer.Top - WlrLayershell.keyboardFocus: root.visible ? WlrKeyboardFocus.OnDemand : WlrKeyboardFocus.None + onFocusedChanged: { + Visibility.pomodoro = focused; + } WrapperItem { id: rect @@ -29,14 +28,6 @@ StyledPanelWindow { topMargin: 24 bottomMargin: 24 - HyprlandFocusGrab { - active: Visibility.pomodoro - windows: [root] - onCleared: { - Visibility.pomodoro = false; - } - } - ColumnLayout { spacing: 22 diff --git a/modules/powermenu/PowerMenu.qml b/modules/powermenu/PowerMenu.qml index 6627c0f..712d94d 100644 --- a/modules/powermenu/PowerMenu.qml +++ b/modules/powermenu/PowerMenu.qml @@ -3,11 +3,9 @@ pragma ComponentBehavior: Bound import qs.components import qs.config import qs.services -import Quickshell.Hyprland import QtQuick import QtQuick.Layouts import Quickshell.Io -import Quickshell.Wayland import Quickshell.Widgets StyledPanelWindow { @@ -18,26 +16,19 @@ StyledPanelWindow { implicitWidth: rect.width implicitHeight: rect.height - WlrLayershell.layer: WlrLayer.Top - WlrLayershell.keyboardFocus: root.visible ? WlrKeyboardFocus.OnDemand : WlrKeyboardFocus.None - Process { id: process } + onFocusedChanged: { + Visibility.powermenu = focused; + } + WrapperItem { id: rect margin: 14 - HyprlandFocusGrab { - active: Visibility.powermenu - windows: [root] - onCleared: { - Visibility.powermenu = false; - } - } - StyledListView { id: list diff --git a/modules/storybook/Storybook.qml b/modules/storybook/Storybook.qml index b0e411f..406cc32 100644 --- a/modules/storybook/Storybook.qml +++ b/modules/storybook/Storybook.qml @@ -5,8 +5,6 @@ import qs.config import qs.services import QtQuick import QtQuick.Controls -import Quickshell.Hyprland -import Quickshell.Wayland StyledPanelWindow { id: root @@ -18,15 +16,8 @@ StyledPanelWindow { background.color: Styling.theme.base200 - WlrLayershell.layer: WlrLayer.Top - WlrLayershell.keyboardFocus: root.visible ? WlrKeyboardFocus.OnDemand : WlrKeyboardFocus.None - - HyprlandFocusGrab { - active: Visibility.storybook - windows: [root] - onCleared: { - Visibility.storybook = false; - } + onFocusedChanged: { + Visibility.storybook = focused; } StyledTabBar {