summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorvaxerski <43317083+vaxerski@users.noreply.github.com>2022-10-31 12:26:07 +0000
committervaxerski <43317083+vaxerski@users.noreply.github.com>2022-10-31 12:26:07 +0000
commita69fd21a1ac90c24cee659595d62329f8638d632 (patch)
treec1c1302b9a732f52607df7c0c6f43525caf3a9f9 /src
parentb6e33830af1a89a2cfbef446de1fc37e8a2b40e3 (diff)
Add an idleinhibit windowrule
Diffstat (limited to 'src')
-rw-r--r--src/Compositor.cpp7
-rw-r--r--src/Window.hpp10
-rw-r--r--src/config/ConfigManager.cpp1
-rw-r--r--src/events/Windows.cpp14
-rw-r--r--src/managers/input/IdleInhibitor.cpp21
5 files changed, 52 insertions, 1 deletions
diff --git a/src/Compositor.cpp b/src/Compositor.cpp
index 12f753f8..ba6312f4 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 236ee47b..bf77454c 100644
--- a/src/Window.hpp
+++ b/src/Window.hpp
@@ -7,6 +7,13 @@
#include "render/decorations/IHyprWindowDecoration.hpp"
#include <deque>
+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 d3b6e507..7e44b41d 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 07835543..034a1005 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 3efb40c6..8c0a3267 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