Files
glassMxrph/quickshell/dock/Dock.qml
T
mxandClaude Opus 5.5 99e64a7713 Add glassMxrph shell sources
Initial commit of the Quickshell desktop suite: bar, dock, launcher,
settings, Control Center, dashboard, OSD, lock screen, desktop widgets,
plugin host with the vendored Noctalia/Omarchy compatibility layer,
helpers, packaging, tests and phase documentation.

Includes the optimization work so far: usage widgets and dashboard
gauges no longer animate continuously, desktop widgets pause while
covered, system controls stop flickering on background polls, dock app
matching uses an indexed catalog, and workspace ghosts are created only
for occupied slots.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-07 22:36:17 +02:00

157 lines
6.1 KiB
QML

pragma ComponentBehavior: Bound
import QtQuick
import Quickshell
import Quickshell.Wayland
import "../components"
import "../services"
import "../core"
import "../theme"
import "DockGeometry.js" as Geometry
// Quickshell selects the concrete layer window at runtime.
// qmllint disable uncreatable-type
PanelWindow {
// qmllint enable uncreatable-type
id: root
screen: ScreenService.resolve(DockModel.options.monitor)
readonly property var options: DockModel.options
readonly property string position: options.position || "bottom"
readonly property bool vertical: position !== "bottom"
readonly property real thickness: (options.iconSize || 48) * (1 + (options.magnification ? options.magnificationStrength : 0)) + 32
readonly property int motionDuration: Math.round(Theme.duration / (options.animationSpeed || 1))
property int hoveredIndex: -1
property bool shown: true
readonly property bool pointerInside: hover.hovered
readonly property bool held: pointerInside || DockState.opened || DockState.draggingId !== ""
readonly property var dockRect: ({
x: screen.x + (vertical ? position === "left" ? options.margin : screen.width - thickness - options.margin : (screen.width - width) / 2),
y: screen.y + (vertical ? (screen.height - height) / 2 : screen.height - thickness - options.margin),
width: vertical ? thickness : width,
height: vertical ? height : thickness
})
readonly property bool overlap: options.visibility === "intelligent" && Geometry.obstructed(dockRect, screen.name, HyprlandService.windows, HyprlandService.visibleWorkspaces)
readonly property bool wantVisible: options.visibility === "always" || held || (options.visibility === "intelligent" && !overlap)
onWantVisibleChanged: updateVisibility()
function updateVisibility() {
if (wantVisible) {
hideTimer.stop();
shown = true;
} else
hideTimer.restart();
}
function dropPin(source, x, y) {
for (const target of DockState.icons) {
if (target.dockWindow !== root || !target.group.pinned || target === source)
continue;
const point = target.mapFromItem(source, x, y);
if (point.x >= 0 && point.y >= 0 && point.x < target.width && point.y < target.height) {
DockModel.reorder(source.group.id, target.group.id);
return;
}
}
}
Component.onCompleted: {
DockState.docks = DockState.docks.concat([root]);
updateVisibility();
}
Component.onDestruction: DockState.docks = DockState.docks.filter(d => d !== root)
anchors {
bottom: !root.vertical
left: root.position === "left"
right: root.position === "right"
}
implicitWidth: vertical ? thickness + options.margin : Math.min(screen.width * 0.9, Math.max(120, grid.implicitWidth + 24))
implicitHeight: vertical ? Math.min(screen.height * 0.85, Math.max(120, grid.implicitHeight + 24)) : thickness + options.margin
color: Theme.transparent
exclusionMode: ExclusionMode.Ignore
WlrLayershell.namespace: "glassMxrph-dock"
WlrLayershell.layer: WlrLayer.Overlay
mask: Region {
item: root.shown ? root.contentItem : sensor
}
HoverHandler {
id: hover
}
Item {
id: sensor
x: root.position === "right" ? root.width - 3 : 0
y: root.vertical ? 0 : root.height - 3
width: root.vertical ? 3 : root.width
height: root.vertical ? root.height : 3
}
Timer {
id: hideTimer
interval: 400
onTriggered: if (!root.wantVisible)
root.shown = false
}
GlassPanel {
id: panel
objectName: "dockSurface"
width: root.vertical ? root.thickness : root.width
height: root.vertical ? root.height : root.thickness
x: root.vertical && root.position === "left" ? root.options.margin : 0
y: 0
opacity: root.shown ? 1 : 0
transform: Translate {
x: root.shown || !root.vertical ? 0 : root.position === "left" ? -root.width : root.width
y: root.shown || root.vertical ? 0 : root.height
Behavior on x {
NumberAnimation {
duration: root.motionDuration
easing.type: Easing.OutCubic
}
}
Behavior on y {
NumberAnimation {
duration: root.motionDuration
easing.type: Easing.OutCubic
}
}
}
Behavior on opacity {
NumberAnimation {
duration: root.motionDuration
}
}
Flickable {
id: view
anchors.fill: parent
anchors.margins: 10
clip: true
contentWidth: root.vertical ? width : grid.implicitWidth
contentHeight: root.vertical ? grid.implicitHeight : height
boundsBehavior: Flickable.StopAtBounds
flickableDirection: root.vertical ? Flickable.VerticalFlick : Flickable.HorizontalFlick
Grid {
id: grid
columns: root.vertical ? 1 : Math.max(1, DockModel.items.length)
spacing: root.options.spacing
x: root.vertical ? (view.width - width) / 2 : 0
y: root.vertical ? 0 : (view.height - height) / 2
Repeater {
model: ScriptModel {
values: DockModel.items
objectProp: "id"
}
DockItem {
dockWindow: root
}
}
}
Text {
anchors.centerIn: parent
visible: DockModel.items.length === 0
text: "Add apps"
color: Theme.textSecondary
font.pixelSize: 13
}
MouseArea {
anchors.fill: parent
enabled: DockModel.items.length === 0
onClicked: ShellState.openSettings("dock")
}
}
}
}