diff --git a/deleted.cpp b/deleted.cpp index 5d88241aff..e2e8b8c8c6 100644 --- a/deleted.cpp +++ b/deleted.cpp @@ -134,7 +134,7 @@ void Deleted::debug(QDebug& stream) const stream << "\'ID:" << window() << "\' (deleted)"; } -void Deleted::layoutDecorationRects(QRect& left, QRect& top, QRect& right, QRect& bottom) const +void Deleted::layoutDecorationRects(QRect& left, QRect& top, QRect& right, QRect& bottom, int) const { left = decoration_left; top = decoration_top; diff --git a/deleted.h b/deleted.h index 93e610b7fa..b91f4e2f5c 100644 --- a/deleted.h +++ b/deleted.h @@ -58,7 +58,7 @@ public: bool noBorder() const { return no_border; } - void layoutDecorationRects(QRect &left, QRect &top, QRect &right, QRect &bottom) const; + void layoutDecorationRects(QRect &left, QRect &top, QRect &right, QRect &bottom, int unused = 0) const; QRect decorationRect() const; virtual Layer layer() const { return m_layer; @@ -67,6 +67,10 @@ public: return m_minimized; } NET::WindowType windowType(bool direct = false, int supported_types = 0) const; + bool decorationPixmapRequiresRepaint() const { + return false; + } + void ensureDecorationPixmapsPainted() {} protected: virtual void debug(QDebug& stream) const; virtual bool shouldUnredirect() const; diff --git a/scene_opengl.cpp b/scene_opengl.cpp index 22c8294d1d..e2ffa9bac0 100644 --- a/scene_opengl.cpp +++ b/scene_opengl.cpp @@ -720,8 +720,6 @@ void SceneOpenGL::Window::performPaint(int mask, QRegion region, WindowPaintData beginRenderWindow(mask, data); - WindowQuadList decoration = data.quads.select(WindowQuadDecoration); - GLVertexBuffer *vbo = GLVertexBuffer::streamingBuffer(); vbo->reset(); @@ -730,63 +728,10 @@ void SceneOpenGL::Window::performPaint(int mask, QRegion region, WindowPaintData paintShadow(region, data, hardwareClipping); } // decorations - Client *client = dynamic_cast(toplevel); - Deleted *deleted = dynamic_cast(toplevel); - if (client || deleted) { - bool noBorder = true; - bool updateDeco = false; - const QPixmap *left = NULL; - const QPixmap *top = NULL; - const QPixmap *right = NULL; - const QPixmap *bottom = NULL; - QRect topRect, leftRect, rightRect, bottomRect; - if (client && !client->noBorder()) { - noBorder = false; - updateDeco = client->decorationPixmapRequiresRepaint(); - client->ensureDecorationPixmapsPainted(); - - client->layoutDecorationRects(leftRect, topRect, rightRect, bottomRect, Client::WindowRelative); - - left = client->leftDecoPixmap(); - top = client->topDecoPixmap(); - right = client->rightDecoPixmap(); - bottom = client->bottomDecoPixmap(); - } - if (deleted && !deleted->noBorder()) { - noBorder = false; - left = deleted->leftDecoPixmap(); - top = deleted->topDecoPixmap(); - right = deleted->rightDecoPixmap(); - bottom = deleted->bottomDecoPixmap(); - deleted->layoutDecorationRects(leftRect, topRect, rightRect, bottomRect); - } - if (!noBorder) { - WindowQuadList topList, leftList, rightList, bottomList; - - foreach (const WindowQuad & quad, decoration) { - if (topRect.contains(QPoint(quad.originalLeft(), quad.originalTop()))) { - topList.append(quad); - continue; - } - if (bottomRect.contains(QPoint(quad.originalLeft(), quad.originalTop()))) { - bottomList.append(quad); - continue; - } - if (leftRect.contains(QPoint(quad.originalLeft(), quad.originalTop()))) { - leftList.append(quad); - continue; - } - if (rightRect.contains(QPoint(quad.originalLeft(), quad.originalTop()))) { - rightList.append(quad); - continue; - } - } - - paintDecoration(top, DecorationTop, region, topRect, data, topList, updateDeco, hardwareClipping); - paintDecoration(left, DecorationLeft, region, leftRect, data, leftList, updateDeco, hardwareClipping); - paintDecoration(right, DecorationRight, region, rightRect, data, rightList, updateDeco, hardwareClipping); - paintDecoration(bottom, DecorationBottom, region, bottomRect, data, bottomList, updateDeco, hardwareClipping); - } + if (toplevel->isClient()) { + paintDecorations(data, region, hardwareClipping); + } else if (toplevel->isDeleted()) { + paintDecorations(data, region, hardwareClipping); } // paint the content @@ -813,6 +758,52 @@ void SceneOpenGL::Window::performPaint(int mask, QRegion region, WindowPaintData endRenderWindow(data); } +template +void SceneOpenGL::Window::paintDecorations(const WindowPaintData &data, const QRegion ®ion, bool hardwareClipping) +{ + T* t = static_cast(toplevel); + if (t->noBorder()) { + return; + } + WindowQuadList decoration = data.quads.select(WindowQuadDecoration); + QRect topRect, leftRect, rightRect, bottomRect; + const bool updateDeco = t->decorationPixmapRequiresRepaint(); + t->ensureDecorationPixmapsPainted(); + + t->layoutDecorationRects(leftRect, topRect, rightRect, bottomRect, Client::WindowRelative); + + const QPixmap *left = t->leftDecoPixmap(); + const QPixmap *top = t->topDecoPixmap(); + const QPixmap *right = t->rightDecoPixmap(); + const QPixmap *bottom = t->bottomDecoPixmap(); + WindowQuadList topList, leftList, rightList, bottomList; + + foreach (const WindowQuad & quad, decoration) { + if (topRect.contains(QPoint(quad.originalLeft(), quad.originalTop()))) { + topList.append(quad); + continue; + } + if (bottomRect.contains(QPoint(quad.originalLeft(), quad.originalTop()))) { + bottomList.append(quad); + continue; + } + if (leftRect.contains(QPoint(quad.originalLeft(), quad.originalTop()))) { + leftList.append(quad); + continue; + } + if (rightRect.contains(QPoint(quad.originalLeft(), quad.originalTop()))) { + rightList.append(quad); + continue; + } + } + + paintDecoration(top, DecorationTop, region, topRect, data, topList, updateDeco, hardwareClipping); + paintDecoration(left, DecorationLeft, region, leftRect, data, leftList, updateDeco, hardwareClipping); + paintDecoration(right, DecorationRight, region, rightRect, data, rightList, updateDeco, hardwareClipping); + paintDecoration(bottom, DecorationBottom, region, bottomRect, data, bottomList, updateDeco, hardwareClipping); +} + + void SceneOpenGL::Window::paintDecoration(const QPixmap* decoration, TextureType decorationType, const QRegion& region, const QRect& rect, const WindowPaintData& data, const WindowQuadList& quads, bool updateDeco, bool hardwareClipping) diff --git a/scene_opengl.h b/scene_opengl.h index a639bd4817..1ee8706129 100644 --- a/scene_opengl.h +++ b/scene_opengl.h @@ -212,6 +212,8 @@ protected: GLTexture *textureForType(TextureType type); private: + template + void paintDecorations(const WindowPaintData &data, const QRegion ®ion, bool hardwareClipping); Texture *texture; Texture *topTexture; Texture *leftTexture;