Compare commits
3
Commits
ebace10767
...
178041edf9
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
178041edf9 | ||
|
|
aecee213f8 | ||
|
|
cc0ae50b95 |
No files matched your search
@@ -145,6 +145,16 @@ MetricsService owns a single demand-driven streaming Python collector. MetricsCa
|
|||||||
|
|
||||||
Theme owns contrast selection and reduced-motion intensity. Shared glass components add inexpensive highlights and reversible motion without per-panel blur effects. ScreenService validates captured output references. MetricsService owns bounded restart backoff. The optional compositor example and read-only doctor keep host integration separate from UI state.
|
Theme owns contrast selection and reduced-motion intensity. Shared glass components add inexpensive highlights and reversible motion without per-panel blur effects. ScreenService validates captured output references. MetricsService owns bounded restart backoff. The optional compositor example and read-only doctor keep host integration separate from UI state.
|
||||||
|
|
||||||
|
## Workspace overview
|
||||||
|
|
||||||
|
`overview/Overview.qml` is a bar drawer (`glassmxrph overview`, IPC `overview`) with one
|
||||||
|
thumbnail per workspace, `bar.workspaces.count` of them in balanced rows of up to five
|
||||||
|
(`OverviewLogic.js`, tested in `tests/overview.test.cjs`). Each thumbnail shows its
|
||||||
|
monitor's wallpaper and that workspace's windows at their real geometry, live through
|
||||||
|
ScreencopyView only while the drawer is open. Tiles are keyed by window address so title
|
||||||
|
changes keep their previews. Clicks, drags and middle-clicks go through HyprlandService
|
||||||
|
(`focusWorkspace`, `moveToWorkspace`, `closeWindow`).
|
||||||
|
|
||||||
## Notifications
|
## Notifications
|
||||||
|
|
||||||
`NotificationService` owns the one native `NotificationServer` (org.freedesktop.Notifications),
|
`NotificationService` owns the one native `NotificationServer` (org.freedesktop.Notifications),
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ Singleton {
|
|||||||
property var wallpaperScreen: null
|
property var wallpaperScreen: null
|
||||||
property var wallpaperWindow: null
|
property var wallpaperWindow: null
|
||||||
function openWallpaperPicker() {
|
function openWallpaperPicker() {
|
||||||
settingsOpen=false;launcherOpen=false;controlCenterOpen=false;dashboardOpen=false;
|
settingsOpen=false;launcherOpen=false;controlCenterOpen=false;dashboardOpen=false;overviewOpen=false;
|
||||||
wallpaperScreen=activeScreen();wallpaperPickerOpen=true;
|
wallpaperScreen=activeScreen();wallpaperPickerOpen=true;
|
||||||
}
|
}
|
||||||
property var systemPills: []
|
property var systemPills: []
|
||||||
@@ -16,6 +16,7 @@ Singleton {
|
|||||||
property var controlCenterWindow: null
|
property var controlCenterWindow: null
|
||||||
function openControlCenter() {
|
function openControlCenter() {
|
||||||
wallpaperPickerOpen=false;
|
wallpaperPickerOpen=false;
|
||||||
|
overviewOpen = false;
|
||||||
dashboardOpen = false;
|
dashboardOpen = false;
|
||||||
if (controlCenterOpen)
|
if (controlCenterOpen)
|
||||||
return;
|
return;
|
||||||
@@ -37,6 +38,7 @@ Singleton {
|
|||||||
property string dashboardTab: ""
|
property string dashboardTab: ""
|
||||||
function openDashboard(tab) {
|
function openDashboard(tab) {
|
||||||
wallpaperPickerOpen = false;
|
wallpaperPickerOpen = false;
|
||||||
|
overviewOpen = false;
|
||||||
controlCenterOpen = false;
|
controlCenterOpen = false;
|
||||||
launcherOpen = false;
|
launcherOpen = false;
|
||||||
settingsOpen = false;
|
settingsOpen = false;
|
||||||
@@ -52,6 +54,26 @@ Singleton {
|
|||||||
else
|
else
|
||||||
openDashboard(tab);
|
openDashboard(tab);
|
||||||
}
|
}
|
||||||
|
// Workspace overview (SUPER+Tab): a drawer of live workspace thumbnails.
|
||||||
|
property bool overviewOpen: false
|
||||||
|
property var overviewScreen: null
|
||||||
|
property var overviewWindow: null
|
||||||
|
function openOverview() {
|
||||||
|
wallpaperPickerOpen = false;
|
||||||
|
controlCenterOpen = false;
|
||||||
|
dashboardOpen = false;
|
||||||
|
launcherOpen = false;
|
||||||
|
settingsOpen = false;
|
||||||
|
if (!overviewOpen)
|
||||||
|
overviewScreen = activeScreen();
|
||||||
|
overviewOpen = true;
|
||||||
|
}
|
||||||
|
function toggleOverview() {
|
||||||
|
if (overviewOpen)
|
||||||
|
overviewOpen = false;
|
||||||
|
else
|
||||||
|
openOverview();
|
||||||
|
}
|
||||||
property bool launcherOpen: false
|
property bool launcherOpen: false
|
||||||
property var launcherScreen: null
|
property var launcherScreen: null
|
||||||
// "apps" searches applications and commands; "clipboard" is Clipboard History;
|
// "apps" searches applications and commands; "clipboard" is Clipboard History;
|
||||||
@@ -63,6 +85,7 @@ Singleton {
|
|||||||
}
|
}
|
||||||
function openLauncher(mode) {
|
function openLauncher(mode) {
|
||||||
wallpaperPickerOpen=false;
|
wallpaperPickerOpen=false;
|
||||||
|
overviewOpen = false;
|
||||||
dashboardOpen = false;
|
dashboardOpen = false;
|
||||||
launcherMode = mode === "clipboard" || mode === "emoji" ? mode : "apps";
|
launcherMode = mode === "clipboard" || mode === "emoji" ? mode : "apps";
|
||||||
if (launcherOpen)
|
if (launcherOpen)
|
||||||
@@ -107,6 +130,7 @@ Singleton {
|
|||||||
}
|
}
|
||||||
function openSettings(page) {
|
function openSettings(page) {
|
||||||
wallpaperPickerOpen=false;
|
wallpaperPickerOpen=false;
|
||||||
|
overviewOpen = false;
|
||||||
dashboardOpen = false;
|
dashboardOpen = false;
|
||||||
controlCenterOpen = false;
|
controlCenterOpen = false;
|
||||||
launcherOpen = false;
|
launcherOpen = false;
|
||||||
|
|||||||
@@ -0,0 +1,452 @@
|
|||||||
|
pragma ComponentBehavior: Bound
|
||||||
|
import QtQuick
|
||||||
|
import Quickshell
|
||||||
|
import Quickshell.Hyprland
|
||||||
|
import Quickshell.Io
|
||||||
|
import Quickshell.Wayland
|
||||||
|
import Quickshell.Widgets
|
||||||
|
import "../components"
|
||||||
|
import "../core"
|
||||||
|
import "../services"
|
||||||
|
import "../theme"
|
||||||
|
import "OverviewLogic.js" as Logic
|
||||||
|
import "../services/AppMatching.js" as Matching
|
||||||
|
|
||||||
|
// Workspace overview (SUPER+Tab): a drawer out of the bar with one live
|
||||||
|
// thumbnail per workspace (bar.workspaces.count of them), drawn over that
|
||||||
|
// monitor's wallpaper. Click a workspace (or a window on it) to go there, drag a window
|
||||||
|
// onto another workspace to move it, middle-click a window to close it.
|
||||||
|
// Arrows/1–9 pick a workspace, Enter goes there, Esc closes.
|
||||||
|
// qmllint disable uncreatable-type
|
||||||
|
PanelWindow {
|
||||||
|
// qmllint enable uncreatable-type
|
||||||
|
id: root
|
||||||
|
screen: ScreenService.current(ShellState.overviewScreen)
|
||||||
|
anchors.top: true
|
||||||
|
readonly property real screenWidth: screen ? screen.width : 1920
|
||||||
|
readonly property real screenHeight: screen ? screen.height : 1080
|
||||||
|
implicitWidth: Math.max(120, Math.round(surface.width))
|
||||||
|
implicitHeight: Math.max(60, Math.round(BarDrawers.bottom + surface.contentHeight))
|
||||||
|
visible: ShellState.overviewOpen || surface.shown
|
||||||
|
color: Theme.transparent
|
||||||
|
exclusionMode: ExclusionMode.Ignore
|
||||||
|
WlrLayershell.namespace: "glassMxrph-overview"
|
||||||
|
WlrLayershell.layer: WlrLayer.Overlay
|
||||||
|
WlrLayershell.keyboardFocus: ShellState.overviewOpen ? WlrKeyboardFocus.Exclusive : WlrKeyboardFocus.None
|
||||||
|
Component.onCompleted: ShellState.overviewWindow = root
|
||||||
|
Component.onDestruction: ShellState.overviewWindow = null
|
||||||
|
|
||||||
|
readonly property bool live: ShellState.overviewOpen
|
||||||
|
readonly property var layout: Logic.grid(ConfigService.ready ? ConfigService.data.bar.workspaces.count : 9)
|
||||||
|
readonly property int focusedId: Hyprland.focusedWorkspace ? Hyprland.focusedWorkspace.id : 0
|
||||||
|
// Workspaces shown on other monitors get a faint outline, as in the bar.
|
||||||
|
readonly property var visibleIds: Hyprland.monitors.values.map(m => m.activeWorkspace ? m.activeWorkspace.id : 0).filter(id => id > 0 && id !== focusedId)
|
||||||
|
readonly property int padding: 20
|
||||||
|
readonly property int gap: 14
|
||||||
|
readonly property int header: 40
|
||||||
|
// Thumbnails keep this screen's aspect ratio.
|
||||||
|
readonly property real aspect: screenHeight > 0 ? screenWidth / screenHeight : 16 / 9
|
||||||
|
readonly property real maxWidth: Math.min(1320, screenWidth - 2 * (BarDrawers.margin + BarDrawers.radius + BarDrawers.ear))
|
||||||
|
readonly property real thumbWidth: Math.floor(Math.min(300, (maxWidth - 2 * padding - (layout.columns - 1) * gap) / layout.columns, (screenHeight * 0.62 / layout.rows - gap) * aspect))
|
||||||
|
readonly property real thumbHeight: Math.round(thumbWidth / aspect)
|
||||||
|
readonly property real thumbRadius: Math.max(8, Theme.radius * 0.6)
|
||||||
|
|
||||||
|
property int selected: 0
|
||||||
|
property string hoveredTitle: ""
|
||||||
|
// Window being dragged, and the workspace slot under it.
|
||||||
|
property string dragAddress: ""
|
||||||
|
property int dropSlot: -1
|
||||||
|
|
||||||
|
function slotX(index) {
|
||||||
|
return Logic.cell(index, layout).column * (thumbWidth + gap);
|
||||||
|
}
|
||||||
|
function slotY(index) {
|
||||||
|
return Logic.cell(index, layout).row * (thumbHeight + gap);
|
||||||
|
}
|
||||||
|
// Workspace slot under a point in grid coordinates, or -1.
|
||||||
|
function slotAt(x, y) {
|
||||||
|
for (let i = 0; i < layout.count; i++)
|
||||||
|
if (x >= slotX(i) && x < slotX(i) + thumbWidth && y >= slotY(i) && y < slotY(i) + thumbHeight)
|
||||||
|
return i;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
function screenNamed(name) {
|
||||||
|
return Quickshell.screens.find(s => s.name === name) || null;
|
||||||
|
}
|
||||||
|
// The monitor a workspace lives on: Hyprland's, else this drawer's.
|
||||||
|
function monitorOf(id) {
|
||||||
|
const ws = Hyprland.workspaces.values.find(w => w.id === id);
|
||||||
|
return ws && ws.monitor ? ws.monitor.name : (screen ? screen.name : "");
|
||||||
|
}
|
||||||
|
function wallpaperFor(name) {
|
||||||
|
const path = WallpaperService.observed[name] || (ConfigService.ready ? ConfigService.data.wallpaper.byMonitor[name] : "") || "";
|
||||||
|
return path ? "file://" + encodeURI(path).replace(/#/g, "%23").replace(/\?/g, "%3F") : "";
|
||||||
|
}
|
||||||
|
function iconFor(win) {
|
||||||
|
const entry = Matching.match(win.appId, win.initialClass, ApplicationsService.entries, ConfigService.ready ? ConfigService.data.dock.appOverrides : ({}));
|
||||||
|
return entry ? ApplicationsService.icon(entry) : Quickshell.iconPath(String(win.appId || "").toLowerCase(), "application-x-executable");
|
||||||
|
}
|
||||||
|
// Closing hands keyboard focus back, and Hyprland then refocuses the
|
||||||
|
// previous window, pulling back to its workspace if the switch came first.
|
||||||
|
// So release focus, then switch once that has gone through.
|
||||||
|
property int pendingWorkspace: 0
|
||||||
|
function go(index) {
|
||||||
|
pendingWorkspace = index + 1;
|
||||||
|
ShellState.overviewOpen = false;
|
||||||
|
switchDelay.restart();
|
||||||
|
}
|
||||||
|
Timer {
|
||||||
|
id: switchDelay
|
||||||
|
interval: 100
|
||||||
|
onTriggered: {
|
||||||
|
HyprlandService.focusWorkspace(root.pendingWorkspace);
|
||||||
|
root.pendingWorkspace = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function select(index) {
|
||||||
|
if (index >= 0 && index < layout.count)
|
||||||
|
selected = index;
|
||||||
|
}
|
||||||
|
|
||||||
|
Connections {
|
||||||
|
target: ShellState
|
||||||
|
function onOverviewOpenChanged() {
|
||||||
|
if (ShellState.overviewOpen) {
|
||||||
|
HyprlandService.refresh();
|
||||||
|
root.selected = root.focusedId >= 1 && root.focusedId <= root.layout.count ? root.focusedId - 1 : 0;
|
||||||
|
root.hoveredTitle = "";
|
||||||
|
root.dragAddress = "";
|
||||||
|
root.dropSlot = -1;
|
||||||
|
Qt.callLater(() => surface.forceActiveFocus());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Exclusive focus routes outside clicks here (see ControlCenter).
|
||||||
|
MouseArea {
|
||||||
|
x: -20000
|
||||||
|
y: -20000
|
||||||
|
width: 40000
|
||||||
|
height: 40000
|
||||||
|
onPressed: ShellState.overviewOpen = false
|
||||||
|
}
|
||||||
|
|
||||||
|
BarDrawer {
|
||||||
|
id: surface
|
||||||
|
objectName: "overviewSurface"
|
||||||
|
y: BarDrawers.bottom
|
||||||
|
open: ShellState.overviewOpen
|
||||||
|
drawerId: "overview"
|
||||||
|
screenName: root.screen ? root.screen.name : ""
|
||||||
|
screenX: (root.screenWidth - width) / 2
|
||||||
|
contentWidth: 2 * root.padding + root.layout.columns * root.thumbWidth + (root.layout.columns - 1) * root.gap
|
||||||
|
contentHeight: 2 * root.padding + root.header + root.layout.rows * root.thumbHeight + (root.layout.rows - 1) * root.gap
|
||||||
|
focus: ShellState.overviewOpen
|
||||||
|
Keys.onEscapePressed: ShellState.overviewOpen = false
|
||||||
|
Keys.onLeftPressed: root.select(Logic.step(root.selected, "left", root.layout))
|
||||||
|
Keys.onRightPressed: root.select(Logic.step(root.selected, "right", root.layout))
|
||||||
|
Keys.onUpPressed: root.select(Logic.step(root.selected, "up", root.layout))
|
||||||
|
Keys.onDownPressed: root.select(Logic.step(root.selected, "down", root.layout))
|
||||||
|
Keys.onTabPressed: root.select(Logic.step(root.selected, "right", root.layout))
|
||||||
|
Keys.onBacktabPressed: root.select(Logic.step(root.selected, "left", root.layout))
|
||||||
|
Keys.onReturnPressed: root.go(root.selected)
|
||||||
|
Keys.onEnterPressed: root.go(root.selected)
|
||||||
|
Keys.onPressed: event => {
|
||||||
|
const n = event.key - Qt.Key_1;
|
||||||
|
if (n >= 0 && n < Math.min(9, root.layout.count)) {
|
||||||
|
root.go(n);
|
||||||
|
event.accepted = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
MouseArea {
|
||||||
|
anchors.fill: parent
|
||||||
|
} // Consume inside clicks without dismissing.
|
||||||
|
|
||||||
|
// Header: title, then whatever is hovered or selected.
|
||||||
|
Item {
|
||||||
|
x: root.padding
|
||||||
|
y: root.padding - 4
|
||||||
|
width: surface.contentWidth - 2 * root.padding
|
||||||
|
height: root.header
|
||||||
|
Text {
|
||||||
|
id: title
|
||||||
|
anchors.left: parent.left
|
||||||
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
|
text: "Workspaces"
|
||||||
|
color: Theme.text
|
||||||
|
font.pixelSize: 20
|
||||||
|
}
|
||||||
|
Text {
|
||||||
|
anchors.left: title.right
|
||||||
|
anchors.leftMargin: 14
|
||||||
|
anchors.right: closeButton.left
|
||||||
|
anchors.rightMargin: 14
|
||||||
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
|
text: root.dragAddress ? (root.dropSlot >= 0 ? "Move to workspace " + (root.dropSlot + 1) : "Drop on a workspace") : root.hoveredTitle || "Workspace " + (root.selected + 1)
|
||||||
|
color: Theme.textSecondary
|
||||||
|
font.pixelSize: 13
|
||||||
|
elide: Text.ElideRight
|
||||||
|
}
|
||||||
|
GlassIconButton {
|
||||||
|
id: closeButton
|
||||||
|
anchors.right: parent.right
|
||||||
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
|
implicitWidth: 30
|
||||||
|
implicitHeight: 30
|
||||||
|
text: "×"
|
||||||
|
Accessible.name: "Close overview"
|
||||||
|
onClicked: ShellState.overviewOpen = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Item {
|
||||||
|
id: gridArea
|
||||||
|
x: root.padding
|
||||||
|
y: root.padding + root.header
|
||||||
|
width: surface.contentWidth - 2 * root.padding
|
||||||
|
height: root.layout.rows * root.thumbHeight + (root.layout.rows - 1) * root.gap
|
||||||
|
|
||||||
|
Repeater {
|
||||||
|
model: root.layout.count
|
||||||
|
delegate: Item {
|
||||||
|
id: slot
|
||||||
|
required property int index
|
||||||
|
readonly property int workspaceId: index + 1
|
||||||
|
readonly property string monitorName: root.monitorOf(workspaceId)
|
||||||
|
readonly property var monitor: root.screenNamed(monitorName)
|
||||||
|
readonly property bool focused: root.focusedId === workspaceId
|
||||||
|
readonly property bool shownElsewhere: root.visibleIds.includes(workspaceId)
|
||||||
|
readonly property bool chosen: root.selected === index
|
||||||
|
readonly property bool dropTarget: root.dropSlot === index
|
||||||
|
readonly property var windows: root.live ? HyprlandService.windows.filter(w => w.workspace === workspaceId).sort((a, b) => (a.floating - b.floating) || (a.active - b.active)) : []
|
||||||
|
x: root.slotX(index)
|
||||||
|
y: root.slotY(index)
|
||||||
|
width: root.thumbWidth
|
||||||
|
height: root.thumbHeight
|
||||||
|
z: windows.some(w => w.address === root.dragAddress) ? 2 : 0
|
||||||
|
scale: dropTarget ? 1.03 : 1
|
||||||
|
Behavior on scale {
|
||||||
|
NumberAnimation {
|
||||||
|
duration: Theme.duration
|
||||||
|
easing.type: Easing.OutCubic
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ClippingRectangle {
|
||||||
|
anchors.fill: parent
|
||||||
|
radius: root.thumbRadius
|
||||||
|
color: Theme.surfaceVariant
|
||||||
|
Image {
|
||||||
|
anchors.fill: parent
|
||||||
|
source: root.live ? root.wallpaperFor(slot.monitorName) : ""
|
||||||
|
sourceSize: Qt.size(Math.round(root.thumbWidth * 1.5), Math.round(root.thumbHeight * 1.5))
|
||||||
|
fillMode: Image.PreserveAspectCrop
|
||||||
|
asynchronous: true
|
||||||
|
opacity: status === Image.Ready ? (slot.windows.length ? 0.55 : 0.4) : 0
|
||||||
|
Behavior on opacity {
|
||||||
|
NumberAnimation {
|
||||||
|
duration: Theme.duration
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Empty workspaces show their number large.
|
||||||
|
Text {
|
||||||
|
anchors.centerIn: parent
|
||||||
|
visible: !slot.windows.length
|
||||||
|
text: slot.workspaceId
|
||||||
|
color: Qt.alpha(Theme.text, 0.35)
|
||||||
|
font.pixelSize: root.thumbHeight * 0.38
|
||||||
|
font.weight: Font.DemiBold
|
||||||
|
}
|
||||||
|
Rectangle {
|
||||||
|
anchors.fill: parent
|
||||||
|
color: workspaceArea.containsMouse && !root.dragAddress ? Theme.hover : Theme.transparent
|
||||||
|
Behavior on color {
|
||||||
|
ColorAnimation {
|
||||||
|
duration: Theme.duration / 2
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
MouseArea {
|
||||||
|
id: workspaceArea
|
||||||
|
anchors.fill: parent
|
||||||
|
hoverEnabled: true
|
||||||
|
cursorShape: Qt.PointingHandCursor
|
||||||
|
onContainsMouseChanged: if (containsMouse) {
|
||||||
|
root.select(slot.index);
|
||||||
|
root.hoveredTitle = "";
|
||||||
|
}
|
||||||
|
onClicked: root.go(slot.index)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Windows, scaled from their monitor into the thumbnail.
|
||||||
|
// Keyed by address so title changes keep each live preview.
|
||||||
|
Repeater {
|
||||||
|
model: ScriptModel {
|
||||||
|
values: slot.windows
|
||||||
|
objectProp: "address"
|
||||||
|
}
|
||||||
|
delegate: Item {
|
||||||
|
id: tile
|
||||||
|
required property var modelData
|
||||||
|
readonly property var win: slot.windows.find(w => w.address === modelData.address) || modelData
|
||||||
|
readonly property var rect: Logic.project(win, slot.monitor ? {
|
||||||
|
x: slot.monitor.x,
|
||||||
|
y: slot.monitor.y,
|
||||||
|
width: slot.monitor.width,
|
||||||
|
height: slot.monitor.height
|
||||||
|
} : null, root.thumbWidth, root.thumbHeight)
|
||||||
|
readonly property bool dragging: root.dragAddress === win.address
|
||||||
|
visible: !!rect
|
||||||
|
x: rect ? rect.x : 0
|
||||||
|
y: rect ? rect.y : 0
|
||||||
|
width: rect ? Math.max(6, rect.width) : 0
|
||||||
|
height: rect ? Math.max(6, rect.height) : 0
|
||||||
|
z: dragging ? 10 : 0
|
||||||
|
opacity: dragging ? 0.85 : 1
|
||||||
|
ClippingRectangle {
|
||||||
|
anchors.fill: parent
|
||||||
|
anchors.margins: 1
|
||||||
|
radius: Math.max(4, root.thumbRadius * 0.5)
|
||||||
|
color: Qt.alpha(Theme.surface, 0.6)
|
||||||
|
border.width: 1
|
||||||
|
border.color: windowArea.containsMouse || tile.dragging ? Theme.accent : Theme.hairline
|
||||||
|
ScreencopyView {
|
||||||
|
id: preview
|
||||||
|
anchors.fill: parent
|
||||||
|
captureSource: root.live && tile.win.handle ? tile.win.handle : null
|
||||||
|
live: root.live
|
||||||
|
constraintSize: Qt.size(Math.round(tile.width * 2), Math.round(tile.height * 2))
|
||||||
|
opacity: hasContent ? 1 : 0
|
||||||
|
Behavior on opacity {
|
||||||
|
NumberAnimation {
|
||||||
|
duration: Theme.duration
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// App icon: the whole tile until the preview arrives, a badge after.
|
||||||
|
Rectangle {
|
||||||
|
readonly property real size: preview.hasContent ? Math.min(26, Math.max(16, Math.min(tile.width, tile.height) * 0.28)) : Math.min(40, Math.min(tile.width, tile.height) * 0.5)
|
||||||
|
visible: size >= 12
|
||||||
|
width: size + 6
|
||||||
|
height: size + 6
|
||||||
|
radius: width / 2.6
|
||||||
|
anchors.centerIn: preview.hasContent ? undefined : parent
|
||||||
|
anchors.right: preview.hasContent ? parent.right : undefined
|
||||||
|
anchors.bottom: preview.hasContent ? parent.bottom : undefined
|
||||||
|
anchors.margins: 4
|
||||||
|
color: preview.hasContent ? Qt.alpha(Theme.surface, 0.72) : Theme.transparent
|
||||||
|
Image {
|
||||||
|
anchors.centerIn: parent
|
||||||
|
width: parent.size
|
||||||
|
height: parent.size
|
||||||
|
source: root.live ? root.iconFor(tile.win) : ""
|
||||||
|
sourceSize: Qt.size(width * 2, height * 2)
|
||||||
|
asynchronous: true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
MouseArea {
|
||||||
|
id: windowArea
|
||||||
|
anchors.fill: parent
|
||||||
|
hoverEnabled: true
|
||||||
|
acceptedButtons: Qt.LeftButton | Qt.MiddleButton
|
||||||
|
cursorShape: tile.dragging ? Qt.ClosedHandCursor : Qt.PointingHandCursor
|
||||||
|
drag.target: tile
|
||||||
|
drag.threshold: 6
|
||||||
|
onContainsMouseChanged: if (containsMouse) {
|
||||||
|
root.select(slot.index);
|
||||||
|
root.hoveredTitle = tile.win.title || tile.win.appId;
|
||||||
|
} else if (root.hoveredTitle === (tile.win.title || tile.win.appId)) {
|
||||||
|
root.hoveredTitle = "";
|
||||||
|
}
|
||||||
|
onPositionChanged: {
|
||||||
|
if (drag.active && !tile.dragging)
|
||||||
|
root.dragAddress = tile.win.address;
|
||||||
|
if (!tile.dragging)
|
||||||
|
return;
|
||||||
|
const p = tile.mapToItem(gridArea, tile.width / 2, tile.height / 2);
|
||||||
|
root.dropSlot = root.slotAt(p.x, p.y);
|
||||||
|
}
|
||||||
|
onReleased: {
|
||||||
|
if (!tile.dragging)
|
||||||
|
return;
|
||||||
|
const target = root.dropSlot;
|
||||||
|
root.dragAddress = "";
|
||||||
|
root.dropSlot = -1;
|
||||||
|
if (target >= 0 && target !== slot.index && HyprlandService.moveToWorkspace(tile.win.address, target + 1))
|
||||||
|
return; // The window list update re-parents the tile.
|
||||||
|
tile.x = Qt.binding(() => tile.rect ? tile.rect.x : 0);
|
||||||
|
tile.y = Qt.binding(() => tile.rect ? tile.rect.y : 0);
|
||||||
|
}
|
||||||
|
onClicked: mouse => {
|
||||||
|
if (mouse.button === Qt.MiddleButton) {
|
||||||
|
HyprlandService.closeWindow(tile.win.address);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
root.go(slot.index);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Number chip, and the focus/selection rings.
|
||||||
|
Rectangle {
|
||||||
|
visible: slot.windows.length > 0
|
||||||
|
x: 6
|
||||||
|
y: parent.height - height - 6
|
||||||
|
width: Math.max(height, chip.implicitWidth + 12)
|
||||||
|
height: 20
|
||||||
|
radius: 10
|
||||||
|
color: slot.focused ? Theme.accent : Qt.alpha(Theme.surface, 0.72)
|
||||||
|
Text {
|
||||||
|
id: chip
|
||||||
|
anchors.centerIn: parent
|
||||||
|
text: slot.workspaceId
|
||||||
|
color: slot.focused ? Theme.accentText : Theme.text
|
||||||
|
font.pixelSize: 11
|
||||||
|
font.weight: Font.DemiBold
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Rectangle {
|
||||||
|
anchors.fill: parent
|
||||||
|
anchors.margins: -3
|
||||||
|
radius: root.thumbRadius + 3
|
||||||
|
color: Theme.transparent
|
||||||
|
border.width: slot.focused || slot.dropTarget ? 2 : slot.chosen || slot.shownElsewhere ? 1.5 : 1
|
||||||
|
border.color: slot.focused || slot.dropTarget ? Theme.accent : slot.shownElsewhere ? Qt.alpha(Theme.accent, 0.6) : slot.chosen ? Qt.alpha(Theme.text, 0.55) : Theme.hairline
|
||||||
|
Behavior on border.color {
|
||||||
|
ColorAnimation {
|
||||||
|
duration: Theme.duration / 2
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
IpcHandler {
|
||||||
|
target: "overview"
|
||||||
|
function toggle(): void {
|
||||||
|
ShellState.toggleOverview();
|
||||||
|
}
|
||||||
|
function open(): void {
|
||||||
|
ShellState.openOverview();
|
||||||
|
}
|
||||||
|
function close(): void {
|
||||||
|
ShellState.overviewOpen = false;
|
||||||
|
}
|
||||||
|
function status(): string {
|
||||||
|
return JSON.stringify({
|
||||||
|
opened: ShellState.overviewOpen,
|
||||||
|
screen: root.screen ? root.screen.name : "",
|
||||||
|
workspaces: root.layout.count,
|
||||||
|
rows: root.layout.rows,
|
||||||
|
columns: root.layout.columns,
|
||||||
|
selected: root.selected + 1
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,65 @@
|
|||||||
|
// Pure helpers for the workspace overview: the grid of workspace slots,
|
||||||
|
// keyboard movement through it and where a window sits in its thumbnail.
|
||||||
|
|
||||||
|
// Up to five slots a row; rows are balanced (9 → 5 + 4, 6 → 3 + 3).
|
||||||
|
function grid(count) {
|
||||||
|
const n = Math.max(1, Math.floor(count) || 1);
|
||||||
|
const rows = Math.ceil(n / 5);
|
||||||
|
const columns = Math.ceil(n / rows);
|
||||||
|
return {count: n, rows: rows, columns: columns};
|
||||||
|
}
|
||||||
|
|
||||||
|
// Slot index → row and (fractional) column. A short last row is centred.
|
||||||
|
function cell(index, g) {
|
||||||
|
const row = Math.floor(index / g.columns);
|
||||||
|
const inRow = row === g.rows - 1 ? g.count - row * g.columns : g.columns;
|
||||||
|
return {row: row, column: index % g.columns + (g.columns - inRow) / 2};
|
||||||
|
}
|
||||||
|
|
||||||
|
// Next slot for an arrow key ("left", "right", "up", "down"). Left/right
|
||||||
|
// wrap through every slot; up/down pick the nearest slot in the next row,
|
||||||
|
// wrapping from the last row to the first.
|
||||||
|
function step(index, direction, g) {
|
||||||
|
const n = g.count;
|
||||||
|
if (index < 0 || index >= n)
|
||||||
|
return 0;
|
||||||
|
if (direction === "left")
|
||||||
|
return (index - 1 + n) % n;
|
||||||
|
if (direction === "right")
|
||||||
|
return (index + 1) % n;
|
||||||
|
if (g.rows < 2)
|
||||||
|
return index;
|
||||||
|
const here = cell(index, g);
|
||||||
|
const row = (here.row + (direction === "up" ? -1 : 1) + g.rows) % g.rows;
|
||||||
|
let best = -1, distance = Infinity;
|
||||||
|
for (let i = row * g.columns; i < Math.min(n, (row + 1) * g.columns); i++) {
|
||||||
|
const d = Math.abs(cell(i, g).column - here.column);
|
||||||
|
if (d < distance - 1e-6) {
|
||||||
|
best = i;
|
||||||
|
distance = d;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return best;
|
||||||
|
}
|
||||||
|
|
||||||
|
// A window's rectangle inside a width × height thumbnail of its monitor.
|
||||||
|
// The monitor (logical {x, y, width, height}) is fitted into the thumbnail,
|
||||||
|
// centred when the aspect ratios differ, and the window clipped to it.
|
||||||
|
// Returns null when nothing of the window is on the monitor.
|
||||||
|
function project(win, monitor, width, height) {
|
||||||
|
if (!monitor || monitor.width <= 0 || monitor.height <= 0 || win.width <= 0 || win.height <= 0)
|
||||||
|
return null;
|
||||||
|
const s = Math.min(width / monitor.width, height / monitor.height);
|
||||||
|
const ox = (width - monitor.width * s) / 2, oy = (height - monitor.height * s) / 2;
|
||||||
|
const left = Math.max(win.x, monitor.x), top = Math.max(win.y, monitor.y);
|
||||||
|
const right = Math.min(win.x + win.width, monitor.x + monitor.width);
|
||||||
|
const bottom = Math.min(win.y + win.height, monitor.y + monitor.height);
|
||||||
|
if (right <= left || bottom <= top)
|
||||||
|
return null;
|
||||||
|
return {
|
||||||
|
x: ox + (left - monitor.x) * s,
|
||||||
|
y: oy + (top - monitor.y) * s,
|
||||||
|
width: (right - left) * s,
|
||||||
|
height: (bottom - top) * s
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -61,6 +61,24 @@ Singleton {
|
|||||||
return false;
|
return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
function focusWorkspace(id) {
|
||||||
|
if (!Number.isInteger(id) || id < 1)
|
||||||
|
return false;
|
||||||
|
Hyprland.dispatch("hl.dsp.focus({ workspace = '" + id + "' })");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
// Moves a window to a workspace without following it there.
|
||||||
|
function moveToWorkspace(address, id) {
|
||||||
|
if (!/^(0x)?[0-9a-f]+$/i.test(address) || !Number.isInteger(id) || id < 1)
|
||||||
|
return false;
|
||||||
|
Hyprland.dispatch("hl.dsp.window.move({ workspace = '" + id + "', follow = false, window = 'address:" + (address.startsWith("0x") ? address : "0x" + address) + "' })");
|
||||||
|
clientsDebounce.restart();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
// Re-reads window geometry now (Hyprland emits no event for resizes).
|
||||||
|
function refresh() {
|
||||||
|
clientsDebounce.restart();
|
||||||
|
}
|
||||||
Process {
|
Process {
|
||||||
id: clientsQuery
|
id: clientsQuery
|
||||||
command: ["hyprctl", "-j", "clients"]
|
command: ["hyprctl", "-j", "clients"]
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import "widgets"
|
|||||||
import "wallpaper"
|
import "wallpaper"
|
||||||
import "controlcenter"
|
import "controlcenter"
|
||||||
import "dashboard"
|
import "dashboard"
|
||||||
|
import "overview"
|
||||||
import "osd"
|
import "osd"
|
||||||
import "notifications"
|
import "notifications"
|
||||||
import "lock"
|
import "lock"
|
||||||
@@ -36,6 +37,7 @@ ShellRoot {
|
|||||||
WallpaperPicker {}
|
WallpaperPicker {}
|
||||||
ControlCenter {}
|
ControlCenter {}
|
||||||
Dashboard {}
|
Dashboard {}
|
||||||
|
Overview {}
|
||||||
PluginHost {}
|
PluginHost {}
|
||||||
Osd {}
|
Osd {}
|
||||||
NotificationPopups {}
|
NotificationPopups {}
|
||||||
@@ -104,6 +106,7 @@ ShellRoot {
|
|||||||
ShellState.wallpaperPickerOpen = false;
|
ShellState.wallpaperPickerOpen = false;
|
||||||
ShellState.controlCenterOpen = false;
|
ShellState.controlCenterOpen = false;
|
||||||
ShellState.dashboardOpen = false;
|
ShellState.dashboardOpen = false;
|
||||||
|
ShellState.overviewOpen = false;
|
||||||
ShellState.settingsOpen = false;
|
ShellState.settingsOpen = false;
|
||||||
ShellState.launcherOpen = false;
|
ShellState.launcherOpen = false;
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-1
@@ -31,6 +31,9 @@ case "${1:-run}" in
|
|||||||
launcher)
|
launcher)
|
||||||
exec quickshell ipc --path "$project_dir/quickshell" call launcher toggle
|
exec quickshell ipc --path "$project_dir/quickshell" call launcher toggle
|
||||||
;;
|
;;
|
||||||
|
overview)
|
||||||
|
exec quickshell ipc --path "$project_dir/quickshell" call overview toggle
|
||||||
|
;;
|
||||||
clipboard|emoji)
|
clipboard|emoji)
|
||||||
exec quickshell ipc --path "$project_dir/quickshell" call launcher "$1"
|
exec quickshell ipc --path "$project_dir/quickshell" call launcher "$1"
|
||||||
;;
|
;;
|
||||||
@@ -70,5 +73,5 @@ case "${1:-run}" in
|
|||||||
settings|close|status)
|
settings|close|status)
|
||||||
exec quickshell ipc --path "$project_dir/quickshell" call shell "$1"
|
exec quickshell ipc --path "$project_dir/quickshell" call shell "$1"
|
||||||
;;
|
;;
|
||||||
*) echo 'Usage: glassmxrph [run|wallpaper|launcher|clipboard|emoji|dashboard [TAB]|plugin ACTION|controlcenter|lock|widgets|osd ACTION|notifications ACTION|settings|close|status|doctor]' >&2; exit 2 ;;
|
*) echo 'Usage: glassmxrph [run|wallpaper|launcher|overview|clipboard|emoji|dashboard [TAB]|plugin ACTION|controlcenter|lock|widgets|osd ACTION|notifications ACTION|settings|close|status|doctor]' >&2; exit 2 ;;
|
||||||
esac
|
esac
|
||||||
@@ -7,6 +7,7 @@ node "$project_dir/tests/dock.test.cjs"
|
|||||||
node "$project_dir/tests/launcher.test.cjs"
|
node "$project_dir/tests/launcher.test.cjs"
|
||||||
node "$project_dir/tests/widgets.test.cjs"
|
node "$project_dir/tests/widgets.test.cjs"
|
||||||
node "$project_dir/tests/controlcenter.test.cjs"
|
node "$project_dir/tests/controlcenter.test.cjs"
|
||||||
|
node "$project_dir/tests/overview.test.cjs"
|
||||||
python3 "$project_dir/tests/providers_test.py"
|
python3 "$project_dir/tests/providers_test.py"
|
||||||
python3 "$project_dir/tests/system_providers_test.py"
|
python3 "$project_dir/tests/system_providers_test.py"
|
||||||
python3 "$project_dir/tests/metrics_test.py"
|
python3 "$project_dir/tests/metrics_test.py"
|
||||||
|
|||||||
@@ -0,0 +1,42 @@
|
|||||||
|
const assert = require('assert'), fs = require('fs'), path = require('path'), vm = require('vm');
|
||||||
|
const api = vm.createContext({});
|
||||||
|
vm.runInContext(fs.readFileSync(path.join(__dirname, '../quickshell/overview/OverviewLogic.js'), 'utf8'), api);
|
||||||
|
const dims = g => g.rows + 'x' + g.columns;
|
||||||
|
// Balanced rows of at most five.
|
||||||
|
assert.equal(dims(api.grid(9)), '2x5');
|
||||||
|
assert.equal(dims(api.grid(10)), '2x5');
|
||||||
|
assert.equal(dims(api.grid(6)), '2x3');
|
||||||
|
assert.equal(dims(api.grid(4)), '1x4');
|
||||||
|
assert.equal(dims(api.grid(0)), '1x1');
|
||||||
|
assert.equal(dims(api.grid(11)), '3x4');
|
||||||
|
// A short last row is centred.
|
||||||
|
const g9 = api.grid(9);
|
||||||
|
assert.equal(JSON.stringify(api.cell(0, g9)), '{"row":0,"column":0}');
|
||||||
|
assert.equal(JSON.stringify(api.cell(5, g9)), '{"row":1,"column":0.5}');
|
||||||
|
assert.equal(JSON.stringify(api.cell(8, g9)), '{"row":1,"column":3.5}');
|
||||||
|
// Left/right wrap through every slot.
|
||||||
|
assert.equal(api.step(0, 'left', g9), 8);
|
||||||
|
assert.equal(api.step(8, 'right', g9), 0);
|
||||||
|
assert.equal(api.step(4, 'right', g9), 5);
|
||||||
|
// Up/down go to the nearest slot in the other row and wrap.
|
||||||
|
assert.equal(api.step(0, 'down', g9), 5);
|
||||||
|
assert.equal(api.step(4, 'down', g9), 8);
|
||||||
|
assert.equal(api.step(5, 'up', g9), 0);
|
||||||
|
assert.equal(api.step(8, 'up', g9), 3);
|
||||||
|
assert.equal(api.step(6, 'down', g9), 1);
|
||||||
|
assert.equal(api.step(2, 'up', g9), 6);
|
||||||
|
// One row: up/down stay; an unknown slot starts at the first.
|
||||||
|
assert.equal(api.step(2, 'down', api.grid(4)), 2);
|
||||||
|
assert.equal(api.step(-1, 'right', g9), 0);
|
||||||
|
// Windows are scaled into the thumbnail relative to their monitor.
|
||||||
|
const mon = {x: 1920, y: 0, width: 1920, height: 1080};
|
||||||
|
assert.equal(JSON.stringify(api.project({x: 1920, y: 0, width: 960, height: 1080}, mon, 192, 108)), '{"x":0,"y":0,"width":96,"height":108}');
|
||||||
|
// Off-monitor parts are clipped; windows elsewhere are dropped.
|
||||||
|
assert.equal(JSON.stringify(api.project({x: 3600, y: 540, width: 600, height: 1080}, mon, 192, 108)), '{"x":168,"y":54,"width":24,"height":54}');
|
||||||
|
assert.equal(api.project({x: 0, y: 0, width: 800, height: 600}, mon, 192, 108), null);
|
||||||
|
assert.equal(api.project({x: 1920, y: 0, width: 0, height: 10}, mon, 192, 108), null);
|
||||||
|
assert.equal(api.project({x: 0, y: 0, width: 10, height: 10}, null, 192, 108), null);
|
||||||
|
// A portrait monitor in a landscape thumbnail is centred.
|
||||||
|
const portrait = {x: 0, y: 0, width: 1080, height: 1920};
|
||||||
|
assert.equal(JSON.stringify(api.project({x: 0, y: 0, width: 1080, height: 1920}, portrait, 192, 108)), '{"x":65.625,"y":0,"width":60.75,"height":108}');
|
||||||
|
console.log('overview logic: ok');
|
||||||
Reference in new issue
Block a user