From 7a2591a1fa183410c32762ae3a271ba6df8a2c25 Mon Sep 17 00:00:00 2001 From: Louis des Landes Date: Fri, 12 Sep 2025 10:42:24 +0930 Subject: [PATCH] fix: wayland sleep inhibit on client Fixes #8827 Adds the XWindowsPowerManager to the EiScreen as, despite the name, this works on Wayland as well. --- src/lib/platform/EiScreen.cpp | 6 ++++++ src/lib/platform/EiScreen.h | 3 +++ 2 files changed, 9 insertions(+) diff --git a/src/lib/platform/EiScreen.cpp b/src/lib/platform/EiScreen.cpp index ca1c8367f..6350a5545 100644 --- a/src/lib/platform/EiScreen.cpp +++ b/src/lib/platform/EiScreen.cpp @@ -14,6 +14,7 @@ #include "base/Log.h" #include "base/Stopwatch.h" #include "common/Constants.h" +#include "deskflow/App.h" #include "deskflow/Clipboard.h" #include "deskflow/KeyMap.h" #include "deskflow/ScreenException.h" @@ -73,6 +74,11 @@ EiScreen::EiScreen(bool isPrimary, IEventQueue *events, bool usePortal, deskflow throw std::runtime_error("failed to init ei context"); } } + + // disable sleep if the flag is set + if (App::instance().argsBase().m_preventSleep) { + m_powerManager.disableSleep(); + } } EiScreen::~EiScreen() diff --git a/src/lib/platform/EiScreen.h b/src/lib/platform/EiScreen.h index 3c7e88c1b..0a615815e 100644 --- a/src/lib/platform/EiScreen.h +++ b/src/lib/platform/EiScreen.h @@ -9,6 +9,7 @@ #include "deskflow/KeyMap.h" #include "deskflow/PlatformScreen.h" +#include "platform/XWindowsPowerManager.h" #include #include @@ -188,6 +189,8 @@ private: using HotKeyMap = std::map; HotKeyMap m_hotkeys; + // Despite the name XWindowsPowerManager, this works on Wayland too + XWindowsPowerManager m_powerManager; }; } // namespace deskflow