From 2e33ef5b7f8822b7aabed4ad77a53b00439fec08 Mon Sep 17 00:00:00 2001 From: outfoxxed Date: Mon, 19 May 2025 00:01:04 -0700 Subject: [PATCH] hyprland/ipc: track workspace fullscreen state --- src/wayland/hyprland/ipc/connection.cpp | 9 +++++++++ src/wayland/hyprland/ipc/workspace.cpp | 2 ++ src/wayland/hyprland/ipc/workspace.hpp | 5 +++++ 3 files changed, 16 insertions(+) diff --git a/src/wayland/hyprland/ipc/connection.cpp b/src/wayland/hyprland/ipc/connection.cpp index 5e56e09b..1c9f4ebf 100644 --- a/src/wayland/hyprland/ipc/connection.cpp +++ b/src/wayland/hyprland/ipc/connection.cpp @@ -381,6 +381,15 @@ void HyprlandIpc::onEvent(HyprlandIpcEvent* event) { << (*workspaceIter)->bindableName().value() << "to" << 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); } } diff --git a/src/wayland/hyprland/ipc/workspace.cpp b/src/wayland/hyprland/ipc/workspace.cpp index d8f00e3d..bc0070d7 100644 --- a/src/wayland/hyprland/ipc/workspace.cpp +++ b/src/wayland/hyprland/ipc/workspace.cpp @@ -38,6 +38,7 @@ void HyprlandWorkspace::updateInitial(qint32 id, const QString& name) { void HyprlandWorkspace::updateFromObject(QVariantMap object) { auto monitorId = object.value("monitorID").value(); auto monitorName = object.value("monitor").value(); + auto hasFullscreen = object.value("hasfullscreen").value(); auto initial = this->bId == -1; @@ -59,6 +60,7 @@ void HyprlandWorkspace::updateFromObject(QVariantMap object) { this->setMonitor(monitor); } + this->bHasFullscreen = hasFullscreen; this->mLastIpcObject = std::move(object); emit this->lastIpcObjectChanged(); } diff --git a/src/wayland/hyprland/ipc/workspace.hpp b/src/wayland/hyprland/ipc/workspace.hpp index a67a7fec..3493c5f1 100644 --- a/src/wayland/hyprland/ipc/workspace.hpp +++ b/src/wayland/hyprland/ipc/workspace.hpp @@ -24,6 +24,8 @@ class HyprlandWorkspace: public QObject { /// If this workspace is currently active on a monitor and that monitor is currently /// focused. See also @@active. 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. /// /// > [!WARNING] This is *not* updated unless the workspace object is fetched again from @@ -53,6 +55,7 @@ public: [[nodiscard]] QBindable bindableName() { return &this->bName; } [[nodiscard]] QBindable bindableActive() { return &this->bActive; } [[nodiscard]] QBindable bindableFocused() { return &this->bFocused; } + [[nodiscard]] QBindable bindableHasFullscreen() { return &this->bHasFullscreen; } [[nodiscard]] QBindable bindableMonitor() { return &this->bMonitor; } [[nodiscard]] QVariantMap lastIpcObject() const; @@ -64,6 +67,7 @@ signals: void nameChanged(); void activeChanged(); void focusedChanged(); + void hasFullscreenChanged(); void lastIpcObjectChanged(); void monitorChanged(); @@ -80,6 +84,7 @@ private: Q_OBJECT_BINDABLE_PROPERTY(HyprlandWorkspace, QString, bName, &HyprlandWorkspace::nameChanged); Q_OBJECT_BINDABLE_PROPERTY(HyprlandWorkspace, bool, bActive, &HyprlandWorkspace::activeChanged); 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); // clang-format on };