session: show/hide on drag

This commit is contained in:
2 * r + 2 * t 2025-05-13 19:15:02 +10:00
parent 3fd429c9f3
commit ea4aedd625
3 changed files with 18 additions and 4 deletions

View file

@ -4,6 +4,7 @@ import Quickshell
import QtQuick
Singleton {
readonly property int dragThreshold: 30
readonly property Sizes sizes: Sizes {}
component Sizes: QtObject {

View file

@ -13,9 +13,12 @@ MouseArea {
property bool osdHovered
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;
function withinPanelHeight(panel: Item, x: real, y: real): bool {
return y >= panel.y && y <= panel.y + panel.height;
}
function inRightPanel(panel: Item, x: real, y: real): bool {
return x > panel.x && withinPanelHeight(panel, x, y);
}
anchors.fill: parent
@ -30,9 +33,18 @@ MouseArea {
const {x, y} = Hyprland.cursorPos;
// Show osd on hover
const showOsd = root.inOsd(x, y);
const showOsd = root.inRightPanel(panels.osd, x, y);
root.visibilities.osd = showOsd;
root.osdHovered = showOsd;
// Show/hide session on drag
if (root.pressed && root.withinPanelHeight(panels.session, x, y)) {
const dragX = x - root.dragStart.x;
if (dragX < -SessionConfig.dragThreshold)
root.visibilities.session = true;
else if (dragX > SessionConfig.dragThreshold)
root.visibilities.session = false;
}
}
}

View file

@ -21,6 +21,7 @@ Item {
Osd.Wrapper {
id: osd
clip: root.visibilities.session
screen: root.screen
visibility: root.visibilities.osd