diff --git a/src/wayland/hyprland/ipc/hyprland_toplevel.hpp b/src/wayland/hyprland/ipc/hyprland_toplevel.hpp index 4d61bef8..ebd4f844 100644 --- a/src/wayland/hyprland/ipc/hyprland_toplevel.hpp +++ b/src/wayland/hyprland/ipc/hyprland_toplevel.hpp @@ -37,6 +37,12 @@ class HyprlandToplevel: public QObject { Q_PROPERTY(bool activated READ default NOTIFY activatedChanged BINDABLE bindableActivated); /// Whether the client is urgent or not Q_PROPERTY(bool urgent READ default NOTIFY urgentChanged BINDABLE bindableUrgent); + /// Last json returned for this toplevel, as a javascript object. + /// + /// > [!WARNING] This is *not* updated unless the toplevel object is fetched again from + /// > Hyprland. If you need a value that is subject to change and does not have a dedicated + /// > property, run @@Hyprland.refreshToplevels() and wait for this property to update. + Q_PROPERTY(QVariantMap lastIpcObject READ default BINDABLE bindableLastIpcObject NOTIFY lastIpcObjectChanged); /// The current workspace of the toplevel (might be null) Q_PROPERTY(qs::hyprland::ipc::HyprlandWorkspace* workspace READ default NOTIFY workspaceChanged BINDABLE bindableWorkspace); /// The current monitor of the toplevel (might be null) @@ -71,6 +77,10 @@ public: [[nodiscard]] QBindable bindableActivated() { return &this->bActivated; } [[nodiscard]] QBindable bindableUrgent() { return &this->bUrgent; } + [[nodiscard]] QBindable bindableLastIpcObject() const { + return &this->bLastIpcObject; + }; + [[nodiscard]] QBindable bindableWorkspace() { return &this->bWorkspace; } void setWorkspace(HyprlandWorkspace* workspace); @@ -86,6 +96,7 @@ signals: void urgentChanged(); void workspaceChanged(); void monitorChanged(); + void lastIpcObjectChanged(); private slots: void onActivatedChanged(); @@ -103,6 +114,7 @@ private: Q_OBJECT_BINDABLE_PROPERTY(HyprlandToplevel, bool, bUrgent, &HyprlandToplevel::urgentChanged); Q_OBJECT_BINDABLE_PROPERTY(HyprlandToplevel, HyprlandWorkspace*, bWorkspace, &HyprlandToplevel::workspaceChanged); Q_OBJECT_BINDABLE_PROPERTY(HyprlandToplevel, HyprlandMonitor*, bMonitor, &HyprlandToplevel::monitorChanged); + Q_OBJECT_BINDABLE_PROPERTY(HyprlandToplevel, QVariantMap, bLastIpcObject, &HyprlandToplevel::lastIpcObjectChanged); // clang-format on }; diff --git a/src/wayland/hyprland/ipc/qml.cpp b/src/wayland/hyprland/ipc/qml.cpp index 3694c97c..89eec9e3 100644 --- a/src/wayland/hyprland/ipc/qml.cpp +++ b/src/wayland/hyprland/ipc/qml.cpp @@ -47,6 +47,7 @@ HyprlandMonitor* HyprlandIpcQml::monitorFor(QuickshellScreenInfo* screen) { void HyprlandIpcQml::refreshMonitors() { HyprlandIpc::instance()->refreshMonitors(false); } void HyprlandIpcQml::refreshWorkspaces() { HyprlandIpc::instance()->refreshWorkspaces(false); } +void HyprlandIpcQml::refreshToplevels() { HyprlandIpc::instance()->refreshToplevels(); } QString HyprlandIpcQml::requestSocketPath() { return HyprlandIpc::instance()->requestSocketPath(); } QString HyprlandIpcQml::eventSocketPath() { return HyprlandIpc::instance()->eventSocketPath(); } diff --git a/src/wayland/hyprland/ipc/qml.hpp b/src/wayland/hyprland/ipc/qml.hpp index fce50cc1..ebf5d80a 100644 --- a/src/wayland/hyprland/ipc/qml.hpp +++ b/src/wayland/hyprland/ipc/qml.hpp @@ -62,6 +62,12 @@ public: /// so this function is available if required. Q_INVOKABLE static void refreshWorkspaces(); + /// Refresh toplevel information. + /// + /// Many actions that will invalidate workspace state don't send events, + /// so this function is available if required. + Q_INVOKABLE static void refreshToplevels(); + [[nodiscard]] static QString requestSocketPath(); [[nodiscard]] static QString eventSocketPath(); [[nodiscard]] static QBindable bindableFocusedMonitor();