diff options
author | Johan Klokkhammer Helsing <johan.helsing@qt.io> | 2019-10-28 12:05:09 +0100 |
---|---|---|
committer | Johan Klokkhammer Helsing <johan.helsing@qt.io> | 2019-11-12 13:34:05 +0100 |
commit | d58008c4310f99d0faebcfb2fd9aa9296b813ecf (patch) | |
tree | 7aee8434512b2142c4a604e688488a051464189b /src/client/qwaylandwindow.cpp | |
parent | acddf1834ffa1b256a38919d9626f1e12460b484 (diff) | |
download | qtwayland-d58008c4310f99d0faebcfb2fd9aa9296b813ecf.tar.gz |
Client: Support running with no screens
[ChangeLog][QPA plugin] The QPA plugin now supports running with no screens
attached. This is handled by adding a fake screen when the last screen is
disconnected, similarly to what the other QPA plugins do.
Fixes: QTBUG-79111
Change-Id: I4a0e023ae784217dd030f0c62f12487fdff4825c
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
Diffstat (limited to 'src/client/qwaylandwindow.cpp')
-rw-r--r-- | src/client/qwaylandwindow.cpp | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/src/client/qwaylandwindow.cpp b/src/client/qwaylandwindow.cpp index 950486c0..751058d8 100644 --- a/src/client/qwaylandwindow.cpp +++ b/src/client/qwaylandwindow.cpp @@ -73,9 +73,9 @@ Q_LOGGING_CATEGORY(lcWaylandBackingstore, "qt.qpa.wayland.backingstore") QWaylandWindow *QWaylandWindow::mMouseGrab = nullptr; -QWaylandWindow::QWaylandWindow(QWindow *window) +QWaylandWindow::QWaylandWindow(QWindow *window, QWaylandDisplay *display) : QPlatformWindow(window) - , mDisplay(waylandScreen()->display()) + , mDisplay(display) , mFrameQueue(mDisplay->createEventQueue()) , mResizeAfterSwap(qEnvironmentVariableIsSet("QT_WAYLAND_RESIZE_AFTER_SWAP")) { @@ -177,7 +177,7 @@ void QWaylandWindow::initWindow() } } - mScale = waylandScreen()->scale(); + mScale = waylandScreen() ? waylandScreen()->scale() : 1; // fallback to 1 if we don't have a real screen // Enable high-dpi rendering. Scale() returns the screen scale factor and will // typically be integer 1 (normal-dpi) or 2 (high-dpi). Call set_buffer_scale() @@ -402,14 +402,14 @@ void QWaylandWindow::closePopups(QWaylandWindow *parent) } } -QWaylandScreen *QWaylandWindow::calculateScreenFromSurfaceEvents() const +QPlatformScreen *QWaylandWindow::calculateScreenFromSurfaceEvents() const { if (mSurface) { if (auto *screen = mSurface->oldestEnteredScreen()) return screen; } - return waylandScreen(); + return QPlatformWindow::screen(); } void QWaylandWindow::setVisible(bool visible) @@ -690,7 +690,11 @@ QWaylandSubSurface *QWaylandWindow::subSurfaceWindow() const QWaylandScreen *QWaylandWindow::waylandScreen() const { - return static_cast<QWaylandScreen *>(QPlatformWindow::screen()); + auto *platformScreen = QPlatformWindow::screen(); + Q_ASSERT(platformScreen); + if (platformScreen->isPlaceholder()) + return nullptr; + return static_cast<QWaylandScreen *>(platformScreen); } void QWaylandWindow::handleContentOrientationChange(Qt::ScreenOrientation orientation) @@ -962,7 +966,7 @@ void QWaylandWindow::handleMouseEventWithDecoration(QWaylandInputDevice *inputDe void QWaylandWindow::handleScreensChanged() { - QWaylandScreen *newScreen = calculateScreenFromSurfaceEvents(); + QPlatformScreen *newScreen = calculateScreenFromSurfaceEvents(); if (newScreen == mLastReportedScreen) return; @@ -970,7 +974,7 @@ void QWaylandWindow::handleScreensChanged() QWindowSystemInterface::handleWindowScreenChanged(window(), newScreen->QPlatformScreen::screen()); mLastReportedScreen = newScreen; - int scale = newScreen->scale(); + int scale = newScreen->isPlaceholder() ? 1 : static_cast<QWaylandScreen *>(newScreen)->scale(); if (scale != mScale) { mScale = scale; if (mSurface && mDisplay->compositorVersion() >= 3) |