split decorationRect / visibleRect usage

REVIEW: 104215

cherry-picked from 0f3380f3b10e57416f81a1288dc10b8dfe11d87e
Conflicts:

	kwin/geometry.cpp
	kwin/scene.cpp
This commit is contained in:
Thomas Lübking 2012-03-10 11:34:56 +01:00
parent 5bf62e5308
commit 1070bf895b
8 changed files with 23 additions and 33 deletions

View file

@ -2425,12 +2425,7 @@ void Client::setSessionInteract(bool needed)
QRect Client::decorationRect() const QRect Client::decorationRect() const
{ {
if (decoration && decoration->widget()) { if (decoration && decoration->widget()) {
QRect r = decoration->widget()->rect().translated(-padding_left, -padding_top); return decoration->widget()->rect().translated(-padding_left, -padding_top);
if (hasShadow())
r |= shadow()->shadowRegion().boundingRect();
return r;
} else if (hasShadow()) {
return shadow()->shadowRegion().boundingRect();
} else { } else {
return QRect(0, 0, width(), height()); return QRect(0, 0, width(), height());
} }

View file

@ -782,7 +782,7 @@ void Toplevel::addLayerRepaint(const QRegion& r)
void Toplevel::addRepaintFull() void Toplevel::addRepaintFull()
{ {
repaints_region = decorationRect(); repaints_region = visibleRect().translated(-pos());
workspace()->checkCompositeTimer(); workspace()->checkCompositeTimer();
} }

View file

@ -149,11 +149,7 @@ void Deleted::layoutDecorationRects(QRect& left, QRect& top, QRect& right, QRect
QRect Deleted::decorationRect() const QRect Deleted::decorationRect() const
{ {
QRect r(rect()); return rect().adjusted(-padding_left, -padding_top, padding_top, padding_bottom);
r.adjust(-padding_left, -padding_top, padding_top, padding_bottom);
if (hasShadow())
r |= shadow()->shadowRegion().boundingRect();
return r;
} }
QRect Deleted::transparentRect() const QRect Deleted::transparentRect() const

View file

@ -1914,7 +1914,7 @@ void Client::setGeometry(int x, int y, int w, int h, ForceGeometry_t force)
discardWindowPixmap(); discardWindowPixmap();
emit geometryShapeChanged(this, geom_before_block); emit geometryShapeChanged(this, geom_before_block);
} }
const QRect deco_rect = decorationRect().translated(geom.x(), geom.y()); const QRect deco_rect = visibleRect();
addLayerRepaint(deco_rect_before_block); addLayerRepaint(deco_rect_before_block);
addLayerRepaint(deco_rect); addLayerRepaint(deco_rect);
geom_before_block = geom; geom_before_block = geom;
@ -1981,7 +1981,7 @@ void Client::plainResize(int w, int h, ForceGeometry_t force)
workspace()->checkUnredirect(); workspace()->checkUnredirect();
discardWindowPixmap(); discardWindowPixmap();
emit geometryShapeChanged(this, geom_before_block); emit geometryShapeChanged(this, geom_before_block);
const QRect deco_rect = decorationRect().translated(geom.x(), geom.y()); const QRect deco_rect = visibleRect();
addLayerRepaint(deco_rect_before_block); addLayerRepaint(deco_rect_before_block);
addLayerRepaint(deco_rect); addLayerRepaint(deco_rect);
geom_before_block = geom; geom_before_block = geom;
@ -2028,7 +2028,7 @@ void Client::move(int x, int y, ForceGeometry_t force)
workspace()->tiling()->notifyTilingWindowMove(this, moveResizeGeom, initialMoveResizeGeom); workspace()->tiling()->notifyTilingWindowMove(this, moveResizeGeom, initialMoveResizeGeom);
#endif #endif
// client itself is not damaged // client itself is not damaged
const QRect deco_rect = decorationRect().translated(geom.x(), geom.y()); const QRect deco_rect = visibleRect();
addLayerRepaint(deco_rect_before_block); addLayerRepaint(deco_rect_before_block);
addLayerRepaint(deco_rect); // trigger repaint of window's new location addLayerRepaint(deco_rect); // trigger repaint of window's new location
geom_before_block = geom; geom_before_block = geom;

View file

@ -536,7 +536,7 @@ WindowQuadList Scene::Window::buildQuads(bool force) const
if (cached_quad_list != NULL && !force) if (cached_quad_list != NULL && !force)
return *cached_quad_list; return *cached_quad_list;
WindowQuadList ret; WindowQuadList ret;
if (toplevel->clientPos() == QPoint(0, 0) && toplevel->clientSize() == toplevel->visibleRect().size()) if (toplevel->clientPos() == QPoint(0, 0) && toplevel->clientSize() == toplevel->decorationRect().size())
ret = makeQuads(WindowQuadContents, shape()); // has no decoration ret = makeQuads(WindowQuadContents, shape()); // has no decoration
else { else {
Client *client = dynamic_cast<Client*>(toplevel); Client *client = dynamic_cast<Client*>(toplevel);

View file

@ -283,6 +283,7 @@ void SceneXrender::windowAdded(Toplevel* c)
//**************************************** //****************************************
QPixmap *SceneXrender::Window::temp_pixmap = 0; QPixmap *SceneXrender::Window::temp_pixmap = 0;
QRect SceneXrender::Window::temp_visibleRect;
SceneXrender::Window::Window(Toplevel* c) SceneXrender::Window::Window(Toplevel* c)
: Scene::Window(c) : Scene::Window(c)
@ -411,14 +412,14 @@ QPoint SceneXrender::Window::mapToScreen(int mask, const WindowPaintData &data,
void SceneXrender::Window::prepareTempPixmap() void SceneXrender::Window::prepareTempPixmap()
{ {
const QRect r = static_cast<Client*>(toplevel)->decorationRect(); temp_visibleRect = toplevel->visibleRect().translated(-toplevel->pos());
if (temp_pixmap && Extensions::nonNativePixmaps()) if (temp_pixmap && Extensions::nonNativePixmaps())
XFreePixmap(display(), temp_pixmap->handle()); // The picture owns the pixmap now XFreePixmap(display(), temp_pixmap->handle()); // The picture owns the pixmap now
if (!temp_pixmap) if (!temp_pixmap)
temp_pixmap = new QPixmap(r.width(), r.height()); temp_pixmap = new QPixmap(temp_visibleRect.size());
else if (temp_pixmap->width() < r.width() || temp_pixmap->height() < r.height()) { else if (temp_pixmap->width() < temp_visibleRect.width() || temp_pixmap->height() < temp_visibleRect.height()) {
*temp_pixmap = QPixmap(r.width(), r.height()); *temp_pixmap = QPixmap(temp_visibleRect.size());
scene_setXRenderOffscreenTarget(0); // invalidate, better crash than cause weird results for developers scene_setXRenderOffscreenTarget(0); // invalidate, better crash than cause weird results for developers
} }
if (Extensions::nonNativePixmaps()) { if (Extensions::nonNativePixmaps()) {
@ -471,9 +472,7 @@ void SceneXrender::Window::performPaint(int mask, QRegion region, WindowPaintDat
Client *client = dynamic_cast<Client*>(toplevel); Client *client = dynamic_cast<Client*>(toplevel);
Deleted *deleted = dynamic_cast<Deleted*>(toplevel); Deleted *deleted = dynamic_cast<Deleted*>(toplevel);
const QRect decorationRect = toplevel->decorationRect(); const QRect decorationRect = toplevel->decorationRect();
if (client && Workspace::self()->decorationHasAlpha()) if ((client || deleted) && Workspace::self()->decorationHasAlpha())
transformed_shape = decorationRect;
else if (deleted && Workspace::self()->decorationHasAlpha())
transformed_shape = decorationRect; transformed_shape = decorationRect;
else else
transformed_shape = shape(); transformed_shape = shape();
@ -538,9 +537,10 @@ void SceneXrender::Window::performPaint(int mask, QRegion region, WindowPaintDat
Picture renderTarget = buffer; Picture renderTarget = buffer;
if (blitInTempPixmap) { if (blitInTempPixmap) {
if (scene_xRenderOffscreenTarget()) if (scene_xRenderOffscreenTarget()) {
temp_visibleRect = toplevel->visibleRect().translated(-toplevel->pos());
renderTarget = *scene_xRenderOffscreenTarget(); renderTarget = *scene_xRenderOffscreenTarget();
else { } else {
prepareTempPixmap(); prepareTempPixmap();
renderTarget = temp_pixmap->x11PictureHandle(); renderTarget = temp_pixmap->x11PictureHandle();
} }
@ -568,7 +568,7 @@ void SceneXrender::Window::performPaint(int mask, QRegion region, WindowPaintDat
//END OF STUPID RADEON HACK //END OF STUPID RADEON HACK
} }
#define MAP_RECT_TO_TARGET(_RECT_) \ #define MAP_RECT_TO_TARGET(_RECT_) \
if (blitInTempPixmap) _RECT_.translate(-decorationRect.topLeft()); else _RECT_ = mapToScreen(mask, data, _RECT_) if (blitInTempPixmap) _RECT_.translate(-temp_visibleRect.topLeft()); else _RECT_ = mapToScreen(mask, data, _RECT_)
//BEGIN deco preparations //BEGIN deco preparations
bool noBorder = true; bool noBorder = true;
@ -624,7 +624,7 @@ void SceneXrender::Window::performPaint(int mask, QRegion region, WindowPaintDat
//BEGIN client preparations //BEGIN client preparations
QRect dr = cr; QRect dr = cr;
if (blitInTempPixmap) { if (blitInTempPixmap) {
dr.translate(-decorationRect.topLeft()); dr.translate(-temp_visibleRect.topLeft());
} else { } else {
dr = mapToScreen(mask, data, dr); // Destination rect dr = mapToScreen(mask, data, dr); // Destination rect
if (scaled) { if (scaled) {
@ -685,13 +685,14 @@ XRenderComposite(display(), PictOpOver, _PART_->x11PictureHandle(), decorationAl
// fake brightness change by overlaying black // fake brightness change by overlaying black
XRenderColor col = { 0, 0, 0, 0xffff *(1 - data.brightness) * data.opacity }; XRenderColor col = { 0, 0, 0, 0xffff *(1 - data.brightness) * data.opacity };
if (blitInTempPixmap) { if (blitInTempPixmap) {
XRenderFillRectangle(display(), PictOpOver, renderTarget, &col, -decorationRect.left(), -decorationRect.top(), width(), height()); XRenderFillRectangle(display(), PictOpOver, renderTarget, &col,
-temp_visibleRect.left(), -temp_visibleRect.top(), width(), height());
} else { } else {
XRenderFillRectangle(display(), PictOpOver, renderTarget, &col, wr.x(), wr.y(), wr.width(), wr.height()); XRenderFillRectangle(display(), PictOpOver, renderTarget, &col, wr.x(), wr.y(), wr.width(), wr.height());
} }
} }
if (blitInTempPixmap) { if (blitInTempPixmap) {
const QRect r = mapToScreen(mask, data, decorationRect); const QRect r = mapToScreen(mask, data, temp_visibleRect);
XRenderSetPictureTransform(display(), temp_pixmap->x11PictureHandle(), &xform); XRenderSetPictureTransform(display(), temp_pixmap->x11PictureHandle(), &xform);
XRenderSetPictureFilter(display(), temp_pixmap->x11PictureHandle(), const_cast<char*>("good"), NULL, 0); XRenderSetPictureFilter(display(), temp_pixmap->x11PictureHandle(), const_cast<char*>("good"), NULL, 0);
XRenderComposite(display(), PictOpOver, temp_pixmap->x11PictureHandle(), None, buffer, XRenderComposite(display(), PictOpOver, temp_pixmap->x11PictureHandle(), None, buffer,

View file

@ -91,6 +91,7 @@ private:
double alpha_cached_opacity; double alpha_cached_opacity;
QRegion transformed_shape; QRegion transformed_shape;
static QPixmap *temp_pixmap; static QPixmap *temp_pixmap;
static QRect temp_visibleRect;
}; };
class SceneXrender::EffectFrame class SceneXrender::EffectFrame

View file

@ -96,10 +96,7 @@ QDebug& operator<<(QDebug& stream, const ConstToplevelList& list)
QRect Toplevel::decorationRect() const QRect Toplevel::decorationRect() const
{ {
QRect r(rect()); return rect();
if (hasShadow())
r |= shadow()->shadowRegion().boundingRect();
return r;
} }
void Toplevel::detectShape(Window id) void Toplevel::detectShape(Window id)