summaryrefslogtreecommitdiff
path: root/src/managers/input/IdleInhibitor.cpp
diff options
context:
space:
mode:
authorVaxry <vaxry@vaxry.net>2024-05-04 23:46:10 +0100
committerVaxry <vaxry@vaxry.net>2024-05-04 23:46:10 +0100
commit0b215c5f246d3fde6c023e78b3e3579f7498c172 (patch)
treeb4449e42b8deb0efc259b463307e2f1e69335dc0 /src/managers/input/IdleInhibitor.cpp
parenta3309b51a254f142c535022615be6f76eb23fa9b (diff)
idle-inhibit: fix and cleanup visibility logic
fixes #5878
Diffstat (limited to 'src/managers/input/IdleInhibitor.cpp')
-rw-r--r--src/managers/input/IdleInhibitor.cpp31
1 files changed, 19 insertions, 12 deletions
diff --git a/src/managers/input/IdleInhibitor.cpp b/src/managers/input/IdleInhibitor.cpp
index 40c8c637..dc7c61c3 100644
--- a/src/managers/input/IdleInhibitor.cpp
+++ b/src/managers/input/IdleInhibitor.cpp
@@ -14,26 +14,33 @@ void CInputManager::newIdleInhibitor(std::any inhibitor) {
recheckIdleInhibitorStatus();
});
- const auto PWINDOW = g_pCompositor->getWindowFromSurface(PINHIBIT->inhibitor->surface);
-
- if (PWINDOW) {
- PINHIBIT->pWindow = PWINDOW;
- PINHIBIT->windowDestroyListener = PWINDOW->events.destroy.registerListener([PINHIBIT](std::any data) {
- Debug::log(WARN, "Inhibitor got its window destroyed before its inhibitor resource.");
- PINHIBIT->pWindow.reset();
- });
- } else
- Debug::log(WARN, "Inhibitor is for no window?");
+ auto WLSurface = CWLSurface::surfaceFromWlr(PINHIBIT->inhibitor->surface);
+
+ if (!WLSurface) {
+ Debug::log(LOG, "Inhibitor has no HL Surface attached to it, likely meaning it's a non-desktop element. Ignoring.");
+ PINHIBIT->inert = true;
+ recheckIdleInhibitorStatus();
+ return;
+ }
+
+ PINHIBIT->surfaceDestroyListener = WLSurface->events.destroy.registerListener(
+ [this, PINHIBIT](std::any data) { std::erase_if(m_vIdleInhibitors, [PINHIBIT](const auto& other) { return other.get() == PINHIBIT; }); });
+
recheckIdleInhibitorStatus();
}
void CInputManager::recheckIdleInhibitorStatus() {
for (auto& ii : m_vIdleInhibitors) {
- if (ii->pWindow.expired())
+ if (ii->inert)
+ continue;
+
+ auto WLSurface = CWLSurface::surfaceFromWlr(ii->inhibitor->surface);
+
+ if (!WLSurface)
continue;
- if (g_pHyprRenderer->shouldRenderWindow(ii->pWindow.lock())) {
+ if (WLSurface->visible()) {
PROTO::idle->setInhibit(true);
return;
}