dock: unload when not needed

This commit is contained in:
end-4
2025-06-10 09:14:54 +02:00
parent cf652482c5
commit f7f4affe51
+106 -103
View File
@@ -18,127 +18,130 @@ Scope { // Scope
Variants { // For each monitor Variants { // For each monitor
model: Quickshell.screens model: Quickshell.screens
PanelWindow { // Window
Loader {
id: dockLoader
required property var modelData required property var modelData
id: dockRoot active: ConfigOptions?.dock.hoverToReveal || (!ToplevelManager.activeToplevel?.activated)
screen: modelData
property bool reveal: root.pinned sourceComponent: PanelWindow { // Window
|| (ConfigOptions?.dock.hoverToReveal && dockMouseArea.containsMouse) id: dockRoot
|| dockApps.requestDockShow screen: dockLoader.modelData
|| (!ToplevelManager.activeToplevel?.activated)
anchors { property bool reveal: root.pinned
bottom: true || (ConfigOptions?.dock.hoverToReveal && dockMouseArea.containsMouse)
left: true || dockApps.requestDockShow
right: true || (!ToplevelManager.activeToplevel?.activated)
}
function hide() { anchors {
cheatsheetLoader.active = false bottom: true
} left: true
exclusiveZone: root.pinned ? implicitHeight right: true
- (Appearance.sizes.hyprlandGapsOut)
- (Appearance.sizes.elevationMargin - Appearance.sizes.hyprlandGapsOut) : 0
implicitWidth: dockBackground.implicitWidth
WlrLayershell.namespace: "quickshell:dock"
color: "transparent"
implicitHeight: (ConfigOptions?.dock.height ?? 70) + Appearance.sizes.elevationMargin + Appearance.sizes.hyprlandGapsOut
mask: Region {
item: dockMouseArea
}
MouseArea {
id: dockMouseArea
anchors.top: parent.top
height: parent.height
anchors.topMargin: dockRoot.reveal ? 0 :
ConfigOptions?.dock.hoverToReveal ? (dockRoot.implicitHeight - ConfigOptions.dock.hoverRegionHeight) :
(dockRoot.implicitHeight + 1)
anchors.left: parent.left
anchors.right: parent.right
hoverEnabled: true
Behavior on anchors.topMargin {
animation: Appearance.animation.elementMoveFast.numberAnimation.createObject(this)
} }
Item { exclusiveZone: root.pinned ? implicitHeight
id: dockHoverRegion - (Appearance.sizes.hyprlandGapsOut)
anchors.fill: parent - (Appearance.sizes.elevationMargin - Appearance.sizes.hyprlandGapsOut) : 0
Item { // Wrapper for the dock background implicitWidth: dockBackground.implicitWidth
id: dockBackground WlrLayershell.namespace: "quickshell:dock"
anchors { color: "transparent"
top: parent.top
bottom: parent.bottom
horizontalCenter: parent.horizontalCenter
}
implicitWidth: dockRow.implicitWidth + 5 * 2 implicitHeight: (ConfigOptions?.dock.height ?? 70) + Appearance.sizes.elevationMargin + Appearance.sizes.hyprlandGapsOut
height: parent.height - Appearance.sizes.elevationMargin - Appearance.sizes.hyprlandGapsOut
StyledRectangularShadow { mask: Region {
target: dockVisualBackground item: dockMouseArea
} }
Rectangle { // The real rectangle that is visible
id: dockVisualBackground
property real margin: Appearance.sizes.elevationMargin
anchors.fill: parent
anchors.topMargin: Appearance.sizes.elevationMargin
anchors.bottomMargin: Appearance.sizes.hyprlandGapsOut
color: Appearance.colors.colLayer0
radius: Appearance.rounding.large
}
RowLayout { MouseArea {
id: dockRow id: dockMouseArea
anchors.top: parent.top anchors.top: parent.top
anchors.bottom: parent.bottom height: parent.height
anchors.horizontalCenter: parent.horizontalCenter anchors.topMargin: dockRoot.reveal ? 0 :
spacing: 3 ConfigOptions?.dock.hoverToReveal ? (dockRoot.implicitHeight - ConfigOptions.dock.hoverRegionHeight) :
property real padding: 5 (dockRoot.implicitHeight + 1)
VerticalButtonGroup { anchors.left: parent.left
Layout.topMargin: Appearance.sizes.hyprlandGapsOut // why does this work anchors.right: parent.right
GroupButton { // Pin button hoverEnabled: true
baseWidth: 35
baseHeight: 35 Behavior on anchors.topMargin {
clickedWidth: baseWidth animation: Appearance.animation.elementMoveFast.numberAnimation.createObject(this)
clickedHeight: baseHeight + 20 }
buttonRadius: Appearance.rounding.normal
toggled: root.pinned Item {
onClicked: root.pinned = !root.pinned id: dockHoverRegion
contentItem: MaterialSymbol { anchors.fill: parent
text: "keep"
horizontalAlignment: Text.AlignHCenter Item { // Wrapper for the dock background
iconSize: Appearance.font.pixelSize.larger id: dockBackground
color: root.pinned ? Appearance.m3colors.m3onPrimary : Appearance.colors.colOnLayer0 anchors {
top: parent.top
bottom: parent.bottom
horizontalCenter: parent.horizontalCenter
}
implicitWidth: dockRow.implicitWidth + 5 * 2
height: parent.height - Appearance.sizes.elevationMargin - Appearance.sizes.hyprlandGapsOut
StyledRectangularShadow {
target: dockVisualBackground
}
Rectangle { // The real rectangle that is visible
id: dockVisualBackground
property real margin: Appearance.sizes.elevationMargin
anchors.fill: parent
anchors.topMargin: Appearance.sizes.elevationMargin
anchors.bottomMargin: Appearance.sizes.hyprlandGapsOut
color: Appearance.colors.colLayer0
radius: Appearance.rounding.large
}
RowLayout {
id: dockRow
anchors.top: parent.top
anchors.bottom: parent.bottom
anchors.horizontalCenter: parent.horizontalCenter
spacing: 3
property real padding: 5
VerticalButtonGroup {
Layout.topMargin: Appearance.sizes.hyprlandGapsOut // why does this work
GroupButton { // Pin button
baseWidth: 35
baseHeight: 35
clickedWidth: baseWidth
clickedHeight: baseHeight + 20
buttonRadius: Appearance.rounding.normal
toggled: root.pinned
onClicked: root.pinned = !root.pinned
contentItem: MaterialSymbol {
text: "keep"
horizontalAlignment: Text.AlignHCenter
iconSize: Appearance.font.pixelSize.larger
color: root.pinned ? Appearance.m3colors.m3onPrimary : Appearance.colors.colOnLayer0
}
} }
} }
} DockSeparator {}
DockSeparator {} DockApps { id: dockApps; }
DockApps { id: dockApps; } DockSeparator {}
DockSeparator {} DockButton {
DockButton { Layout.fillHeight: true
Layout.fillHeight: true onClicked: Hyprland.dispatch("global quickshell:overviewToggle")
onClicked: Hyprland.dispatch("global quickshell:overviewToggle") contentItem: MaterialSymbol {
contentItem: MaterialSymbol { anchors.fill: parent
anchors.fill: parent horizontalAlignment: Text.AlignHCenter
horizontalAlignment: Text.AlignHCenter font.pixelSize: parent.width / 2
font.pixelSize: parent.width / 2 text: "apps"
text: "apps" color: Appearance.colors.colOnLayer0
color: Appearance.colors.colOnLayer0 }
} }
} }
} }
} }
}
}
} }
} }
} }