split decorationRect / visibleRect usage
REVIEW: 104215 cherry-picked from 0f3380f3b10e57416f81a1288dc10b8dfe11d87e Conflicts: kwin/geometry.cpp kwin/scene.cpp
This commit is contained in:
parent
5bf62e5308
commit
1070bf895b
8 changed files with 23 additions and 33 deletions
|
@ -2425,12 +2425,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());
|
||||
}
|
||||
|
|
|
@ -782,7 +782,7 @@ void Toplevel::addLayerRepaint(const QRegion& r)
|
|||
|
||||
void Toplevel::addRepaintFull()
|
||||
{
|
||||
repaints_region = decorationRect();
|
||||
repaints_region = visibleRect().translated(-pos());
|
||||
workspace()->checkCompositeTimer();
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -1914,7 +1914,7 @@ void Client::setGeometry(int x, int y, int w, int h, ForceGeometry_t force)
|
|||
discardWindowPixmap();
|
||||
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);
|
||||
geom_before_block = geom;
|
||||
|
@ -1981,7 +1981,7 @@ void Client::plainResize(int w, int h, ForceGeometry_t force)
|
|||
workspace()->checkUnredirect();
|
||||
discardWindowPixmap();
|
||||
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);
|
||||
geom_before_block = geom;
|
||||
|
@ -2028,7 +2028,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();
|
||||
addLayerRepaint(deco_rect_before_block);
|
||||
addLayerRepaint(deco_rect); // trigger repaint of window's new location
|
||||
geom_before_block = geom;
|
||||
|
|
|
@ -536,7 +536,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);
|
||||
|
|
|
@ -283,6 +283,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)
|
||||
|
@ -411,14 +412,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()) {
|
||||
|
@ -471,9 +472,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();
|
||||
|
@ -538,9 +537,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();
|
||||
}
|
||||
|
@ -568,7 +568,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;
|
||||
|
@ -624,7 +624,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) {
|
||||
|
@ -685,13 +685,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,
|
||||
|
|
|
@ -91,6 +91,7 @@ private:
|
|||
double alpha_cached_opacity;
|
||||
QRegion transformed_shape;
|
||||
static QPixmap *temp_pixmap;
|
||||
static QRect temp_visibleRect;
|
||||
};
|
||||
|
||||
class SceneXrender::EffectFrame
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue