1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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/.
15 #include <vcl/dllapi.h>
18 #include <string_view>
20 enum ApplicationInhibitFlags
22 APPLICATION_INHIBIT_LOGOUT
= (1 << 0),
23 APPLICATION_INHIBIT_IDLE
= (1 << 3) // Inhibit the session being marked as idle
26 class VCL_PLUGIN_PUBLIC SessionManagerInhibitor
29 void inhibit(bool bInhibit
, std::u16string_view sReason
, ApplicationInhibitFlags eType
,
30 unsigned int window_system_id
, std::optional
<Display
*> pDisplay
,
31 const char* application_id
= nullptr);
34 // These are all used as guint, however this header may be included
35 // in kde/tde/etc backends, where we would ideally avoid having
36 // any glib dependencies, hence the direct use of unsigned int.
37 std::optional
<unsigned int> mnFDOSSCookie
; // FDO ScreenSaver Inhibit
38 std::optional
<unsigned int> mnFDOPMCookie
; // FDO PowerManagement Inhibit
39 std::optional
<unsigned int> mnGSMCookie
;
40 std::optional
<unsigned int> mnMSMCookie
;
42 std::optional
<int> mnXScreenSaverTimeout
;
45 BOOL mbDPMSWasEnabled
;
46 CARD16 mnDPMSStandbyTimeout
;
47 CARD16 mnDPMSSuspendTimeout
;
48 CARD16 mnDPMSOffTimeout
;
51 // There are a bunch of different dbus based inhibition APIs. Some call
52 // themselves ScreenSaver inhibition, some are PowerManagement inhibition,
53 // but they appear to have the same effect. There doesn't appear to be one
54 // all encompassing standard, hence we should just try all of them.
56 // The current APIs we have: (note: the list of supported environments is incomplete)
57 // FDSSO: org.freedesktop.ScreenSaver::Inhibit - appears to be supported only by KDE?
58 // FDOPM: org.freedesktop.PowerManagement.Inhibit::Inhibit - XFCE, (KDE) ?
59 // (KDE: doesn't inhibit screensaver, but does inhibit PowerManagement)
60 // GSM: org.gnome.SessionManager::Inhibit - gnome 3
61 // MSM: org.mate.Sessionmanager::Inhibit - Mate <= 1.10, is identical to GSM
62 // (This is replaced by the GSM interface from Mate 1.12 onwards)
64 // Note: the Uninhibit call has different spelling in FDOSS (UnInhibit) vs GSM (Uninhibit)
65 void inhibitFDOSS(bool bInhibit
, const char* appname
, const char* reason
);
66 void inhibitFDOPM(bool bInhibit
, const char* appname
, const char* reason
);
67 void inhibitGSM(bool bInhibit
, const char* appname
, const char* reason
,
68 ApplicationInhibitFlags eType
, unsigned int window_system_id
);
69 void inhibitMSM(bool bInhibit
, const char* appname
, const char* reason
,
70 ApplicationInhibitFlags eType
, unsigned int window_system_id
);
72 void inhibitXScreenSaver(bool bInhibit
, Display
* pDisplay
);
73 static void inhibitXAutoLock(bool bInhibit
, Display
* pDisplay
);
74 void inhibitDPMS(bool bInhibit
, Display
* pDisplay
);
77 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */