diff options
| author | 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> | 2025-04-29 21:54:57 +1000 |
|---|---|---|
| committer | 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> | 2025-04-29 21:54:57 +1000 |
| commit | 7358e10bcb7621437d27e35334fa1cd9e136bffd (patch) | |
| tree | d1ff2cf5310884915910bd2bfa1fe184878fe399 /services | |
| parent | bar: occupied workspaces no need for layout (diff) | |
| download | caelestia-shell-7358e10bcb7621437d27e35334fa1cd9e136bffd.tar.gz caelestia-shell-7358e10bcb7621437d27e35334fa1cd9e136bffd.tar.bz2 caelestia-shell-7358e10bcb7621437d27e35334fa1cd9e136bffd.zip | |
hyprland: use qtobjects
Diffstat (limited to 'services')
| -rw-r--r-- | services/Hyprland.qml | 53 |
1 files changed, 31 insertions, 22 deletions
diff --git a/services/Hyprland.qml b/services/Hyprland.qml index df2f0ba..a8a6c44 100644 --- a/services/Hyprland.qml +++ b/services/Hyprland.qml @@ -8,12 +8,12 @@ import QtQuick Singleton { id: root - readonly property ListModel clients: ListModel {} + property list<Client> clients: [] readonly property var workspaces: Hyprland.workspaces readonly property var monitors: Hyprland.monitors - property var activeClient: null - property HyprlandWorkspace activeWorkspace: focusedMonitor?.activeWorkspace ?? null - property HyprlandMonitor focusedMonitor: Hyprland.monitors.values.find(m => m.lastIpcObject.focused) ?? null + readonly property Client activeClient: Client {} + readonly property HyprlandWorkspace activeWorkspace: focusedMonitor?.activeWorkspace ?? null + readonly property HyprlandMonitor focusedMonitor: Hyprland.monitors.values.find(m => m.lastIpcObject.focused) ?? null function reload() { Hyprland.refreshWorkspaces(); @@ -43,15 +43,9 @@ Singleton { stdout: SplitParser { onRead: data => { const clients = JSON.parse(data); - root.clients.clear(); - for (const client of clients) { - root.clients.append({ - lastIpcObject: client, - address: client.address, - class: client.class, - title: client.title - }); - } + root.clients = clients.map(c => clientComp.createObject(root, { + lastIpcObject: c + })).filter(c => c); } } } @@ -60,15 +54,30 @@ Singleton { id: getActiveClient command: ["sh", "-c", "hyprctl -j activewindow | jq -c"] stdout: SplitParser { - onRead: data => { - const client = JSON.parse(data); - root.activeClient = { - lastIpcObject: client, - address: client.address, - class: client.class, - title: client.title - }; - } + onRead: data => root.activeClient.lastIpcObject = JSON.parse(data) } } + + component Client: QtObject { + property var lastIpcObject + property string address: lastIpcObject?.address ?? "" + property string wmClass: lastIpcObject?.class ?? "" + property string title: lastIpcObject?.title ?? "" + property string initialClass: lastIpcObject?.initialClass ?? "" + property string initialTitle: lastIpcObject?.initialTitle ?? "" + property int x: lastIpcObject?.at[0] ?? 0 + property int y: lastIpcObject?.at[1] ?? 0 + property int width: lastIpcObject?.size[0] ?? 0 + property int height: lastIpcObject?.size[1] ?? 0 + property HyprlandWorkspace workspace: Hyprland.workspaces.values.find(w => w.id === lastIpcObject?.workspace.id) ?? null + property bool floating: lastIpcObject?.floating ?? false + property bool fullscreen: lastIpcObject?.fullscreen ?? false + property int pid: lastIpcObject?.pid ?? 0 + } + + Component { + id: clientComp + + Client {} + } } |