Skip to content

Commit 767a8ef

Browse files
committed
hyprland/ipc: expose HyprlandToplevel jsons
1 parent a5cbd37 commit 767a8ef

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed

src/wayland/hyprland/ipc/hyprland_toplevel.hpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,12 @@ class HyprlandToplevel: public QObject {
3737
Q_PROPERTY(bool activated READ default NOTIFY activatedChanged BINDABLE bindableActivated);
3838
/// Whether the client is urgent or not
3939
Q_PROPERTY(bool urgent READ default NOTIFY urgentChanged BINDABLE bindableUrgent);
40+
/// Last json returned for this toplevel, as a javascript object.
41+
///
42+
/// > [!WARNING] This is *not* updated unless the toplevel object is fetched again from
43+
/// > Hyprland. If you need a value that is subject to change and does not have a dedicated
44+
/// > property, run @@Hyprland.refreshToplevels() and wait for this property to update.
45+
Q_PROPERTY(QVariantMap lastIpcObject READ default BINDABLE bindableLastIpcObject NOTIFY lastIpcObjectChanged);
4046
/// The current workspace of the toplevel (might be null)
4147
Q_PROPERTY(qs::hyprland::ipc::HyprlandWorkspace* workspace READ default NOTIFY workspaceChanged BINDABLE bindableWorkspace);
4248
/// The current monitor of the toplevel (might be null)
@@ -71,6 +77,10 @@ class HyprlandToplevel: public QObject {
7177
[[nodiscard]] QBindable<bool> bindableActivated() { return &this->bActivated; }
7278
[[nodiscard]] QBindable<bool> bindableUrgent() { return &this->bUrgent; }
7379

80+
[[nodiscard]] QBindable<QVariantMap> bindableLastIpcObject() const {
81+
return &this->bLastIpcObject;
82+
};
83+
7484
[[nodiscard]] QBindable<HyprlandWorkspace*> bindableWorkspace() { return &this->bWorkspace; }
7585
void setWorkspace(HyprlandWorkspace* workspace);
7686

@@ -86,6 +96,7 @@ class HyprlandToplevel: public QObject {
8696
void urgentChanged();
8797
void workspaceChanged();
8898
void monitorChanged();
99+
void lastIpcObjectChanged();
89100

90101
private slots:
91102
void onActivatedChanged();
@@ -103,6 +114,7 @@ private slots:
103114
Q_OBJECT_BINDABLE_PROPERTY(HyprlandToplevel, bool, bUrgent, &HyprlandToplevel::urgentChanged);
104115
Q_OBJECT_BINDABLE_PROPERTY(HyprlandToplevel, HyprlandWorkspace*, bWorkspace, &HyprlandToplevel::workspaceChanged);
105116
Q_OBJECT_BINDABLE_PROPERTY(HyprlandToplevel, HyprlandMonitor*, bMonitor, &HyprlandToplevel::monitorChanged);
117+
Q_OBJECT_BINDABLE_PROPERTY(HyprlandToplevel, QVariantMap, bLastIpcObject, &HyprlandToplevel::lastIpcObjectChanged);
106118
// clang-format on
107119
};
108120

src/wayland/hyprland/ipc/qml.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ HyprlandMonitor* HyprlandIpcQml::monitorFor(QuickshellScreenInfo* screen) {
4747

4848
void HyprlandIpcQml::refreshMonitors() { HyprlandIpc::instance()->refreshMonitors(false); }
4949
void HyprlandIpcQml::refreshWorkspaces() { HyprlandIpc::instance()->refreshWorkspaces(false); }
50+
void HyprlandIpcQml::refreshToplevels() { HyprlandIpc::instance()->refreshToplevels(); }
5051
QString HyprlandIpcQml::requestSocketPath() { return HyprlandIpc::instance()->requestSocketPath(); }
5152
QString HyprlandIpcQml::eventSocketPath() { return HyprlandIpc::instance()->eventSocketPath(); }
5253

src/wayland/hyprland/ipc/qml.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,12 @@ class HyprlandIpcQml: public QObject {
6262
/// so this function is available if required.
6363
Q_INVOKABLE static void refreshWorkspaces();
6464

65+
/// Refresh toplevel information.
66+
///
67+
/// Many actions that will invalidate workspace state don't send events,
68+
/// so this function is available if required.
69+
Q_INVOKABLE static void refreshToplevels();
70+
6571
[[nodiscard]] static QString requestSocketPath();
6672
[[nodiscard]] static QString eventSocketPath();
6773
[[nodiscard]] static QBindable<HyprlandMonitor*> bindableFocusedMonitor();

0 commit comments

Comments
 (0)