Move ownership of Session to Application
The Session can be useful not only to the platform backend but also input backends and for things such as vt switching, etc. Therefore it's better to have the Application own the Session.
This commit is contained in:
parent
5e669aece9
commit
cf3fe003e6
20 changed files with 54 additions and 61 deletions
|
@ -14,6 +14,7 @@
|
||||||
#include "inputmethod.h"
|
#include "inputmethod.h"
|
||||||
#include "platform.h"
|
#include "platform.h"
|
||||||
#include "pluginmanager.h"
|
#include "pluginmanager.h"
|
||||||
|
#include "session.h"
|
||||||
#include "utils/xcbutils.h"
|
#include "utils/xcbutils.h"
|
||||||
#include "wayland_server.h"
|
#include "wayland_server.h"
|
||||||
#include "workspace.h"
|
#include "workspace.h"
|
||||||
|
@ -68,6 +69,7 @@ WaylandTestApplication::WaylandTestApplication(OperationMode mode, int &argc, ch
|
||||||
removeLibraryPath(ownPath);
|
removeLibraryPath(ownPath);
|
||||||
addLibraryPath(ownPath);
|
addLibraryPath(ownPath);
|
||||||
|
|
||||||
|
setSession(Session::create(Session::Type::Noop));
|
||||||
setPlatform(std::make_unique<VirtualBackend>());
|
setPlatform(std::make_unique<VirtualBackend>());
|
||||||
WaylandServer::create(this);
|
WaylandServer::create(this);
|
||||||
setProcessStartupEnvironment(QProcessEnvironment::systemEnvironment());
|
setProcessStartupEnvironment(QProcessEnvironment::systemEnvironment());
|
||||||
|
|
|
@ -78,11 +78,11 @@ static QStringList splitPathList(const QString &input, const QChar delimiter)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
DrmBackend::DrmBackend(QObject *parent)
|
DrmBackend::DrmBackend(Session *session, QObject *parent)
|
||||||
: Platform(parent)
|
: Platform(parent)
|
||||||
, m_udev(std::make_unique<Udev>())
|
, m_udev(std::make_unique<Udev>())
|
||||||
, m_udevMonitor(m_udev->monitor())
|
, m_udevMonitor(m_udev->monitor())
|
||||||
, m_session(Session::create())
|
, m_session(session)
|
||||||
, m_explicitGpus(splitPathList(qEnvironmentVariable("KWIN_DRM_DEVICES"), ':'))
|
, m_explicitGpus(splitPathList(qEnvironmentVariable("KWIN_DRM_DEVICES"), ':'))
|
||||||
, m_dpmsFilter()
|
, m_dpmsFilter()
|
||||||
{
|
{
|
||||||
|
@ -93,16 +93,16 @@ DrmBackend::DrmBackend(QObject *parent)
|
||||||
|
|
||||||
DrmBackend::~DrmBackend() = default;
|
DrmBackend::~DrmBackend() = default;
|
||||||
|
|
||||||
|
Session *DrmBackend::session() const
|
||||||
|
{
|
||||||
|
return m_session;
|
||||||
|
}
|
||||||
|
|
||||||
bool DrmBackend::isActive() const
|
bool DrmBackend::isActive() const
|
||||||
{
|
{
|
||||||
return m_active;
|
return m_active;
|
||||||
}
|
}
|
||||||
|
|
||||||
Session *DrmBackend::session() const
|
|
||||||
{
|
|
||||||
return m_session.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
Outputs DrmBackend::outputs() const
|
Outputs DrmBackend::outputs() const
|
||||||
{
|
{
|
||||||
return m_outputs;
|
return m_outputs;
|
||||||
|
@ -196,17 +196,17 @@ void DrmBackend::deactivate()
|
||||||
bool DrmBackend::initialize()
|
bool DrmBackend::initialize()
|
||||||
{
|
{
|
||||||
// TODO: Pause/Resume individual GPU devices instead.
|
// TODO: Pause/Resume individual GPU devices instead.
|
||||||
connect(session(), &Session::devicePaused, this, [this](dev_t deviceId) {
|
connect(m_session, &Session::devicePaused, this, [this](dev_t deviceId) {
|
||||||
if (primaryGpu()->deviceId() == deviceId) {
|
if (primaryGpu()->deviceId() == deviceId) {
|
||||||
deactivate();
|
deactivate();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
connect(session(), &Session::deviceResumed, this, [this](dev_t deviceId) {
|
connect(m_session, &Session::deviceResumed, this, [this](dev_t deviceId) {
|
||||||
if (primaryGpu()->deviceId() == deviceId) {
|
if (primaryGpu()->deviceId() == deviceId) {
|
||||||
reactivate();
|
reactivate();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
connect(session(), &Session::awoke, this, &DrmBackend::turnOutputsOn);
|
connect(m_session, &Session::awoke, this, &DrmBackend::turnOutputsOn);
|
||||||
|
|
||||||
if (!m_explicitGpus.isEmpty()) {
|
if (!m_explicitGpus.isEmpty()) {
|
||||||
for (const QString &fileName : m_explicitGpus) {
|
for (const QString &fileName : m_explicitGpus) {
|
||||||
|
@ -280,7 +280,7 @@ void DrmBackend::handleUdevEvent()
|
||||||
|
|
||||||
DrmGpu *DrmBackend::addGpu(const QString &fileName)
|
DrmGpu *DrmBackend::addGpu(const QString &fileName)
|
||||||
{
|
{
|
||||||
int fd = session()->openRestricted(fileName);
|
int fd = m_session->openRestricted(fileName);
|
||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
qCWarning(KWIN_DRM) << "failed to open drm device at" << fileName;
|
qCWarning(KWIN_DRM) << "failed to open drm device at" << fileName;
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
@ -290,7 +290,7 @@ DrmGpu *DrmBackend::addGpu(const QString &fileName)
|
||||||
drmModeRes *resources = drmModeGetResources(fd);
|
drmModeRes *resources = drmModeGetResources(fd);
|
||||||
if (!resources) {
|
if (!resources) {
|
||||||
qCDebug(KWIN_DRM) << "Skipping KMS incapable drm device node at" << fileName;
|
qCDebug(KWIN_DRM) << "Skipping KMS incapable drm device node at" << fileName;
|
||||||
session()->closeRestricted(fd);
|
m_session->closeRestricted(fd);
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
drmModeFreeResources(resources);
|
drmModeFreeResources(resources);
|
||||||
|
@ -298,7 +298,7 @@ DrmGpu *DrmBackend::addGpu(const QString &fileName)
|
||||||
struct stat buf;
|
struct stat buf;
|
||||||
if (fstat(fd, &buf) == -1) {
|
if (fstat(fd, &buf) == -1) {
|
||||||
qCDebug(KWIN_DRM, "Failed to fstat %s: %s", qPrintable(fileName), strerror(errno));
|
qCDebug(KWIN_DRM, "Failed to fstat %s: %s", qPrintable(fileName), strerror(errno));
|
||||||
session()->closeRestricted(fd);
|
m_session->closeRestricted(fd);
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -549,7 +549,7 @@ void DrmBackend::enableOutput(DrmAbstractOutput *output, bool enable)
|
||||||
|
|
||||||
std::unique_ptr<InputBackend> DrmBackend::createInputBackend()
|
std::unique_ptr<InputBackend> DrmBackend::createInputBackend()
|
||||||
{
|
{
|
||||||
return std::make_unique<LibinputBackend>(session());
|
return std::make_unique<LibinputBackend>(m_session);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<QPainterBackend> DrmBackend::createQPainterBackend()
|
std::unique_ptr<QPainterBackend> DrmBackend::createQPainterBackend()
|
||||||
|
|
|
@ -24,6 +24,7 @@ struct gbm_bo;
|
||||||
namespace KWin
|
namespace KWin
|
||||||
{
|
{
|
||||||
|
|
||||||
|
class Session;
|
||||||
class Udev;
|
class Udev;
|
||||||
class UdevMonitor;
|
class UdevMonitor;
|
||||||
class UdevDevice;
|
class UdevDevice;
|
||||||
|
@ -39,16 +40,17 @@ class KWIN_EXPORT DrmBackend : public Platform
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit DrmBackend(QObject *parent = nullptr);
|
explicit DrmBackend(Session *session, QObject *parent = nullptr);
|
||||||
~DrmBackend() override;
|
~DrmBackend() override;
|
||||||
|
|
||||||
|
Session *session() const;
|
||||||
|
|
||||||
std::unique_ptr<InputBackend> createInputBackend() override;
|
std::unique_ptr<InputBackend> createInputBackend() override;
|
||||||
std::unique_ptr<QPainterBackend> createQPainterBackend() override;
|
std::unique_ptr<QPainterBackend> createQPainterBackend() override;
|
||||||
std::unique_ptr<OpenGLBackend> createOpenGLBackend() override;
|
std::unique_ptr<OpenGLBackend> createOpenGLBackend() override;
|
||||||
|
|
||||||
std::optional<DmaBufParams> testCreateDmaBuf(const QSize &size, quint32 format, const QVector<uint64_t> &modifiers) override;
|
std::optional<DmaBufParams> testCreateDmaBuf(const QSize &size, quint32 format, const QVector<uint64_t> &modifiers) override;
|
||||||
std::shared_ptr<DmaBufTexture> createDmaBufTexture(const QSize &size, quint32 format, const uint64_t modifier) override;
|
std::shared_ptr<DmaBufTexture> createDmaBufTexture(const QSize &size, quint32 format, const uint64_t modifier) override;
|
||||||
Session *session() const override;
|
|
||||||
bool initialize() override;
|
bool initialize() override;
|
||||||
|
|
||||||
Outputs outputs() const override;
|
Outputs outputs() const override;
|
||||||
|
@ -100,7 +102,7 @@ private:
|
||||||
|
|
||||||
std::unique_ptr<Udev> m_udev;
|
std::unique_ptr<Udev> m_udev;
|
||||||
std::unique_ptr<UdevMonitor> m_udevMonitor;
|
std::unique_ptr<UdevMonitor> m_udevMonitor;
|
||||||
std::unique_ptr<Session> m_session;
|
Session *m_session;
|
||||||
// all outputs, enabled and disabled
|
// all outputs, enabled and disabled
|
||||||
QVector<DrmAbstractOutput *> m_outputs;
|
QVector<DrmAbstractOutput *> m_outputs;
|
||||||
// only enabled outputs
|
// only enabled outputs
|
||||||
|
|
|
@ -9,7 +9,6 @@
|
||||||
#include "virtual_backend.h"
|
#include "virtual_backend.h"
|
||||||
|
|
||||||
#include "composite.h"
|
#include "composite.h"
|
||||||
#include "session.h"
|
|
||||||
#include "virtual_egl_backend.h"
|
#include "virtual_egl_backend.h"
|
||||||
#include "virtual_output.h"
|
#include "virtual_output.h"
|
||||||
#include "virtual_qpainter_backend.h"
|
#include "virtual_qpainter_backend.h"
|
||||||
|
@ -21,7 +20,6 @@ namespace KWin
|
||||||
|
|
||||||
VirtualBackend::VirtualBackend(QObject *parent)
|
VirtualBackend::VirtualBackend(QObject *parent)
|
||||||
: Platform(parent)
|
: Platform(parent)
|
||||||
, m_session(Session::create(Session::Type::Noop))
|
|
||||||
{
|
{
|
||||||
if (qEnvironmentVariableIsSet("KWIN_WAYLAND_VIRTUAL_SCREENSHOTS")) {
|
if (qEnvironmentVariableIsSet("KWIN_WAYLAND_VIRTUAL_SCREENSHOTS")) {
|
||||||
m_screenshotDir.reset(new QTemporaryDir);
|
m_screenshotDir.reset(new QTemporaryDir);
|
||||||
|
@ -45,11 +43,6 @@ VirtualBackend::~VirtualBackend()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Session *VirtualBackend::session() const
|
|
||||||
{
|
|
||||||
return m_session.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool VirtualBackend::initialize()
|
bool VirtualBackend::initialize()
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -30,7 +30,6 @@ public:
|
||||||
VirtualBackend(QObject *parent = nullptr);
|
VirtualBackend(QObject *parent = nullptr);
|
||||||
~VirtualBackend() override;
|
~VirtualBackend() override;
|
||||||
|
|
||||||
Session *session() const override;
|
|
||||||
bool initialize() override;
|
bool initialize() override;
|
||||||
|
|
||||||
bool saveFrames() const
|
bool saveFrames() const
|
||||||
|
@ -67,7 +66,6 @@ private:
|
||||||
QVector<VirtualOutput *> m_outputs;
|
QVector<VirtualOutput *> m_outputs;
|
||||||
QVector<VirtualOutput *> m_outputsEnabled;
|
QVector<VirtualOutput *> m_outputsEnabled;
|
||||||
std::unique_ptr<QTemporaryDir> m_screenshotDir;
|
std::unique_ptr<QTemporaryDir> m_screenshotDir;
|
||||||
std::unique_ptr<Session> m_session;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace KWin
|
} // namespace KWin
|
||||||
|
|
|
@ -14,7 +14,6 @@
|
||||||
#include <gbm.h>
|
#include <gbm.h>
|
||||||
#endif
|
#endif
|
||||||
#include "renderloop_p.h"
|
#include "renderloop_p.h"
|
||||||
#include "session.h"
|
|
||||||
#include "wayland_logging.h"
|
#include "wayland_logging.h"
|
||||||
#include "wayland_output.h"
|
#include "wayland_output.h"
|
||||||
#include "wayland_qpainter_backend.h"
|
#include "wayland_qpainter_backend.h"
|
||||||
|
@ -568,7 +567,6 @@ void WaylandSeat::destroyTouchDevice()
|
||||||
|
|
||||||
WaylandBackend::WaylandBackend(QObject *parent)
|
WaylandBackend::WaylandBackend(QObject *parent)
|
||||||
: Platform(parent)
|
: Platform(parent)
|
||||||
, m_session(Session::create(Session::Type::Noop))
|
|
||||||
, m_display(nullptr)
|
, m_display(nullptr)
|
||||||
, m_eventQueue(new EventQueue(this))
|
, m_eventQueue(new EventQueue(this))
|
||||||
, m_registry(new Registry(this))
|
, m_registry(new Registry(this))
|
||||||
|
@ -710,11 +708,6 @@ bool WaylandBackend::initialize()
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Session *WaylandBackend::session() const
|
|
||||||
{
|
|
||||||
return m_session.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
void WaylandBackend::initConnection()
|
void WaylandBackend::initConnection()
|
||||||
{
|
{
|
||||||
connect(
|
connect(
|
||||||
|
|
|
@ -252,7 +252,6 @@ public:
|
||||||
explicit WaylandBackend(QObject *parent = nullptr);
|
explicit WaylandBackend(QObject *parent = nullptr);
|
||||||
~WaylandBackend() override;
|
~WaylandBackend() override;
|
||||||
bool initialize() override;
|
bool initialize() override;
|
||||||
Session *session() const override;
|
|
||||||
wl_display *display();
|
wl_display *display();
|
||||||
KWayland::Client::Compositor *compositor();
|
KWayland::Client::Compositor *compositor();
|
||||||
KWayland::Client::SubCompositor *subCompositor();
|
KWayland::Client::SubCompositor *subCompositor();
|
||||||
|
@ -330,7 +329,6 @@ private:
|
||||||
|
|
||||||
WaylandOutput *createOutput(const QString &name, const QPoint &position, const QSize &size);
|
WaylandOutput *createOutput(const QString &name, const QPoint &position, const QSize &size);
|
||||||
|
|
||||||
std::unique_ptr<Session> m_session;
|
|
||||||
wl_display *m_display;
|
wl_display *m_display;
|
||||||
KWayland::Client::EventQueue *m_eventQueue;
|
KWayland::Client::EventQueue *m_eventQueue;
|
||||||
KWayland::Client::Registry *m_registry;
|
KWayland::Client::Registry *m_registry;
|
||||||
|
|
|
@ -100,7 +100,6 @@ bool XrandrEventFilter::event(xcb_generic_event_t *event)
|
||||||
|
|
||||||
X11StandalonePlatform::X11StandalonePlatform(QObject *parent)
|
X11StandalonePlatform::X11StandalonePlatform(QObject *parent)
|
||||||
: Platform(parent)
|
: Platform(parent)
|
||||||
, m_session(Session::create(Session::Type::Noop))
|
|
||||||
, m_updateOutputsTimer(new QTimer(this))
|
, m_updateOutputsTimer(new QTimer(this))
|
||||||
, m_x11Display(QX11Info::display())
|
, m_x11Display(QX11Info::display())
|
||||||
, m_renderLoop(std::make_unique<RenderLoop>())
|
, m_renderLoop(std::make_unique<RenderLoop>())
|
||||||
|
@ -154,11 +153,6 @@ bool X11StandalonePlatform::initialize()
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Session *X11StandalonePlatform::session() const
|
|
||||||
{
|
|
||||||
return m_session.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
std::unique_ptr<OpenGLBackend> X11StandalonePlatform::createOpenGLBackend()
|
std::unique_ptr<OpenGLBackend> X11StandalonePlatform::createOpenGLBackend()
|
||||||
{
|
{
|
||||||
switch (options->glPlatformInterface()) {
|
switch (options->glPlatformInterface()) {
|
||||||
|
|
|
@ -35,7 +35,6 @@ public:
|
||||||
X11StandalonePlatform(QObject *parent = nullptr);
|
X11StandalonePlatform(QObject *parent = nullptr);
|
||||||
~X11StandalonePlatform() override;
|
~X11StandalonePlatform() override;
|
||||||
bool initialize() override;
|
bool initialize() override;
|
||||||
Session *session() const override;
|
|
||||||
|
|
||||||
std::unique_ptr<OpenGLBackend> createOpenGLBackend() override;
|
std::unique_ptr<OpenGLBackend> createOpenGLBackend() override;
|
||||||
Edge *createScreenEdge(ScreenEdges *parent) override;
|
Edge *createScreenEdge(ScreenEdges *parent) override;
|
||||||
|
@ -86,7 +85,6 @@ private:
|
||||||
void updateRefreshRate();
|
void updateRefreshRate();
|
||||||
void updateCursor();
|
void updateCursor();
|
||||||
|
|
||||||
std::unique_ptr<Session> m_session;
|
|
||||||
std::unique_ptr<XInputIntegration> m_xinputIntegration;
|
std::unique_ptr<XInputIntegration> m_xinputIntegration;
|
||||||
QThread *m_openGLFreezeProtectionThread = nullptr;
|
QThread *m_openGLFreezeProtectionThread = nullptr;
|
||||||
QTimer *m_openGLFreezeProtection = nullptr;
|
QTimer *m_openGLFreezeProtection = nullptr;
|
||||||
|
|
|
@ -11,7 +11,6 @@
|
||||||
|
|
||||||
#include <config-kwin.h>
|
#include <config-kwin.h>
|
||||||
|
|
||||||
#include "session.h"
|
|
||||||
#include "utils/xcbutils.h"
|
#include "utils/xcbutils.h"
|
||||||
#include "wayland_server.h"
|
#include "wayland_server.h"
|
||||||
#include "x11_windowed_egl_backend.h"
|
#include "x11_windowed_egl_backend.h"
|
||||||
|
@ -164,7 +163,6 @@ void X11WindowedInputBackend::initialize()
|
||||||
|
|
||||||
X11WindowedBackend::X11WindowedBackend(QObject *parent)
|
X11WindowedBackend::X11WindowedBackend(QObject *parent)
|
||||||
: Platform(parent)
|
: Platform(parent)
|
||||||
, m_session(Session::create(Session::Type::Noop))
|
|
||||||
{
|
{
|
||||||
setSupportsPointerWarping(true);
|
setSupportsPointerWarping(true);
|
||||||
}
|
}
|
||||||
|
@ -234,11 +232,6 @@ bool X11WindowedBackend::initialize()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Session *X11WindowedBackend::session() const
|
|
||||||
{
|
|
||||||
return m_session.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
void X11WindowedBackend::initXInput()
|
void X11WindowedBackend::initXInput()
|
||||||
{
|
{
|
||||||
#if HAVE_X11_XINPUT
|
#if HAVE_X11_XINPUT
|
||||||
|
|
|
@ -88,7 +88,6 @@ public:
|
||||||
X11WindowedBackend(QObject *parent = nullptr);
|
X11WindowedBackend(QObject *parent = nullptr);
|
||||||
~X11WindowedBackend() override;
|
~X11WindowedBackend() override;
|
||||||
bool initialize() override;
|
bool initialize() override;
|
||||||
Session *session() const override;
|
|
||||||
|
|
||||||
xcb_connection_t *connection() const
|
xcb_connection_t *connection() const
|
||||||
{
|
{
|
||||||
|
@ -151,7 +150,6 @@ private:
|
||||||
void initXInput();
|
void initXInput();
|
||||||
X11WindowedOutput *findOutput(xcb_window_t window) const;
|
X11WindowedOutput *findOutput(xcb_window_t window) const;
|
||||||
|
|
||||||
std::unique_ptr<Session> m_session;
|
|
||||||
xcb_connection_t *m_connection = nullptr;
|
xcb_connection_t *m_connection = nullptr;
|
||||||
xcb_screen_t *m_screen = nullptr;
|
xcb_screen_t *m_screen = nullptr;
|
||||||
xcb_key_symbols_t *m_keySymbols = nullptr;
|
xcb_key_symbols_t *m_keySymbols = nullptr;
|
||||||
|
|
|
@ -25,7 +25,6 @@ ColorManager::ColorManager()
|
||||||
: d(std::make_unique<ColorManagerPrivate>())
|
: d(std::make_unique<ColorManagerPrivate>())
|
||||||
{
|
{
|
||||||
Platform *platform = kwinApp()->platform();
|
Platform *platform = kwinApp()->platform();
|
||||||
Session *session = platform->session();
|
|
||||||
|
|
||||||
const QVector<Output *> outputs = platform->enabledOutputs();
|
const QVector<Output *> outputs = platform->enabledOutputs();
|
||||||
for (Output *output : outputs) {
|
for (Output *output : outputs) {
|
||||||
|
@ -34,7 +33,7 @@ ColorManager::ColorManager()
|
||||||
|
|
||||||
connect(platform, &Platform::outputEnabled, this, &ColorManager::handleOutputEnabled);
|
connect(platform, &Platform::outputEnabled, this, &ColorManager::handleOutputEnabled);
|
||||||
connect(platform, &Platform::outputDisabled, this, &ColorManager::handleOutputDisabled);
|
connect(platform, &Platform::outputDisabled, this, &ColorManager::handleOutputDisabled);
|
||||||
connect(session, &Session::activeChanged, this, &ColorManager::handleSessionActiveChanged);
|
connect(kwinApp()->session(), &Session::activeChanged, this, &ColorManager::handleSessionActiveChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
ColorManager::~ColorManager() = default;
|
ColorManager::~ColorManager() = default;
|
||||||
|
|
|
@ -316,7 +316,7 @@ public:
|
||||||
if (event->type() == QEvent::KeyPress && !event->isAutoRepeat()) {
|
if (event->type() == QEvent::KeyPress && !event->isAutoRepeat()) {
|
||||||
const xkb_keysym_t keysym = event->nativeVirtualKey();
|
const xkb_keysym_t keysym = event->nativeVirtualKey();
|
||||||
if (keysym >= XKB_KEY_XF86Switch_VT_1 && keysym <= XKB_KEY_XF86Switch_VT_12) {
|
if (keysym >= XKB_KEY_XF86Switch_VT_1 && keysym <= XKB_KEY_XF86Switch_VT_12) {
|
||||||
kwinApp()->platform()->session()->switchTo(keysym - XKB_KEY_XF86Switch_VT_1 + 1);
|
kwinApp()->session()->switchTo(keysym - XKB_KEY_XF86Switch_VT_1 + 1);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2846,7 +2846,7 @@ private:
|
||||||
void InputRedirection::setupInputFilters()
|
void InputRedirection::setupInputFilters()
|
||||||
{
|
{
|
||||||
const bool hasGlobalShortcutSupport = waylandServer()->hasGlobalShortcutSupport();
|
const bool hasGlobalShortcutSupport = waylandServer()->hasGlobalShortcutSupport();
|
||||||
if ((kwinApp()->platform()->session()->capabilities() & Session::Capability::SwitchTerminal)
|
if ((kwinApp()->session()->capabilities() & Session::Capability::SwitchTerminal)
|
||||||
&& hasGlobalShortcutSupport) {
|
&& hasGlobalShortcutSupport) {
|
||||||
installInputEventFilter(new VirtualTerminalFilter);
|
installInputEventFilter(new VirtualTerminalFilter);
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
#if KWIN_BUILD_SCREENLOCKER
|
#if KWIN_BUILD_SCREENLOCKER
|
||||||
#include "screenlockerwatcher.h"
|
#include "screenlockerwatcher.h"
|
||||||
#endif
|
#endif
|
||||||
|
#include "session.h"
|
||||||
#include "sm.h"
|
#include "sm.h"
|
||||||
#include "utils/xcbutils.h"
|
#include "utils/xcbutils.h"
|
||||||
#include "wayland/surface_interface.h"
|
#include "wayland/surface_interface.h"
|
||||||
|
@ -125,6 +126,7 @@ Application::~Application()
|
||||||
destroyColorManager();
|
destroyColorManager();
|
||||||
destroyAtoms();
|
destroyAtoms();
|
||||||
destroyPlatform();
|
destroyPlatform();
|
||||||
|
m_session.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::notifyStarted()
|
void Application::notifyStarted()
|
||||||
|
@ -553,6 +555,12 @@ void Application::setPlatform(std::unique_ptr<Platform> &&platform)
|
||||||
m_platform = std::move(platform);
|
m_platform = std::move(platform);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Application::setSession(std::unique_ptr<Session> &&session)
|
||||||
|
{
|
||||||
|
Q_ASSERT(!m_session);
|
||||||
|
m_session = std::move(session);
|
||||||
|
}
|
||||||
|
|
||||||
PluginManager *Application::pluginManager() const
|
PluginManager *Application::pluginManager() const
|
||||||
{
|
{
|
||||||
return m_pluginManager.get();
|
return m_pluginManager.get();
|
||||||
|
|
|
@ -28,6 +28,7 @@ namespace KWin
|
||||||
{
|
{
|
||||||
|
|
||||||
class Platform;
|
class Platform;
|
||||||
|
class Session;
|
||||||
class X11EventFilter;
|
class X11EventFilter;
|
||||||
class PluginManager;
|
class PluginManager;
|
||||||
class InputMethod;
|
class InputMethod;
|
||||||
|
@ -228,6 +229,12 @@ public:
|
||||||
}
|
}
|
||||||
void setPlatform(std::unique_ptr<Platform> &&platform);
|
void setPlatform(std::unique_ptr<Platform> &&platform);
|
||||||
|
|
||||||
|
Session *session() const
|
||||||
|
{
|
||||||
|
return m_session.get();
|
||||||
|
}
|
||||||
|
void setSession(std::unique_ptr<Session> &&session);
|
||||||
|
|
||||||
bool isTerminating() const
|
bool isTerminating() const
|
||||||
{
|
{
|
||||||
return m_terminating;
|
return m_terminating;
|
||||||
|
@ -297,6 +304,7 @@ private:
|
||||||
#if KWIN_BUILD_ACTIVITIES
|
#if KWIN_BUILD_ACTIVITIES
|
||||||
bool m_useKActivities = true;
|
bool m_useKActivities = true;
|
||||||
#endif
|
#endif
|
||||||
|
std::unique_ptr<Session> m_session;
|
||||||
std::unique_ptr<Platform> m_platform;
|
std::unique_ptr<Platform> m_platform;
|
||||||
bool m_terminating = false;
|
bool m_terminating = false;
|
||||||
qreal m_xwaylandScale = 1;
|
qreal m_xwaylandScale = 1;
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
#include "effects.h"
|
#include "effects.h"
|
||||||
#include "inputmethod.h"
|
#include "inputmethod.h"
|
||||||
#include "platform.h"
|
#include "platform.h"
|
||||||
|
#include "session.h"
|
||||||
#include "tabletmodemanager.h"
|
#include "tabletmodemanager.h"
|
||||||
#include "utils/realtime.h"
|
#include "utils/realtime.h"
|
||||||
#include "wayland/display.h"
|
#include "wayland/display.h"
|
||||||
|
@ -542,15 +543,23 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
switch (backendType) {
|
switch (backendType) {
|
||||||
case BackendType::Kms:
|
case BackendType::Kms:
|
||||||
a.setPlatform(std::make_unique<KWin::DrmBackend>());
|
a.setSession(KWin::Session::create());
|
||||||
|
if (!a.session()) {
|
||||||
|
std::cerr << "FATAl ERROR: could not acquire a session" << std::endl;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
a.setPlatform(std::make_unique<KWin::DrmBackend>(a.session()));
|
||||||
break;
|
break;
|
||||||
case BackendType::Virtual:
|
case BackendType::Virtual:
|
||||||
|
a.setSession(KWin::Session::create(KWin::Session::Type::Noop));
|
||||||
a.setPlatform(std::make_unique<KWin::VirtualBackend>());
|
a.setPlatform(std::make_unique<KWin::VirtualBackend>());
|
||||||
break;
|
break;
|
||||||
case BackendType::X11:
|
case BackendType::X11:
|
||||||
|
a.setSession(KWin::Session::create(KWin::Session::Type::Noop));
|
||||||
a.setPlatform(std::make_unique<KWin::X11WindowedBackend>());
|
a.setPlatform(std::make_unique<KWin::X11WindowedBackend>());
|
||||||
break;
|
break;
|
||||||
case BackendType::Wayland:
|
case BackendType::Wayland:
|
||||||
|
a.setSession(KWin::Session::create(KWin::Session::Type::Noop));
|
||||||
a.setPlatform(std::make_unique<KWin::Wayland::WaylandBackend>());
|
a.setPlatform(std::make_unique<KWin::Wayland::WaylandBackend>());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
|
|
||||||
#include "backends/x11/standalone/x11_standalone_platform.h"
|
#include "backends/x11/standalone/x11_standalone_platform.h"
|
||||||
#include "platform.h"
|
#include "platform.h"
|
||||||
|
#include "session.h"
|
||||||
#include "sm.h"
|
#include "sm.h"
|
||||||
#include "tabletmodemanager.h"
|
#include "tabletmodemanager.h"
|
||||||
#include "utils/xcbutils.h"
|
#include "utils/xcbutils.h"
|
||||||
|
@ -410,6 +411,7 @@ int main(int argc, char *argv[])
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
a.setSession(KWin::Session::create(KWin::Session::Type::Noop));
|
||||||
a.setPlatform(std::make_unique<KWin::X11StandalonePlatform>());
|
a.setPlatform(std::make_unique<KWin::X11StandalonePlatform>());
|
||||||
a.start();
|
a.start();
|
||||||
|
|
||||||
|
|
|
@ -42,7 +42,6 @@ class OutlineVisual;
|
||||||
class QPainterBackend;
|
class QPainterBackend;
|
||||||
class Scene;
|
class Scene;
|
||||||
class ScreenEdges;
|
class ScreenEdges;
|
||||||
class Session;
|
|
||||||
class OutputConfiguration;
|
class OutputConfiguration;
|
||||||
struct DmaBufParams;
|
struct DmaBufParams;
|
||||||
|
|
||||||
|
@ -64,7 +63,6 @@ class KWIN_EXPORT Platform : public QObject
|
||||||
public:
|
public:
|
||||||
~Platform() override;
|
~Platform() override;
|
||||||
|
|
||||||
virtual Session *session() const = 0;
|
|
||||||
virtual bool initialize() = 0;
|
virtual bool initialize() = 0;
|
||||||
virtual std::unique_ptr<InputBackend> createInputBackend();
|
virtual std::unique_ptr<InputBackend> createInputBackend();
|
||||||
virtual std::unique_ptr<OpenGLBackend> createOpenGLBackend();
|
virtual std::unique_ptr<OpenGLBackend> createOpenGLBackend();
|
||||||
|
|
|
@ -101,7 +101,7 @@ NightColorManager::NightColorManager()
|
||||||
|
|
||||||
connect(kwinApp()->colorManager(), &ColorManager::deviceAdded, this, &NightColorManager::hardReset);
|
connect(kwinApp()->colorManager(), &ColorManager::deviceAdded, this, &NightColorManager::hardReset);
|
||||||
|
|
||||||
connect(kwinApp()->platform()->session(), &Session::activeChanged, this, [this](bool active) {
|
connect(kwinApp()->session(), &Session::activeChanged, this, [this](bool active) {
|
||||||
if (active) {
|
if (active) {
|
||||||
hardReset();
|
hardReset();
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -115,7 +115,7 @@ std::vector<UdevDevice::Ptr> UdevEnumerate::find()
|
||||||
if (deviceSeat.isEmpty()) {
|
if (deviceSeat.isEmpty()) {
|
||||||
deviceSeat = defaultSeat;
|
deviceSeat = defaultSeat;
|
||||||
}
|
}
|
||||||
if (deviceSeat != kwinApp()->platform()->session()->seat()) {
|
if (deviceSeat != kwinApp()->session()->seat()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
vect.push_back(std::move(device));
|
vect.push_back(std::move(device));
|
||||||
|
|
Loading…
Reference in a new issue