diff --git a/abstract_backend.cpp b/abstract_backend.cpp index 44b50e136f..1d523bf51d 100644 --- a/abstract_backend.cpp +++ b/abstract_backend.cpp @@ -54,4 +54,9 @@ OpenGLBackend *AbstractBackend::createOpenGLBackend() return nullptr; } +QPainterBackend *AbstractBackend::createQPainterBackend() +{ + return nullptr; +} + } diff --git a/abstract_backend.h b/abstract_backend.h index 9f30253de1..193935dd1a 100644 --- a/abstract_backend.h +++ b/abstract_backend.h @@ -26,6 +26,7 @@ namespace KWin { class OpenGLBackend; +class QPainterBackend; class Screens; class KWIN_EXPORT AbstractBackend : public QObject @@ -38,6 +39,7 @@ public: virtual void installCursorImage(Qt::CursorShape shape); virtual Screens *createScreens(QObject *parent = nullptr); virtual OpenGLBackend *createOpenGLBackend(); + virtual QPainterBackend *createQPainterBackend(); protected: explicit AbstractBackend(QObject *parent = nullptr); diff --git a/scene_qpainter.cpp b/scene_qpainter.cpp index 0bafc01ffd..107b1b703d 100644 --- a/scene_qpainter.cpp +++ b/scene_qpainter.cpp @@ -256,10 +256,9 @@ SceneQPainter *SceneQPainter::createScene(QObject *parent) QScopedPointer backend; #if HAVE_WAYLAND if (kwinApp()->shouldUseWaylandForCompositing()) { - if (X11WindowedBackend *b = dynamic_cast(waylandServer()->backend())) { - backend.reset(new X11WindowedQPainterBackend(b)); - } else if (Wayland::WaylandBackend *b = dynamic_cast(waylandServer()->backend())) { - backend.reset(new WaylandQPainterBackend(b)); + backend.reset(waylandServer()->backend()->createQPainterBackend()); + if (backend.isNull()) { + return nullptr; } if (backend->isFailed()) { return NULL; diff --git a/wayland_backend.cpp b/wayland_backend.cpp index b42e4ad4b8..ea9ebeff37 100644 --- a/wayland_backend.cpp +++ b/wayland_backend.cpp @@ -23,6 +23,7 @@ along with this program. If not, see . #include "cursor.h" #include "input.h" #include "main.h" +#include "scene_qpainter.h" #include "screens_wayland.h" #include "utils.h" #include "wayland_server.h" @@ -657,6 +658,11 @@ OpenGLBackend *WaylandBackend::createOpenGLBackend() #endif } +QPainterBackend *WaylandBackend::createQPainterBackend() +{ + return new WaylandQPainterBackend(this); +} + } } // KWin diff --git a/wayland_backend.h b/wayland_backend.h index 096ebc378a..c2c22d50d7 100644 --- a/wayland_backend.h +++ b/wayland_backend.h @@ -171,6 +171,7 @@ public: Screens *createScreens(QObject *parent = nullptr) override; OpenGLBackend *createOpenGLBackend() override; + QPainterBackend *createQPainterBackend() override; protected: void connectNotify(const QMetaMethod &signal) override; diff --git a/x11windowed_backend.cpp b/x11windowed_backend.cpp index 9352435197..197fa36251 100644 --- a/x11windowed_backend.cpp +++ b/x11windowed_backend.cpp @@ -20,6 +20,7 @@ along with this program. If not, see . #include "x11windowed_backend.h" #include "composite.h" #include "input.h" +#include "scene_qpainter.h" #include "screens_x11windowed.h" #include "utils.h" #include "wayland_server.h" @@ -314,4 +315,9 @@ OpenGLBackend *X11WindowedBackend::createOpenGLBackend() return nullptr; } +QPainterBackend *X11WindowedBackend::createQPainterBackend() +{ + return new X11WindowedQPainterBackend(this); +} + } diff --git a/x11windowed_backend.h b/x11windowed_backend.h index 5a381d2718..1dc3c70793 100644 --- a/x11windowed_backend.h +++ b/x11windowed_backend.h @@ -68,6 +68,7 @@ public: Screens *createScreens(QObject *parent = nullptr) override; OpenGLBackend *createOpenGLBackend() override; + QPainterBackend* createQPainterBackend() override; Q_SIGNALS: void sizeChanged();