v0 overivew
This commit is contained in:
1 parent
ed75fa0db9
commit
f5a0a53f89
17 files changed
+943
-34
No files matched your search
@@ -1,16 +1,8 @@
|
||||
# Agent Instructions
|
||||
|
||||
Key non-negotiable rules from that file:
|
||||
|
||||
- **Always present a plan first** and wait for user approval before making any changes — no matter how small the task.
|
||||
- Never commit or create branches unless explicitly asked.
|
||||
|
||||
# Agent Guidelines — nixos-setup
|
||||
|
||||
Rules and best practices for any AI agent working in this repository.
|
||||
Read this file before making any changes.
|
||||
|
||||
---
|
||||
`CLAUDE.md` and `.agents/AGENTS.md` are symlinks to this file. Do not treat them as separate copies.
|
||||
|
||||
## Mandatory First Step — Always Present a Plan
|
||||
|
||||
@@ -25,30 +17,24 @@ Your plan must include:
|
||||
|
||||
Only after the user approves the plan may you proceed with edits.
|
||||
|
||||
---
|
||||
|
||||
## Hard Rules — Never Break These
|
||||
## Hard Rules
|
||||
|
||||
**Your job:** Make correct edits to source files. The user validates and runs builds themselves.
|
||||
|
||||
**Even if the user says "go ahead":** Do NOT run these. Your role is to write good Nix, not execute it.
|
||||
**Even if the user says "go ahead":** Do NOT run builds, evals, or similar commands.
|
||||
|
||||
### ❌ NEVER modify `GUIDELINES.md` unless explicitly requested by the user
|
||||
|
||||
You must **live and die by these rules** and hold yourself accountable to them.
|
||||
These are not suggestions — they are non-negotiable.
|
||||
|
||||
### KEEP EVERYTHING CONCISE, shorter concise comments are preferable, less jargon and more common words.
|
||||
- Keep comments short and plain. Prefer common words over jargon.
|
||||
- Minimize the use of `var` in type definitions. Always prefer explicit types where possible.
|
||||
- When setting up a new type via `QtObject`, avoid providing defaults unless there is a good reason.
|
||||
|
||||
## When In Doubt
|
||||
|
||||
If you are unsure whether a command is safe, **assume it is NOT SAFE and don't run it.**
|
||||
If you are unsure whether a command is safe, assume it is **not** and don't run it.
|
||||
|
||||
Instead: describe what you would do and ask the user for permission.
|
||||
Describe what you would do and ask the user for permission.
|
||||
|
||||
## Commit / Branch / Git Policy
|
||||
|
||||
- Do NOT commit changes or create branches unless the user explicitly asks
|
||||
- Do NOT `git add`, `git commit`, or `git push` autonomously
|
||||
- You may run `git add` **only** if required for a Nix evaluation (e.g., new files must be tracked for flakes)
|
||||
- Do not commit changes or create branches unless the user explicitly asks
|
||||
- Do not `git add`, `git commit`, or `git push` autonomously
|
||||
- Describe what you changed in your final message so the user can review before committing
|
||||
Generated
+8
-10
@@ -2,18 +2,16 @@
|
||||
"nodes": {
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1789006805,
|
||||
"narHash": "sha256-xB8mKMOx1IA9vTDNLmJZ6n4wCMq/cuWBBOzGCRnqxrU=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "8ce4ef6cb6f871616146b9fe26d2a5ae594e94fe",
|
||||
"type": "github"
|
||||
"lastModified": 1789114715,
|
||||
"narHash": "sha256-ugpsyk3NM2s87vXfUiIIiibbJ4Pp0JPS5p/3mfs+q+c=",
|
||||
"rev": "21a67dc470149f337cecafbe965d8d252a390518",
|
||||
"revCount": 1013883,
|
||||
"type": "tarball",
|
||||
"url": "https://api.flakehub.com/f/pinned/NixOS/nixpkgs/0.2605.1013883%2Brev-21a67dc470149f337cecafbe965d8d252a390518/01a0941f-eef0-70e0-93ac-63af13618393/source.tar.gz"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"ref": "nixos-unstable",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
"type": "tarball",
|
||||
"url": "https://flakehub.com/f/NixOS/nixpkgs/0"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
|
||||
@@ -0,0 +1,215 @@
|
||||
import QtQuick
|
||||
import Quickshell
|
||||
import Quickshell.Wayland
|
||||
import Quickshell.Hyprland
|
||||
import "types"
|
||||
|
||||
// Snapshot of monitors / workspaces / windows for the overview.
|
||||
// Call refresh() when the overlay is shown; browsing a monitor only rebuilds.
|
||||
Scope {
|
||||
id: root
|
||||
|
||||
required property string browsedMonitor
|
||||
|
||||
property list<Monitor> monitors
|
||||
property list<MonitorStats> monitorStats
|
||||
property list<OverviewRow> rows
|
||||
property QtObject snapshotRoot
|
||||
readonly property bool rebuildPending: delayedRebuild.running
|
||||
|
||||
signal rebuilt()
|
||||
|
||||
Component { id: snapRootComp; QtObject {} }
|
||||
Component { id: monitorComp; Monitor {} }
|
||||
Component { id: monitorStatsComp; MonitorStats {} }
|
||||
Component { id: workspaceInfoComp; WorkspaceInfo {} }
|
||||
Component { id: windowInfoComp; WindowInfo {} }
|
||||
Component { id: overviewRowComp; OverviewRow {} }
|
||||
|
||||
Timer {
|
||||
id: delayedRebuild
|
||||
interval: 80
|
||||
repeat: false
|
||||
onTriggered: root.rebuild()
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: Hyprland.monitors
|
||||
function onValuesChanged() { delayedRebuild.restart(); }
|
||||
}
|
||||
Connections {
|
||||
target: Hyprland.workspaces
|
||||
function onValuesChanged() { delayedRebuild.restart(); }
|
||||
}
|
||||
Connections {
|
||||
target: Hyprland.toplevels
|
||||
function onValuesChanged() { delayedRebuild.restart(); }
|
||||
}
|
||||
|
||||
function refresh() {
|
||||
Hyprland.refreshMonitors();
|
||||
Hyprland.refreshWorkspaces();
|
||||
Hyprland.refreshToplevels();
|
||||
delayedRebuild.restart();
|
||||
root.rebuild();
|
||||
}
|
||||
|
||||
function monitorNameOf(tl, ws) {
|
||||
if (tl?.monitor?.name)
|
||||
return tl.monitor.name;
|
||||
if (ws?.monitor?.name)
|
||||
return ws.monitor.name;
|
||||
const ipcMon = tl?.lastIpcObject?.monitor;
|
||||
if (typeof ipcMon === "string" && ipcMon.length)
|
||||
return ipcMon;
|
||||
if (typeof ipcMon === "number") {
|
||||
const m = (Hyprland.monitors?.values ?? []).find(mon => mon.id === ipcMon);
|
||||
if (m)
|
||||
return m.name;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
function resolveWayland(tl) {
|
||||
if (tl?.wayland)
|
||||
return tl.wayland;
|
||||
const title = tl?.title ?? "";
|
||||
const appId = tl?.lastIpcObject?.class ?? "";
|
||||
const list = ToplevelManager?.toplevels?.values ?? [];
|
||||
let match = list.find(t => t.title === title && (!appId || t.appId === appId));
|
||||
if (match)
|
||||
return match;
|
||||
return list.find(t => title && t.title === title) ?? null;
|
||||
}
|
||||
|
||||
function snapshotWindow(tl) {
|
||||
const ipc = tl.lastIpcObject;
|
||||
return windowInfoComp.createObject(root.snapshotRoot, {
|
||||
address: tl.address ?? ipc?.address ?? "",
|
||||
title: tl.title ?? ipc?.title ?? "",
|
||||
appClass: ipc?.class ?? "",
|
||||
size: (ipc && ipc.size) ? [ipc.size[0], ipc.size[1]] : [0, 0],
|
||||
at: (ipc && ipc.at) ? [ipc.at[0], ipc.at[1]] : [0, 0],
|
||||
wayland: root.resolveWayland(tl),
|
||||
activated: !!tl.activated,
|
||||
monitorName: "",
|
||||
});
|
||||
}
|
||||
|
||||
function collectToplevels() {
|
||||
const seen = {};
|
||||
const out = [];
|
||||
function add(tl) {
|
||||
if (!tl)
|
||||
return;
|
||||
const key = tl.address ?? tl.lastIpcObject?.address ?? "";
|
||||
if (key) {
|
||||
if (seen[key])
|
||||
return;
|
||||
seen[key] = true;
|
||||
}
|
||||
out.push(tl);
|
||||
}
|
||||
for (const tl of (Hyprland.toplevels?.values ?? []))
|
||||
add(tl);
|
||||
for (const ws of (Hyprland.workspaces?.values ?? [])) {
|
||||
for (const tl of (ws.toplevels?.values ?? []))
|
||||
add(tl);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
function collectMonitor() {
|
||||
return (Hyprland.monitors?.values ?? []).slice()
|
||||
.sort((a, b) => a.id - b.id)
|
||||
.map(m => monitorComp.createObject(root.snapshotRoot, {
|
||||
monitorId: m.id,
|
||||
name: m.name,
|
||||
x: m.x,
|
||||
y: m.y,
|
||||
width: m.width,
|
||||
height: m.height,
|
||||
scale: m.scale || 1,
|
||||
}));
|
||||
}
|
||||
|
||||
function rebuild() {
|
||||
const oldRoot = root.snapshotRoot;
|
||||
root.snapshotRoot = snapRootComp.createObject(root);
|
||||
|
||||
const monitorSnaps = collectMonitor();
|
||||
|
||||
const byId = {};
|
||||
for (const ws of (Hyprland.workspaces?.values ?? [])) {
|
||||
byId[ws.id] = {
|
||||
id: ws.id,
|
||||
active: !!ws.active,
|
||||
monitorName: ws.monitor?.name ?? "",
|
||||
windows: [],
|
||||
};
|
||||
}
|
||||
|
||||
for (const tl of root.collectToplevels()) {
|
||||
if (tl.mapped === false)
|
||||
continue;
|
||||
const ws = tl.workspace;
|
||||
const ipcWs = tl.lastIpcObject?.workspace;
|
||||
const wsId = ws?.id ?? (typeof ipcWs === "object" ? ipcWs?.id : ipcWs);
|
||||
if (!(wsId in byId)) {
|
||||
byId[wsId] = {
|
||||
id: wsId,
|
||||
active: !!(ws && ws.active),
|
||||
monitorName: "",
|
||||
windows: [],
|
||||
};
|
||||
}
|
||||
const monName = root.monitorNameOf(tl, ws) || byId[wsId].monitorName;
|
||||
if (!byId[wsId].monitorName)
|
||||
byId[wsId].monitorName = monName;
|
||||
const win = root.snapshotWindow(tl);
|
||||
win.monitorName = monName;
|
||||
byId[wsId].windows.push(win);
|
||||
}
|
||||
|
||||
for (const w of Object.values(byId))
|
||||
w.windows.sort((a, b) => (a.at?.[0] ?? 0) - (b.at?.[0] ?? 0));
|
||||
|
||||
const stats = monitorSnaps.map(mon => {
|
||||
const wss = Object.values(byId).filter(w => w.monitorName === mon.name);
|
||||
const windows = Object.values(byId).reduce(
|
||||
(n, w) => n + w.windows.filter(win => win.monitorName === mon.name).length,
|
||||
0
|
||||
);
|
||||
return monitorStatsComp.createObject(root.snapshotRoot, {
|
||||
workspaces: wss.length,
|
||||
windows: windows,
|
||||
});
|
||||
});
|
||||
|
||||
const browsed = root.browsedMonitor;
|
||||
const rows = Object.values(byId)
|
||||
.filter(w => {
|
||||
if (!browsed)
|
||||
return false;
|
||||
return w.monitorName === browsed
|
||||
|| w.windows.some(win => win.monitorName === browsed);
|
||||
})
|
||||
.sort((a, b) => a.id - b.id)
|
||||
.map(w => overviewRowComp.createObject(root.snapshotRoot, {
|
||||
workspace: workspaceInfoComp.createObject(root.snapshotRoot, {
|
||||
workspaceId: w.id,
|
||||
active: w.active,
|
||||
}),
|
||||
toplevels: w.monitorName === browsed
|
||||
? w.windows
|
||||
: w.windows.filter(win => win.monitorName === browsed),
|
||||
}));
|
||||
|
||||
root.monitors = monitorSnaps;
|
||||
root.monitorStats = stats;
|
||||
root.rows = rows;
|
||||
if (oldRoot)
|
||||
oldRoot.destroy();
|
||||
root.rebuilt();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
import QtQuick
|
||||
|
||||
// Mini-map of the real monitor layout: each pill is positioned and sized
|
||||
// proportionally to its monitor's actual x/y/resolution in Hyprland's
|
||||
// compositor space (see conf/monitors.lua), like a display-arrangement UI.
|
||||
Item {
|
||||
id: root
|
||||
|
||||
required property var theme
|
||||
required property var monitors
|
||||
required property var monitorStats
|
||||
required property string focusedMonitorName
|
||||
|
||||
signal monitorClicked(int index)
|
||||
|
||||
readonly property real mapWidth: 240
|
||||
readonly property real minPillWidth: 34
|
||||
readonly property real minPillHeight: 26
|
||||
|
||||
// Hyprland reports width/height as raw output resolution but x/y in
|
||||
// scaled/logical space, so divide by scale to put everything in the
|
||||
// same coordinate system before computing positions/sizes.
|
||||
function logicalRect(m) {
|
||||
return { x: m.x, y: m.y, w: m.width / m.scale, h: m.height / m.scale };
|
||||
}
|
||||
|
||||
readonly property var rects: root.monitors.map(root.logicalRect)
|
||||
readonly property var bounds: {
|
||||
if (root.rects.length === 0) return { minX: 0, minY: 0, maxX: 1, maxY: 1 };
|
||||
return {
|
||||
minX: Math.min(...root.rects.map(r => r.x)),
|
||||
minY: Math.min(...root.rects.map(r => r.y)),
|
||||
maxX: Math.max(...root.rects.map(r => r.x + r.w)),
|
||||
maxY: Math.max(...root.rects.map(r => r.y + r.h)),
|
||||
};
|
||||
}
|
||||
readonly property real totalWidth: Math.max(1, root.bounds.maxX - root.bounds.minX)
|
||||
readonly property real totalHeight: Math.max(1, root.bounds.maxY - root.bounds.minY)
|
||||
readonly property real scaleFactor: root.mapWidth / root.totalWidth
|
||||
|
||||
visible: monitors.length > 1
|
||||
width: root.totalWidth * root.scaleFactor
|
||||
height: root.totalHeight * root.scaleFactor
|
||||
|
||||
Repeater {
|
||||
model: root.monitors
|
||||
|
||||
Rectangle {
|
||||
id: pill
|
||||
required property var modelData
|
||||
required property int index
|
||||
|
||||
readonly property bool active: modelData.name === root.focusedMonitorName
|
||||
readonly property var rect: root.logicalRect(modelData)
|
||||
|
||||
x: (rect.x - root.bounds.minX) * root.scaleFactor
|
||||
y: (rect.y - root.bounds.minY) * root.scaleFactor
|
||||
width: Math.max(rect.w * root.scaleFactor, root.minPillWidth)
|
||||
height: Math.max(rect.h * root.scaleFactor, root.minPillHeight)
|
||||
radius: 6
|
||||
color: pill.active ? root.theme.selectedBorder : root.theme.cardBg
|
||||
border.width: 1
|
||||
border.color: root.theme.cardBorder
|
||||
clip: true
|
||||
|
||||
Text {
|
||||
anchors.centerIn: parent
|
||||
width: parent.width - 4
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
elide: Text.ElideRight
|
||||
text: {
|
||||
const s = root.monitorStats[pill.index];
|
||||
return (pill.index + 1) + ": " + pill.modelData.name
|
||||
+ (s ? " " + s.workspaces + "/" + s.windows : "");
|
||||
}
|
||||
color: root.theme.textColor
|
||||
font.pixelSize: Math.max(9, Math.min(11, pill.height * 0.3))
|
||||
font.bold: pill.active
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
onClicked: root.monitorClicked(pill.index)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,327 @@
|
||||
import QtQuick
|
||||
import Quickshell
|
||||
import Quickshell.Wayland
|
||||
import Quickshell.Hyprland
|
||||
|
||||
PanelWindow {
|
||||
id: root
|
||||
|
||||
required property bool shellOpen
|
||||
required property string browsedMonitor
|
||||
signal requestClose()
|
||||
signal requestBrowseMonitor(string name)
|
||||
|
||||
visible: root.shellOpen
|
||||
|
||||
color: "transparent"
|
||||
|
||||
WlrLayershell.namespace: "quickshell:overview"
|
||||
WlrLayershell.layer: WlrLayer.Overlay
|
||||
WlrLayershell.exclusiveZone: -1
|
||||
WlrLayershell.keyboardFocus: root.visible ? WlrKeyboardFocus.OnDemand : WlrKeyboardFocus.None
|
||||
|
||||
anchors {
|
||||
top: true
|
||||
left: true
|
||||
right: true
|
||||
bottom: true
|
||||
}
|
||||
|
||||
property Theme theme: Theme {}
|
||||
|
||||
property bool resetOnRebuild: false
|
||||
|
||||
property HyprlandWindowState windowState: HyprlandWindowState {
|
||||
id: winState
|
||||
browsedMonitor: root.browsedMonitor
|
||||
onRebuilt: {
|
||||
if (root.resetOnRebuild) {
|
||||
root.resetOnRebuild = winState.rebuildPending;
|
||||
root.resetSelection();
|
||||
} else {
|
||||
root.clampSelection();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
readonly property var rows: windowState.rows
|
||||
readonly property var sortedMonitors: windowState.monitors
|
||||
readonly property var monitorStats: windowState.monitorStats
|
||||
|
||||
property int selectedRow: 0
|
||||
property int selectedCol: 0
|
||||
|
||||
function clampSelection() {
|
||||
if (root.rows.length === 0) {
|
||||
root.selectedRow = 0;
|
||||
root.selectedCol = 0;
|
||||
return;
|
||||
}
|
||||
if (root.selectedRow >= root.rows.length) root.selectedRow = root.rows.length - 1;
|
||||
if (root.selectedRow < 0) root.selectedRow = 0;
|
||||
const count = root.rows[root.selectedRow].toplevels.length;
|
||||
if (root.selectedCol >= count) root.selectedCol = Math.max(0, count - 1);
|
||||
if (root.selectedCol < 0) root.selectedCol = 0;
|
||||
}
|
||||
|
||||
// Reset the selection to the active workspace/window whenever the
|
||||
// overview opens.
|
||||
function resetSelection() {
|
||||
const activeRowIndex = root.rows.findIndex(r => r.workspace.active);
|
||||
root.selectedRow = activeRowIndex >= 0 ? activeRowIndex : 0;
|
||||
const row = root.rows[root.selectedRow];
|
||||
const activeColIndex = row ? row.toplevels.findIndex(tl => tl.activated) : -1;
|
||||
root.selectedCol = activeColIndex >= 0 ? activeColIndex : 0;
|
||||
root.clampSelection();
|
||||
}
|
||||
|
||||
function moveSelection(dRow, dCol) {
|
||||
if (root.rows.length === 0) return;
|
||||
if (dRow !== 0) {
|
||||
root.selectedRow = (root.selectedRow + dRow + root.rows.length) % root.rows.length;
|
||||
root.clampSelection();
|
||||
}
|
||||
if (dCol !== 0) {
|
||||
const count = root.rows[root.selectedRow].toplevels.length;
|
||||
if (count > 0) root.selectedCol = (root.selectedCol + dCol + count) % count;
|
||||
}
|
||||
}
|
||||
|
||||
function activateSelection() {
|
||||
const row = root.rows[root.selectedRow];
|
||||
if (!row) { root.requestClose(); return; }
|
||||
if (!row.workspace.active) {
|
||||
Quickshell.execDetached(["hyprctl", "dispatch", `hl.dsp.focus({workspace = ${row.workspace.workspaceId}})`]);
|
||||
}
|
||||
const tl = row.toplevels[root.selectedCol];
|
||||
if (tl) {
|
||||
const addr = tl.address.startsWith("0x") ? tl.address : "0x" + tl.address;
|
||||
Quickshell.execDetached(["hyprctl", "dispatch", `hl.dsp.focus({window = "address:${addr}"})`]);
|
||||
}
|
||||
root.requestClose();
|
||||
}
|
||||
|
||||
// Advances which monitor's overview is being browsed (see shell.qml) —
|
||||
// purely local UI state, doesn't touch Hyprland's real focused monitor.
|
||||
function cycleMonitor() {
|
||||
const mons = root.sortedMonitors;
|
||||
if (mons.length === 0) return;
|
||||
const curIdx = Math.max(0, mons.findIndex(m => m.name === root.browsedMonitor));
|
||||
const mon = mons[(curIdx + 1) % mons.length];
|
||||
root.requestBrowseMonitor(mon.name);
|
||||
}
|
||||
|
||||
// Jump straight to the Nth monitor's overview (0-based), bound to number
|
||||
// keys 1-9 and the monitor bar.
|
||||
function focusMonitorByIndex(i) {
|
||||
const mon = root.sortedMonitors[i];
|
||||
if (!mon) return;
|
||||
root.requestBrowseMonitor(mon.name);
|
||||
}
|
||||
|
||||
onBrowsedMonitorChanged: {
|
||||
if (root.visible) {
|
||||
root.resetOnRebuild = true;
|
||||
root.windowState.rebuild();
|
||||
}
|
||||
}
|
||||
|
||||
onVisibleChanged: {
|
||||
if (root.visible) {
|
||||
root.resetOnRebuild = true;
|
||||
root.windowState.refresh();
|
||||
Qt.callLater(() => focusScope.forceActiveFocus());
|
||||
}
|
||||
}
|
||||
|
||||
HyprlandFocusGrab {
|
||||
windows: [root]
|
||||
active: root.visible
|
||||
onCleared: {
|
||||
if (root.visible) root.requestClose();
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
color: root.theme.backdrop
|
||||
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
onClicked: root.requestClose()
|
||||
}
|
||||
}
|
||||
|
||||
FocusScope {
|
||||
id: focusScope
|
||||
anchors.fill: parent
|
||||
focus: root.visible
|
||||
|
||||
// Hovering a card recenters the carousel, which can slide a
|
||||
// different card under an otherwise-stationary cursor and retrigger
|
||||
// hover on it ("combo hover"). A pure movement-distance check isn't
|
||||
// enough — ordinary mouse/trackpad jitter (a few px) clears a small
|
||||
// threshold on its own. So: hard-lock all hover triggers for the
|
||||
// duration of the recentering animation (nothing can retrigger while
|
||||
// cards are still sliding), and additionally require the cursor to
|
||||
// have moved well past jitter range since the last accepted trigger.
|
||||
HoverHandler {
|
||||
id: mouseTracker
|
||||
}
|
||||
property point lastHoverAcceptPos: Qt.point(-1, -1)
|
||||
property bool hoverLocked: false
|
||||
Timer {
|
||||
id: hoverLockTimer
|
||||
interval: root.theme.carouselDuration
|
||||
onTriggered: focusScope.hoverLocked = false
|
||||
}
|
||||
function shouldAcceptHover() {
|
||||
if (focusScope.hoverLocked) return false;
|
||||
const cur = mouseTracker.point.position;
|
||||
const dx = cur.x - focusScope.lastHoverAcceptPos.x;
|
||||
const dy = cur.y - focusScope.lastHoverAcceptPos.y;
|
||||
if ((dx * dx + dy * dy) <= 1600) return false; // 40px
|
||||
focusScope.lastHoverAcceptPos = cur;
|
||||
focusScope.hoverLocked = true;
|
||||
hoverLockTimer.restart();
|
||||
return true;
|
||||
}
|
||||
|
||||
Keys.onPressed: event => {
|
||||
switch (event.key) {
|
||||
case Qt.Key_Left:
|
||||
root.moveSelection(0, -1);
|
||||
break;
|
||||
case Qt.Key_Right:
|
||||
root.moveSelection(0, 1);
|
||||
break;
|
||||
case Qt.Key_Up:
|
||||
root.moveSelection(-1, 0);
|
||||
break;
|
||||
case Qt.Key_Down:
|
||||
root.moveSelection(1, 0);
|
||||
break;
|
||||
case Qt.Key_Return:
|
||||
case Qt.Key_Enter:
|
||||
root.activateSelection();
|
||||
break;
|
||||
case Qt.Key_Escape:
|
||||
root.requestClose();
|
||||
break;
|
||||
case Qt.Key_M:
|
||||
root.cycleMonitor();
|
||||
break;
|
||||
case Qt.Key_1:
|
||||
case Qt.Key_2:
|
||||
case Qt.Key_3:
|
||||
case Qt.Key_4:
|
||||
case Qt.Key_5:
|
||||
case Qt.Key_6:
|
||||
case Qt.Key_7:
|
||||
case Qt.Key_8:
|
||||
case Qt.Key_9:
|
||||
root.focusMonitorByIndex(event.key - Qt.Key_1);
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
event.accepted = true;
|
||||
}
|
||||
|
||||
// Two-finger trackpad swipe moves the selection like the arrow keys:
|
||||
// vertical swipe = workspace rows, horizontal swipe = windows in a
|
||||
// row. High-res trackpads report swipes as pixel deltas (angleDelta is
|
||||
// tiny/zero), so prefer pixelDelta and fall back to angleDelta (for
|
||||
// notch-style mice). Deltas accumulate on the dominant axis and a
|
||||
// single step is taken once the swipe crosses the threshold.
|
||||
WheelHandler {
|
||||
id: swipeHandler
|
||||
target: focusScope
|
||||
property real accY: 0
|
||||
property real accX: 0
|
||||
|
||||
function step(dRow, dCol) {
|
||||
root.moveSelection(dRow, dCol);
|
||||
swipeHandler.accY = 0;
|
||||
swipeHandler.accX = 0;
|
||||
}
|
||||
|
||||
onWheel: event => {
|
||||
console.log("WHEEL px=" + event.pixelDelta.x + "," + event.pixelDelta.y
|
||||
+ " ang=" + event.angleDelta.x + "," + event.angleDelta.y);
|
||||
const px = event.pixelDelta;
|
||||
const ang = event.angleDelta;
|
||||
const dx = px.x !== 0 ? px.x : ang.x;
|
||||
const dy = px.y !== 0 ? px.y : ang.y;
|
||||
swipeHandler.accX += dx;
|
||||
swipeHandler.accY += dy;
|
||||
|
||||
if (Math.abs(swipeHandler.accY) >= Math.abs(swipeHandler.accX)) {
|
||||
if (swipeHandler.accY <= -root.theme.swipeThreshold) swipeHandler.step(-1, 0);
|
||||
else if (swipeHandler.accY >= root.theme.swipeThreshold) swipeHandler.step(1, 0);
|
||||
} else {
|
||||
if (swipeHandler.accX <= -root.theme.swipeThreshold) swipeHandler.step(0, 1);
|
||||
else if (swipeHandler.accX >= root.theme.swipeThreshold) swipeHandler.step(0, -1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
MonitorBar {
|
||||
anchors.top: parent.top
|
||||
anchors.topMargin: 24
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
theme: root.theme
|
||||
monitors: root.sortedMonitors
|
||||
monitorStats: root.monitorStats
|
||||
focusedMonitorName: root.browsedMonitor
|
||||
onMonitorClicked: index => root.focusMonitorByIndex(index)
|
||||
}
|
||||
|
||||
Item {
|
||||
anchors.fill: parent
|
||||
|
||||
Repeater {
|
||||
model: root.rows
|
||||
|
||||
WorkspaceRow {
|
||||
required property var modelData
|
||||
required property int index
|
||||
|
||||
theme: root.theme
|
||||
workspace: modelData.workspace
|
||||
toplevels: modelData.toplevels
|
||||
selectedIndex: index === root.selectedRow ? root.selectedCol : -1
|
||||
live: root.visible
|
||||
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
anchors.verticalCenterOffset: (index - root.selectedRow) * root.theme.carouselStepY
|
||||
opacity: 1 - Math.min(Math.abs(index - root.selectedRow) * root.theme.carouselFadeStep, root.theme.carouselMaxFade)
|
||||
scale: 1 - Math.min(Math.abs(index - root.selectedRow) * root.theme.carouselScaleStep, root.theme.carouselMaxScaleReduction)
|
||||
|
||||
Behavior on anchors.verticalCenterOffset {
|
||||
NumberAnimation { duration: root.theme.carouselDuration; easing.type: Easing.OutCubic }
|
||||
}
|
||||
Behavior on opacity {
|
||||
NumberAnimation { duration: root.theme.carouselDuration }
|
||||
}
|
||||
Behavior on scale {
|
||||
NumberAnimation { duration: root.theme.carouselDuration }
|
||||
}
|
||||
|
||||
onCardClicked: colIndex => {
|
||||
root.selectedRow = index;
|
||||
root.selectedCol = colIndex;
|
||||
root.activateSelection();
|
||||
}
|
||||
onCardHovered: colIndex => {
|
||||
if (!focusScope.shouldAcceptHover()) return;
|
||||
root.selectedRow = index;
|
||||
root.selectedCol = colIndex;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
import QtQuick
|
||||
|
||||
QtObject {
|
||||
readonly property color backdrop: "#cc0b0e14"
|
||||
readonly property color cardBg: "#332a2e3a"
|
||||
readonly property color cardBorder: "#40ffffff"
|
||||
readonly property color selectedBorder: "#7aa2f7"
|
||||
readonly property color textColor: "#ffffff"
|
||||
readonly property color emptyTextColor: "#80ffffff"
|
||||
readonly property real cornerRadius: 10
|
||||
readonly property real cardHeight: 180
|
||||
readonly property real cardSpacing: 20
|
||||
|
||||
// Carousel layout: fixed step distances between slots on each axis, and
|
||||
// per-step falloff for opacity/scale as items recede from the centered
|
||||
// (selected) slot.
|
||||
readonly property real carouselStepX: cardHeight * 2.6 + cardSpacing
|
||||
readonly property real carouselStepY: cardHeight + 70
|
||||
readonly property real carouselFadeStep: 0.35
|
||||
readonly property real carouselMaxFade: 0.85
|
||||
readonly property real carouselScaleStep: 0.08
|
||||
readonly property real carouselMaxScaleReduction: 0.3
|
||||
readonly property int carouselDuration: 220
|
||||
|
||||
// A two-finger swipe must cross this many pixels (or angleDelta units)
|
||||
// before the selection steps once.
|
||||
readonly property int swipeThreshold: 120
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
import QtQuick
|
||||
import Quickshell
|
||||
import Quickshell.Wayland
|
||||
|
||||
Rectangle {
|
||||
id: root
|
||||
|
||||
required property var theme
|
||||
required property var toplevel
|
||||
required property bool selected
|
||||
required property bool live
|
||||
|
||||
signal activated()
|
||||
signal hovered()
|
||||
|
||||
readonly property real aspect: {
|
||||
const size = root.toplevel ? root.toplevel.size : null;
|
||||
return (size && size[0] > 0 && size[1] > 0) ? size[0] / size[1] : (16 / 9);
|
||||
}
|
||||
|
||||
width: Math.min(height * aspect, theme.cardHeight * 2.2)
|
||||
height: theme.cardHeight
|
||||
radius: theme.cornerRadius
|
||||
color: theme.cardBg
|
||||
border.width: selected ? 3 : 1
|
||||
border.color: selected ? theme.selectedBorder : theme.cardBorder
|
||||
clip: true
|
||||
|
||||
ScreencopyView {
|
||||
id: preview
|
||||
anchors.fill: parent
|
||||
anchors.margins: 3
|
||||
captureSource: root.live && root.toplevel ? root.toplevel.wayland : null
|
||||
live: root.live
|
||||
paintCursor: false
|
||||
constraintSize: Qt.size(root.width - 6, root.height - 6)
|
||||
}
|
||||
|
||||
Image {
|
||||
anchors.left: parent.left
|
||||
anchors.bottom: parent.bottom
|
||||
anchors.margins: 6
|
||||
width: 20
|
||||
height: 20
|
||||
source: Quickshell.iconPath(root.toplevel ? root.toplevel.appClass : "", "application-x-executable")
|
||||
sourceSize: Qt.size(20, 20)
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
anchors.bottom: parent.bottom
|
||||
height: title.implicitHeight + 8
|
||||
color: "#99000000"
|
||||
|
||||
Text {
|
||||
id: title
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
anchors.leftMargin: 30
|
||||
anchors.rightMargin: 6
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
elide: Text.ElideRight
|
||||
color: theme.textColor
|
||||
text: root.toplevel ? root.toplevel.title : ""
|
||||
font.pixelSize: 12
|
||||
}
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
hoverEnabled: true
|
||||
onClicked: root.activated()
|
||||
onEntered: root.hovered()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
import QtQuick
|
||||
|
||||
Item {
|
||||
id: root
|
||||
|
||||
required property var theme
|
||||
required property var workspace
|
||||
required property var toplevels
|
||||
required property int selectedIndex
|
||||
required property bool live
|
||||
|
||||
signal cardClicked(int index)
|
||||
signal cardHovered(int index)
|
||||
|
||||
// Slot cards are centered on when nothing in this row is selected (e.g.
|
||||
// it's not the active row), so an inactive row still reads as centered.
|
||||
readonly property int centerIndex: selectedIndex >= 0 ? selectedIndex : Math.floor((toplevels.length - 1) / 2)
|
||||
|
||||
height: label.implicitHeight + theme.cardSpacing * 0.5 + theme.cardHeight
|
||||
|
||||
Text {
|
||||
id: label
|
||||
anchors.top: parent.top
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
text: "Workspace " + (root.workspace ? root.workspace.workspaceId : "?")
|
||||
color: root.theme.textColor
|
||||
font.pixelSize: 14
|
||||
font.bold: root.workspace && root.workspace.active
|
||||
}
|
||||
|
||||
Item {
|
||||
id: cardArea
|
||||
anchors.top: label.bottom
|
||||
anchors.topMargin: root.theme.cardSpacing * 0.5
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
height: root.theme.cardHeight
|
||||
|
||||
Repeater {
|
||||
model: root.toplevels
|
||||
|
||||
WindowCard {
|
||||
required property var modelData
|
||||
required property int index
|
||||
|
||||
theme: root.theme
|
||||
toplevel: modelData
|
||||
selected: index === root.selectedIndex
|
||||
live: root.live
|
||||
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
anchors.horizontalCenterOffset: (index - root.centerIndex) * root.theme.carouselStepX
|
||||
opacity: 1 - Math.min(Math.abs(index - root.centerIndex) * root.theme.carouselFadeStep, root.theme.carouselMaxFade)
|
||||
scale: 1 - Math.min(Math.abs(index - root.centerIndex) * root.theme.carouselScaleStep, root.theme.carouselMaxScaleReduction)
|
||||
|
||||
Behavior on anchors.horizontalCenterOffset {
|
||||
NumberAnimation { duration: root.theme.carouselDuration; easing.type: Easing.OutCubic }
|
||||
}
|
||||
Behavior on opacity {
|
||||
NumberAnimation { duration: root.theme.carouselDuration }
|
||||
}
|
||||
Behavior on scale {
|
||||
NumberAnimation { duration: root.theme.carouselDuration }
|
||||
}
|
||||
|
||||
onActivated: root.cardClicked(index)
|
||||
onHovered: root.cardHovered(index)
|
||||
}
|
||||
}
|
||||
|
||||
// Placeholder for an empty workspace so the row stays visible
|
||||
// and selectable even with no windows.
|
||||
Rectangle {
|
||||
visible: root.toplevels.length === 0
|
||||
anchors.centerIn: parent
|
||||
width: root.theme.cardHeight * 1.6
|
||||
height: root.theme.cardHeight
|
||||
radius: root.theme.cornerRadius
|
||||
color: "transparent"
|
||||
border.width: root.selectedIndex === 0 ? 3 : 1
|
||||
border.color: root.selectedIndex === 0 ? root.theme.selectedBorder : root.theme.cardBorder
|
||||
|
||||
Text {
|
||||
anchors.centerIn: parent
|
||||
text: "Empty"
|
||||
color: root.theme.emptyTextColor
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
onClicked: root.cardClicked(0)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
HyprlandWindowState 1.0 HyprlandWindowState.qml
|
||||
MonitorBar 1.0 MonitorBar.qml
|
||||
OverviewWindow 1.0 OverviewWindow.qml
|
||||
Theme 1.0 Theme.qml
|
||||
WindowCard 1.0 WindowCard.qml
|
||||
WorkspaceRow 1.0 WorkspaceRow.qml
|
||||
Monitor 1.0 types/Monitor.qml
|
||||
MonitorStats 1.0 types/MonitorStats.qml
|
||||
OverviewRow 1.0 types/OverviewRow.qml
|
||||
WindowInfo 1.0 types/WindowInfo.qml
|
||||
WorkspaceInfo 1.0 types/WorkspaceInfo.qml
|
||||
@@ -0,0 +1,35 @@
|
||||
import Quickshell
|
||||
import Quickshell.Io
|
||||
import Quickshell.Hyprland
|
||||
|
||||
ShellRoot {
|
||||
id: shell
|
||||
|
||||
property bool overviewOpen: false
|
||||
property string browsedMonitor: ""
|
||||
property var anchorScreen: null
|
||||
|
||||
onOverviewOpenChanged: {
|
||||
if (shell.overviewOpen) {
|
||||
const mon = Hyprland.focusedMonitor;
|
||||
shell.browsedMonitor = mon ? mon.name : "";
|
||||
shell.anchorScreen = Quickshell.screens.find(s => mon && s.name === mon.name) ?? Quickshell.screens[0];
|
||||
}
|
||||
}
|
||||
|
||||
IpcHandler {
|
||||
target: "overview"
|
||||
|
||||
function toggle(): void {
|
||||
shell.overviewOpen = !shell.overviewOpen;
|
||||
}
|
||||
}
|
||||
|
||||
OverviewWindow {
|
||||
screen: shell.anchorScreen
|
||||
shellOpen: shell.overviewOpen
|
||||
browsedMonitor: shell.browsedMonitor
|
||||
onRequestClose: shell.overviewOpen = false
|
||||
onRequestBrowseMonitor: name => shell.browsedMonitor = name
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
import QtQuick
|
||||
|
||||
QtObject {
|
||||
property int monitorId
|
||||
property string name
|
||||
property int x
|
||||
property int y
|
||||
property int width
|
||||
property int height
|
||||
property real scale
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
import QtQuick
|
||||
|
||||
QtObject {
|
||||
property int workspaces
|
||||
property int windows
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
import QtQuick
|
||||
|
||||
QtObject {
|
||||
property WorkspaceInfo workspace
|
||||
property var toplevels
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
import QtQuick
|
||||
|
||||
QtObject {
|
||||
property string address
|
||||
property string title
|
||||
property string appClass
|
||||
property var size
|
||||
property var at
|
||||
property var wayland
|
||||
property bool activated
|
||||
property string monitorName
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
import QtQuick
|
||||
|
||||
QtObject {
|
||||
property int workspaceId
|
||||
property bool active
|
||||
}
|
||||
@@ -14,3 +14,11 @@ def "main carousel" [
|
||||
$env.SKYG_APP_CAROUSEL = $path_to_config
|
||||
qs -p ($REPO_ROOT | path join "app-carousel")
|
||||
}
|
||||
|
||||
def "main overview" [] {
|
||||
qs -p ($REPO_ROOT | path join "overview")
|
||||
}
|
||||
|
||||
def "main overview toggle" [] {
|
||||
qs -p ($REPO_ROOT | path join "overview") ipc call overview toggle
|
||||
}
|
||||
Reference in new issue
Block a user