LibreOffice Module vcl (master) 1
sessioninhibitor.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{
25 APPLICATION_INHIBIT_IDLE = (1 << 3) // Inhibit the session being marked as idle
26};
27
29{
30public:
31 void inhibit(bool bInhibit, std::u16string_view sReason, ApplicationInhibitFlags eType,
32 unsigned int window_system_id, std::optional<Display*> pDisplay,
33 const char* application_id = nullptr);
34
35private:
36 // These are all used as guint, however this header may be included
37 // in kde/tde/etc backends, where we would ideally avoid having
38 // any glib dependencies, hence the direct use of unsigned int.
39 std::optional<unsigned int> mnFDOSSCookie; // FDO ScreenSaver Inhibit
40 std::optional<unsigned int> mnFDOPMCookie; // FDO PowerManagement Inhibit
41 std::optional<unsigned int> mnGSMCookie;
42 std::optional<unsigned int> mnMSMCookie;
43
44 std::optional<int> mnXScreenSaverTimeout;
45
46#if !defined(__sun)
51#endif
52
53 // There are a bunch of different dbus based inhibition APIs. Some call
54 // themselves ScreenSaver inhibition, some are PowerManagement inhibition,
55 // but they appear to have the same effect. There doesn't appear to be one
56 // all encompassing standard, hence we should just try all of them.
57 //
58 // The current APIs we have: (note: the list of supported environments is incomplete)
59 // FDSSO: org.freedesktop.ScreenSaver::Inhibit - appears to be supported only by KDE?
60 // FDOPM: org.freedesktop.PowerManagement.Inhibit::Inhibit - XFCE, (KDE) ?
61 // (KDE: doesn't inhibit screensaver, but does inhibit PowerManagement)
62 // GSM: org.gnome.SessionManager::Inhibit - gnome 3
63 // MSM: org.mate.Sessionmanager::Inhibit - Mate <= 1.10, is identical to GSM
64 // (This is replaced by the GSM interface from Mate 1.12 onwards)
65 //
66 // Note: the Uninhibit call has different spelling in FDOSS (UnInhibit) vs GSM (Uninhibit)
67 void inhibitFDOSS(bool bInhibit, const char* appname, const char* reason);
68 void inhibitFDOPM(bool bInhibit, const char* appname, const char* reason);
69 void inhibitGSM(bool bInhibit, const char* appname, const char* reason,
70 ApplicationInhibitFlags eType, unsigned int window_system_id);
71 void inhibitMSM(bool bInhibit, const char* appname, const char* reason,
72 ApplicationInhibitFlags eType, unsigned int window_system_id);
73
74 void inhibitXScreenSaver(bool bInhibit, Display* pDisplay);
75 static void inhibitXAutoLock(bool bInhibit, Display* pDisplay);
76 void inhibitDPMS(bool bInhibit, Display* pDisplay);
77};
78
79#endif // INCLUDED_VCL_INC_UNX_SCREENSAVERINHIBITOR_HXX
80
81/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
std::optional< unsigned int > mnMSMCookie
std::optional< unsigned int > mnFDOSSCookie
void inhibitDPMS(bool bInhibit, Display *pDisplay)
static void inhibitXAutoLock(bool bInhibit, Display *pDisplay)
void inhibitMSM(bool bInhibit, const char *appname, const char *reason, ApplicationInhibitFlags eType, unsigned int window_system_id)
void inhibitGSM(bool bInhibit, const char *appname, const char *reason, ApplicationInhibitFlags eType, unsigned int window_system_id)
std::optional< int > mnXScreenSaverTimeout
std::optional< unsigned int > mnGSMCookie
std::optional< unsigned int > mnFDOPMCookie
void inhibit(bool bInhibit, std::u16string_view sReason, ApplicationInhibitFlags eType, unsigned int window_system_id, std::optional< Display * > pDisplay, const char *application_id=nullptr)
void inhibitFDOSS(bool bInhibit, const char *appname, const char *reason)
void inhibitXScreenSaver(bool bInhibit, Display *pDisplay)
void inhibitFDOPM(bool bInhibit, const char *appname, const char *reason)
#define VCL_PLUGIN_PUBLIC
Definition: dllapi.h:40
Display
const wchar_t *typedef BOOL
ApplicationInhibitFlags
@ APPLICATION_INHIBIT_IDLE
@ APPLICATION_INHIBIT_LOGOUT