osd: fix show on hover + show on audio/brightness change
This commit is contained in:
parent
1656e5c355
commit
9c3e2fffbd
5 changed files with 91 additions and 5 deletions
|
|
@ -80,6 +80,7 @@ Variants {
|
||||||
}
|
}
|
||||||
|
|
||||||
Interactions {
|
Interactions {
|
||||||
|
screen: scope.modelData
|
||||||
visibilities: visibilities
|
visibilities: visibilities
|
||||||
|
|
||||||
Panels {
|
Panels {
|
||||||
|
|
|
||||||
|
|
@ -1,22 +1,44 @@
|
||||||
import "root:/services"
|
import "root:/services"
|
||||||
import "root:/config"
|
import "root:/config"
|
||||||
|
import "root:/modules/osd" as Osd
|
||||||
import Quickshell
|
import Quickshell
|
||||||
import QtQuick
|
import QtQuick
|
||||||
|
|
||||||
MouseArea {
|
MouseArea {
|
||||||
|
id: root
|
||||||
|
|
||||||
|
required property ShellScreen screen
|
||||||
required property PersistentProperties visibilities
|
required property PersistentProperties visibilities
|
||||||
|
|
||||||
|
property bool osdHovered
|
||||||
property point dragStart
|
property point dragStart
|
||||||
|
|
||||||
|
function inOsd(x: real, y: real): bool {
|
||||||
|
const osd = panels.osd;
|
||||||
|
return x > width - BorderConfig.thickness - osd.width && y >= osd.y && y <= osd.y + osd.height;
|
||||||
|
}
|
||||||
|
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
hoverEnabled: true
|
hoverEnabled: true
|
||||||
|
|
||||||
onPressed: event => dragStart = Qt.point(event.x, event.y)
|
onPressed: event => dragStart = Qt.point(event.x, event.y)
|
||||||
onExited: visibilities.osd = false
|
|
||||||
|
|
||||||
onPositionChanged: ({x, y}) => {
|
Connections {
|
||||||
|
target: Hyprland
|
||||||
|
|
||||||
|
function onCursorPosChanged(): void {
|
||||||
|
const {x, y} = Hyprland.cursorPos;
|
||||||
|
|
||||||
// Show osd on hover
|
// Show osd on hover
|
||||||
const osd = panels.osd;
|
const showOsd = root.inOsd(x, y);
|
||||||
visibilities.osd = (x > width - BorderConfig.thickness - osd.width && y >= osd.y && y <= osd.y + osd.height);
|
root.visibilities.osd = showOsd;
|
||||||
|
root.osdHovered = showOsd;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Osd.Interactions {
|
||||||
|
screen: root.screen
|
||||||
|
visibilities: root.visibilities
|
||||||
|
hovered: root.osdHovered
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
48
modules/osd/Interactions.qml
Normal file
48
modules/osd/Interactions.qml
Normal file
|
|
@ -0,0 +1,48 @@
|
||||||
|
import "root:/services"
|
||||||
|
import "root:/config"
|
||||||
|
import Quickshell
|
||||||
|
import QtQuick
|
||||||
|
|
||||||
|
Scope {
|
||||||
|
id: root
|
||||||
|
|
||||||
|
required property ShellScreen screen
|
||||||
|
required property PersistentProperties visibilities
|
||||||
|
required property bool hovered
|
||||||
|
readonly property Brightness.Monitor monitor: Brightness.getMonitorForScreen(screen)
|
||||||
|
|
||||||
|
function show(): void {
|
||||||
|
root.visibilities.osd = true;
|
||||||
|
timer.restart();
|
||||||
|
}
|
||||||
|
|
||||||
|
Connections {
|
||||||
|
target: Audio
|
||||||
|
|
||||||
|
function onMutedChanged(): void {
|
||||||
|
root.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
function onVolumeChanged(): void {
|
||||||
|
root.show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Connections {
|
||||||
|
target: root.monitor
|
||||||
|
|
||||||
|
function onBrightnessChanged(): void {
|
||||||
|
root.show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Timer {
|
||||||
|
id: timer
|
||||||
|
|
||||||
|
interval: OsdConfig.hideDelay
|
||||||
|
onTriggered: {
|
||||||
|
if (!root.hovered)
|
||||||
|
root.visibilities.osd = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -95,6 +95,7 @@ Singleton {
|
||||||
if (Math.round(brightness * 100) === rounded)
|
if (Math.round(brightness * 100) === rounded)
|
||||||
return;
|
return;
|
||||||
brightness = value;
|
brightness = value;
|
||||||
|
console.log(brightness)
|
||||||
setProc.command = isDdc ? ["ddcutil", "-b", busNum, "setvcp", "10", rounded] : ["brightnessctl", "s", `${rounded}%`];
|
setProc.command = isDdc ? ["ddcutil", "-b", busNum, "setvcp", "10", rounded] : ["brightnessctl", "s", `${rounded}%`];
|
||||||
setProc.startDetached();
|
setProc.startDetached();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@ Singleton {
|
||||||
readonly property HyprlandWorkspace activeWorkspace: focusedMonitor?.activeWorkspace ?? null
|
readonly property HyprlandWorkspace activeWorkspace: focusedMonitor?.activeWorkspace ?? null
|
||||||
readonly property HyprlandMonitor focusedMonitor: Hyprland.focusedMonitor
|
readonly property HyprlandMonitor focusedMonitor: Hyprland.focusedMonitor
|
||||||
readonly property int activeWsId: activeWorkspace?.id ?? 1
|
readonly property int activeWsId: activeWorkspace?.id ?? 1
|
||||||
|
property point cursorPos
|
||||||
|
|
||||||
function reload() {
|
function reload() {
|
||||||
Hyprland.refreshWorkspaces();
|
Hyprland.refreshWorkspaces();
|
||||||
|
|
@ -38,6 +39,19 @@ Singleton {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FrameAnimation {
|
||||||
|
running: true
|
||||||
|
onTriggered: getCursorPos.running = true
|
||||||
|
}
|
||||||
|
|
||||||
|
Process {
|
||||||
|
id: getCursorPos
|
||||||
|
command: ["hyprctl", "cursorpos"]
|
||||||
|
stdout: SplitParser {
|
||||||
|
onRead: data => root.cursorPos = data
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Process {
|
Process {
|
||||||
id: getClients
|
id: getClients
|
||||||
command: ["sh", "-c", "hyprctl -j clients | jq -c"]
|
command: ["sh", "-c", "hyprctl -j clients | jq -c"]
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue