mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-02 11:25:58 +01:00
Implement urgency hint for workspaces (#1379)
When there are any unfocused windows that request activation, mark the workspace as urgent.
This commit is contained in:
parent
b3012d97ab
commit
668d90c700
4 changed files with 35 additions and 1 deletions
|
@ -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())
|
||||
|
|
|
@ -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*);
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
Loading…
Reference in a new issue