[plugins/qpa] Add a dummy screen on startup

Qt has problems initializing everything correctly if there is no screen
at startup. E.g. the breeze widget style tries to initialize some pixmaps
and this fails. In worst case hitting asserts in Qt (debug build).

This change creates a dummy screen which gets destroyed as soon as there
is a real screen.

Reviewed-By: notmart and sebas
remotes/origin/Plasma/5.6
Martin Gräßlin 10 years ago
parent 544e5a7fb8
commit 51ee514227
  1. 6
      plugins/qpa/integration.cpp
  2. 3
      plugins/qpa/integration.h
  3. 4
      plugins/qpa/screen.cpp

@ -88,6 +88,8 @@ void Integration::initialize()
// TODO: start initialize Wayland once the internal Wayland connection is created
connect(kwinApp(), &Application::screensCreated, this, &Integration::initializeWayland, Qt::QueuedConnection);
QPlatformIntegration::initialize();
m_dummyScreen = new Screen(nullptr);
screenAdded(m_dummyScreen);
}
QAbstractEventDispatcher *Integration::createEventDispatcher() const
@ -178,6 +180,10 @@ void Integration::initializeWayland()
void Integration::createWaylandOutput(quint32 name, quint32 version)
{
if (m_dummyScreen) {
destroyScreen(m_dummyScreen);
m_dummyScreen = nullptr;
}
using namespace KWayland::Client;
auto o = m_registry->createOutput(name, version, this);
connect(o, &Output::changed, this,

@ -40,6 +40,8 @@ namespace KWin
namespace QPA
{
class Screen;
class Integration : public QObject, public QPlatformIntegration
{
Q_OBJECT
@ -74,6 +76,7 @@ private:
KWayland::Client::Compositor *m_compositor = nullptr;
KWayland::Client::Shell *m_shell = nullptr;
EGLDisplay m_eglDisplay = EGL_NO_DISPLAY;
Screen *m_dummyScreen = nullptr;
};
}

@ -49,12 +49,12 @@ QImage::Format Screen::format() const
QRect Screen::geometry() const
{
return m_output->geometry();
return m_output ? m_output->geometry() : QRect(0, 0, 1, 1);
}
QSizeF Screen::physicalSize() const
{
return m_output->physicalSize();
return m_output ? m_output->physicalSize() : QPlatformScreen::physicalSize();
}
QPlatformCursor *Screen::cursor() const

Loading…
Cancel
Save