[wayland] Create QPainterBackend through the AbstractBackend
SceneQPainter delegates creation to the AbstractBackend removing the casting logic.
This commit is contained in:
parent
e1ae0b8bc4
commit
2b0a837340
7 changed files with 24 additions and 4 deletions
|
@ -54,4 +54,9 @@ OpenGLBackend *AbstractBackend::createOpenGLBackend()
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
QPainterBackend *AbstractBackend::createQPainterBackend()
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -256,10 +256,9 @@ SceneQPainter *SceneQPainter::createScene(QObject *parent)
|
|||
QScopedPointer<QPainterBackend> backend;
|
||||
#if HAVE_WAYLAND
|
||||
if (kwinApp()->shouldUseWaylandForCompositing()) {
|
||||
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));
|
||||
backend.reset(waylandServer()->backend()->createQPainterBackend());
|
||||
if (backend.isNull()) {
|
||||
return nullptr;
|
||||
}
|
||||
if (backend->isFailed()) {
|
||||
return NULL;
|
||||
|
|
|
@ -23,6 +23,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
#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
|
||||
|
|
|
@ -171,6 +171,7 @@ public:
|
|||
|
||||
Screens *createScreens(QObject *parent = nullptr) override;
|
||||
OpenGLBackend *createOpenGLBackend() override;
|
||||
QPainterBackend *createQPainterBackend() override;
|
||||
|
||||
protected:
|
||||
void connectNotify(const QMetaMethod &signal) override;
|
||||
|
|
|
@ -20,6 +20,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
#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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -68,6 +68,7 @@ public:
|
|||
|
||||
Screens *createScreens(QObject *parent = nullptr) override;
|
||||
OpenGLBackend *createOpenGLBackend() override;
|
||||
QPainterBackend* createQPainterBackend() override;
|
||||
|
||||
Q_SIGNALS:
|
||||
void sizeChanged();
|
||||
|
|
Loading…
Reference in a new issue