kwin/src/session.h
Vlad Zahorodnii 4a1d5ea53c backends/drm: Improve PauseDevice/ResumeDevice signal handling
systemd takes care of setting and dropping master permissions when
sending PauseDevice and ResumeDevice signals.

When the ResumeDevice signal is received, the relevant drm device should
already have master permissions set up.

On the other hand, when the active property changes, there's still a
chance that systemd haven't granted drm master permissions to us.
2021-11-25 15:06:49 +00:00

118 lines
2.9 KiB
C++

/*
SPDX-FileCopyrightText: 2020 Vlad Zahorodnii <vlad.zahorodnii@kde.org>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#pragma once
#include <kwinglobals.h>
#include <QObject>
#include <QString>
#include <sys/types.h>
namespace KWin
{
/**
* The Session class represents the session controlled by the compositor.
*
* The Session class provides information about the virtual terminal where the compositor
* is running and a way to open files that require special privileges, e.g. DRM devices or
* input devices.
*/
class KWIN_EXPORT Session : public QObject
{
Q_OBJECT
public:
/**
* This enum type is used to specify the type of the session.
*/
enum class Type {
Noop,
ConsoleKit,
Logind,
};
/**
* This enum type is used to specify optional capabilities of the session.
*/
enum class Capability : uint {
SwitchTerminal = 0x1,
};
Q_DECLARE_FLAGS(Capabilities, Capability)
static Session *create(QObject *parent = nullptr);
static Session *create(Type type, QObject *parent = nullptr);
/**
* Returns @c true if the session is active; otherwise returns @c false.
*/
virtual bool isActive() const = 0;
/**
* Returns the capabilities supported by the session.
*/
virtual Capabilities capabilities() const = 0;
/**
* Returns the seat name for the Session.
*/
virtual QString seat() const = 0;
/**
* Returns the terminal controlled by the Session.
*/
virtual uint terminal() const = 0;
/**
* Opens the file with the specified @a fileName. Returns the file descriptor
* of the file or @a -1 if an error has occurred.
*/
virtual int openRestricted(const QString &fileName) = 0;
/**
* Closes a file that has been opened using the openRestricted() function.
*/
virtual void closeRestricted(int fileDescriptor) = 0;
/**
* Switches to the specified virtual @a terminal. This function does nothing if the
* Capability::SwitchTerminal capability is unsupported.
*/
virtual void switchTo(uint terminal) = 0;
Q_SIGNALS:
/**
* This signal is emitted when the session is resuming from suspend.
*/
void awoke();
/**
* This signal is emitted when the active state of the session has changed.
*/
void activeChanged(bool active);
/**
* This signal is emitted when the specified device can be used again.
*/
void deviceResumed(dev_t deviceId);
/**
* This signal is emitted when the given device cannot be used by the compositor
* anymore. For example, this normally occurs when switching between VTs.
*
* Note that when this signal is emitted for a DRM device, master permissions can
* be already revoked.
*/
void devicePaused(dev_t deviceId);
protected:
explicit Session(QObject *parent = nullptr);
};
} // namespace KWin
Q_DECLARE_OPERATORS_FOR_FLAGS(KWin::Session::Capabilities)