diff --git a/abstract_backend.cpp b/abstract_backend.cpp index 6ce90d71ee..a0dd763638 100644 --- a/abstract_backend.cpp +++ b/abstract_backend.cpp @@ -43,4 +43,10 @@ void AbstractBackend::installCursorImage(Qt::CursorShape shape) Q_UNUSED(shape) } +Screens *AbstractBackend::createScreens(QObject *parent) +{ + Q_UNUSED(parent) + return nullptr; +} + } diff --git a/abstract_backend.h b/abstract_backend.h index 54465e4c8f..94e407517c 100644 --- a/abstract_backend.h +++ b/abstract_backend.h @@ -25,6 +25,8 @@ along with this program. If not, see . namespace KWin { +class Screens; + class KWIN_EXPORT AbstractBackend : public QObject { Q_OBJECT @@ -33,6 +35,7 @@ public: virtual void installCursorFromServer(); virtual void installCursorImage(Qt::CursorShape shape); + virtual Screens *createScreens(QObject *parent = nullptr); protected: explicit AbstractBackend(QObject *parent = nullptr); diff --git a/screens.cpp b/screens.cpp index d2473ce9b7..9ac8e6ef9e 100644 --- a/screens.cpp +++ b/screens.cpp @@ -25,11 +25,8 @@ along with this program. If not, see . #include #include "screens_xrandr.h" #if HAVE_WAYLAND -#include "screens_wayland.h" -#include "wayland_backend.h" +#include "abstract_backend.h" #include "wayland_server.h" -#include "x11windowed_backend.h" -#include "screens_x11windowed.h" #endif #ifdef KWIN_UNIT_TEST #include @@ -47,11 +44,7 @@ Screens *Screens::create(QObject *parent) #else #if HAVE_WAYLAND if (kwinApp()->shouldUseWaylandForCompositing()) { - if (X11WindowedBackend *b = dynamic_cast(waylandServer()->backend())) { - s_self = new X11WindowedScreens(b, parent); - } else if (Wayland::WaylandBackend *b = dynamic_cast(waylandServer()->backend())) { - s_self = new WaylandScreens(b, parent); - } + s_self = waylandServer()->backend()->createScreens(parent); } #endif if (kwinApp()->operationMode() == Application::OperationModeX11) { diff --git a/wayland_backend.cpp b/wayland_backend.cpp index 778e8b3bce..5b9349d5fd 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 "screens_wayland.h" #include "utils.h" #include "wayland_server.h" #include @@ -639,6 +640,11 @@ void WaylandBackend::connectNotify(const QMetaMethod &signal) } } +Screens *WaylandBackend::createScreens(QObject *parent) +{ + return new WaylandScreens(this, parent); +} + } } // KWin diff --git a/wayland_backend.h b/wayland_backend.h index 5b28114d76..a3f397db08 100644 --- a/wayland_backend.h +++ b/wayland_backend.h @@ -169,6 +169,8 @@ public: void installCursorImage(Qt::CursorShape shape) override; void installCursorFromServer() override; + Screens *createScreens(QObject *parent = nullptr) override; + protected: void connectNotify(const QMetaMethod &signal) override; diff --git a/x11windowed_backend.cpp b/x11windowed_backend.cpp index 005c37696f..d8b34a312d 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 "screens_x11windowed.h" #include "utils.h" #include "wayland_server.h" #include "xcbutils.h" @@ -293,4 +294,9 @@ xcb_window_t X11WindowedBackend::rootWindow() const return m_screen->root; } +Screens *X11WindowedBackend::createScreens(QObject *parent) +{ + return new X11WindowedScreens(this, parent); +} + } diff --git a/x11windowed_backend.h b/x11windowed_backend.h index b00a53e643..afecb70a1b 100644 --- a/x11windowed_backend.h +++ b/x11windowed_backend.h @@ -66,6 +66,8 @@ public: void installCursorFromServer() override; + Screens *createScreens(QObject *parent = nullptr) override; + Q_SIGNALS: void sizeChanged();