summaryrefslogtreecommitdiffstats
path: root/src/client/qwaylandwindow.cpp
diff options
context:
space:
mode:
authorJohan Klokkhammer Helsing <johan.helsing@qt.io>2017-08-18 13:08:50 +0200
committerJohan Helsing <johan.helsing@qt.io>2017-11-15 06:44:37 +0000
commit595e46e03cda85fc8a552bf593f72c996410c711 (patch)
treeef16dee9b9d993e744c71a6248b087ad3df6aae6 /src/client/qwaylandwindow.cpp
parentec30d132b300c75d547feafea1dd950285aecba0 (diff)
Automatically change scale when entering a new output
Change-Id: I99198d47eac5b2091fe2bfd8fc24646be9c9890a Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@liri.io> Reviewed-by: David Edmundson <davidedmundson@kde.org>
Diffstat (limited to 'src/client/qwaylandwindow.cpp')
-rw-r--r--src/client/qwaylandwindow.cpp27
1 files changed, 23 insertions, 4 deletions
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)
{