diff --git a/src/Compositor.cpp b/src/Compositor.cpp index 2e331ad7..e44632c1 100644 --- a/src/Compositor.cpp +++ b/src/Compositor.cpp @@ -826,6 +826,17 @@ void CCompositor::focusWindow(CWindow* pWindow, wlr_surface* pSurface) { updateWindowAnimatedDecorationValues(pWindow); + // Handle urgency hint on the workspace + if (pWindow->m_bIsUrgent) { + pWindow->m_bIsUrgent = false; + if (!hasUrgentWindowOnWorkspace(pWindow->m_iWorkspaceID)) { + const auto PWORKSPACE = getWorkspaceByID(pWindow->m_iWorkspaceID); + if (PWORKSPACE->m_pWlrHandle) { + wlr_ext_workspace_handle_v1_set_urgent(PWORKSPACE->m_pWlrHandle, 0); + } + } + } + // Send an event g_pEventManager->postEvent(SHyprIPCEvent{"activewindow", g_pXWaylandManager->getAppIDClass(pWindow) + "," + pWindow->m_szTitle}); @@ -1046,6 +1057,15 @@ int CCompositor::getWindowsOnWorkspace(const int& id) { return no; } +bool CCompositor::hasUrgentWindowOnWorkspace(const int& id) { + for (auto& w : m_vWindows) { + if (w->m_iWorkspaceID == id && w->m_bIsMapped && w->m_bIsUrgent) + return true; + } + + return false; +} + CWindow* CCompositor::getFirstWindowOnWorkspace(const int& id) { for (auto& w : m_vWindows) { if (w->m_iWorkspaceID == id && w->m_bIsMapped && !w->isHidden()) diff --git a/src/Compositor.hpp b/src/Compositor.hpp index fb0eb8fa..080ac96f 100644 --- a/src/Compositor.hpp +++ b/src/Compositor.hpp @@ -135,6 +135,7 @@ class CCompositor { void sanityCheckWorkspaces(); void updateWorkspaceWindowDecos(const int&); int getWindowsOnWorkspace(const int&); + bool hasUrgentWindowOnWorkspace(const int&); CWindow* getFirstWindowOnWorkspace(const int&); CWindow* getFullscreenWindowOnWorkspace(const int&); bool doesSeatAcceptInput(wlr_surface*); diff --git a/src/Window.hpp b/src/Window.hpp index 758acd4d..a9f64379 100644 --- a/src/Window.hpp +++ b/src/Window.hpp @@ -157,6 +157,9 @@ class CWindow { // For pinned (sticky) windows bool m_bPinned = false; + // urgency hint + bool m_bIsUrgent = false; + // fakefullscreen bool m_bFakeFullscreenState = false; diff --git a/src/events/Windows.cpp b/src/events/Windows.cpp index 134d822c..86496bfc 100644 --- a/src/events/Windows.cpp +++ b/src/events/Windows.cpp @@ -803,7 +803,7 @@ void Events::listener_activateXDG(wl_listener* listener, void* data) { Debug::log(LOG, "Activate request for surface at %x", E->surface); - if (!*PFOCUSONACTIVATE || !wlr_surface_is_xdg_surface(E->surface)) + if (!wlr_surface_is_xdg_surface(E->surface)) return; const auto PWINDOW = g_pCompositor->getWindowFromSurface(E->surface); @@ -811,6 +811,16 @@ void Events::listener_activateXDG(wl_listener* listener, void* data) { if (!PWINDOW || PWINDOW == g_pCompositor->m_pLastWindow) return; + PWINDOW->m_bIsUrgent = true; + + const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(PWINDOW->m_iWorkspaceID); + if (PWORKSPACE->m_pWlrHandle) { + wlr_ext_workspace_handle_v1_set_urgent(PWORKSPACE->m_pWlrHandle, 1); + } + + if (!*PFOCUSONACTIVATE) + return; + if (PWINDOW->m_bIsFloating) g_pCompositor->moveWindowToTop(PWINDOW);