feat: show osd on border hover

This commit is contained in:
2 * r + 2 * t 2025-05-05 20:21:56 +10:00
parent c650f4392d
commit 137fd56bb2
3 changed files with 38 additions and 0 deletions

View file

@ -68,6 +68,12 @@ Scope {
LayerShadow { LayerShadow {
source: effect source: effect
} }
MouseArea {
anchors.fill: parent
hoverEnabled: true
onPositionChanged: event => Drawers.setPosForScreen(root.screen, event.x, event.y)
}
} }
ExclusionZone { ExclusionZone {

View file

@ -12,6 +12,7 @@ Variants {
required property ShellScreen modelData required property ShellScreen modelData
readonly property Brightness.Monitor monitor: Brightness.getMonitorForScreen(modelData) readonly property Brightness.Monitor monitor: Brightness.getMonitorForScreen(modelData)
property int winHeight
property bool osdVisible property bool osdVisible
property bool hovered property bool hovered
@ -50,6 +51,15 @@ Variants {
} }
} }
Connections {
target: Drawers
function onPosChanged(screen: ShellScreen, x: int, y: int): void {
if (screen === root.modelData && x > screen.width / 2 && y > (screen.height - root.winHeight) / 2 && y < (screen.height + root.winHeight) / 2)
root.show();
}
}
LazyLoader { LazyLoader {
loading: true loading: true
@ -68,6 +78,8 @@ Variants {
anchors.right: true anchors.right: true
height: wrapper.height height: wrapper.height
Component.onCompleted: root.winHeight = height
Background { Background {
id: bg id: bg

20
services/Drawers.qml Normal file
View file

@ -0,0 +1,20 @@
pragma Singleton
import Quickshell
Singleton {
id: root
property var positions: ({})
signal posChanged(screen: ShellScreen, x: int, y: int)
function getPosForScreen(screen: ShellScreen): point {
return positions[screen] || Qt.point(0, 0);
}
function setPosForScreen(screen: ShellScreen, x: int, y: int): void {
positions[screen] = Qt.point(x, y);
posChanged(screen, x, y);
}
}