From 78107f16fae039582d7dbd40293f7dc8ed7fb871 Mon Sep 17 00:00:00 2001 From: scorpion-26 <58082714+scorpion-26@users.noreply.github.com> Date: Sun, 5 Mar 2023 20:25:51 +0100 Subject: [PATCH] Always activate first x monitors The workspace of a second monitor would not be activated, so lastActiveWorkspace of that would be nullptr. This would also happen for the first monitor (First and second swapped) after Hyprland boot. Now the WS of the first monitor is fully activated by default and every other monitor has at least lastActiveWorkspace set (Assumes, that WS with MonID + 1 is on that monitor). --- src/Workspaces.cpp | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/Workspaces.cpp b/src/Workspaces.cpp index 2b594a7..88cd548 100644 --- a/src/Workspaces.cpp +++ b/src/Workspaces.cpp @@ -67,10 +67,15 @@ namespace Workspaces { if (*state == ZEXT_WORKSPACE_HANDLE_V1_STATE_ACTIVE) { + LOG("Wayland: Activate Workspace " << workspace.id); group.lastActiveWorkspace = ws; workspace.active = true; } } + if (!workspace.active) + { + LOG("Wayland: Deactivate Workspace " << workspace.id); + } } static void OnWorkspaceRemove(void*, zext_workspace_handle_v1* ws) { @@ -202,6 +207,31 @@ namespace Workspaces RuntimeConfig::Get().hasWorkspaces = false; return; } + + // Hack: manually activate workspace for each monitor + for (auto& monitor : monitors) + { + // Find group + auto& group = workspaceGroups[monitor.second.workspaceGroup]; + + // Find ws with monitor index + 1 + auto workspaceIt = std::find_if(workspaces.begin(), workspaces.end(), + [&](const std::pair& ws) + { + return ws.second.id == monitor.first + 1; + }); + if (workspaceIt != workspaces.end()) + { + LOG("Forcefully activate workspace " << workspaceIt->second.id) + if (workspaceIt->second.id == 1) + { + // Activate first workspace + workspaceIt->second.active = true; + } + // Make it visible + group.lastActiveWorkspace = workspaceIt->first; + } + } } // Hack for unified interface