session: show/hide on drag
This commit is contained in:
parent
3fd429c9f3
commit
ea4aedd625
3 changed files with 18 additions and 4 deletions
|
|
@ -4,6 +4,7 @@ import Quickshell
|
||||||
import QtQuick
|
import QtQuick
|
||||||
|
|
||||||
Singleton {
|
Singleton {
|
||||||
|
readonly property int dragThreshold: 30
|
||||||
readonly property Sizes sizes: Sizes {}
|
readonly property Sizes sizes: Sizes {}
|
||||||
|
|
||||||
component Sizes: QtObject {
|
component Sizes: QtObject {
|
||||||
|
|
|
||||||
|
|
@ -13,9 +13,12 @@ MouseArea {
|
||||||
property bool osdHovered
|
property bool osdHovered
|
||||||
property point dragStart
|
property point dragStart
|
||||||
|
|
||||||
function inOsd(x: real, y: real): bool {
|
function withinPanelHeight(panel: Item, x: real, y: real): bool {
|
||||||
const osd = panels.osd;
|
return y >= panel.y && y <= panel.y + panel.height;
|
||||||
return x > width - BorderConfig.thickness - osd.width && y >= osd.y && y <= osd.y + osd.height;
|
}
|
||||||
|
|
||||||
|
function inRightPanel(panel: Item, x: real, y: real): bool {
|
||||||
|
return x > panel.x && withinPanelHeight(panel, x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
|
@ -30,9 +33,18 @@ MouseArea {
|
||||||
const {x, y} = Hyprland.cursorPos;
|
const {x, y} = Hyprland.cursorPos;
|
||||||
|
|
||||||
// Show osd on hover
|
// Show osd on hover
|
||||||
const showOsd = root.inOsd(x, y);
|
const showOsd = root.inRightPanel(panels.osd, x, y);
|
||||||
root.visibilities.osd = showOsd;
|
root.visibilities.osd = showOsd;
|
||||||
root.osdHovered = 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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,7 @@ Item {
|
||||||
Osd.Wrapper {
|
Osd.Wrapper {
|
||||||
id: osd
|
id: osd
|
||||||
|
|
||||||
|
clip: root.visibilities.session
|
||||||
screen: root.screen
|
screen: root.screen
|
||||||
visibility: root.visibilities.osd
|
visibility: root.visibilities.osd
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue