From 1deea69170b42f0c5062eefef88bb5ef7898f5e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Mon, 7 Oct 2013 11:55:42 +0200 Subject: [PATCH] [paintredirector] Pass KDecoration to PaintRedirector Gives us more power in the future. --- client.cpp | 2 +- paintredirector.cpp | 28 +++++++++++++++------------- paintredirector.h | 13 ++++++++----- 3 files changed, 24 insertions(+), 19 deletions(-) diff --git a/client.cpp b/client.cpp index ae74d3060f..4145f584cc 100644 --- a/client.cpp +++ b/client.cpp @@ -460,7 +460,7 @@ void Client::createDecoration(const QRect& oldgeom) move(calculateGravitation(false)); plainResize(sizeForClientSize(clientSize()), ForceGeometrySet); if (Compositor::compositing()) { - paintRedirector = PaintRedirector::create(this, decoration->widget()); + paintRedirector = PaintRedirector::create(this, decoration); discardWindowPixmap(); } emit geometryShapeChanged(this, oldgeom); diff --git a/paintredirector.cpp b/paintredirector.cpp index e888f8f52d..bb61ebd40d 100644 --- a/paintredirector.cpp +++ b/paintredirector.cpp @@ -39,23 +39,24 @@ DEALINGS IN THE SOFTWARE. namespace KWin { -PaintRedirector *PaintRedirector::create(Client *c, QWidget *widget) +PaintRedirector *PaintRedirector::create(Client *c, KDecoration *deco) { if (effects->isOpenGLCompositing()) { - return new OpenGLPaintRedirector(c, widget); + return new OpenGLPaintRedirector(c, deco); } else { - return new RasterXRenderPaintRedirector(c, widget); + return new RasterXRenderPaintRedirector(c, deco); } } -PaintRedirector::PaintRedirector(Client *c, QWidget* w) - : QObject(w) - , widget(w) +PaintRedirector::PaintRedirector(Client *c, KDecoration *deco) + : QObject(deco) + , widget(deco->widget()) , recursionCheck(false) , m_client(c) + , m_decoration(deco) , m_requiresRepaint(false) { - added(w); + added(deco->widget()); } PaintRedirector::~PaintRedirector() @@ -67,6 +68,7 @@ void PaintRedirector::reparent(Deleted *d) setParent(d); widget = NULL; m_client = NULL; + m_decoration = NULL; } static int align(int value, int align) @@ -272,8 +274,8 @@ void PaintRedirector::paint(DecorationPixmap border, const QRect& r, const QRect -ImageBasedPaintRedirector::ImageBasedPaintRedirector(Client *c, QWidget *widget) - : PaintRedirector(c, widget) +ImageBasedPaintRedirector::ImageBasedPaintRedirector(Client *c, KDecoration *deco) + : PaintRedirector(c, deco) { } @@ -307,8 +309,8 @@ void ImageBasedPaintRedirector::discardScratch() // ------------------------------------------------------------------ -OpenGLPaintRedirector::OpenGLPaintRedirector(Client *c, QWidget *widget) - : ImageBasedPaintRedirector(c, widget) +OpenGLPaintRedirector::OpenGLPaintRedirector(Client *c, KDecoration *deco) + : ImageBasedPaintRedirector(c, deco) { for (int i = 0; i < TextureCount; ++i) m_textures[i] = NULL; @@ -386,8 +388,8 @@ void OpenGLPaintRedirector::updatePixmaps(const QRect *rects, const QRegion ® -RasterXRenderPaintRedirector::RasterXRenderPaintRedirector(Client *c, QWidget *widget) - : ImageBasedPaintRedirector(c, widget) +RasterXRenderPaintRedirector::RasterXRenderPaintRedirector(Client *c, KDecoration *deco) + : ImageBasedPaintRedirector(c, deco) , m_gc(0) { for (int i=0; i +class KDecoration; + namespace KWin { @@ -84,12 +86,12 @@ public: * is created. **/ void reparent(Deleted *d); - static PaintRedirector *create(Client *c, QWidget* widget); + static PaintRedirector *create(Client *c, KDecoration *deco); public Q_SLOTS: void ensurePixmapsPainted(); protected: - PaintRedirector(Client *c, QWidget* widget); + PaintRedirector(Client *c, KDecoration *deco); virtual xcb_render_picture_t picture(DecorationPixmap border) const; virtual GLTexture *texture(DecorationPixmap border) const; virtual void resizePixmaps(const QRect *rects); @@ -117,6 +119,7 @@ private: QBasicTimer cleanupTimer; Client *m_client; + KDecoration *m_decoration; bool m_requiresRepaint; }; @@ -126,7 +129,7 @@ class ImageBasedPaintRedirector : public PaintRedirector public: virtual ~ImageBasedPaintRedirector(); protected: - ImageBasedPaintRedirector(Client *c, QWidget *widget); + ImageBasedPaintRedirector(Client *c, KDecoration *deco); virtual QPaintDevice *recreateScratch(const QSize &size); virtual QPaintDevice *scratch(); virtual void fillScratch(Qt::GlobalColor color); @@ -143,7 +146,7 @@ class OpenGLPaintRedirector : public ImageBasedPaintRedirector enum Texture { LeftRight = 0, TopBottom, TextureCount }; public: - OpenGLPaintRedirector(Client *c, QWidget *widget); + OpenGLPaintRedirector(Client *c, KDecoration *deco); virtual ~OpenGLPaintRedirector(); GLTexture *leftRightTexture() const { return m_textures[LeftRight]; } @@ -161,7 +164,7 @@ class RasterXRenderPaintRedirector : public ImageBasedPaintRedirector { Q_OBJECT public: - RasterXRenderPaintRedirector(Client *c, QWidget *widget); + RasterXRenderPaintRedirector(Client *c, KDecoration *deco); virtual ~RasterXRenderPaintRedirector(); protected: