overview: (properly) put overview grid in loader

This commit is contained in:
end-4
2025-05-21 22:12:05 +02:00
parent d26a95253e
commit 2571b3f532
@@ -10,103 +10,98 @@ import Quickshell.Wayland
import Quickshell.Hyprland import Quickshell.Hyprland
Scope { Scope {
id: root
Variants { Variants {
model: Quickshell.screens model: Quickshell.screens
PanelWindow {
id: root
required property var modelData
property string searchingText: ""
readonly property HyprlandMonitor monitor: Hyprland.monitorFor(root.screen)
property bool monitorIsFocused: (Hyprland.focusedMonitor?.id == monitor.id)
screen: modelData
visible: GlobalStates.overviewOpen
Loader { WlrLayershell.namespace: "quickshell:overview"
id: overviewLoader WlrLayershell.layer: WlrLayer.Overlay
active: GlobalStates.overviewOpen WlrLayershell.keyboardFocus: GlobalStates.overviewOpen ? WlrKeyboardFocus.OnDemand : WlrKeyboardFocus.None
property var modelData color: "transparent"
PanelWindow { mask: Region {
id: root item: GlobalStates.overviewOpen ? columnLayout : null
property string searchingText: "" }
readonly property HyprlandMonitor monitor: Hyprland.monitorFor(root.screen)
property bool monitorIsFocused: (Hyprland.focusedMonitor?.id == monitor.id)
screen: modelData
visible: true
WlrLayershell.namespace: "quickshell:overview" anchors {
WlrLayershell.layer: WlrLayer.Overlay top: true
WlrLayershell.keyboardFocus: GlobalStates.overviewOpen ? WlrKeyboardFocus.OnDemand : WlrKeyboardFocus.None left: true
color: "transparent" right: true
bottom: true
}
mask: Region { HyprlandFocusGrab {
item: GlobalStates.overviewOpen ? columnLayout : null id: grab
windows: [ root ]
property bool canBeActive: root.monitorIsFocused
active: false
onCleared: () => {
if (!active) GlobalStates.overviewOpen = false
} }
}
anchors { Connections {
top: true target: GlobalStates
left: true function onOverviewOpenChanged() {
right: true delayedGrabTimer.start()
bottom: true
} }
}
HyprlandFocusGrab { Timer {
id: grab id: delayedGrabTimer
windows: [ root ] interval: ConfigOptions.hacks.arbitraryRaceConditionDelay
property bool canBeActive: root.monitorIsFocused repeat: false
active: false onTriggered: {
onCleared: () => { if (!grab.canBeActive) return
if (!active) GlobalStates.overviewOpen = false grab.active = GlobalStates.overviewOpen
}
}
implicitWidth: columnLayout.width
implicitHeight: columnLayout.height
ColumnLayout {
id: columnLayout
visible: GlobalStates.overviewOpen
anchors.horizontalCenter: parent.horizontalCenter
Keys.onPressed: (event) => {
if (event.key === Qt.Key_Escape) {
GlobalStates.overviewOpen = false;
} }
} }
Connections { Item {
target: GlobalStates height: 1 // Prevent Wayland protocol error
function onOverviewOpenChanged() { width: 1 // Prevent Wayland protocol error
delayedGrabTimer.start() }
SearchWidget {
panelWindow: root
Layout.alignment: Qt.AlignHCenter
onSearchingTextChanged: (text) => {
root.searchingText = searchingText
} }
} }
Timer { Loader {
id: delayedGrabTimer id: overviewLoader
interval: ConfigOptions.hacks.arbitraryRaceConditionDelay active: GlobalStates.overviewOpen
repeat: false sourceComponent: OverviewWidget {
onTriggered: {
if (!grab.canBeActive) return
grab.active = GlobalStates.overviewOpen
}
}
implicitWidth: columnLayout.width
implicitHeight: columnLayout.height
ColumnLayout {
id: columnLayout
visible: GlobalStates.overviewOpen
anchors.horizontalCenter: parent.horizontalCenter
Keys.onPressed: (event) => {
if (event.key === Qt.Key_Escape) {
GlobalStates.overviewOpen = false;
}
}
Item {
height: 1 // Prevent Wayland protocol error
width: 1 // Prevent Wayland protocol error
}
SearchWidget {
panelWindow: root
Layout.alignment: Qt.AlignHCenter
onSearchingTextChanged: (text) => {
root.searchingText = searchingText
}
}
OverviewWidget {
panelWindow: root panelWindow: root
visible: (root.searchingText == "") visible: (root.searchingText == "")
} }
} }
} }
}
}
} }
IpcHandler { IpcHandler {