From cd3d588abdc23e19acf2452ad9bd08ae21de0ec0 Mon Sep 17 00:00:00 2001 From: Tom Benham Date: Fri, 12 Apr 2024 11:33:29 +0200 Subject: [PATCH 1/2] [hyprland/workspaces] Fix active workspace not getting updated on multi monitor setups --- src/modules/hyprland/workspaces.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/modules/hyprland/workspaces.cpp b/src/modules/hyprland/workspaces.cpp index 5d7436e7..671a4a8b 100644 --- a/src/modules/hyprland/workspaces.cpp +++ b/src/modules/hyprland/workspaces.cpp @@ -318,7 +318,7 @@ void Workspaces::onEvent(const std::string &ev) { onWorkspaceCreated(payload); } else if (eventName == "focusedmon") { onMonitorFocused(payload); - } else if (eventName == "moveworkspace" && !allOutputs()) { + } else if (eventName == "moveworkspace") { onWorkspaceMoved(payload); } else if (eventName == "openwindow") { onWindowOpened(payload); @@ -387,6 +387,13 @@ void Workspaces::onWorkspaceCreated(std::string const &workspaceName, void Workspaces::onWorkspaceMoved(std::string const &payload) { spdlog::debug("Workspace moved: {}", payload); + + // Update active workspace + m_activeWorkspaceName = (gIPC->getSocket1JsonReply("activeworkspace"))["name"].asString(); + + if (allOutputs()) + return; + std::string workspaceName = payload.substr(0, payload.find(',')); std::string monitorName = payload.substr(payload.find(',') + 1); From 084b561d5bc93a07a3f5777bef3357cf405e60cb Mon Sep 17 00:00:00 2001 From: Tom Benham Date: Fri, 12 Apr 2024 11:35:41 +0200 Subject: [PATCH 2/2] [hyprland/workspaces] Update window count and sort workspaces AFTER their creation --- src/modules/hyprland/workspaces.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/modules/hyprland/workspaces.cpp b/src/modules/hyprland/workspaces.cpp index 671a4a8b..3c03c708 100644 --- a/src/modules/hyprland/workspaces.cpp +++ b/src/modules/hyprland/workspaces.cpp @@ -194,6 +194,10 @@ void Workspaces::doUpdate() { for (auto &[workspaceData, clientsData] : m_workspacesToCreate) { createWorkspace(workspaceData, clientsData); } + if (!m_workspacesToCreate.empty()) { + updateWindowCount(); + sortWorkspaces(); + } m_workspacesToCreate.clear(); // get all active workspaces @@ -391,8 +395,7 @@ void Workspaces::onWorkspaceMoved(std::string const &payload) { // Update active workspace m_activeWorkspaceName = (gIPC->getSocket1JsonReply("activeworkspace"))["name"].asString(); - if (allOutputs()) - return; + if (allOutputs()) return; std::string workspaceName = payload.substr(0, payload.find(',')); std::string monitorName = payload.substr(payload.find(',') + 1); @@ -833,8 +836,6 @@ void Workspaces::init() { m_activeWorkspaceName = (gIPC->getSocket1JsonReply("activeworkspace"))["name"].asString(); initializeWorkspaces(); - updateWindowCount(); - sortWorkspaces(); dp.emit(); }