diff options
author | Vaxry <[email protected]> | 2024-12-13 21:30:19 +0000 |
---|---|---|
committer | Vaxry <[email protected]> | 2024-12-13 21:30:24 +0000 |
commit | 35e134e5700b7adb393ba91127bd11188259b901 (patch) | |
tree | 1315cc125918fb64d2905c296cf72f64c01c717d | |
parent | 452a7e6905de61f076065ef4c294dc62f86327ae (diff) | |
download | Hyprland-35e134e5700b7adb393ba91127bd11188259b901.tar.gz Hyprland-35e134e5700b7adb393ba91127bd11188259b901.zip |
hyprctl: add an inhibitingIdle field to windows
fixes #4322
-rw-r--r-- | src/debug/HyprCtl.cpp | 9 | ||||
-rw-r--r-- | src/managers/input/IdleInhibitor.cpp | 54 | ||||
-rw-r--r-- | src/managers/input/InputManager.hpp | 1 |
3 files changed, 47 insertions, 17 deletions
diff --git a/src/debug/HyprCtl.cpp b/src/debug/HyprCtl.cpp index 2566a483..5ce3933c 100644 --- a/src/debug/HyprCtl.cpp +++ b/src/debug/HyprCtl.cpp @@ -245,7 +245,8 @@ std::string CHyprCtl::getWindowData(PHLWINDOW w, eHyprCtlOutputFormat format) { "grouped": [{}], "tags": [{}], "swallowing": "0x{:x}", - "focusHistoryID": {} + "focusHistoryID": {}, + "inhibitingIdle": {} }},)#", (uintptr_t)w.get(), (w->m_bIsMapped ? "true" : "false"), (w->isHidden() ? "true" : "false"), (int)w->m_vRealPosition.goal().x, (int)w->m_vRealPosition.goal().y, (int)w->m_vRealSize.goal().x, (int)w->m_vRealSize.goal().y, w->m_pWorkspace ? w->workspaceID() : WORKSPACE_INVALID, @@ -253,18 +254,18 @@ std::string CHyprCtl::getWindowData(PHLWINDOW w, eHyprCtlOutputFormat format) { (int64_t)w->monitorID(), escapeJSONStrings(w->m_szClass), escapeJSONStrings(w->m_szTitle), escapeJSONStrings(w->m_szInitialClass), escapeJSONStrings(w->m_szInitialTitle), w->getPID(), ((int)w->m_bIsX11 == 1 ? "true" : "false"), (w->m_bPinned ? "true" : "false"), (uint8_t)w->m_sFullscreenState.internal, (uint8_t)w->m_sFullscreenState.client, getGroupedData(w, format), getTagsData(w, format), - (uintptr_t)w->m_pSwallowed.lock().get(), getFocusHistoryID(w)); + (uintptr_t)w->m_pSwallowed.lock().get(), getFocusHistoryID(w), (g_pInputManager->isWindowInhibiting(w, false) ? "true" : "false")); } else { return std::format( "Window {:x} -> {}:\n\tmapped: {}\n\thidden: {}\n\tat: {},{}\n\tsize: {},{}\n\tworkspace: {} ({})\n\tfloating: {}\n\tpseudo: {}\n\tmonitor: {}\n\tclass: {}\n\ttitle: " "{}\n\tinitialClass: {}\n\tinitialTitle: {}\n\tpid: " "{}\n\txwayland: {}\n\tpinned: " - "{}\n\tfullscreen: {}\n\tfullscreenClient: {}\n\tgrouped: {}\n\ttags: {}\n\tswallowing: {:x}\n\tfocusHistoryID: {}\n\n", + "{}\n\tfullscreen: {}\n\tfullscreenClient: {}\n\tgrouped: {}\n\ttags: {}\n\tswallowing: {:x}\n\tfocusHistoryID: {}\n\tinhibitingIdle: {}\n\n", (uintptr_t)w.get(), w->m_szTitle, (int)w->m_bIsMapped, (int)w->isHidden(), (int)w->m_vRealPosition.goal().x, (int)w->m_vRealPosition.goal().y, (int)w->m_vRealSize.goal().x, (int)w->m_vRealSize.goal().y, w->m_pWorkspace ? w->workspaceID() : WORKSPACE_INVALID, (!w->m_pWorkspace ? "" : w->m_pWorkspace->m_szName), (int)w->m_bIsFloating, (int)w->m_bIsPseudotiled, (int64_t)w->monitorID(), w->m_szClass, w->m_szTitle, w->m_szInitialClass, w->m_szInitialTitle, w->getPID(), (int)w->m_bIsX11, (int)w->m_bPinned, (uint8_t)w->m_sFullscreenState.internal, (uint8_t)w->m_sFullscreenState.client, getGroupedData(w, format), getTagsData(w, format), - (uintptr_t)w->m_pSwallowed.lock().get(), getFocusHistoryID(w)); + (uintptr_t)w->m_pSwallowed.lock().get(), getFocusHistoryID(w), (int)g_pInputManager->isWindowInhibiting(w, false)); } } 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; } diff --git a/src/managers/input/InputManager.hpp b/src/managers/input/InputManager.hpp index 57f93d2a..e56aaf6f 100644 --- a/src/managers/input/InputManager.hpp +++ b/src/managers/input/InputManager.hpp @@ -171,6 +171,7 @@ class CInputManager { // void newIdleInhibitor(std::any); void recheckIdleInhibitorStatus(); + bool isWindowInhibiting(const PHLWINDOW& pWindow, bool onlyHl = true); SSwipeGesture m_sActiveSwipe; |