summaryrefslogtreecommitdiff
path: root/services
diff options
context:
space:
mode:
Diffstat (limited to 'services')
-rw-r--r--services/Hyprland.qml37
1 files changed, 21 insertions, 16 deletions
diff --git a/services/Hyprland.qml b/services/Hyprland.qml
index 92f1de5..336be73 100644
--- a/services/Hyprland.qml
+++ b/services/Hyprland.qml
@@ -11,7 +11,7 @@ Singleton {
property list<Client> clients: []
readonly property var workspaces: Hyprland.workspaces
readonly property var monitors: Hyprland.monitors
- readonly property Client activeClient: Client {}
+ property Client activeClient: null
readonly property HyprlandWorkspace activeWorkspace: focusedMonitor?.activeWorkspace ?? null
readonly property HyprlandMonitor focusedMonitor: Hyprland.monitors.values.find(m => m.lastIpcObject.focused) ?? null
@@ -54,25 +54,30 @@ Singleton {
id: getActiveClient
command: ["sh", "-c", "hyprctl -j activewindow | jq -c"]
stdout: SplitParser {
- onRead: data => root.activeClient.lastIpcObject = JSON.parse(data)
+ onRead: data => {
+ const client = JSON.parse(data);
+ root.activeClient = client.address ? clientComp.createObject(root, {
+ lastIpcObject: client
+ }) : null;
+ }
}
}
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
+ required 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]
+ property int y: lastIpcObject.at[1]
+ property int width: lastIpcObject.size[0]
+ property int height: lastIpcObject.size[1]
+ property HyprlandWorkspace workspace: Hyprland.workspaces.values.find(w => w.id === lastIpcObject.workspace.id) ?? null
+ property bool floating: lastIpcObject.floating
+ property bool fullscreen: lastIpcObject.fullscreen
+ property int pid: lastIpcObject.pid
}
Component {