[wayland] Backends are no longer singletons
They are installed in the WaylandServer, thus we don't need an explicit singleton accessor. If we need to differentiate we can cast.
This commit is contained in:
parent
93e717b072
commit
49f58059c6
17 changed files with 77 additions and 82 deletions
|
@ -19,12 +19,13 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*********************************************************************/
|
||||
#ifndef KWIN_ABSTRACT_BACKEND_H
|
||||
#define KWIN_ABSTRACT_BACKEND_H
|
||||
#include <kwin_export.h>
|
||||
#include <QObject>
|
||||
|
||||
namespace KWin
|
||||
{
|
||||
|
||||
class AbstractBackend : public QObject
|
||||
class KWIN_EXPORT AbstractBackend : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
|
|
@ -39,6 +39,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
#include "xcbutils.h"
|
||||
#if HAVE_WAYLAND
|
||||
#include "wayland_backend.h"
|
||||
#include "wayland_server.h"
|
||||
#endif
|
||||
#include "decorations/decoratedclient.h"
|
||||
|
||||
|
@ -118,9 +119,9 @@ Compositor::Compositor(QObject* workspace)
|
|||
connect(&m_unusedSupportPropertyTimer, SIGNAL(timeout()), SLOT(deleteUnusedSupportProperties()));
|
||||
#if HAVE_WAYLAND
|
||||
if (kwinApp()->operationMode() != Application::OperationModeX11) {
|
||||
if (Wayland::WaylandBackend::self()) {
|
||||
connect(Wayland::WaylandBackend::self(), &Wayland::WaylandBackend::systemCompositorDied, this, &Compositor::finish);
|
||||
connect(Wayland::WaylandBackend::self(), &Wayland::WaylandBackend::backendReady, this, &Compositor::setup);
|
||||
if (Wayland::WaylandBackend *w = dynamic_cast<Wayland::WaylandBackend *>(waylandServer()->backend())) {
|
||||
connect(w, &Wayland::WaylandBackend::systemCompositorDied, this, &Compositor::finish);
|
||||
connect(w, &Wayland::WaylandBackend::backendReady, this, &Compositor::setup);
|
||||
} else {
|
||||
QMetaObject::invokeMethod(this, "setup", Qt::QueuedConnection);
|
||||
}
|
||||
|
|
|
@ -37,11 +37,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
namespace KWin
|
||||
{
|
||||
|
||||
EglWaylandBackend::EglWaylandBackend()
|
||||
EglWaylandBackend::EglWaylandBackend(Wayland::WaylandBackend *b)
|
||||
: QObject(NULL)
|
||||
, AbstractEglBackend()
|
||||
, m_bufferAge(0)
|
||||
, m_wayland(Wayland::WaylandBackend::self())
|
||||
, m_wayland(b)
|
||||
, m_overlay(NULL)
|
||||
{
|
||||
if (!m_wayland) {
|
||||
|
|
|
@ -51,7 +51,7 @@ class EglWaylandBackend : public QObject, public AbstractEglBackend
|
|||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
EglWaylandBackend();
|
||||
EglWaylandBackend(Wayland::WaylandBackend *b);
|
||||
virtual ~EglWaylandBackend();
|
||||
virtual void screenGeometryChanged(const QSize &size);
|
||||
virtual SceneOpenGL::TexturePrivate *createBackendTexture(SceneOpenGL::Texture *texture);
|
||||
|
|
|
@ -88,7 +88,7 @@ void ApplicationWayland::performStartup()
|
|||
// try creating the Wayland Backend
|
||||
createInput();
|
||||
createBackend();
|
||||
if (X11WindowedBackend::self()) {
|
||||
if (dynamic_cast<X11WindowedBackend*>(waylandServer()->backend())) {
|
||||
continueStartupWithScreens();
|
||||
}
|
||||
}
|
||||
|
@ -98,7 +98,7 @@ void ApplicationWayland::createBackend()
|
|||
AbstractBackend *backend = nullptr;
|
||||
if (m_windowed) {
|
||||
if (!m_waylandDisplay.isEmpty()) {
|
||||
Wayland::WaylandBackend *b = Wayland::WaylandBackend::create(m_waylandDisplay, this);
|
||||
Wayland::WaylandBackend *b = new Wayland::WaylandBackend(m_waylandDisplay, this);
|
||||
connect(b, &Wayland::WaylandBackend::connectionFailed, this,
|
||||
[] () {
|
||||
fputs(i18n("kwin_wayland: could not connect to Wayland Server, ensure WAYLAND_DISPLAY is set.\n").toLocal8Bit().constData(), stderr);
|
||||
|
@ -109,7 +109,7 @@ void ApplicationWayland::createBackend()
|
|||
backend = b;
|
||||
}
|
||||
if (!backend && !m_x11Display.isEmpty()) {
|
||||
KWin::X11WindowedBackend *x11Backend = KWin::X11WindowedBackend::create(m_x11Display, m_backendSize, this);
|
||||
KWin::X11WindowedBackend *x11Backend = new KWin::X11WindowedBackend(m_x11Display, m_backendSize, this);
|
||||
if (x11Backend->isValid()) {
|
||||
backend = x11Backend;
|
||||
waylandServer()->seat()->setHasPointer(true);
|
||||
|
@ -128,8 +128,8 @@ void ApplicationWayland::createBackend()
|
|||
|
||||
void ApplicationWayland::continueStartupWithScreens()
|
||||
{
|
||||
if (Wayland::WaylandBackend::self()) {
|
||||
disconnect(Wayland::WaylandBackend::self(), &Wayland::WaylandBackend::outputsChanged, this, &ApplicationWayland::continueStartupWithScreens);
|
||||
if (Wayland::WaylandBackend *w = dynamic_cast<Wayland::WaylandBackend *>(waylandServer()->backend())) {
|
||||
disconnect(w, &Wayland::WaylandBackend::outputsChanged, this, &ApplicationWayland::continueStartupWithScreens);
|
||||
}
|
||||
createScreens();
|
||||
waylandServer()->initOutputs();
|
||||
|
|
|
@ -33,6 +33,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
#if HAVE_WAYLAND_EGL
|
||||
#include "egl_wayland_backend.h"
|
||||
#include "wayland_backend.h"
|
||||
#include "wayland_server.h"
|
||||
#endif
|
||||
#if HAVE_X11_XCB
|
||||
#include "x11windowed_backend.h"
|
||||
|
@ -500,13 +501,15 @@ SceneOpenGL *SceneOpenGL::createScene(QObject *parent)
|
|||
#ifdef KWIN_HAVE_EGL
|
||||
if (kwinApp()->shouldUseWaylandForCompositing()) {
|
||||
#if HAVE_WAYLAND_EGL
|
||||
if (Wayland::WaylandBackend::self()) {
|
||||
backend = new EglWaylandBackend();
|
||||
if (Wayland::WaylandBackend *b = dynamic_cast<Wayland::WaylandBackend*>(waylandServer()->backend())) {
|
||||
backend = new EglWaylandBackend(b);
|
||||
}
|
||||
#endif
|
||||
#if HAVE_X11_XCB
|
||||
if (!backend && X11WindowedBackend::self()) {
|
||||
backend = new EglOnXBackend(X11WindowedBackend::self());
|
||||
if (!backend) {
|
||||
if (X11WindowedBackend *b = dynamic_cast<X11WindowedBackend*>(waylandServer()->backend())) {
|
||||
backend = new EglOnXBackend(b);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
} else {
|
||||
|
|
|
@ -27,6 +27,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
#include "toplevel.h"
|
||||
#if HAVE_WAYLAND
|
||||
#include "wayland_backend.h"
|
||||
#include "wayland_server.h"
|
||||
#include "x11windowed_backend.h"
|
||||
#include <KWayland/Client/buffer.h>
|
||||
#include <KWayland/Client/shm_pool.h>
|
||||
|
@ -81,16 +82,17 @@ void QPainterBackend::setFailed(const QString &reason)
|
|||
// WaylandQPainterBackend
|
||||
//****************************************
|
||||
|
||||
WaylandQPainterBackend::WaylandQPainterBackend()
|
||||
WaylandQPainterBackend::WaylandQPainterBackend(Wayland::WaylandBackend *b)
|
||||
: QPainterBackend()
|
||||
, m_backend(b)
|
||||
, m_needsFullRepaint(true)
|
||||
, m_backBuffer(QImage(QSize(), QImage::Format_RGB32))
|
||||
, m_buffer()
|
||||
{
|
||||
connect(Wayland::WaylandBackend::self()->shmPool(), SIGNAL(poolResized()), SLOT(remapBuffer()));
|
||||
connect(Wayland::WaylandBackend::self(), &Wayland::WaylandBackend::shellSurfaceSizeChanged,
|
||||
connect(b->shmPool(), SIGNAL(poolResized()), SLOT(remapBuffer()));
|
||||
connect(b, &Wayland::WaylandBackend::shellSurfaceSizeChanged,
|
||||
this, &WaylandQPainterBackend::screenGeometryChanged);
|
||||
connect(Wayland::WaylandBackend::self()->surface(), &KWayland::Client::Surface::frameRendered,
|
||||
connect(b->surface(), &KWayland::Client::Surface::frameRendered,
|
||||
Compositor::self(), &Compositor::bufferSwapComplete);
|
||||
}
|
||||
|
||||
|
@ -114,7 +116,7 @@ void WaylandQPainterBackend::present(int mask, const QRegion &damage)
|
|||
}
|
||||
Compositor::self()->aboutToSwapBuffers();
|
||||
m_needsFullRepaint = false;
|
||||
auto s = Wayland::WaylandBackend::self()->surface();
|
||||
auto s = m_backend->surface();
|
||||
s->attachBuffer(m_buffer);
|
||||
s->damage(damage);
|
||||
s->commit();
|
||||
|
@ -149,8 +151,8 @@ void WaylandQPainterBackend::prepareRenderingFrame()
|
|||
}
|
||||
}
|
||||
m_buffer.clear();
|
||||
const QSize size(Wayland::WaylandBackend::self()->shellSurfaceSize());
|
||||
m_buffer = Wayland::WaylandBackend::self()->shmPool()->getBuffer(size, size.width() * 4);
|
||||
const QSize size(m_backend->shellSurfaceSize());
|
||||
m_buffer = m_backend->shmPool()->getBuffer(size, size.width() * 4);
|
||||
if (!m_buffer) {
|
||||
qCDebug(KWIN_CORE) << "Did not get a new Buffer from Shm Pool";
|
||||
m_backBuffer = QImage();
|
||||
|
@ -186,16 +188,17 @@ bool WaylandQPainterBackend::needsFullRepaint() const
|
|||
//****************************************
|
||||
// X11WindowedBackend
|
||||
//****************************************
|
||||
X11WindowedQPainterBackend::X11WindowedQPainterBackend()
|
||||
X11WindowedQPainterBackend::X11WindowedQPainterBackend(X11WindowedBackend *backend)
|
||||
: QPainterBackend()
|
||||
, m_backBuffer(X11WindowedBackend::self()->size(), QImage::Format_RGB32)
|
||||
, m_backBuffer(backend->size(), QImage::Format_RGB32)
|
||||
, m_backend(backend)
|
||||
{
|
||||
}
|
||||
|
||||
X11WindowedQPainterBackend::~X11WindowedQPainterBackend()
|
||||
{
|
||||
if (m_gc) {
|
||||
xcb_free_gc(X11WindowedBackend::self()->connection(), m_gc);
|
||||
xcb_free_gc(m_backend->connection(), m_gc);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -226,8 +229,8 @@ void X11WindowedQPainterBackend::present(int mask, const QRegion &damage)
|
|||
{
|
||||
Q_UNUSED(mask)
|
||||
Q_UNUSED(damage)
|
||||
xcb_connection_t *c = X11WindowedBackend::self()->connection();
|
||||
const xcb_window_t window = X11WindowedBackend::self()->window();
|
||||
xcb_connection_t *c = m_backend->connection();
|
||||
const xcb_window_t window = m_backend->window();
|
||||
if (m_gc == XCB_NONE) {
|
||||
m_gc = xcb_generate_id(c);
|
||||
xcb_create_gc(c, m_gc, window, 0, nullptr);
|
||||
|
@ -253,10 +256,10 @@ SceneQPainter *SceneQPainter::createScene(QObject *parent)
|
|||
QScopedPointer<QPainterBackend> backend;
|
||||
#if HAVE_WAYLAND
|
||||
if (kwinApp()->shouldUseWaylandForCompositing()) {
|
||||
if (X11WindowedBackend::self()) {
|
||||
backend.reset(new X11WindowedQPainterBackend);
|
||||
} else {
|
||||
backend.reset(new WaylandQPainterBackend);
|
||||
if (X11WindowedBackend *b = dynamic_cast<X11WindowedBackend*>(waylandServer()->backend())) {
|
||||
backend.reset(new X11WindowedQPainterBackend(b));
|
||||
} else if (Wayland::WaylandBackend *b = dynamic_cast<Wayland::WaylandBackend*>(waylandServer()->backend())) {
|
||||
backend.reset(new WaylandQPainterBackend(b));
|
||||
}
|
||||
if (backend->isFailed()) {
|
||||
return NULL;
|
||||
|
|
|
@ -40,6 +40,12 @@ namespace Xcb {
|
|||
class Shm;
|
||||
}
|
||||
|
||||
namespace Wayland
|
||||
{
|
||||
class WaylandBackend;
|
||||
}
|
||||
class X11WindowedBackend;
|
||||
|
||||
class QPainterBackend
|
||||
{
|
||||
public:
|
||||
|
@ -108,7 +114,7 @@ class WaylandQPainterBackend : public QObject, public QPainterBackend
|
|||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
WaylandQPainterBackend();
|
||||
explicit WaylandQPainterBackend(Wayland::WaylandBackend *b);
|
||||
virtual ~WaylandQPainterBackend();
|
||||
|
||||
virtual void present(int mask, const QRegion& damage) override;
|
||||
|
@ -120,6 +126,7 @@ public:
|
|||
private Q_SLOTS:
|
||||
void remapBuffer();
|
||||
private:
|
||||
Wayland::WaylandBackend *m_backend;
|
||||
bool m_needsFullRepaint;
|
||||
QImage m_backBuffer;
|
||||
QWeakPointer<KWayland::Client::Buffer> m_buffer;
|
||||
|
@ -129,7 +136,7 @@ class X11WindowedQPainterBackend : public QObject, public QPainterBackend
|
|||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
X11WindowedQPainterBackend();
|
||||
X11WindowedQPainterBackend(X11WindowedBackend *backend);
|
||||
virtual ~X11WindowedQPainterBackend();
|
||||
|
||||
QImage *buffer() override;
|
||||
|
@ -143,6 +150,7 @@ private:
|
|||
bool m_needsFullRepaint = true;
|
||||
xcb_gcontext_t m_gc = XCB_NONE;
|
||||
QImage m_backBuffer;
|
||||
X11WindowedBackend *m_backend;
|
||||
};
|
||||
#endif
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
#if HAVE_WAYLAND
|
||||
#include "screens_wayland.h"
|
||||
#include "wayland_backend.h"
|
||||
#include "wayland_server.h"
|
||||
#include "x11windowed_backend.h"
|
||||
#include "screens_x11windowed.h"
|
||||
#endif
|
||||
|
@ -46,10 +47,10 @@ Screens *Screens::create(QObject *parent)
|
|||
#else
|
||||
#if HAVE_WAYLAND
|
||||
if (kwinApp()->shouldUseWaylandForCompositing()) {
|
||||
if (X11WindowedBackend::self()) {
|
||||
s_self = new X11WindowedScreens(parent);
|
||||
} else if (Wayland::WaylandBackend::self()) {
|
||||
s_self = new WaylandScreens(parent);
|
||||
if (X11WindowedBackend *b = dynamic_cast<X11WindowedBackend*>(waylandServer()->backend())) {
|
||||
s_self = new X11WindowedScreens(b, parent);
|
||||
} else if (Wayland::WaylandBackend *b = dynamic_cast<Wayland::WaylandBackend*>(waylandServer()->backend())) {
|
||||
s_self = new WaylandScreens(b, parent);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -32,8 +32,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
namespace KWin
|
||||
{
|
||||
|
||||
WaylandScreens::WaylandScreens(QObject* parent)
|
||||
WaylandScreens::WaylandScreens(Wayland::WaylandBackend *backend, QObject* parent)
|
||||
: Screens(parent)
|
||||
, m_backend(backend)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -44,7 +45,7 @@ WaylandScreens::~WaylandScreens()
|
|||
void WaylandScreens::init()
|
||||
{
|
||||
Screens::init();
|
||||
connect(Wayland::WaylandBackend::self(), &Wayland::WaylandBackend::outputsChanged,
|
||||
connect(m_backend, &Wayland::WaylandBackend::outputsChanged,
|
||||
this, &WaylandScreens::startChangedTimer);
|
||||
updateCount();
|
||||
}
|
||||
|
@ -87,7 +88,7 @@ void WaylandScreens::updateCount()
|
|||
{
|
||||
m_geometries.clear();
|
||||
int count = 0;
|
||||
const QList<KWayland::Client::Output*> &outputs = Wayland::WaylandBackend::self()->outputs();
|
||||
const QList<KWayland::Client::Output*> &outputs = m_backend->outputs();
|
||||
for (auto it = outputs.begin(); it != outputs.end(); ++it) {
|
||||
if ((*it)->pixelSize().isEmpty()) {
|
||||
continue;
|
||||
|
|
|
@ -25,11 +25,16 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
namespace KWin
|
||||
{
|
||||
|
||||
namespace Wayland
|
||||
{
|
||||
class WaylandBackend;
|
||||
}
|
||||
|
||||
class WaylandScreens : public Screens
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit WaylandScreens(QObject *parent);
|
||||
explicit WaylandScreens(Wayland::WaylandBackend *backend, QObject *parent);
|
||||
virtual ~WaylandScreens();
|
||||
void init() override;
|
||||
QRect geometry(int screen) const override;
|
||||
|
@ -40,6 +45,7 @@ protected Q_SLOTS:
|
|||
void updateCount() override;
|
||||
private:
|
||||
void updateXRandr();
|
||||
Wayland::WaylandBackend *m_backend;
|
||||
QList<QRect> m_geometries;
|
||||
};
|
||||
|
||||
|
|
|
@ -23,8 +23,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
namespace KWin
|
||||
{
|
||||
|
||||
X11WindowedScreens::X11WindowedScreens(QObject *parent)
|
||||
X11WindowedScreens::X11WindowedScreens(X11WindowedBackend *backend, QObject *parent)
|
||||
: Screens(parent)
|
||||
, m_backend(backend)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -33,7 +34,7 @@ X11WindowedScreens::~X11WindowedScreens() = default;
|
|||
void X11WindowedScreens::init()
|
||||
{
|
||||
KWin::Screens::init();
|
||||
connect(X11WindowedBackend::self(), &X11WindowedBackend::sizeChanged,
|
||||
connect(m_backend, &X11WindowedBackend::sizeChanged,
|
||||
this, &X11WindowedScreens::startChangedTimer);
|
||||
updateCount();
|
||||
emit changed();
|
||||
|
@ -50,7 +51,7 @@ QRect X11WindowedScreens::geometry(int screen) const
|
|||
QSize X11WindowedScreens::size(int screen) const
|
||||
{
|
||||
if (screen == 0) {
|
||||
return X11WindowedBackend::self()->size();
|
||||
return m_backend->size();
|
||||
}
|
||||
return QSize();
|
||||
}
|
||||
|
|
|
@ -23,18 +23,22 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
|
||||
namespace KWin
|
||||
{
|
||||
class X11WindowedBackend;
|
||||
|
||||
class X11WindowedScreens : public Screens
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
X11WindowedScreens(QObject *parent = nullptr);
|
||||
X11WindowedScreens(X11WindowedBackend *backend, QObject *parent = nullptr);
|
||||
virtual ~X11WindowedScreens();
|
||||
void init() override;
|
||||
QRect geometry(int screen) const override;
|
||||
int number(const QPoint &pos) const override;
|
||||
QSize size(int screen) const override;
|
||||
void updateCount() override;
|
||||
|
||||
private:
|
||||
X11WindowedBackend *m_backend;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -355,14 +355,6 @@ void WaylandCursor::setCursorImage(Qt::CursorShape shape)
|
|||
#endif
|
||||
}
|
||||
|
||||
WaylandBackend *WaylandBackend::s_self = 0;
|
||||
WaylandBackend *WaylandBackend::create(const QByteArray &display, QObject *parent)
|
||||
{
|
||||
Q_ASSERT(!s_self);
|
||||
s_self = new WaylandBackend(display, parent);
|
||||
return s_self;
|
||||
}
|
||||
|
||||
WaylandBackend::WaylandBackend(const QByteArray &display, QObject *parent)
|
||||
: AbstractBackend(parent)
|
||||
, m_display(nullptr)
|
||||
|
@ -449,7 +441,6 @@ WaylandBackend::~WaylandBackend()
|
|||
m_connectionThread->wait();
|
||||
|
||||
qCDebug(KWIN_CORE) << "Destroyed Wayland display";
|
||||
s_self = NULL;
|
||||
}
|
||||
|
||||
void WaylandBackend::destroyOutputs()
|
||||
|
|
|
@ -153,6 +153,7 @@ class KWIN_EXPORT WaylandBackend : public AbstractBackend
|
|||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit WaylandBackend(const QByteArray &display, QObject *parent = nullptr);
|
||||
virtual ~WaylandBackend();
|
||||
wl_display *display();
|
||||
KWayland::Client::Compositor *compositor();
|
||||
|
@ -165,11 +166,6 @@ public:
|
|||
void installCursorImage(Qt::CursorShape shape) override;
|
||||
void installCursorFromServer() override;
|
||||
|
||||
static WaylandBackend *create(const QByteArray &display, QObject *parent = nullptr);
|
||||
static WaylandBackend *self() {
|
||||
return s_self;
|
||||
}
|
||||
|
||||
protected:
|
||||
void connectNotify(const QMetaMethod &signal) override;
|
||||
|
||||
|
@ -180,7 +176,6 @@ Q_SIGNALS:
|
|||
void outputsChanged();
|
||||
void connectionFailed();
|
||||
private:
|
||||
explicit WaylandBackend(const QByteArray &display, QObject *parent = nullptr);
|
||||
void initConnection();
|
||||
void createSurface();
|
||||
void destroyOutputs();
|
||||
|
@ -201,7 +196,6 @@ private:
|
|||
KWayland::Client::SubCompositor *m_subCompositor;
|
||||
WaylandCursor *m_cursor;
|
||||
bool m_ready = false;
|
||||
static WaylandBackend *s_self;
|
||||
};
|
||||
|
||||
inline
|
||||
|
|
|
@ -41,15 +41,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
namespace KWin
|
||||
{
|
||||
|
||||
X11WindowedBackend *X11WindowedBackend::s_self = nullptr;
|
||||
|
||||
X11WindowedBackend *X11WindowedBackend::create(const QByteArray &display, const QSize &size, QObject *parent)
|
||||
{
|
||||
Q_ASSERT(!s_self);
|
||||
s_self = new X11WindowedBackend(display, size, parent);
|
||||
return s_self;
|
||||
}
|
||||
|
||||
X11WindowedBackend::X11WindowedBackend(const QByteArray &display, const QSize &size, QObject *parent)
|
||||
: AbstractBackend(parent)
|
||||
, m_size(size)
|
||||
|
@ -97,7 +88,6 @@ X11WindowedBackend::~X11WindowedBackend()
|
|||
}
|
||||
xcb_disconnect(m_connection);
|
||||
}
|
||||
s_self = nullptr;
|
||||
}
|
||||
|
||||
void X11WindowedBackend::createWindow()
|
||||
|
|
|
@ -39,6 +39,7 @@ class KWIN_EXPORT X11WindowedBackend : public AbstractBackend
|
|||
Q_OBJECT
|
||||
Q_PROPERTY(QSize size READ size NOTIFY sizeChanged)
|
||||
public:
|
||||
X11WindowedBackend(const QByteArray &display, const QSize &size, QObject *parent);
|
||||
virtual ~X11WindowedBackend();
|
||||
|
||||
xcb_connection_t *connection() const {
|
||||
|
@ -65,14 +66,10 @@ public:
|
|||
|
||||
void installCursorFromServer() override;
|
||||
|
||||
static X11WindowedBackend *self();
|
||||
static X11WindowedBackend *create(const QByteArray &display, const QSize &size, QObject *parent);
|
||||
|
||||
Q_SIGNALS:
|
||||
void sizeChanged();
|
||||
|
||||
private:
|
||||
X11WindowedBackend(const QByteArray &display, const QSize &size, QObject *parent);
|
||||
void createWindow();
|
||||
void startEventReading();
|
||||
void handleEvent(xcb_generic_event_t *event);
|
||||
|
@ -90,14 +87,8 @@ private:
|
|||
xcb_atom_t m_deleteWindowProtocol = XCB_ATOM_NONE;
|
||||
xcb_cursor_t m_cursor = XCB_CURSOR_NONE;
|
||||
Display *m_display = nullptr;
|
||||
static X11WindowedBackend *s_self;
|
||||
};
|
||||
|
||||
inline X11WindowedBackend *X11WindowedBackend::self()
|
||||
{
|
||||
return s_self;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue