[wayland] Create Screens through the AbstractBackend
The AbstractBackend provides a virtual method to create the Screens. A concrete backend can implement this method to create the backend specific Screens instance. This removes the casting logic from Screens::create.
This commit is contained in:
parent
3389c7569f
commit
65839e1617
7 changed files with 27 additions and 9 deletions
|
@ -43,4 +43,10 @@ void AbstractBackend::installCursorImage(Qt::CursorShape shape)
|
|||
Q_UNUSED(shape)
|
||||
}
|
||||
|
||||
Screens *AbstractBackend::createScreens(QObject *parent)
|
||||
{
|
||||
Q_UNUSED(parent)
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -25,6 +25,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
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);
|
||||
|
|
11
screens.cpp
11
screens.cpp
|
@ -25,11 +25,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
#include <config-kwin.h>
|
||||
#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 <mock_screens.h>
|
||||
|
@ -47,11 +44,7 @@ Screens *Screens::create(QObject *parent)
|
|||
#else
|
||||
#if HAVE_WAYLAND
|
||||
if (kwinApp()->shouldUseWaylandForCompositing()) {
|
||||
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);
|
||||
}
|
||||
s_self = waylandServer()->backend()->createScreens(parent);
|
||||
}
|
||||
#endif
|
||||
if (kwinApp()->operationMode() == Application::OperationModeX11) {
|
||||
|
|
|
@ -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 "screens_wayland.h"
|
||||
#include "utils.h"
|
||||
#include "wayland_server.h"
|
||||
#include <KWayland/Client/buffer.h>
|
||||
|
@ -639,6 +640,11 @@ void WaylandBackend::connectNotify(const QMetaMethod &signal)
|
|||
}
|
||||
}
|
||||
|
||||
Screens *WaylandBackend::createScreens(QObject *parent)
|
||||
{
|
||||
return new WaylandScreens(this, parent);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} // KWin
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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 "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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -66,6 +66,8 @@ public:
|
|||
|
||||
void installCursorFromServer() override;
|
||||
|
||||
Screens *createScreens(QObject *parent = nullptr) override;
|
||||
|
||||
Q_SIGNALS:
|
||||
void sizeChanged();
|
||||
|
||||
|
|
Loading…
Reference in a new issue