diff --git a/src/Compositor.cpp b/src/Compositor.cpp index 12f753f8d..ba6312f44 100644 --- a/src/Compositor.cpp +++ b/src/Compositor.cpp @@ -728,6 +728,8 @@ void CCompositor::focusWindow(CWindow* pWindow, wlr_surface* pSurface) { g_pLayoutManager->getCurrentLayout()->onWindowFocusChange(nullptr); m_pLastFocus = nullptr; + + g_pInputManager->recheckIdleInhibitorStatus(); return; } @@ -787,7 +789,8 @@ void CCompositor::focusWindow(CWindow* pWindow, wlr_surface* pSurface) { if (PCONSTRAINT) g_pInputManager->constrainMouse(m_sSeat.mouse, PCONSTRAINT); } - + + g_pInputManager->recheckIdleInhibitorStatus(); } void CCompositor::focusSurface(wlr_surface* pSurface, CWindow* pWindowOwner) { @@ -1691,6 +1694,8 @@ void CCompositor::setWindowFullscreen(CWindow* pWindow, bool on, eFullscreenMode g_pXWaylandManager->setWindowSize(pWindow, pWindow->m_vRealSize.goalv(), true); forceReportSizesToWindowsOnWorkspace(pWindow->m_iWorkspaceID); + + g_pInputManager->recheckIdleInhibitorStatus(); } void CCompositor::moveUnmanagedX11ToWindows(CWindow* pWindow) { diff --git a/src/Window.hpp b/src/Window.hpp index 236ee47b2..bf77454c4 100644 --- a/src/Window.hpp +++ b/src/Window.hpp @@ -7,6 +7,13 @@ #include "render/decorations/IHyprWindowDecoration.hpp" #include +enum eIdleInhibitMode { + IDLEINHIBIT_NONE = 0, + IDLEINHIBIT_ALWAYS, + IDLEINHIBIT_FULLSCREEN, + IDLEINHIBIT_FOCUS +}; + struct SWindowSpecialRenderData { float alpha = 1.f; float alphaInactive = -1.f; // -1 means unset @@ -154,6 +161,9 @@ public: uint64_t m_iLastToplevelMonitorID = -1; uint64_t m_iLastSurfaceMonitorID = -1; + // for idle inhibiting windows + eIdleInhibitMode m_eIdleInhibitMode = IDLEINHIBIT_NONE; + // For the list lookup bool operator==(const CWindow& rhs) { return m_uSurface.xdg == rhs.m_uSurface.xdg && m_uSurface.xwayland == rhs.m_uSurface.xwayland && m_vPosition == rhs.m_vPosition && m_vSize == rhs.m_vSize && m_bFadingOut == rhs.m_bFadingOut; diff --git a/src/config/ConfigManager.cpp b/src/config/ConfigManager.cpp index d3b6e5071..7e44b41d8 100644 --- a/src/config/ConfigManager.cpp +++ b/src/config/ConfigManager.cpp @@ -756,6 +756,7 @@ bool windowRuleValid(const std::string& RULE) { && RULE.find("maxsize") != 0 && RULE.find("pseudo") != 0 && RULE.find("monitor") != 0 + && RULE.find("idleinhibit") != 0 && RULE != "nofocus" && RULE != "noblur" && RULE != "noshadow" diff --git a/src/events/Windows.cpp b/src/events/Windows.cpp index 078355434..034a10055 100644 --- a/src/events/Windows.cpp +++ b/src/events/Windows.cpp @@ -201,6 +201,20 @@ void Events::listener_mapWindow(void* owner, void* data) { } else if (r.szRule.find("animation") == 0) { auto STYLE = r.szRule.substr(r.szRule.find_first_of(' ') + 1); PWINDOW->m_sAdditionalConfigData.animationStyle = STYLE; + } else if (r.szRule.find("idleinhibit") == 0) { + auto IDLERULE = r.szRule.substr(r.szRule.find_first_of(' ') + 1); + + if (IDLERULE == "none") { + PWINDOW->m_eIdleInhibitMode = IDLEINHIBIT_NONE; + } else if (IDLERULE == "always") { + PWINDOW->m_eIdleInhibitMode = IDLEINHIBIT_ALWAYS; + } else if (IDLERULE == "focus") { + PWINDOW->m_eIdleInhibitMode = IDLEINHIBIT_FOCUS; + } else if (IDLERULE == "fullscreen") { + PWINDOW->m_eIdleInhibitMode = IDLEINHIBIT_FULLSCREEN; + } else { + Debug::log(ERR, "Rule idleinhibit: unknown mode %s", IDLERULE.c_str()); + } } } diff --git a/src/managers/input/IdleInhibitor.cpp b/src/managers/input/IdleInhibitor.cpp index 3efb40c68..8c0a3267c 100644 --- a/src/managers/input/IdleInhibitor.cpp +++ b/src/managers/input/IdleInhibitor.cpp @@ -49,6 +49,27 @@ void CInputManager::recheckIdleInhibitorStatus() { } } + // check manual user-set inhibitors + for (auto& w : g_pCompositor->m_vWindows) { + if (w->m_eIdleInhibitMode == IDLEINHIBIT_NONE) + continue; + + if (w->m_eIdleInhibitMode == IDLEINHIBIT_ALWAYS) { + wlr_idle_set_enabled(g_pCompositor->m_sWLRIdle, g_pCompositor->m_sSeat.seat, false); + return; + } + + if (w->m_eIdleInhibitMode == IDLEINHIBIT_FOCUS && g_pCompositor->isWindowActive(w.get())) { + wlr_idle_set_enabled(g_pCompositor->m_sWLRIdle, g_pCompositor->m_sSeat.seat, false); + return; + } + + if (w->m_eIdleInhibitMode == IDLEINHIBIT_FULLSCREEN && w->m_bIsFullscreen && g_pCompositor->isWorkspaceVisible(w->m_iWorkspaceID)) { + wlr_idle_set_enabled(g_pCompositor->m_sWLRIdle, g_pCompositor->m_sSeat.seat, false); + return; + } + } + wlr_idle_set_enabled(g_pCompositor->m_sWLRIdle, g_pCompositor->m_sSeat.seat, true); return; } \ No newline at end of file