hyprland/ipc: track workspace fullscreen state

This commit is contained in:
outfoxxed 2025-05-19 00:01:04 -07:00
parent edfc4c681c
commit 2e33ef5b7f
Signed by untrusted user: outfoxxed
GPG key ID: 4C88A185FB89301E
3 changed files with 16 additions and 0 deletions

View file

@ -381,6 +381,15 @@ void HyprlandIpc::onEvent(HyprlandIpcEvent* event) {
<< (*workspaceIter)->bindableName().value() << "to" << name; << (*workspaceIter)->bindableName().value() << "to" << name;
(*workspaceIter)->bindableName().setValue(name); (*workspaceIter)->bindableName().setValue(name);
} else if (event->name == "fullscreen") {
if (auto* workspace = this->bFocusedWorkspace.value()) {
workspace->bindableHasFullscreen().setValue(event->data == "1");
}
// In theory knowing the current workspace would be enough to determine where
// the fullscreen state changed, but this falls apart if you move a fullscreen
// window between workspaces.
this->refreshWorkspaces(false);
} }
} }

View file

@ -38,6 +38,7 @@ void HyprlandWorkspace::updateInitial(qint32 id, const QString& name) {
void HyprlandWorkspace::updateFromObject(QVariantMap object) { void HyprlandWorkspace::updateFromObject(QVariantMap object) {
auto monitorId = object.value("monitorID").value<qint32>(); auto monitorId = object.value("monitorID").value<qint32>();
auto monitorName = object.value("monitor").value<QString>(); auto monitorName = object.value("monitor").value<QString>();
auto hasFullscreen = object.value("hasfullscreen").value<bool>();
auto initial = this->bId == -1; auto initial = this->bId == -1;
@ -59,6 +60,7 @@ void HyprlandWorkspace::updateFromObject(QVariantMap object) {
this->setMonitor(monitor); this->setMonitor(monitor);
} }
this->bHasFullscreen = hasFullscreen;
this->mLastIpcObject = std::move(object); this->mLastIpcObject = std::move(object);
emit this->lastIpcObjectChanged(); emit this->lastIpcObjectChanged();
} }

View file

@ -24,6 +24,8 @@ class HyprlandWorkspace: public QObject {
/// If this workspace is currently active on a monitor and that monitor is currently /// If this workspace is currently active on a monitor and that monitor is currently
/// focused. See also @@active. /// focused. See also @@active.
Q_PROPERTY(bool focused READ default NOTIFY focusedChanged BINDABLE bindableFocused); Q_PROPERTY(bool focused READ default NOTIFY focusedChanged BINDABLE bindableFocused);
/// If this workspace currently has a fullscreen client.
Q_PROPERTY(bool hasFullscreen READ default NOTIFY focusedChanged BINDABLE bindableHasFullscreen);
/// Last json returned for this workspace, as a javascript object. /// Last json returned for this workspace, as a javascript object.
/// ///
/// > [!WARNING] This is *not* updated unless the workspace object is fetched again from /// > [!WARNING] This is *not* updated unless the workspace object is fetched again from
@ -53,6 +55,7 @@ public:
[[nodiscard]] QBindable<QString> bindableName() { return &this->bName; } [[nodiscard]] QBindable<QString> bindableName() { return &this->bName; }
[[nodiscard]] QBindable<bool> bindableActive() { return &this->bActive; } [[nodiscard]] QBindable<bool> bindableActive() { return &this->bActive; }
[[nodiscard]] QBindable<bool> bindableFocused() { return &this->bFocused; } [[nodiscard]] QBindable<bool> bindableFocused() { return &this->bFocused; }
[[nodiscard]] QBindable<bool> bindableHasFullscreen() { return &this->bHasFullscreen; }
[[nodiscard]] QBindable<HyprlandMonitor*> bindableMonitor() { return &this->bMonitor; } [[nodiscard]] QBindable<HyprlandMonitor*> bindableMonitor() { return &this->bMonitor; }
[[nodiscard]] QVariantMap lastIpcObject() const; [[nodiscard]] QVariantMap lastIpcObject() const;
@ -64,6 +67,7 @@ signals:
void nameChanged(); void nameChanged();
void activeChanged(); void activeChanged();
void focusedChanged(); void focusedChanged();
void hasFullscreenChanged();
void lastIpcObjectChanged(); void lastIpcObjectChanged();
void monitorChanged(); void monitorChanged();
@ -80,6 +84,7 @@ private:
Q_OBJECT_BINDABLE_PROPERTY(HyprlandWorkspace, QString, bName, &HyprlandWorkspace::nameChanged); Q_OBJECT_BINDABLE_PROPERTY(HyprlandWorkspace, QString, bName, &HyprlandWorkspace::nameChanged);
Q_OBJECT_BINDABLE_PROPERTY(HyprlandWorkspace, bool, bActive, &HyprlandWorkspace::activeChanged); Q_OBJECT_BINDABLE_PROPERTY(HyprlandWorkspace, bool, bActive, &HyprlandWorkspace::activeChanged);
Q_OBJECT_BINDABLE_PROPERTY(HyprlandWorkspace, bool, bFocused, &HyprlandWorkspace::focusedChanged); Q_OBJECT_BINDABLE_PROPERTY(HyprlandWorkspace, bool, bFocused, &HyprlandWorkspace::focusedChanged);
Q_OBJECT_BINDABLE_PROPERTY(HyprlandWorkspace, bool, bHasFullscreen, &HyprlandWorkspace::hasFullscreenChanged);
Q_OBJECT_BINDABLE_PROPERTY(HyprlandWorkspace, HyprlandMonitor*, bMonitor, &HyprlandWorkspace::monitorChanged); Q_OBJECT_BINDABLE_PROPERTY(HyprlandWorkspace, HyprlandMonitor*, bMonitor, &HyprlandWorkspace::monitorChanged);
// clang-format on // clang-format on
}; };