diff options
author | Michael Weghorn <m.weghorn@posteo.de> | 2024-08-15 10:13:27 +0200 |
---|---|---|
committer | Michael Weghorn <m.weghorn@posteo.de> | 2024-08-15 20:36:35 +0200 |
commit | 445ab7c94ca547f1d8d37c85a26fac2ef8d86ce6 (patch) | |
tree | 74769b8985a5d419950c2a9c47f686b79130851a /vcl/inc | |
parent | e8d59edf9dddf809a08cf827235ebb033590f819 (diff) |
vcl: Allow DBus-based session inhibition without requiring X11
So far, building `SessionManagerInhibitor` code was
conditional on `USING_X11`.
Besides direct X11 API calls, it uses DBus calls to inhibit
lockscreen, power management, etc.
The DBus based ways don't depend on X11 at all.
Therefore, build the `SessionManagerInhibitor`code on
relevant platforms unless the GUI feature is disabled
altogether, and make only the X11 specific code conditional
on `USING_X11` in addition.
Move the non-X11 specific code from the existing
`SessionManagerInhibitor::inhibit` to a new overloaded
version that doesn't require an (X11) `Display` param.
This builds successfully in an
`--enable-gui --without-x` build.
Change-Id: Ic46c3f18151340a5ea6c0b62a82c957fd1cd6484
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/171895
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
Diffstat (limited to 'vcl/inc')
-rw-r--r-- | vcl/inc/unx/sessioninhibitor.hxx | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/vcl/inc/unx/sessioninhibitor.hxx b/vcl/inc/unx/sessioninhibitor.hxx index 94eb9fa82a8a..130ead989869 100644 --- a/vcl/inc/unx/sessioninhibitor.hxx +++ b/vcl/inc/unx/sessioninhibitor.hxx @@ -9,8 +9,12 @@ #pragma once +#include <config_vclplug.h> + +#if USING_X11 #include <X11/Xlib.h> #include <X11/Xmd.h> +#endif #include <vcl/dllapi.h> @@ -27,8 +31,13 @@ class VCL_PLUGIN_PUBLIC SessionManagerInhibitor { public: void inhibit(bool bInhibit, std::u16string_view sReason, ApplicationInhibitFlags eType, + unsigned int window_system_id = 0, const char* application_id = nullptr); +#if USING_X11 + // calls the above and direct X11-specific API calls in addition + void inhibit(bool bInhibit, std::u16string_view sReason, ApplicationInhibitFlags eType, unsigned int window_system_id, std::optional<Display*> pDisplay, const char* application_id = nullptr); +#endif private: // These are all used as guint, however this header may be included @@ -40,11 +49,15 @@ private: std::optional<int> mnXScreenSaverTimeout; -#if !defined(__sun) +#if USING_X11 && !defined(__sun) BOOL mbDPMSWasEnabled; CARD16 mnDPMSStandbyTimeout; CARD16 mnDPMSSuspendTimeout; CARD16 mnDPMSOffTimeout; + + SAL_DLLPRIVATE void inhibitXScreenSaver(bool bInhibit, Display* pDisplay); + SAL_DLLPRIVATE static void inhibitXAutoLock(bool bInhibit, Display* pDisplay); + SAL_DLLPRIVATE void inhibitDPMS(bool bInhibit, Display* pDisplay); #endif // There are a bunch of different dbus based inhibition APIs. Some call @@ -63,10 +76,6 @@ private: SAL_DLLPRIVATE void inhibitFDOPM(bool bInhibit, const char* appname, const char* reason); SAL_DLLPRIVATE void inhibitGSM(bool bInhibit, const char* appname, const char* reason, ApplicationInhibitFlags eType, unsigned int window_system_id); - - SAL_DLLPRIVATE void inhibitXScreenSaver(bool bInhibit, Display* pDisplay); - SAL_DLLPRIVATE static void inhibitXAutoLock(bool bInhibit, Display* pDisplay); - SAL_DLLPRIVATE void inhibitDPMS(bool bInhibit, Display* pDisplay); }; /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |