From 795de6c6d6663b6891c94644dc3e2f2528c83749 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lubo=C5=A1=20Lu=C5=88=C3=A1k?= Date: Sun, 15 Apr 2007 18:12:24 +0000 Subject: [PATCH] Centered placement in slots. svn path=/branches/work/kwin_composite/; revision=654291 --- effects/presentwindows.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/effects/presentwindows.cpp b/effects/presentwindows.cpp index 67bf91ffe9..02f422fbe3 100644 --- a/effects/presentwindows.cpp +++ b/effects/presentwindows.cpp @@ -529,8 +529,22 @@ void PresentWindowsEffect::calculateWindowTransformationsClosest(EffectWindowLis area.y() + ((*it).slot / columns ) * slotheight, slotwidth, slotheight ); geom.adjust( 10, 10, -10, -10 ); // borders + float scale; + EffectWindow* w = it.key(); + if( geom.width() / float( w->width()) < geom.height() / float( w->height())) + { // center vertically + scale = geom.width() / float( w->width()); + geom.moveTop( geom.top() + ( geom.height() - int( w->height() * scale )) / 2 ); + geom.setHeight( int( w->height() * scale )); + } + else + { // center horizontally + scale = geom.height() / float( w->height()); + geom.moveLeft( geom.left() + ( geom.width() - int( w->width() * scale )) / 2 ); + geom.setWidth( int( w->width() * scale )); + } (*it).area = geom; - (*it).scale = qMin( geom.width() / float( it.key()->width()), geom.height() / float( it.key()->height())); + (*it).scale = scale; (*it).hover = 0; } }