repositories / dotfiles
dotfiles
bugabingas dorkfiles
owned by admin
quickshell/nuguland/OverlayHost.qml
Rawpragma ComponentBehavior: Bound
import QtQuick
import Quickshell
import Quickshell.Wayland
// Controller for registry entries of kind "overlay": glance-only layer-shell
// surfaces. Owns surface creation, screen selection (primary screen only, so a
// value never shows once per screen), placement (top-right, below nothing: the
// panel offsets its own content) and input policy (no keyboard focus, no
// exclusive zone). Never renders feature content; it loads the entry's panel.
// Also hosts every entry's `focusOverlay`: the same input policy on the focused
// output, filling the output's area outside the bar.
Scope {
id: root
required property Registry registry
required property string primaryScreenName
// Focus overlays only: the focused output's name, and the bar's thickness and
// orientation on the primary screen; null means the primary screen and no bar.
property Niri niriService: null
property SurfaceManager surfaces: null
readonly property string focusedScreenName: String((root.niriService ? root.niriService.focusedOutputName : "") || root.primaryScreenName)
// Mapped surface of one overlay entry, or null while hidden; read-only, for
// diagnostics and fixtures.
function surface(name: string): PanelWindow {
for (const perFeature of features.instances)
for (const window of (perFeature as Variants).instances) {
const panel = window as PanelWindow;
if (panel.objectName === `${name}OverlaySurface` && panel.visible)
return panel;
}
return null;
}
// Mapped focus overlay of one entry, or null while hidden; read-only, for fixtures.
function focusSurface(name: string): PanelWindow {
for (const perFeature of focusFeatures.instances)
for (const window of (perFeature as Variants).instances) {
const panel = window as PanelWindow;
if (panel.objectName === `${name}FocusOverlaySurface` && panel.visible)
return panel;
}
return null;
}
Variants {
id: features
model: root.registry.overlays
delegate: Component {
Variants {
id: perFeature
required property FeatureEntry modelData
model: Quickshell.screens
delegate: Component {
PanelWindow {
required property ShellScreen modelData
objectName: `${perFeature.modelData.name}OverlaySurface`
screen: modelData
visible: perFeature.modelData.kind === "overlay" && perFeature.modelData.overlayShown && modelData.name === root.primaryScreenName
implicitWidth: perFeature.modelData.width
implicitHeight: panelLoader.implicitHeight
color: "transparent"
exclusionMode: ExclusionMode.Ignore
WlrLayershell.layer: WlrLayer.Overlay
WlrLayershell.namespace: `nuguland-${perFeature.modelData.name}`
WlrLayershell.keyboardFocus: WlrKeyboardFocus.None
anchors {
top: true
right: true
}
Loader {
id: panelLoader
anchors.fill: parent
sourceComponent: perFeature.modelData.panel
}
// empty input region: the overlay never takes clicks,
// they pass through to whatever lies beneath
mask: Region {}
}
}
}
}
}
Variants {
id: focusFeatures
model: root.registry.focusOverlays
delegate: Component {
Variants {
id: focusFeature
required property FeatureEntry modelData
model: Quickshell.screens
delegate: Component {
PanelWindow {
id: focusWindow
required property ShellScreen modelData
// The bar lives on the primary screen only.
readonly property int barThickness: root.surfaces && modelData.name === root.primaryScreenName ? root.surfaces.barHeight : 0
readonly property bool verticalBar: !!root.surfaces && root.surfaces.orientation === "vertical"
objectName: `${focusFeature.modelData.name}FocusOverlaySurface`
screen: modelData
visible: focusFeature.modelData.focusOverlayShown && String(modelData.name || "") === root.focusedScreenName
implicitWidth: 1
implicitHeight: 1
color: "transparent"
exclusionMode: ExclusionMode.Ignore
WlrLayershell.layer: WlrLayer.Overlay
WlrLayershell.namespace: `nuguland-${focusFeature.modelData.name}-overlay`
WlrLayershell.keyboardFocus: WlrKeyboardFocus.None
anchors {
top: true
left: true
right: true
bottom: true
}
Loader {
x: focusWindow.verticalBar ? focusWindow.barThickness : 0
y: focusWindow.verticalBar ? 0 : focusWindow.barThickness
width: Math.max(1, focusWindow.width - x)
height: Math.max(1, focusWindow.height - y)
sourceComponent: focusFeature.modelData.focusOverlay
}
mask: Region {}
}
}
}
}
}
}