summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohan Klokkhammer Helsing <johan.helsing@qt.io>2016-06-09 15:33:33 +0200
committerJohan Helsing <johan.helsing@qt.io>2016-06-23 14:21:15 +0000
commite3cd3459c304ea6b35d95d6e40b90dfe43bd2a68 (patch)
tree14f11431be59e9152a5894fca1da354c5ab0a7d8
parent903cdcb6e00fd7f2ae04612c64dfa6c53f72e75b (diff)
Take buffer scale into account when calculating unset window geometry
This fixes a resize issue where the window would scale to be bufferScale times the size it should have been. Change-Id: I4d3eee52d54a063c0a617a053cbe05b351f18f76 Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io> Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@hawaiios.org>
-rw-r--r--src/compositor/extensions/qwaylandxdgshell.cpp37
-rw-r--r--src/compositor/extensions/qwaylandxdgshell.h1
-rw-r--r--src/compositor/extensions/qwaylandxdgshell_p.h2
3 files changed, 33 insertions, 7 deletions
diff --git a/src/compositor/extensions/qwaylandxdgshell.cpp b/src/compositor/extensions/qwaylandxdgshell.cpp
index 0b45b21ac..8b07283e7 100644
--- a/src/compositor/extensions/qwaylandxdgshell.cpp
+++ b/src/compositor/extensions/qwaylandxdgshell.cpp
@@ -246,6 +246,27 @@ void QWaylandXdgSurfacePrivate::handleFocusReceived()
q->sendConfigure(current.size, current.states);
}
+QRect QWaylandXdgSurfacePrivate::calculateFallbackWindowGeometry() const
+{
+ // TODO: The unset window geometry should include subsurfaces as well, so this solution
+ // won't work too well on those kinds of clients.
+ return QRect(QPoint(0, 0), m_surface->size() / m_surface->bufferScale());
+}
+
+void QWaylandXdgSurfacePrivate::updateFallbackWindowGeometry()
+{
+ Q_Q(QWaylandXdgSurface);
+ if (!m_unsetWindowGeometry)
+ return;
+
+ const QRect unsetGeometry = calculateFallbackWindowGeometry();
+ if (unsetGeometry == m_windowGeometry)
+ return;
+
+ m_windowGeometry = unsetGeometry;
+ emit q->windowGeometryChanged();
+}
+
void QWaylandXdgSurfacePrivate::xdg_surface_destroy_resource(Resource *resource)
{
Q_UNUSED(resource);
@@ -625,8 +646,9 @@ void QWaylandXdgSurface::initialize(QWaylandXdgShell *xdgShell, QWaylandSurface
d->m_surface = surface;
d->init(resource.resource());
setExtensionContainer(surface);
- d->m_windowGeometry = QRect(QPoint(0,0), surface->size());
+ d->m_windowGeometry = d->calculateFallbackWindowGeometry();
connect(surface, &QWaylandSurface::sizeChanged, this, &QWaylandXdgSurface::handleSurfaceSizeChanged);
+ connect(surface, &QWaylandSurface::bufferScaleChanged, this, &QWaylandXdgSurface::handleBufferScaleChanged);
emit surfaceChanged();
emit windowGeometryChanged();
QWaylandCompositorExtension::initialize();
@@ -652,12 +674,13 @@ QList<int> QWaylandXdgSurface::statesAsInts() const
void QWaylandXdgSurface::handleSurfaceSizeChanged()
{
Q_D(QWaylandXdgSurface);
- if (d->m_unsetWindowGeometry && d->m_windowGeometry.size() != surface()->size()) {
- // TODO: The unset window geometry should include subsurfaces as well, so this solution
- // won't work too well on those kinds of clients.
- d->m_windowGeometry.setSize(surface()->size());
- emit windowGeometryChanged();
- }
+ d->updateFallbackWindowGeometry();
+}
+
+void QWaylandXdgSurface::handleBufferScaleChanged()
+{
+ Q_D(QWaylandXdgSurface);
+ d->updateFallbackWindowGeometry();
}
/*!
diff --git a/src/compositor/extensions/qwaylandxdgshell.h b/src/compositor/extensions/qwaylandxdgshell.h
index 2187086ac..2da7f3d3d 100644
--- a/src/compositor/extensions/qwaylandxdgshell.h
+++ b/src/compositor/extensions/qwaylandxdgshell.h
@@ -190,6 +190,7 @@ private:
private Q_SLOTS:
void handleSurfaceSizeChanged();
+ void handleBufferScaleChanged();
};
class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandXdgPopup : public QWaylandShellSurfaceTemplate<QWaylandXdgPopup>
diff --git a/src/compositor/extensions/qwaylandxdgshell_p.h b/src/compositor/extensions/qwaylandxdgshell_p.h
index fa0e7037d..23c95bdeb 100644
--- a/src/compositor/extensions/qwaylandxdgshell_p.h
+++ b/src/compositor/extensions/qwaylandxdgshell_p.h
@@ -107,6 +107,8 @@ public:
void handleFocusLost();
void handleFocusReceived();
+ QRect calculateFallbackWindowGeometry() const;
+ void updateFallbackWindowGeometry();
private:
QWaylandXdgShell *m_xdgShell;