Add 'active' css class to special workspaces

pull/2894/head
Jannik 2024-02-07 16:33:19 +01:00
parent 4c5ff80bbd
commit 3bfcd5e086
No known key found for this signature in database
2 changed files with 14 additions and 1 deletions

View File

@ -144,6 +144,7 @@ class Workspaces : public AModule, public EventHandler {
// workspace events // workspace events
void onWorkspaceActivated(std::string const& payload); void onWorkspaceActivated(std::string const& payload);
void onSpecialWorkspaceActivated(std::string const& payload);
void onWorkspaceDestroyed(std::string const& payload); void onWorkspaceDestroyed(std::string const& payload);
void onWorkspaceCreated(std::string const& workspaceName, void onWorkspaceCreated(std::string const& workspaceName,
Json::Value const& clientsData = Json::Value::nullRef); Json::Value const& clientsData = Json::Value::nullRef);
@ -199,6 +200,7 @@ class Workspaces : public AModule, public EventHandler {
bool m_withIcon; bool m_withIcon;
uint64_t m_monitorId; uint64_t m_monitorId;
std::string m_activeWorkspaceName; std::string m_activeWorkspaceName;
std::string m_activeSpecialWorkspaceName;
std::vector<std::unique_ptr<Workspace>> m_workspaces; std::vector<std::unique_ptr<Workspace>> m_workspaces;
std::vector<std::pair<Json::Value, Json::Value>> m_workspacesToCreate; std::vector<std::pair<Json::Value, Json::Value>> m_workspacesToCreate;
std::vector<std::string> m_workspacesToRemove; std::vector<std::string> m_workspacesToRemove;

View File

@ -136,6 +136,7 @@ void Workspaces::registerOrphanWindow(WindowCreationPayload create_window_paylod
auto Workspaces::registerIpc() -> void { auto Workspaces::registerIpc() -> void {
gIPC->registerForIPC("workspace", this); gIPC->registerForIPC("workspace", this);
gIPC->registerForIPC("activespecial", this);
gIPC->registerForIPC("createworkspace", this); gIPC->registerForIPC("createworkspace", this);
gIPC->registerForIPC("destroyworkspace", this); gIPC->registerForIPC("destroyworkspace", this);
gIPC->registerForIPC("focusedmon", this); gIPC->registerForIPC("focusedmon", this);
@ -187,7 +188,8 @@ void Workspaces::doUpdate() {
for (auto &workspace : m_workspaces) { for (auto &workspace : m_workspaces) {
// active // active
workspace->setActive(workspace->name() == m_activeWorkspaceName); workspace->setActive( workspace->name() == m_activeWorkspaceName ||
workspace->name() == m_activeSpecialWorkspaceName );
// disable urgency if workspace is active // disable urgency if workspace is active
if (workspace->name() == m_activeWorkspaceName && workspace->isUrgent()) { if (workspace->name() == m_activeWorkspaceName && workspace->isUrgent()) {
workspace->setUrgent(false); workspace->setUrgent(false);
@ -266,6 +268,8 @@ void Workspaces::onEvent(const std::string &ev) {
if (eventName == "workspace") { if (eventName == "workspace") {
onWorkspaceActivated(payload); onWorkspaceActivated(payload);
} else if (eventName == "activespecial") {
onSpecialWorkspaceActivated(payload);
} else if (eventName == "destroyworkspace") { } else if (eventName == "destroyworkspace") {
onWorkspaceDestroyed(payload); onWorkspaceDestroyed(payload);
} else if (eventName == "createworkspace") { } else if (eventName == "createworkspace") {
@ -295,6 +299,13 @@ void Workspaces::onWorkspaceActivated(std::string const &payload) {
m_activeWorkspaceName = payload; m_activeWorkspaceName = payload;
} }
void Workspaces::onSpecialWorkspaceActivated(std::string const &payload) {
std::string name(begin(payload), begin(payload) + payload.find_first_of(','));
m_activeSpecialWorkspaceName = (
( name == "special" || name == "" ) ? name : name.substr(8, name.length() - 8)
);
}
void Workspaces::onWorkspaceDestroyed(std::string const &payload) { void Workspaces::onWorkspaceDestroyed(std::string const &payload) {
if (!isDoubleSpecial(payload)) { if (!isDoubleSpecial(payload)) {
m_workspacesToRemove.push_back(payload); m_workspacesToRemove.push_back(payload);