Version 5.4.3.2, tag libreoffice-5.4.3.2
[LibreOffice.git] / vcl / inc / unx / screensaverinhibitor.hxx
blob76c57722c3389d89eb6eb88ba481b33881e91ebd
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 */
10 #ifndef INCLUDED_VCL_INC_UNX_SCREENSAVERINHIBITOR_HXX
11 #define INCLUDED_VCL_INC_UNX_SCREENSAVERINHIBITOR_HXX
13 #include <X11/Xlib.h>
14 #include <X11/Xutil.h>
15 #if !defined(__sun) && !defined(AIX)
16 #include <X11/extensions/dpms.h>
17 #endif
19 #include <rtl/ustring.hxx>
20 #include <vcl/dllapi.h>
22 #include <boost/optional.hpp>
24 class VCL_PLUGIN_PUBLIC ScreenSaverInhibitor
26 public:
27 void inhibit( bool bInhibit, const rtl::OUString& sReason,
28 bool bIsX11, const boost::optional<unsigned int>& xid, boost::optional<Display*> pDisplay );
30 private:
31 // These are all used as guint, however this header may be included
32 // in kde/tde/etc backends, where we would ideally avoid having
33 // any glib dependencies, hence the direct use of unsigned int.
34 boost::optional<unsigned int> mnFDOCookie; // FDO ScreenSaver Inhibit
35 boost::optional<unsigned int> mnFDOPMCookie; // FDO PowerManagement Inhibit
36 boost::optional<unsigned int> mnGSMCookie;
37 boost::optional<unsigned int> mnMSMCookie;
39 boost::optional<int> mnXScreenSaverTimeout;
41 #if !defined(__sun) && !defined(AIX)
42 BOOL mbDPMSWasEnabled;
43 CARD16 mnDPMSStandbyTimeout;
44 CARD16 mnDPMSSuspendTimeout;
45 CARD16 mnDPMSOffTimeout;
46 #endif
48 // There are a bunch of different dbus based inhibition APIs. Some call
49 // themselves ScreenSaver inhibition, some are PowerManagement inhibition,
50 // but they appear to have the same effect. There doesn't appear to be one
51 // all encompassing standard, hence we should just try all of tem.
53 // The current APIs we have: (note: the list of supported environments is incomplete)
54 // FDO: org.freedesktop.ScreenSaver::Inhibit - appears to be supported only by KDE?
55 // FDOPM: org.freedesktop.PowerManagement.Inhibit::Inhibit - XFCE, (KDE) ?
56 // (KDE: doesn't inhibit screensaver, but does inhibit PowerManagement)
57 // GSM: org.gnome.SessionManager::Inhibit - gnome 3
58 // MSM: org.mate.Sessionmanager::Inhibit - Mate <= 1.10, is identical to GSM
59 // (This is replaced by the GSM interface from Mate 1.12 onwards)
61 // Note: the Uninhibit call has different spelling in FDO (UnInhibit) vs GSM (Uninhibit)
62 void inhibitFDO( bool bInhibit, const char* appname, const char* reason );
63 void inhibitFDOPM( bool bInhibit, const char* appname, const char* reason );
64 void inhibitGSM( bool bInhibit, const char* appname, const char* reason, const unsigned int xid );
65 void inhibitMSM( bool bInhibit, const char* appname, const char* reason, const unsigned int xid );
67 void inhibitXScreenSaver( bool bInhibit, Display* pDisplay );
68 static void inhibitXAutoLock( bool bInhibit, Display* pDisplay );
69 void inhibitDPMS( bool bInhibit, Display* pDisplay );
72 #endif // INCLUDED_VCL_INC_UNX_SCREENSAVERINHIBITOR_HXX
74 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */