[paintredirector] Pass KDecoration to PaintRedirector

Gives us more power in the future.
This commit is contained in:
Martin Gräßlin 2013-10-07 11:55:42 +02:00
parent acd0015c6e
commit 1deea69170
3 changed files with 24 additions and 19 deletions

View file

@ -460,7 +460,7 @@ void Client::createDecoration(const QRect& oldgeom)
move(calculateGravitation(false)); move(calculateGravitation(false));
plainResize(sizeForClientSize(clientSize()), ForceGeometrySet); plainResize(sizeForClientSize(clientSize()), ForceGeometrySet);
if (Compositor::compositing()) { if (Compositor::compositing()) {
paintRedirector = PaintRedirector::create(this, decoration->widget()); paintRedirector = PaintRedirector::create(this, decoration);
discardWindowPixmap(); discardWindowPixmap();
} }
emit geometryShapeChanged(this, oldgeom); emit geometryShapeChanged(this, oldgeom);

View file

@ -39,23 +39,24 @@ DEALINGS IN THE SOFTWARE.
namespace KWin namespace KWin
{ {
PaintRedirector *PaintRedirector::create(Client *c, QWidget *widget) PaintRedirector *PaintRedirector::create(Client *c, KDecoration *deco)
{ {
if (effects->isOpenGLCompositing()) { if (effects->isOpenGLCompositing()) {
return new OpenGLPaintRedirector(c, widget); return new OpenGLPaintRedirector(c, deco);
} else { } else {
return new RasterXRenderPaintRedirector(c, widget); return new RasterXRenderPaintRedirector(c, deco);
} }
} }
PaintRedirector::PaintRedirector(Client *c, QWidget* w) PaintRedirector::PaintRedirector(Client *c, KDecoration *deco)
: QObject(w) : QObject(deco)
, widget(w) , widget(deco->widget())
, recursionCheck(false) , recursionCheck(false)
, m_client(c) , m_client(c)
, m_decoration(deco)
, m_requiresRepaint(false) , m_requiresRepaint(false)
{ {
added(w); added(deco->widget());
} }
PaintRedirector::~PaintRedirector() PaintRedirector::~PaintRedirector()
@ -67,6 +68,7 @@ void PaintRedirector::reparent(Deleted *d)
setParent(d); setParent(d);
widget = NULL; widget = NULL;
m_client = NULL; m_client = NULL;
m_decoration = NULL;
} }
static int align(int value, int align) 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) ImageBasedPaintRedirector::ImageBasedPaintRedirector(Client *c, KDecoration *deco)
: PaintRedirector(c, widget) : PaintRedirector(c, deco)
{ {
} }
@ -307,8 +309,8 @@ void ImageBasedPaintRedirector::discardScratch()
// ------------------------------------------------------------------ // ------------------------------------------------------------------
OpenGLPaintRedirector::OpenGLPaintRedirector(Client *c, QWidget *widget) OpenGLPaintRedirector::OpenGLPaintRedirector(Client *c, KDecoration *deco)
: ImageBasedPaintRedirector(c, widget) : ImageBasedPaintRedirector(c, deco)
{ {
for (int i = 0; i < TextureCount; ++i) for (int i = 0; i < TextureCount; ++i)
m_textures[i] = NULL; m_textures[i] = NULL;
@ -386,8 +388,8 @@ void OpenGLPaintRedirector::updatePixmaps(const QRect *rects, const QRegion &reg
RasterXRenderPaintRedirector::RasterXRenderPaintRedirector(Client *c, QWidget *widget) RasterXRenderPaintRedirector::RasterXRenderPaintRedirector(Client *c, KDecoration *deco)
: ImageBasedPaintRedirector(c, widget) : ImageBasedPaintRedirector(c, deco)
, m_gc(0) , m_gc(0)
{ {
for (int i=0; i<PixmapCount; ++i) { for (int i=0; i<PixmapCount; ++i) {

View file

@ -33,6 +33,8 @@ DEALINGS IN THE SOFTWARE.
// xcb // xcb
#include <xcb/render.h> #include <xcb/render.h>
class KDecoration;
namespace KWin namespace KWin
{ {
@ -84,12 +86,12 @@ public:
* is created. * is created.
**/ **/
void reparent(Deleted *d); void reparent(Deleted *d);
static PaintRedirector *create(Client *c, QWidget* widget); static PaintRedirector *create(Client *c, KDecoration *deco);
public Q_SLOTS: public Q_SLOTS:
void ensurePixmapsPainted(); void ensurePixmapsPainted();
protected: protected:
PaintRedirector(Client *c, QWidget* widget); PaintRedirector(Client *c, KDecoration *deco);
virtual xcb_render_picture_t picture(DecorationPixmap border) const; virtual xcb_render_picture_t picture(DecorationPixmap border) const;
virtual GLTexture *texture(DecorationPixmap border) const; virtual GLTexture *texture(DecorationPixmap border) const;
virtual void resizePixmaps(const QRect *rects); virtual void resizePixmaps(const QRect *rects);
@ -117,6 +119,7 @@ private:
QBasicTimer cleanupTimer; QBasicTimer cleanupTimer;
Client *m_client; Client *m_client;
KDecoration *m_decoration;
bool m_requiresRepaint; bool m_requiresRepaint;
}; };
@ -126,7 +129,7 @@ class ImageBasedPaintRedirector : public PaintRedirector
public: public:
virtual ~ImageBasedPaintRedirector(); virtual ~ImageBasedPaintRedirector();
protected: protected:
ImageBasedPaintRedirector(Client *c, QWidget *widget); ImageBasedPaintRedirector(Client *c, KDecoration *deco);
virtual QPaintDevice *recreateScratch(const QSize &size); virtual QPaintDevice *recreateScratch(const QSize &size);
virtual QPaintDevice *scratch(); virtual QPaintDevice *scratch();
virtual void fillScratch(Qt::GlobalColor color); virtual void fillScratch(Qt::GlobalColor color);
@ -143,7 +146,7 @@ class OpenGLPaintRedirector : public ImageBasedPaintRedirector
enum Texture { LeftRight = 0, TopBottom, TextureCount }; enum Texture { LeftRight = 0, TopBottom, TextureCount };
public: public:
OpenGLPaintRedirector(Client *c, QWidget *widget); OpenGLPaintRedirector(Client *c, KDecoration *deco);
virtual ~OpenGLPaintRedirector(); virtual ~OpenGLPaintRedirector();
GLTexture *leftRightTexture() const { return m_textures[LeftRight]; } GLTexture *leftRightTexture() const { return m_textures[LeftRight]; }
@ -161,7 +164,7 @@ class RasterXRenderPaintRedirector : public ImageBasedPaintRedirector
{ {
Q_OBJECT Q_OBJECT
public: public:
RasterXRenderPaintRedirector(Client *c, QWidget *widget); RasterXRenderPaintRedirector(Client *c, KDecoration *deco);
virtual ~RasterXRenderPaintRedirector(); virtual ~RasterXRenderPaintRedirector();
protected: protected: