vcl/Library_vcl.mk | 4 +++- vcl/inc/qt5/QtFrame.hxx | 4 ++-- vcl/inc/unx/sessioninhibitor.hxx | 19 ++++++++++++++----- vcl/qt5/QtFrame.cxx | 11 +++-------- vcl/unx/generic/window/sessioninhibitor.cxx | 22 ++++++++++++++++++---- 5 files changed, 40 insertions(+), 20 deletions(-)
New commits: commit 2f6f717073084b17e9be80e32a87200bacd1b74c Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Thu Aug 15 11:29:36 2024 +0200 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Thu Aug 15 20:36:42 2024 +0200 qt: Drop X11 condition for session/screensaver inhibition The DBus based session/sreenlock inhibition work on Wayland just fine, and in a quick test with the qt6 VCL plugin on Plasma 5 Wayland on Debian testing, the screen saver is inhibited as expected and doesn't start while an Impress presentation is running. The code in `QtFrame::StartPresentation` being guarded by a `CHECK_ANY_QT_USING_X11` at first looks like this was all X11-only code. It already worked just fine on Wayland before that commit however, as it's a build time check only, and X11 is enabled by default at build time, and the code would run just fine on Wayland then with a null X11 Display. Drop the `CHECK_ANY_QT_USING_X11` (build-time) condition altogether, now that `USING_X11` is no more required after Change-Id: Ic46c3f18151340a5ea6c0b62a82c957fd1cd6484 Author: Michael Weghorn <m.wegh...@posteo.de> Date: Thu Aug 15 10:13:27 2024 +0200 vcl: Allow DBus-based session inhibition without requiring X11 Move the X11-specific code into the `#if CHECK_QT5_USING_X11` block and call the overload that doesn't require an X11 Display otherwise. Change-Id: Idee0564d136e59ce54945670dee26df0cfc64d85 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/171896 Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> Tested-by: Jenkins diff --git a/vcl/inc/qt5/QtFrame.hxx b/vcl/inc/qt5/QtFrame.hxx index b80818687c0e..57a1b8cd1e2c 100644 --- a/vcl/inc/qt5/QtFrame.hxx +++ b/vcl/inc/qt5/QtFrame.hxx @@ -33,8 +33,8 @@ #include <QtCore/QObject> -#if CHECK_ANY_QT_USING_X11 #include <unx/sessioninhibitor.hxx> +#if CHECK_ANY_QT_USING_X11 // any better way to get rid of the X11 / Qt type clashes? #undef Bool #undef CursorShape @@ -101,8 +101,8 @@ class VCLPLUG_QT_PUBLIC QtFrame : public QObject, public SalFrame sal_uInt32 m_nRestoreScreen; QRect m_aRestoreGeometry; -#if CHECK_ANY_QT_USING_X11 SessionManagerInhibitor m_SessionManagerInhibitor; +#if CHECK_ANY_QT_USING_X11 ModKeyFlags m_nKeyModifiers; #endif diff --git a/vcl/qt5/QtFrame.cxx b/vcl/qt5/QtFrame.cxx index 3949650a410c..80c03174c221 100644 --- a/vcl/qt5/QtFrame.cxx +++ b/vcl/qt5/QtFrame.cxx @@ -745,25 +745,20 @@ void QtFrame::ShowFullScreen(bool bFullScreen, sal_Int32 nScreen) void QtFrame::StartPresentation(bool bStart) { -#if CHECK_ANY_QT_USING_X11 - // meh - so there's no Qt platform independent solution - // https://forum.qt.io/topic/38504/solved-qdialog-in-fullscreen-disable-os-screensaver assert(m_aSystemData.platform != SystemEnvData::Platform::Invalid); - unsigned int nRootWindow(0); - std::optional<Display*> aDisplay; #if CHECK_QT5_USING_X11 + unsigned int nRootWindow(0); + std::optional<Display*> aDisplay; if (QX11Info::isPlatformX11()) { nRootWindow = QX11Info::appRootWindow(); aDisplay = QX11Info::display(); } -#endif - m_SessionManagerInhibitor.inhibit(bStart, u"presentation", APPLICATION_INHIBIT_IDLE, nRootWindow, aDisplay); #else - Q_UNUSED(bStart) + m_SessionManagerInhibitor.inhibit(bStart, u"presentation", APPLICATION_INHIBIT_IDLE); #endif } commit 445ab7c94ca547f1d8d37c85a26fac2ef8d86ce6 Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Thu Aug 15 10:13:27 2024 +0200 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Thu Aug 15 20:36:35 2024 +0200 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.wegh...@posteo.de> diff --git a/vcl/Library_vcl.mk b/vcl/Library_vcl.mk index eaeecca9b35f..1635358258a0 100644 --- a/vcl/Library_vcl.mk +++ b/vcl/Library_vcl.mk @@ -577,7 +577,6 @@ endif ifeq ($(USING_X11),TRUE) $(eval $(call gb_Library_add_exception_objects,vcl,\ vcl/unx/generic/desktopdetect/desktopdetector \ - vcl/unx/generic/window/sessioninhibitor \ $(if $(ENABLE_CPDB), \ vcl/unx/generic/printer/cpdmgr \ ) \ @@ -615,6 +614,9 @@ $(eval $(call gb_Library_add_exception_objects,vcl,\ vcl/skia/zone \ vcl/skia/gdiimpl \ ) \ + $(if $(filter LINUX SOLARIS %BSD,$(OS)), \ + vcl/unx/generic/window/sessioninhibitor \ + ) \ )) $(eval $(call gb_Library_use_externals,vcl,\ 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> @@ -26,9 +30,14 @@ enum ApplicationInhibitFlags 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: */ diff --git a/vcl/unx/generic/window/sessioninhibitor.cxx b/vcl/unx/generic/window/sessioninhibitor.cxx index b207c9a1282f..296e8f477130 100644 --- a/vcl/unx/generic/window/sessioninhibitor.cxx +++ b/vcl/unx/generic/window/sessioninhibitor.cxx @@ -14,12 +14,14 @@ #include <unx/gensys.h> #include <unx/sessioninhibitor.hxx> +#if USING_X11 #include <X11/Xlib.h> #include <X11/Xatom.h> #if !defined(__sun) #include <X11/extensions/dpms.h> #endif +#endif #include <config_gio.h> @@ -43,8 +45,7 @@ #include <sal/log.hxx> void SessionManagerInhibitor::inhibit(bool bInhibit, std::u16string_view sReason, ApplicationInhibitFlags eType, - unsigned int window_system_id, std::optional<Display*> pDisplay, - const char* application_id) + unsigned int window_system_id, const char* application_id) { const char* appname = application_id ? application_id : SalGenericSystem::getFrameClassName(); const OString aReason = OUStringToOString( sReason, RTL_TEXTENCODING_UTF8 ); @@ -55,15 +56,26 @@ void SessionManagerInhibitor::inhibit(bool bInhibit, std::u16string_view sReason inhibitFDOPM( bInhibit, appname, aReason.getStr() ); } + inhibitGSM(bInhibit, appname, aReason.getStr(), eType, window_system_id); + +} + + +#if USING_X11 +void SessionManagerInhibitor::inhibit(bool bInhibit, std::u16string_view sReason, ApplicationInhibitFlags eType, + unsigned int window_system_id, std::optional<Display*> pDisplay, + const char* application_id) +{ + inhibit(bInhibit, sReason, eType, window_system_id, application_id); + if (eType == APPLICATION_INHIBIT_IDLE && pDisplay) { inhibitXScreenSaver( bInhibit, *pDisplay ); inhibitXAutoLock( bInhibit, *pDisplay ); inhibitDPMS( bInhibit, *pDisplay ); } - - inhibitGSM(bInhibit, appname, aReason.getStr(), eType, window_system_id); } +#endif #if ENABLE_GIO static void dbusInhibit( bool bInhibit, @@ -231,6 +243,7 @@ void SessionManagerInhibitor::inhibitGSM( bool bInhibit, const char* appname, co #endif // ENABLE_GIO } +#if USING_X11 /** * Disable screensavers using the XSetScreenSaver/XGetScreenSaver API. * @@ -330,5 +343,6 @@ void SessionManagerInhibitor::inhibitDPMS( bool bInhibit, Display* pDisplay ) } #endif // !defined(__sun) } +#endif // USING_X11 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */