From bc7acbde5c5f85382a7055eaf6b39a3d9d8af7a7 Mon Sep 17 00:00:00 2001 From: Brenno Lemos Date: Mon, 8 Jan 2024 18:18:11 -0300 Subject: [PATCH] fix: rename windows while queued for creation this avoids the window arriving with the wrong icon when its eventually able to be created --- src/modules/hyprland/workspaces.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/modules/hyprland/workspaces.cpp b/src/modules/hyprland/workspaces.cpp index eb624a10..e7ed064b 100644 --- a/src/modules/hyprland/workspaces.cpp +++ b/src/modules/hyprland/workspaces.cpp @@ -424,6 +424,7 @@ void Workspaces::onWindowMoved(std::string const &payload) { void Workspaces::onWindowTitleEvent(std::string const &payload) { std::optional> inserter; + // If the window was an orphan, rename it at the orphan's vector if (m_orphanWindowMap.contains(payload)) { inserter = [this](WindowCreationPayload wcp) { this->registerOrphanWindow(std::move(wcp)); }; } else { @@ -431,10 +432,21 @@ void Workspaces::onWindowTitleEvent(std::string const &payload) { std::find_if(m_workspaces.begin(), m_workspaces.end(), [payload](auto &workspace) { return workspace->containsWindow(payload); }); + // If the window exists on a workspace, rename it at the workspace's window + // map if (windowWorkspace != m_workspaces.end()) { inserter = [windowWorkspace](WindowCreationPayload wcp) { (*windowWorkspace)->insertWindow(std::move(wcp)); }; + } else { + auto queuedWindow = std::find_if( + m_windowsToCreate.begin(), m_windowsToCreate.end(), + [payload](auto &windowPayload) { return windowPayload.getAddress() == payload; }); + + // If the window was queued, rename it in the queue + if (queuedWindow != m_windowsToCreate.end()) { + inserter = [queuedWindow](WindowCreationPayload wcp) { *queuedWindow = std::move(wcp); }; + } } }