diff --git a/include/modules/hyprland/workspace.hpp b/include/modules/hyprland/workspace.hpp index 3dedba4c5..d6af37983 100644 --- a/include/modules/hyprland/workspace.hpp +++ b/include/modules/hyprland/workspace.hpp @@ -56,6 +56,7 @@ class Workspace { void setOutput(std::string const& value) { m_output = value; }; bool containsWindow(WindowAddress const& addr) const { return m_windowMap.contains(addr); } void insertWindow(WindowCreationPayload create_window_paylod); + std::string removeWindow(WindowAddress const& addr); void initializeWindowMap(const Json::Value& clients_data); diff --git a/include/modules/hyprland/workspaces.hpp b/include/modules/hyprland/workspaces.hpp index 6b33baeaa..f14565314 100644 --- a/include/modules/hyprland/workspaces.hpp +++ b/include/modules/hyprland/workspaces.hpp @@ -46,6 +46,8 @@ class Workspaces : public AModule, public EventHandler { bool isWorkspaceIgnored(std::string const& workspace_name); bool windowRewriteConfigUsesTitle() const { return m_anyWindowRewriteRuleUsesTitle; } + bool specialWorkspaceIsActive() const; + private: void onEvent(const std::string& e) override; diff --git a/src/modules/hyprland/workspace.cpp b/src/modules/hyprland/workspace.cpp index 4655096f4..817ebed80 100644 --- a/src/modules/hyprland/workspace.cpp +++ b/src/modules/hyprland/workspace.cpp @@ -124,6 +124,22 @@ std::string &Workspace::selectIcon(std::map &icons_map } } + // Check if both isActive and isSpecial + if (isActive() && isSpecial()) { + auto specialActiveIconIt = icons_map.find("special-active"); + if (specialActiveIconIt != icons_map.end()) { + return specialActiveIconIt->second; + } + } + + // Check if isActive but not isSpecial + if (isActive() && !isSpecial()) { + auto normalActiveIconIt = icons_map.find("normal-active"); + if (normalActiveIconIt != icons_map.end()) { + return normalActiveIconIt->second; + } + } + if (isActive()) { auto activeIconIt = icons_map.find("active"); if (activeIconIt != icons_map.end()) { @@ -192,6 +208,14 @@ void Workspace::update(const std::string &format, const std::string &icon) { auto styleContext = m_button.get_style_context(); addOrRemoveClass(styleContext, isActive(), "active"); +// // Only add 'active' class if: +// // (1) This is the special workspace and it is active +// // OR +// // (2) No special workspace is active, and this is the normal active one +// bool specialIsActive = m_workspaceManager.specialWorkspaceIsActive(); +// bool applyActive = isActive() && (!specialIsActive || isSpecial()); +// addOrRemoveClass(styleContext, applyActive, "active"); + addOrRemoveClass(styleContext, isSpecial(), "special"); addOrRemoveClass(styleContext, isEmpty(), "empty"); addOrRemoveClass(styleContext, isPersistent(), "persistent"); diff --git a/src/modules/hyprland/workspaces.cpp b/src/modules/hyprland/workspaces.cpp index 0e2259355..6b2d2a836 100644 --- a/src/modules/hyprland/workspaces.cpp +++ b/src/modules/hyprland/workspaces.cpp @@ -46,6 +46,15 @@ void Workspaces::init() { dp.emit(); } +bool Workspaces::specialWorkspaceIsActive() const { + for (const auto &workspace : m_workspaces) { + if (workspace->isActive() && workspace->isSpecial()) { + return true; + } + } + return false; +} + Json::Value Workspaces::createMonitorWorkspaceData(std::string const &name, std::string const &monitor) { spdlog::trace("Creating persistent workspace: {} on monitor {}", name, monitor); @@ -62,6 +71,15 @@ Json::Value Workspaces::createMonitorWorkspaceData(std::string const &name, return workspaceData; } +void addOrRemoveClassWorkspaces(const Glib::RefPtr &context, bool condition, + const std::string &class_name) { + if (condition) { + context->add_class(class_name); + } else { + context->remove_class(class_name); + } +} + void Workspaces::createWorkspace(Json::Value const &workspace_data, Json::Value const &clients_data) { auto workspaceName = workspace_data["name"].asString(); @@ -856,6 +874,11 @@ void Workspaces::setUrgentWorkspace(std::string const &windowaddress) { auto Workspaces::update() -> void { doUpdate(); AModule::update(); + + //pol was here + bool specialActive = specialWorkspaceIsActive(); + auto styleContext = m_box.get_style_context(); + addOrRemoveClassWorkspaces(styleContext, specialActive, "has-special-active"); } void Workspaces::updateWindowCount() {