aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/managers/input/IdleInhibitor.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/managers/input/IdleInhibitor.cpp')
-rw-r--r--src/managers/input/IdleInhibitor.cpp54
1 files changed, 41 insertions, 13 deletions
diff --git a/src/managers/input/IdleInhibitor.cpp b/src/managers/input/IdleInhibitor.cpp
index a99184e0..74760c0a 100644
--- a/src/managers/input/IdleInhibitor.cpp
+++ b/src/managers/input/IdleInhibitor.cpp
@@ -2,6 +2,7 @@
#include "../../Compositor.hpp"
#include "../../protocols/IdleInhibit.hpp"
#include "../../protocols/IdleNotify.hpp"
+#include "../../protocols/core/Compositor.hpp"
void CInputManager::newIdleInhibitor(std::any inhibitor) {
const auto PINHIBIT = m_vIdleInhibitors.emplace_back(std::make_unique<SIdleInhibitor>()).get();
@@ -50,24 +51,51 @@ void CInputManager::recheckIdleInhibitorStatus() {
// check manual user-set inhibitors
for (auto const& w : g_pCompositor->m_vWindows) {
- if (w->m_eIdleInhibitMode == IDLEINHIBIT_NONE)
- continue;
-
- if (w->m_eIdleInhibitMode == IDLEINHIBIT_ALWAYS) {
+ if (isWindowInhibiting(w)) {
PROTO::idle->setInhibit(true);
return;
}
+ }
- if (w->m_eIdleInhibitMode == IDLEINHIBIT_FOCUS && g_pCompositor->isWindowActive(w)) {
- PROTO::idle->setInhibit(true);
- return;
- }
+ PROTO::idle->setInhibit(false);
+}
- if (w->m_eIdleInhibitMode == IDLEINHIBIT_FULLSCREEN && w->isFullscreen() && w->m_pWorkspace && w->m_pWorkspace->isVisible()) {
- PROTO::idle->setInhibit(true);
- return;
- }
+bool CInputManager::isWindowInhibiting(const PHLWINDOW& w, bool onlyHl) {
+ if (w->m_eIdleInhibitMode == IDLEINHIBIT_ALWAYS)
+ return true;
+
+ if (w->m_eIdleInhibitMode == IDLEINHIBIT_FOCUS && g_pCompositor->isWindowActive(w))
+ return true;
+
+ if (w->m_eIdleInhibitMode == IDLEINHIBIT_FULLSCREEN && w->isFullscreen() && w->m_pWorkspace && w->m_pWorkspace->isVisible())
+ return true;
+
+ if (onlyHl)
+ return false;
+
+ for (auto const& ii : m_vIdleInhibitors) {
+ if (ii->nonDesktop || !ii->inhibitor)
+ continue;
+
+ bool isInhibiting = false;
+ w->m_pWLSurface->resource()->breadthfirst(
+ [&ii](SP<CWLSurfaceResource> surf, const Vector2D& pos, void* data) {
+ if (ii->inhibitor->surface != surf)
+ return;
+
+ auto WLSurface = CWLSurface::fromResource(surf);
+
+ if (!WLSurface)
+ return;
+
+ if (WLSurface->visible())
+ *(bool*)data = true;
+ },
+ &isInhibiting);
+
+ if (isInhibiting)
+ return true;
}
- PROTO::idle->setInhibit(false);
+ return false;
}