From ed5640d8b587fbcfed7dd7967f3de04b37a76f26 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 11:06:44 +0200 Subject: Adding upstream version 4:7.4.7. Signed-off-by: Daniel Baumann --- vcl/inc/unx/screensaverinhibitor.hxx | 72 ++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 vcl/inc/unx/screensaverinhibitor.hxx (limited to 'vcl/inc/unx/screensaverinhibitor.hxx') diff --git a/vcl/inc/unx/screensaverinhibitor.hxx b/vcl/inc/unx/screensaverinhibitor.hxx new file mode 100644 index 000000000..f57d78b97 --- /dev/null +++ b/vcl/inc/unx/screensaverinhibitor.hxx @@ -0,0 +1,72 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#ifndef INCLUDED_VCL_INC_UNX_SCREENSAVERINHIBITOR_HXX +#define INCLUDED_VCL_INC_UNX_SCREENSAVERINHIBITOR_HXX + +#include +#include + +#include +#include + +#include +#include + +class VCL_PLUGIN_PUBLIC ScreenSaverInhibitor +{ +public: + void inhibit(bool bInhibit, std::u16string_view sReason, bool bIsX11, + const std::optional& xid, std::optional pDisplay); + +private: + // These are all used as guint, however this header may be included + // in kde/tde/etc backends, where we would ideally avoid having + // any glib dependencies, hence the direct use of unsigned int. + std::optional mnFDOCookie; // FDO ScreenSaver Inhibit + std::optional mnFDOPMCookie; // FDO PowerManagement Inhibit + std::optional mnGSMCookie; + std::optional mnMSMCookie; + + std::optional mnXScreenSaverTimeout; + +#if !defined(__sun) && !defined(AIX) + BOOL mbDPMSWasEnabled; + CARD16 mnDPMSStandbyTimeout; + CARD16 mnDPMSSuspendTimeout; + CARD16 mnDPMSOffTimeout; +#endif + + // There are a bunch of different dbus based inhibition APIs. Some call + // themselves ScreenSaver inhibition, some are PowerManagement inhibition, + // but they appear to have the same effect. There doesn't appear to be one + // all encompassing standard, hence we should just try all of them. + // + // The current APIs we have: (note: the list of supported environments is incomplete) + // FDO: org.freedesktop.ScreenSaver::Inhibit - appears to be supported only by KDE? + // FDOPM: org.freedesktop.PowerManagement.Inhibit::Inhibit - XFCE, (KDE) ? + // (KDE: doesn't inhibit screensaver, but does inhibit PowerManagement) + // GSM: org.gnome.SessionManager::Inhibit - gnome 3 + // MSM: org.mate.Sessionmanager::Inhibit - Mate <= 1.10, is identical to GSM + // (This is replaced by the GSM interface from Mate 1.12 onwards) + // + // Note: the Uninhibit call has different spelling in FDO (UnInhibit) vs GSM (Uninhibit) + void inhibitFDO(bool bInhibit, const char* appname, const char* reason); + void inhibitFDOPM(bool bInhibit, const char* appname, const char* reason); + void inhibitGSM(bool bInhibit, const char* appname, const char* reason, const unsigned int xid); + void inhibitMSM(bool bInhibit, const char* appname, const char* reason, const unsigned int xid); + + void inhibitXScreenSaver(bool bInhibit, Display* pDisplay); + static void inhibitXAutoLock(bool bInhibit, Display* pDisplay); + void inhibitDPMS(bool bInhibit, Display* pDisplay); +}; + +#endif // INCLUDED_VCL_INC_UNX_SCREENSAVERINHIBITOR_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ -- cgit v1.2.3