nosignal-shell/modules/drawers/Interactions.qml
2 * r + 2 * t 24a3da8138 feat: bar popouts
Create active window popout
2025-06-02 16:31:26 +08:00

81 lines
2.5 KiB
QML

import "root:/services"
import "root:/config"
import "root:/modules/osd" as Osd
import Quickshell
import QtQuick
MouseArea {
id: root
required property ShellScreen screen
required property PersistentProperties visibilities
required property Panels panels
property bool osdHovered
property point dragStart
function withinPanelHeight(panel: Item, x: real, y: real): bool {
const panelY = BorderConfig.thickness + panel.y;
return y >= panelY && y <= panelY + panel.height;
}
function inRightPanel(panel: Item, x: real, y: real): bool {
return x > BorderConfig.thickness + panel.x && withinPanelHeight(panel, x, y);
}
function inTopPanel(panel: Item, x: real, y: real): bool {
const panelX = BorderConfig.thickness + panel.x;
return y < BorderConfig.thickness + panel.y + panel.height && x >= panelX && x <= panelX + panel.width;
}
anchors.fill: parent
hoverEnabled: true
onPressed: event => dragStart = Qt.point(event.x, event.y)
onContainsMouseChanged: {
if (!containsMouse) {
visibilities.osd = false;
osdHovered = false;
visibilities.dashboard = false;
Popouts.hasCurrent = false;
}
}
onPositionChanged: ({x, y}) => {
// Show osd on hover
const showOsd = inRightPanel(panels.osd, x, y);
visibilities.osd = showOsd;
osdHovered = showOsd;
// Show/hide session on drag
if (pressed && withinPanelHeight(panels.session, x, y)) {
const dragX = x - dragStart.x;
if (dragX < -SessionConfig.dragThreshold)
visibilities.session = true;
else if (dragX > SessionConfig.dragThreshold)
visibilities.session = false;
}
// Show dashboard on hover
const showDashboard = root.inTopPanel(panels.dashboard, x, y);
visibilities.dashboard = showDashboard;
// Show popouts on hover
const popout = panels.popouts;
if (x < BorderConfig.thickness + popout.width) {
if (x < BorderConfig.thickness)
// Handle like part of bar
Visibilities.bars[screen].checkPopout(y);
else
// Keep on hover
Popouts.hasCurrent = withinPanelHeight(popout, x, y);
} else
Popouts.hasCurrent = false;
}
Osd.Interactions {
screen: root.screen
visibilities: root.visibilities
hovered: root.osdHovered
}
}