Avoid potential negative array index access to cached text.
[LibreOffice.git] / vcl / inc / unx / sessioninhibitor.hxx
blobca4dc6a93accdbffc8206d57532210f66e1b8f6d
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 #pragma once
12 #include <X11/Xlib.h>
13 #include <X11/Xmd.h>
15 #include <vcl/dllapi.h>
17 #include <optional>
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
28 public:
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);
33 private:
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;
44 #if !defined(__sun)
45 BOOL mbDPMSWasEnabled;
46 CARD16 mnDPMSStandbyTimeout;
47 CARD16 mnDPMSSuspendTimeout;
48 CARD16 mnDPMSOffTimeout;
49 #endif
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: */