put overview in loader

This commit is contained in:
end-4
2025-05-15 23:04:15 +02:00
parent 9c9a615556
commit b022f23d7a
@@ -15,98 +15,96 @@ Scope {
Variants { Variants {
model: Quickshell.screens model: Quickshell.screens
PanelWindow { Loader {
id: root id: overviewLoader
active: GlobalStates.overviewOpen
property var modelData 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
visible: true
WlrLayershell.namespace: "quickshell:overview" PanelWindow {
WlrLayershell.layer: WlrLayer.Overlay id: root
WlrLayershell.keyboardFocus: GlobalStates.overviewOpen ? WlrKeyboardFocus.OnDemand : WlrKeyboardFocus.None property string searchingText: ""
color: "transparent" readonly property HyprlandMonitor monitor: Hyprland.monitorFor(root.screen)
property bool monitorIsFocused: (Hyprland.focusedMonitor?.id == monitor.id)
screen: modelData
visible: true
mask: Region { WlrLayershell.namespace: "quickshell:overview"
item: GlobalStates.overviewOpen ? columnLayout : null WlrLayershell.layer: WlrLayer.Overlay
} WlrLayershell.keyboardFocus: GlobalStates.overviewOpen ? WlrKeyboardFocus.OnDemand : WlrKeyboardFocus.None
color: "transparent"
anchors { mask: Region {
top: true item: GlobalStates.overviewOpen ? columnLayout : null
left: true
right: true
bottom: true
}
HyprlandFocusGrab {
id: grab
windows: [ root ]
property bool canBeActive: root.monitorIsFocused
active: false
onCleared: () => {
if (!active) GlobalStates.overviewOpen = false
} }
}
Connections { anchors {
target: GlobalStates top: true
function onOverviewOpenChanged() { left: true
delayedGrabTimer.start() right: true
bottom: true
} }
}
Timer { HyprlandFocusGrab {
id: delayedGrabTimer id: grab
interval: ConfigOptions.hacks.arbitraryRaceConditionDelay windows: [ root ]
repeat: false property bool canBeActive: root.monitorIsFocused
onTriggered: { active: false
if (!grab.canBeActive) return onCleared: () => {
grab.active = GlobalStates.overviewOpen if (!active) GlobalStates.overviewOpen = false
}
}
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 { Connections {
height: 1 // Prevent Wayland protocol error target: GlobalStates
width: 1 // Prevent Wayland protocol error function onOverviewOpenChanged() {
} delayedGrabTimer.start()
SearchWidget {
panelWindow: root
Layout.alignment: Qt.AlignHCenter
onSearchingTextChanged: (text) => {
root.searchingText = searchingText
} }
} }
Loader { Timer {
id: overviewLoader id: delayedGrabTimer
active: GlobalStates.overviewOpen interval: ConfigOptions.hacks.arbitraryRaceConditionDelay
sourceComponent: OverviewWidget { repeat: false
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 == "")
} }
Layout.preferredWidth: item ? item.implicitWidth : 0
Layout.preferredHeight: item ? item.implicitHeight : 0
} }
}
}
} }
} }