From 827486ff36857ecec21631e98be7a763bb0c2f20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Tue, 8 Dec 2015 10:11:26 +0100 Subject: [PATCH] Introduce a Toplevel::clientContentPos() -> QPoint This describes an additional offset for the client content. On X11 our client content position matches with the window - the window decoration is part of the overall content coordinate system. On Wayland the content is an own texture starting at 0/0. Thus a mapping to texture coordinates will be required when server side decorations are provided. The new information is used in the scene's to adjust the rendering and generating of quads. --- deleted.cpp | 1 + deleted.h | 4 ++++ scene.cpp | 12 ++++++------ scene.h | 2 +- scene_qpainter.cpp | 2 +- shell_client.cpp | 5 +++++ shell_client.h | 1 + toplevel.h | 10 ++++++++++ 8 files changed, 29 insertions(+), 8 deletions(-) diff --git a/deleted.cpp b/deleted.cpp index 7815a9b50c..239ba8fec7 100644 --- a/deleted.cpp +++ b/deleted.cpp @@ -78,6 +78,7 @@ void Deleted::copyToDeleted(Toplevel* c) desk = c->desktop(); activityList = c->activities(); contentsRect = QRect(c->clientPos(), c->clientSize()); + m_contentPos = c->clientContentPos(); transparent_rect = c->transparentRect(); m_layer = c->layer(); m_frame = c->frameId(); diff --git a/deleted.h b/deleted.h index a5996d1354..bb87ae9611 100644 --- a/deleted.h +++ b/deleted.h @@ -49,6 +49,9 @@ public: virtual QStringList activities() const; virtual QPoint clientPos() const; virtual QSize clientSize() const; + QPoint clientContentPos() const override { + return m_contentPos; + } virtual QRect transparentRect() const; virtual bool isDeleted() const; virtual xcb_window_t frameId() const override; @@ -93,6 +96,7 @@ private: int desk; QStringList activityList; QRect contentsRect; // for clientPos()/clientSize() + QPoint m_contentPos; QRect transparent_rect; xcb_window_t m_frame; diff --git a/scene.cpp b/scene.cpp index 61bb3f76b1..e6738530b0 100644 --- a/scene.cpp +++ b/scene.cpp @@ -827,7 +827,7 @@ WindowQuadList Scene::Window::buildQuads(bool force) const QRegion center = toplevel->transparentRect(); QRegion decoration = (client && true ? QRegion(client->decorationRect()) : shape()) - center; - ret = makeQuads(WindowQuadContents, contents); + ret = makeQuads(WindowQuadContents, contents, client->clientContentPos()); QRect rects[4]; bool isShadedClient = false; @@ -910,16 +910,16 @@ WindowQuadList Scene::Window::makeDecorationQuads(const QRect *rects, const QReg return list; } -WindowQuadList Scene::Window::makeQuads(WindowQuadType type, const QRegion& reg) const +WindowQuadList Scene::Window::makeQuads(WindowQuadType type, const QRegion& reg, const QPoint &textureOffset) const { WindowQuadList ret; foreach (const QRect & r, reg.rects()) { WindowQuad quad(type); // TODO asi mam spatne pravy dolni roh - bud tady, nebo v jinych castech - quad[ 0 ] = WindowVertex(r.x(), r.y(), r.x(), r.y()); - quad[ 1 ] = WindowVertex(r.x() + r.width(), r.y(), r.x() + r.width(), r.y()); - quad[ 2 ] = WindowVertex(r.x() + r.width(), r.y() + r.height(), r.x() + r.width(), r.y() + r.height()); - quad[ 3 ] = WindowVertex(r.x(), r.y() + r.height(), r.x(), r.y() + r.height()); + quad[ 0 ] = WindowVertex(r.x(), r.y(), r.x() + textureOffset.x(), r.y() + textureOffset.y()); + quad[ 1 ] = WindowVertex(r.x() + r.width(), r.y(), r.x() + r.width() + textureOffset.x(), r.y() + textureOffset.y()); + quad[ 2 ] = WindowVertex(r.x() + r.width(), r.y() + r.height(), r.x() + r.width() + textureOffset.x(), r.y() + r.height() + textureOffset.y()); + quad[ 3 ] = WindowVertex(r.x(), r.y() + r.height(), r.x() + textureOffset.x(), r.y() + r.height() + textureOffset.y()); ret.append(quad); } return ret; diff --git a/scene.h b/scene.h index 84740c708c..9c947d980d 100644 --- a/scene.h +++ b/scene.h @@ -275,7 +275,7 @@ public: void referencePreviousPixmap(); void unreferencePreviousPixmap(); protected: - WindowQuadList makeQuads(WindowQuadType type, const QRegion& reg) const; + WindowQuadList makeQuads(WindowQuadType type, const QRegion& reg, const QPoint &textureOffset = QPoint(0, 0)) const; WindowQuadList makeDecorationQuads(const QRect *rects, const QRegion ®ion) const; /** * @brief Returns the WindowPixmap for this Window. diff --git a/scene_qpainter.cpp b/scene_qpainter.cpp index de9bba698c..06603cbf13 100644 --- a/scene_qpainter.cpp +++ b/scene_qpainter.cpp @@ -280,7 +280,7 @@ void SceneQPainter::Window::performPaint(int mask, QRegion region, WindowPaintDa renderWindowDecorations(painter); // render content - const QRect src = QRect(toplevel->clientPos(), toplevel->clientSize()); + const QRect src = QRect(toplevel->clientPos() + toplevel->clientContentPos(), toplevel->clientSize()); painter->drawImage(toplevel->clientPos(), pixmap->image(), src); if (!opaque) { diff --git a/shell_client.cpp b/shell_client.cpp index abe1688c2a..ba46ddf6f5 100644 --- a/shell_client.cpp +++ b/shell_client.cpp @@ -200,6 +200,11 @@ QPoint ShellClient::clientPos() const return QPoint(0, 0); } +QPoint ShellClient::clientContentPos() const +{ + return -1 * clientPos(); +} + QSize ShellClient::clientSize() const { // TODO: connect for changes diff --git a/shell_client.h b/shell_client.h index dfb740378f..f023423b37 100644 --- a/shell_client.h +++ b/shell_client.h @@ -44,6 +44,7 @@ public: QStringList activities() const override; QPoint clientPos() const override; + QPoint clientContentPos() const override; QSize clientSize() const override; QRect transparentRect() const override; bool shouldUnredirect() const override; diff --git a/toplevel.h b/toplevel.h index 6067d36b37..91eee5f26f 100644 --- a/toplevel.h +++ b/toplevel.h @@ -226,6 +226,11 @@ public: bool isOnActiveScreen() const; int screen() const; // the screen where the center is virtual QPoint clientPos() const = 0; // inside of geometry() + /** + * Describes how the client's content maps to the window geometry including the frame. + * The default implementation is a 1:1 mapping meaning the frame is part of the content. + **/ + virtual QPoint clientContentPos() const; virtual QSize clientSize() const = 0; virtual QRect visibleRect() const; // the area the window occupies on the screen virtual QRect decorationRect() const; // rect including the decoration shadows @@ -774,6 +779,11 @@ inline const QSharedPointer &Toplevel::internalFramebu return m_internalFBO; } +inline QPoint Toplevel::clientContentPos() const +{ + return QPoint(0, 0); +} + template inline T *Toplevel::findInList(const QList &list, std::function func) {