LibreOffice Module vcl (master)  1
screensaverinhibitor.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
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  */
9 
10 #ifndef INCLUDED_VCL_INC_UNX_SCREENSAVERINHIBITOR_HXX
11 #define INCLUDED_VCL_INC_UNX_SCREENSAVERINHIBITOR_HXX
12 
13 #include <X11/Xlib.h>
14 #include <X11/Xmd.h>
15 
16 #include <rtl/ustring.hxx>
17 #include <vcl/dllapi.h>
18 
19 #include <optional>
20 #include <string_view>
21 
23 {
24 public:
25  void inhibit(bool bInhibit, std::u16string_view sReason, bool bIsX11,
26  const std::optional<unsigned int>& xid, std::optional<Display*> pDisplay);
27 
28 private:
29  // These are all used as guint, however this header may be included
30  // in kde/tde/etc backends, where we would ideally avoid having
31  // any glib dependencies, hence the direct use of unsigned int.
32  std::optional<unsigned int> mnFDOCookie; // FDO ScreenSaver Inhibit
33  std::optional<unsigned int> mnFDOPMCookie; // FDO PowerManagement Inhibit
34  std::optional<unsigned int> mnGSMCookie;
35  std::optional<unsigned int> mnMSMCookie;
36 
37  std::optional<int> mnXScreenSaverTimeout;
38 
39 #if !defined(__sun) && !defined(AIX)
44 #endif
45 
46  // There are a bunch of different dbus based inhibition APIs. Some call
47  // themselves ScreenSaver inhibition, some are PowerManagement inhibition,
48  // but they appear to have the same effect. There doesn't appear to be one
49  // all encompassing standard, hence we should just try all of them.
50  //
51  // The current APIs we have: (note: the list of supported environments is incomplete)
52  // FDO: org.freedesktop.ScreenSaver::Inhibit - appears to be supported only by KDE?
53  // FDOPM: org.freedesktop.PowerManagement.Inhibit::Inhibit - XFCE, (KDE) ?
54  // (KDE: doesn't inhibit screensaver, but does inhibit PowerManagement)
55  // GSM: org.gnome.SessionManager::Inhibit - gnome 3
56  // MSM: org.mate.Sessionmanager::Inhibit - Mate <= 1.10, is identical to GSM
57  // (This is replaced by the GSM interface from Mate 1.12 onwards)
58  //
59  // Note: the Uninhibit call has different spelling in FDO (UnInhibit) vs GSM (Uninhibit)
60  void inhibitFDO(bool bInhibit, const char* appname, const char* reason);
61  void inhibitFDOPM(bool bInhibit, const char* appname, const char* reason);
62  void inhibitGSM(bool bInhibit, const char* appname, const char* reason, const unsigned int xid);
63  void inhibitMSM(bool bInhibit, const char* appname, const char* reason, const unsigned int xid);
64 
65  void inhibitXScreenSaver(bool bInhibit, Display* pDisplay);
66  static void inhibitXAutoLock(bool bInhibit, Display* pDisplay);
67  void inhibitDPMS(bool bInhibit, Display* pDisplay);
68 };
69 
70 #endif // INCLUDED_VCL_INC_UNX_SCREENSAVERINHIBITOR_HXX
71 
72 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
std::optional< unsigned int > mnFDOPMCookie
std::optional< unsigned int > mnGSMCookie
const wchar_t *typedef BOOL
std::optional< int > mnXScreenSaverTimeout
Display
std::optional< unsigned int > mnFDOCookie
std::optional< unsigned int > mnMSMCookie
#define VCL_PLUGIN_PUBLIC
Definition: dllapi.h:40