Commit 6adfe306 authored by Vlad Zahorodnii's avatar Vlad Zahorodnii
Browse files

Drop Platform::createScreens()

Since the Screens class is a convenience wrapper around AbstractOutput
objects that come from the Platform, it should not be platform-specific.

By dropping createScreens(), output-related code becomes simpler.
parent 935a6d7e
......@@ -199,7 +199,7 @@ void PlasmaSurfaceTest::testOSDPlacement()
Q_ARG(int, 2),
Q_ARG(QVector<QRect>, geometries));
QVERIFY(screensChangedSpy.wait());
QCOMPARE(screensChangedSpy.count(), 1);
QCOMPARE(screensChangedSpy.count(), 2);
QCOMPARE(screens()->count(), 2);
QCOMPARE(screens()->geometry(0), geometries.at(0));
QCOMPARE(screens()->geometry(1), geometries.at(1));
......
......@@ -93,7 +93,7 @@ void ScreenChangesTest::testScreenAddRemove()
Q_ARG(int, 2),
Q_ARG(QVector<QRect>, geometries));
QVERIFY(screensChangedSpy.wait());
QCOMPARE(screensChangedSpy.count(), 1);
QCOMPARE(screensChangedSpy.count(), 2);
QCOMPARE(screens()->count(), 2);
QCOMPARE(screens()->geometry(0), geometries.at(0));
QCOMPARE(screens()->geometry(1), geometries.at(1));
......@@ -164,7 +164,7 @@ void ScreenChangesTest::testScreenAddRemove()
Q_ARG(int, 1),
Q_ARG(QVector<QRect>, geometries2));
QVERIFY(screensChangedSpy.wait());
QCOMPARE(screensChangedSpy.count(), 1);
QCOMPARE(screensChangedSpy.count(), 2);
QCOMPARE(screens()->count(), 1);
QCOMPARE(screens()->geometry(0), geometries2.at(0));
......
......@@ -13,6 +13,7 @@ namespace KWin
MockScreens::MockScreens(QObject *parent)
: Screens(parent)
, m_changedTimer(new QTimer(this))
{
}
......@@ -72,6 +73,12 @@ int MockScreens::number(const QPoint &pos) const
void MockScreens::init()
{
Screens::init();
m_changedTimer->setSingleShot(true);
m_changedTimer->setInterval(100);
connect(m_changedTimer, &QTimer::timeout, this, &MockScreens::updateCount);
connect(m_changedTimer, &QTimer::timeout, this, &MockScreens::changed);
m_scheduledGeometries << QRect(0, 0, 100, 100);
updateCount();
}
......@@ -89,4 +96,14 @@ void MockScreens::setGeometries(const QList< QRect > &geometries)
startChangedTimer();
}
bool MockScreens::isChanging() const
{
return m_changedTimer->isActive();
}
void MockScreens::startChangedTimer()
{
m_changedTimer->start();
}
}
......@@ -28,14 +28,17 @@ public:
QSizeF physicalSize(int screen) const override;
void init() override;
bool isChanging() const;
void setGeometries(const QList<QRect> &geometries);
protected Q_SLOTS:
void updateCount() override;
void startChangedTimer();
private:
QList<QRect> m_scheduledGeometries;
QList<QRect> m_geometries;
QTimer *m_changedTimer;
};
}
......
......@@ -125,12 +125,12 @@ void TestScreens::testSize()
QCOMPARE(screens()->size(), QSize(100, 100));
QFETCH(QList<QRect>, geometries);
QVERIFY(!screens()->isChanging());
QVERIFY(!mockScreens->isChanging());
mockScreens->setGeometries(geometries);
QVERIFY(screens()->isChanging());
QVERIFY(mockScreens->isChanging());
QVERIFY(sizeChangedSpy.wait());
QVERIFY(!screens()->isChanging());
QVERIFY(!mockScreens->isChanging());
QTEST(screens()->size(), "expectedSize");
}
......
......@@ -248,18 +248,7 @@ void ApplicationX11::performStartup()
createInput();
connect(platform(), &Platform::screensQueried, this,
[this] {
createWorkspace();
createPlugins();
Xcb::sync(); // Trigger possible errors, there's still a chance to abort
notifyKSplash();
notifyStarted();
}
);
connect(platform(), &Platform::screensQueried, this, &ApplicationX11::continueStartupWithScreens);
connect(platform(), &Platform::initFailed, this,
[] () {
std::cerr << "FATAL ERROR: backend failed to initialize, exiting now" << std::endl;
......@@ -275,6 +264,19 @@ void ApplicationX11::performStartup()
createAtoms();
}
void ApplicationX11::continueStartupWithScreens()
{
disconnect(platform(), &Platform::screensQueried, this, &ApplicationX11::continueStartupWithScreens);
createWorkspace();
createPlugins();
Xcb::sync(); // Trigger possible errors, there's still a chance to abort
notifyKSplash();
notifyStarted();
}
bool ApplicationX11::notify(QObject* o, QEvent* e)
{
if (e->spontaneous() && Workspace::self()->workspaceEvent(e))
......
......@@ -30,6 +30,7 @@ protected:
private Q_SLOTS:
void lostSelection();
void continueStartupWithScreens();
private:
void crashChecking();
......
......@@ -74,12 +74,6 @@ void Platform::doShowCursor()
{
}
Screens *Platform::createScreens(QObject *parent)
{
Q_UNUSED(parent)
return nullptr;
}
OpenGLBackend *Platform::createOpenGLBackend()
{
return nullptr;
......
......@@ -37,7 +37,6 @@ class Outline;
class OutlineVisual;
class QPainterBackend;
class Scene;
class Screens;
class ScreenEdges;
class Toplevel;
#ifdef KWIN_HAVE_XRENDER_COMPOSITING
......@@ -68,7 +67,6 @@ public:
~Platform() override;
virtual void init() = 0;
virtual Screens *createScreens(QObject *parent = nullptr);
virtual OpenGLBackend *createOpenGLBackend();
virtual QPainterBackend *createQPainterBackend();
#ifdef KWIN_HAVE_XRENDER_COMPOSITING
......
......@@ -10,7 +10,6 @@ set(DRM_SOURCES
edid.cpp
logging.cpp
scene_qpainter_drm_backend.cpp
screens_drm.cpp
drm_gpu.cpp
egl_multi_backend.cpp
abstract_egl_drm_backend.cpp
......
......@@ -17,7 +17,6 @@
#include "logind.h"
#include "main.h"
#include "scene_qpainter_drm_backend.h"
#include "screens_drm.h"
#include "udev.h"
#include "wayland_server.h"
#if HAVE_GBM
......@@ -642,11 +641,6 @@ void DrmBackend::moveCursor()
}
}
Screens *DrmBackend::createScreens(QObject *parent)
{
return new DrmScreens(this, parent);
}
QPainterBackend *DrmBackend::createQPainterBackend()
{
m_gpus.at(0)->setDeleteBufferAfterPageFlip(false);
......
......@@ -54,7 +54,6 @@ public:
explicit DrmBackend(QObject *parent = nullptr);
~DrmBackend() override;
Screens *createScreens(QObject *parent = nullptr) override;
QPainterBackend *createQPainterBackend() override;
OpenGLBackend* createOpenGLBackend() override;
DmaBufTexture *createDmaBufTexture(const QSize &size) override;
......
......@@ -16,7 +16,7 @@
#include "logind.h"
#include "logging.h"
#include "main.h"
#include "screens_drm.h"
#include "screens.h"
#include "wayland_server.h"
// KWayland
#include <KWaylandServer/output_interface.h>
......
/*
KWin - the KDE window manager
This file is part of the KDE project.
SPDX-FileCopyrightText: 2015 Martin Gräßlin <mgraesslin@kde.org>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "screens_drm.h"
#include "drm_backend.h"
namespace KWin
{
DrmScreens::DrmScreens(DrmBackend *backend, QObject *parent)
: Screens(parent)
{
connect(backend, &DrmBackend::screensQueried, this, &DrmScreens::updateCount);
connect(backend, &DrmBackend::screensQueried, this, &DrmScreens::changed);
}
}
/*
KWin - the KDE window manager
This file is part of the KDE project.
SPDX-FileCopyrightText: 2015 Martin Gräßlin <mgraesslin@kde.org>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#ifndef KWIN_SCREENS_DRM_H
#define KWIN_SCREENS_DRM_H
#include "screens.h"
namespace KWin
{
class DrmBackend;
class DrmScreens : public Screens
{
Q_OBJECT
public:
DrmScreens(DrmBackend *backend, QObject *parent = nullptr);
};
}
#endif
......@@ -12,7 +12,6 @@
#include "logging.h"
#include "logind.h"
#include "scene_qpainter_fb_backend.h"
#include "screens.h"
#include "virtual_terminal.h"
#include "udev.h"
// system
......@@ -56,11 +55,6 @@ FramebufferBackend::~FramebufferBackend()
}
}
Screens *FramebufferBackend::createScreens(QObject *parent)
{
return Screens::create(parent);
}
QPainterBackend *FramebufferBackend::createQPainterBackend()
{
return new FramebufferQPainterBackend(this);
......
......@@ -38,7 +38,6 @@ public:
explicit FramebufferBackend(QObject *parent = nullptr);
~FramebufferBackend() override;
Screens *createScreens(QObject *parent = nullptr) override;
QPainterBackend *createQPainterBackend() override;
QSize screenSize() const override;
......
......@@ -2,7 +2,6 @@ set(HWCOMPOSER_SOURCES
egl_hwcomposer_backend.cpp
hwcomposer_backend.cpp
logging.cpp
screens_hwcomposer.cpp
)
include_directories(${CMAKE_SOURCE_DIR}/platformsupport/scenes/opengl)
......
......@@ -9,7 +9,6 @@
#include "egl_hwcomposer_backend.h"
#include "hwcomposer_backend.h"
#include "logging.h"
#include "screens_hwcomposer.h"
#include "composite.h"
#include "main.h"
#include "wayland_server.h"
......@@ -346,11 +345,6 @@ HwcomposerWindow *HwcomposerBackend::createSurface()
return new HwcomposerWindow(this);
}
Screens *HwcomposerBackend::createScreens(QObject *parent)
{
return new HwcomposerScreens(this, parent);
}
Outputs HwcomposerBackend::outputs() const
{
if (!m_output.isNull()) {
......
......@@ -62,7 +62,6 @@ public:
virtual ~HwcomposerBackend();
void init() override;
Screens *createScreens(QObject *parent = nullptr) override;
OpenGLBackend *createOpenGLBackend() override;
Outputs outputs() const override;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment