aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Lübking <thomas.luebking@gmail.com>2012-03-10 10:34:56 (GMT)
committerThomas Lübking <thomas.luebking@gmail.com>2012-03-20 23:25:45 (GMT)
commit0f3380f3b10e57416f81a1288dc10b8dfe11d87e (patch)
tree5fe8744d5681c2199d47e8ccc5b33b434a11b58d
parent30ee236d9d7a9c42d763fa4704156846cfa6af25 (diff)
split decorationRect / visibleRect usage
REVIEW: 104215
-rw-r--r--kwin/client.cpp7
-rw-r--r--kwin/composite.cpp2
-rw-r--r--kwin/deleted.cpp6
-rw-r--r--kwin/geometry.cpp6
-rw-r--r--kwin/scene.cpp10
-rw-r--r--kwin/scene_xrender.cpp27
-rw-r--r--kwin/scene_xrender.h1
-rw-r--r--kwin/toplevel.cpp5
8 files changed, 27 insertions, 37 deletions
diff --git a/kwin/client.cpp b/kwin/client.cpp
index 22aa8dc..6176b90 100644
--- a/kwin/client.cpp
+++ b/kwin/client.cpp
@@ -2405,12 +2405,7 @@ void Client::setSessionInteract(bool needed)
QRect Client::decorationRect() const
{
if (decoration && decoration->widget()) {
- QRect r = decoration->widget()->rect().translated(-padding_left, -padding_top);
- if (hasShadow())
- r |= shadow()->shadowRegion().boundingRect();
- return r;
- } else if (hasShadow()) {
- return shadow()->shadowRegion().boundingRect();
+ return decoration->widget()->rect().translated(-padding_left, -padding_top);
} else {
return QRect(0, 0, width(), height());
}
diff --git a/kwin/composite.cpp b/kwin/composite.cpp
index 55a7144..d2d2afb 100644
--- a/kwin/composite.cpp
+++ b/kwin/composite.cpp
@@ -762,7 +762,7 @@ void Toplevel::addRepaint(const QRegion& r)
void Toplevel::addRepaintFull()
{
- repaints_region = decorationRect();
+ repaints_region = visibleRect().translated(-pos());
workspace()->checkCompositeTimer();
}
diff --git a/kwin/deleted.cpp b/kwin/deleted.cpp
index e166bf1..cb240d2 100644
--- a/kwin/deleted.cpp
+++ b/kwin/deleted.cpp
@@ -149,11 +149,7 @@ void Deleted::layoutDecorationRects(QRect& left, QRect& top, QRect& right, QRect
QRect Deleted::decorationRect() const
{
- QRect r(rect());
- r.adjust(-padding_left, -padding_top, padding_top, padding_bottom);
- if (hasShadow())
- r |= shadow()->shadowRegion().boundingRect();
- return r;
+ return rect().adjusted(-padding_left, -padding_top, padding_top, padding_bottom);
}
QRect Deleted::transparentRect() const
diff --git a/kwin/geometry.cpp b/kwin/geometry.cpp
index 49ddd29..5466068 100644
--- a/kwin/geometry.cpp
+++ b/kwin/geometry.cpp
@@ -1946,7 +1946,7 @@ void Client::setGeometry(int x, int y, int w, int h, ForceGeometry_t force, bool
discardWindowPixmap();
emit geometryShapeChanged(this, geom_before_block);
}
- const QRect deco_rect = decorationRect().translated(geom.x(), geom.y());
+ const QRect deco_rect = visibleRect();
addWorkspaceRepaint(deco_rect_before_block);
addWorkspaceRepaint(deco_rect);
geom_before_block = geom;
@@ -2019,7 +2019,7 @@ void Client::plainResize(int w, int h, ForceGeometry_t force, bool emitJs)
workspace()->checkUnredirect();
discardWindowPixmap();
emit geometryShapeChanged(this, geom_before_block);
- const QRect deco_rect = decorationRect().translated(geom.x(), geom.y());
+ const QRect deco_rect = visibleRect();
addWorkspaceRepaint(deco_rect_before_block);
addWorkspaceRepaint(deco_rect);
geom_before_block = geom;
@@ -2064,7 +2064,7 @@ void Client::move(int x, int y, ForceGeometry_t force)
workspace()->tiling()->notifyTilingWindowMove(this, moveResizeGeom, initialMoveResizeGeom);
#endif
// client itself is not damaged
- const QRect deco_rect = decorationRect().translated(geom.x(), geom.y());
+ const QRect deco_rect = visibleRect();
addWorkspaceRepaint(deco_rect_before_block);
addWorkspaceRepaint(deco_rect); // trigger repaint of window's new location
geom_before_block = geom;
diff --git a/kwin/scene.cpp b/kwin/scene.cpp
index 0541198..08b309c 100644
--- a/kwin/scene.cpp
+++ b/kwin/scene.cpp
@@ -213,7 +213,7 @@ void Scene::paintGenericScreen(int orig_mask, ScreenPaintData)
// Reset the repaint_region.
// This has to be done here because many effects schedule a repaint for
// the next frame within Effects::prePaintWindow.
- topw->resetRepaints(topw->decorationRect());
+ topw->resetRepaints(topw->visibleRect().translated(-topw->pos()));
WindowPrePaintData data;
data.mask = orig_mask | (w->isOpaque() ? PAINT_WINDOW_OPAQUE : PAINT_WINDOW_TRANSLUCENT);
@@ -269,7 +269,7 @@ void Scene::paintSimpleScreen(int orig_mask, QRegion region)
// Reset the repaint_region.
// This has to be done here because many effects schedule a repaint for
// the next frame within Effects::prePaintWindow.
- topw->resetRepaints(topw->decorationRect());
+ topw->resetRepaints(topw->visibleRect().translated(-topw->pos()));
// Clip out the decoration for opaque windows; the decoration is drawn in the second pass
if (w->isOpaque()) {
// the window is fully opaque
@@ -314,7 +314,7 @@ void Scene::paintSimpleScreen(int orig_mask, QRegion region)
// In case there is a window with a higher stackposition which has translucent regions
// (e.g. decorations) that still have to be drawn, we also have to repaint the current window
// in these particular regions
- data->region |= (upperTranslucentDamage & tlw->decorationRect().translated(tlw->pos()));
+ data->region |= (upperTranslucentDamage & tlw->visibleRect());
// subtract the parts which have possibly been drawn already as part of
// a higher opaque window
@@ -360,7 +360,7 @@ void Scene::paintSimpleScreen(int orig_mask, QRegion region)
Toplevel *tlw = data.key()->window();
// add all regions of the lower windows which have already be drawn in the 1st pass
- data->region |= (lowerOpaqueDamage & tlw->decorationRect().translated(tlw->pos()));
+ data->region |= (lowerOpaqueDamage & tlw->visibleRect());
// and extend that region by opaque parts of ourself
lowerOpaqueDamage |= data->painted_1stpass;
@@ -572,7 +572,7 @@ WindowQuadList Scene::Window::buildQuads(bool force) const
if (cached_quad_list != NULL && !force)
return *cached_quad_list;
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
else {
Client *client = dynamic_cast<Client*>(toplevel);
diff --git a/kwin/scene_xrender.cpp b/kwin/scene_xrender.cpp
index 8a06d6a..0318e31 100644
--- a/kwin/scene_xrender.cpp
+++ b/kwin/scene_xrender.cpp
@@ -355,6 +355,7 @@ void SceneXrender::windowAdded(Toplevel* c)
//****************************************
QPixmap *SceneXrender::Window::temp_pixmap = 0;
+QRect SceneXrender::Window::temp_visibleRect;
SceneXrender::Window::Window(Toplevel* c)
: Scene::Window(c)
@@ -483,14 +484,14 @@ QPoint SceneXrender::Window::mapToScreen(int mask, const WindowPaintData &data,
void SceneXrender::Window::prepareTempPixmap()
{
- const QRect r = static_cast<Client*>(toplevel)->decorationRect();
+ temp_visibleRect = toplevel->visibleRect().translated(-toplevel->pos());
if (temp_pixmap && Extensions::nonNativePixmaps())
XFreePixmap(display(), temp_pixmap->handle()); // The picture owns the pixmap now
if (!temp_pixmap)
- temp_pixmap = new QPixmap(r.width(), r.height());
- else if (temp_pixmap->width() < r.width() || temp_pixmap->height() < r.height()) {
- *temp_pixmap = QPixmap(r.width(), r.height());
+ temp_pixmap = new QPixmap(temp_visibleRect.size());
+ else if (temp_pixmap->width() < temp_visibleRect.width() || temp_pixmap->height() < temp_visibleRect.height()) {
+ *temp_pixmap = QPixmap(temp_visibleRect.size());
scene_setXRenderOffscreenTarget(0); // invalidate, better crash than cause weird results for developers
}
if (Extensions::nonNativePixmaps()) {
@@ -543,9 +544,7 @@ void SceneXrender::Window::performPaint(int mask, QRegion region, WindowPaintDat
Client *client = dynamic_cast<Client*>(toplevel);
Deleted *deleted = dynamic_cast<Deleted*>(toplevel);
const QRect decorationRect = toplevel->decorationRect();
- if (client && Workspace::self()->decorationHasAlpha())
- transformed_shape = decorationRect;
- else if (deleted && Workspace::self()->decorationHasAlpha())
+ if ((client || deleted) && Workspace::self()->decorationHasAlpha())
transformed_shape = decorationRect;
else
transformed_shape = shape();
@@ -610,9 +609,10 @@ void SceneXrender::Window::performPaint(int mask, QRegion region, WindowPaintDat
Picture renderTarget = buffer;
if (blitInTempPixmap) {
- if (scene_xRenderOffscreenTarget())
+ if (scene_xRenderOffscreenTarget()) {
+ temp_visibleRect = toplevel->visibleRect().translated(-toplevel->pos());
renderTarget = *scene_xRenderOffscreenTarget();
- else {
+ } else {
prepareTempPixmap();
renderTarget = temp_pixmap->x11PictureHandle();
}
@@ -640,7 +640,7 @@ void SceneXrender::Window::performPaint(int mask, QRegion region, WindowPaintDat
//END OF STUPID RADEON HACK
}
#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
bool noBorder = true;
@@ -696,7 +696,7 @@ void SceneXrender::Window::performPaint(int mask, QRegion region, WindowPaintDat
//BEGIN client preparations
QRect dr = cr;
if (blitInTempPixmap) {
- dr.translate(-decorationRect.topLeft());
+ dr.translate(-temp_visibleRect.topLeft());
} else {
dr = mapToScreen(mask, data, dr); // Destination rect
if (scaled) {
@@ -757,13 +757,14 @@ XRenderComposite(display(), PictOpOver, _PART_->x11PictureHandle(), decorationAl
// fake brightness change by overlaying black
XRenderColor col = { 0, 0, 0, 0xffff *(1 - data.brightness) * data.opacity };
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 {
XRenderFillRectangle(display(), PictOpOver, renderTarget, &col, wr.x(), wr.y(), wr.width(), wr.height());
}
}
if (blitInTempPixmap) {
- const QRect r = mapToScreen(mask, data, decorationRect);
+ const QRect r = mapToScreen(mask, data, temp_visibleRect);
XRenderSetPictureTransform(display(), temp_pixmap->x11PictureHandle(), &xform);
XRenderSetPictureFilter(display(), temp_pixmap->x11PictureHandle(), const_cast<char*>("good"), NULL, 0);
XRenderComposite(display(), PictOpOver, temp_pixmap->x11PictureHandle(), None, buffer,
diff --git a/kwin/scene_xrender.h b/kwin/scene_xrender.h
index 23ff2ad..140426e 100644
--- a/kwin/scene_xrender.h
+++ b/kwin/scene_xrender.h
@@ -93,6 +93,7 @@ private:
double alpha_cached_opacity;
QRegion transformed_shape;
static QPixmap *temp_pixmap;
+ static QRect temp_visibleRect;
};
class SceneXrender::EffectFrame
diff --git a/kwin/toplevel.cpp b/kwin/toplevel.cpp
index 0716c2f..b3f0228 100644
--- a/kwin/toplevel.cpp
+++ b/kwin/toplevel.cpp
@@ -96,10 +96,7 @@ QDebug& operator<<(QDebug& stream, const ConstToplevelList& list)
QRect Toplevel::decorationRect() const
{
- QRect r(rect());
- if (hasShadow())
- r |= shadow()->shadowRegion().boundingRect();
- return r;
+ return rect();
}
void Toplevel::detectShape(Window id)