From 595e46e03cda85fc8a552bf593f72c996410c711 Mon Sep 17 00:00:00 2001 From: Johan Klokkhammer Helsing Date: Fri, 18 Aug 2017 13:08:50 +0200 Subject: Automatically change scale when entering a new output Change-Id: I99198d47eac5b2091fe2bfd8fc24646be9c9890a Reviewed-by: Pier Luigi Fiorini Reviewed-by: David Edmundson --- src/client/qwaylandwindow.cpp | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) (limited to 'src/client/qwaylandwindow.cpp') diff --git a/src/client/qwaylandwindow.cpp b/src/client/qwaylandwindow.cpp index 48f0d213a..2d7a0c3b5 100644 --- a/src/client/qwaylandwindow.cpp +++ b/src/client/qwaylandwindow.cpp @@ -128,6 +128,12 @@ QWaylandWindow::~QWaylandWindow() } } +void QWaylandWindow::ensureSize() +{ + if (mBackingStore) + mBackingStore->ensureSize(); +} + void QWaylandWindow::initWindow() { if (window()->type() == Qt::Desktop) @@ -199,7 +205,6 @@ void QWaylandWindow::initWindow() // 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() // to inform the compositor that high-resolution buffers will be provided. - //FIXME this needs to be changed when the screen changes along with a resized backing store if (mDisplay->compositorVersion() >= 3) set_buffer_scale(scale()); @@ -523,7 +528,7 @@ void QWaylandWindow::surface_enter(wl_output *output) QWaylandScreen *newScreen = calculateScreenFromSurfaceEvents(); if (oldScreen != newScreen) //currently this will only happen if the first wl_surface.enter is for a non-primary screen - QWindowSystemInterface::handleWindowScreenChanged(window(), newScreen->QPlatformScreen::screen()); + handleScreenChanged(); } void QWaylandWindow::surface_leave(wl_output *output) @@ -540,7 +545,7 @@ void QWaylandWindow::surface_leave(wl_output *output) QWaylandScreen *newScreen = calculateScreenFromSurfaceEvents(); if (oldScreen != newScreen) - QWindowSystemInterface::handleWindowScreenChanged(window(), newScreen->QPlatformScreen::screen()); + handleScreenChanged(); } void QWaylandWindow::handleScreenRemoved(QScreen *qScreen) @@ -550,7 +555,7 @@ void QWaylandWindow::handleScreenRemoved(QScreen *qScreen) if (wasRemoved) { QWaylandScreen *newScreen = calculateScreenFromSurfaceEvents(); if (oldScreen != newScreen) - QWindowSystemInterface::handleWindowScreenChanged(window(), newScreen->QPlatformScreen::screen()); + handleScreenChanged(); } } @@ -914,6 +919,20 @@ void QWaylandWindow::handleMouseEventWithDecoration(QWaylandInputDevice *inputDe } } +void QWaylandWindow::handleScreenChanged() +{ + QWaylandScreen *newScreen = calculateScreenFromSurfaceEvents(); + QWindowSystemInterface::handleWindowScreenChanged(window(), newScreen->QPlatformScreen::screen()); + + int scale = newScreen->scale(); + if (scale != mScale) { + mScale = scale; + if (isInitialized() && mDisplay->compositorVersion() >= 3) + set_buffer_scale(mScale); + ensureSize(); + } +} + #if QT_CONFIG(cursor) void QWaylandWindow::setMouseCursor(QWaylandInputDevice *device, const QCursor &cursor) { -- cgit v1.2.3