From 79b7925098936ebf3a8e6ca3119256fb4f1a52a9 Mon Sep 17 00:00:00 2001 From: Johan Klokkhammer Helsing Date: Wed, 17 Oct 2018 14:07:42 +0200 Subject: Compositor: Fix coordinate system inconsistencies Several properties were using pixel coordinates and surface coordinates without converting. [ChangeLog][Compositor] QWaylandSurface::destinationSize has been added which returns the size of the surface that will be displayed on the screen in surface coordinates. [ChangeLog][Compositor] Fixed a bug where QWaylandSurface::inputRegionContains would return true for some points outside surfaces with buffer scale > 1. [ChangeLog][Compositor] Fixed a bug which caused ShellSurfaceItems for surfaces with buffer scale > 1 to move too much when resizing interactively. It also gets rid of all calls to QWaylandSurface::size, which confusingly returns the size of the surface's buffer in pixel coordinates. Most properties now use destionationSize's surface coordinates consistently. Hopefully, QWaylandSurface::size can be renamed or removed in Qt 6. Change-Id: I007256a8df7759cf74fbfd51624fa1f90c083336 Reviewed-by: Paul Olav Tvete --- examples/wayland/minimal-cpp/compositor.h | 4 ++-- examples/wayland/minimal-cpp/window.cpp | 2 +- examples/wayland/qwindow-compositor/compositor.cpp | 4 ++-- examples/wayland/qwindow-compositor/compositor.h | 2 +- examples/wayland/qwindow-compositor/window.cpp | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) (limited to 'examples') diff --git a/examples/wayland/minimal-cpp/compositor.h b/examples/wayland/minimal-cpp/compositor.h index f06421320..3c0c80e0e 100644 --- a/examples/wayland/minimal-cpp/compositor.h +++ b/examples/wayland/minimal-cpp/compositor.h @@ -71,11 +71,11 @@ public: QOpenGLTexture *getTexture(); int iviId() const { return m_iviId; } - QRect globalGeometry() const { return QRect(globalPosition(), surface()->size()); } + QRect globalGeometry() const { return QRect(globalPosition(), surface()->destinationSize()); } void setGlobalPosition(const QPoint &globalPos) { m_pos = globalPos; m_positionSet = true; } QPoint globalPosition() const { return m_pos; } QPoint mapToLocal(const QPoint &globalPos) const; - QSize size() const { return surface() ? surface()->size() : QSize(); } + QSize size() const { return surface() ? surface()->destinationSize() : QSize(); } void initPosition(const QSize &screenSize, const QSize &surfaceSize); diff --git a/examples/wayland/minimal-cpp/window.cpp b/examples/wayland/minimal-cpp/window.cpp index 673e15fd8..f345bd51f 100644 --- a/examples/wayland/minimal-cpp/window.cpp +++ b/examples/wayland/minimal-cpp/window.cpp @@ -95,7 +95,7 @@ void Window::paintGL() GLuint textureId = texture->textureId(); QWaylandSurface *surface = view->surface(); if (surface && surface->hasContent()) { - QSize s = surface->size(); + QSize s = surface->destinationSize(); view->initPosition(size(), s); QPointF pos = view->globalPosition(); QRectF surfaceGeometry(pos, s); diff --git a/examples/wayland/qwindow-compositor/compositor.cpp b/examples/wayland/qwindow-compositor/compositor.cpp index f25e67d87..199de22e2 100644 --- a/examples/wayland/qwindow-compositor/compositor.cpp +++ b/examples/wayland/qwindow-compositor/compositor.cpp @@ -79,7 +79,7 @@ QOpenGLTexture *View::getTexture() if (newContent) { m_texture = buf.toOpenGLTexture(); if (surface()) { - m_size = surface()->size(); + m_size = surface()->destinationSize(); m_origin = buf.origin() == QWaylandSurface::OriginTopLeft ? QOpenGLTextureBlitter::OriginTopLeft : QOpenGLTextureBlitter::OriginBottomLeft; @@ -96,7 +96,7 @@ QOpenGLTextureBlitter::Origin View::textureOrigin() const QSize View::size() const { - return surface() ? surface()->size() : m_size; + return surface() ? surface()->destinationSize() : m_size; } bool View::isCursor() const diff --git a/examples/wayland/qwindow-compositor/compositor.h b/examples/wayland/qwindow-compositor/compositor.h index 2a395a1ab..8f18dc53d 100644 --- a/examples/wayland/qwindow-compositor/compositor.h +++ b/examples/wayland/qwindow-compositor/compositor.h @@ -82,7 +82,7 @@ public: void setParentView(View *parent) { m_parentView = parent; } View *parentView() const { return m_parentView; } QPointF parentPosition() const { return m_parentView ? (m_parentView->position() + m_parentView->parentPosition()) : QPointF(); } - QSize windowSize() { return m_xdgSurface ? m_xdgSurface->windowGeometry().size() : surface() ? surface()->size() : m_size; } + QSize windowSize() { return m_xdgSurface ? m_xdgSurface->windowGeometry().size() : surface() ? surface()->destinationSize() : m_size; } QPoint offset() const { return m_offset; } qreal animationFactor() const {return m_animationFactor; } diff --git a/examples/wayland/qwindow-compositor/window.cpp b/examples/wayland/qwindow-compositor/window.cpp index 80aeec4c3..b8b8e52ec 100644 --- a/examples/wayland/qwindow-compositor/window.cpp +++ b/examples/wayland/qwindow-compositor/window.cpp @@ -180,7 +180,7 @@ void Window::startResize(int edge, bool anchored) m_grabState = ResizeGrab; m_resizeEdge = edge; m_resizeAnchored = anchored; - m_resizeAnchorPosition = getAnchorPosition(m_mouseView->position(), edge, m_mouseView->surface()->size()); + m_resizeAnchorPosition = getAnchorPosition(m_mouseView->position(), edge, m_mouseView->surface()->destinationSize()); } void Window::startDrag(View *dragIcon) -- cgit v1.2.3