From 9027b501c85c4845981463f130de0f27fa7442fb Mon Sep 17 00:00:00 2001 From: Rivo Laks Date: Fri, 30 Mar 2007 15:35:19 +0000 Subject: [PATCH] Interpolate between brightness changes when highlighting window under cursor. svn path=/branches/work/kwin_composite/; revision=648132 --- effects/presentwindows.cpp | 12 ++++++++++-- effects/presentwindows.h | 1 + 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/effects/presentwindows.cpp b/effects/presentwindows.cpp index 82fa1089a9..fc695c5e4b 100644 --- a/effects/presentwindows.cpp +++ b/effects/presentwindows.cpp @@ -81,6 +81,13 @@ void PresentWindowsEffect::prePaintWindow( EffectWindow* w, int* mask, QRegion* Client* c = static_cast< Client* >( w->window() ); if( mActiveness < 1.0f && (c->isMinimized() || !c->isOnCurrentDesktop() )) *mask |= Scene::PAINT_WINDOW_TRANSLUCENT; + // Change window's hover according to cursor pos + WindowData& windata = mWindowData[w->window()]; + const float hoverchangetime = 200; + if( windata.area.contains(cursorPos()) ) + windata.hover = qMin(1.0f, windata.hover + time / hoverchangetime); + else + windata.hover = qMax(0.0f, windata.hover - time / hoverchangetime); } effects->prePaintWindow( w, mask, paint, clip, time ); @@ -97,8 +104,7 @@ void PresentWindowsEffect::paintWindow( EffectWindow* w, int mask, QRegion regio data.xTranslate = (int)interpolate(data.xTranslate, windata.area.left() - w->window()->x(), mActiveness); data.yTranslate = (int)interpolate(data.yTranslate, windata.area.top() - w->window()->y(), mActiveness); // Darken all windows except for the one under the cursor - if( !windata.area.contains(cursorPos()) ) - data.brightness *= interpolate(1.0, 0.7, mActiveness); + data.brightness *= interpolate(1.0, 0.7, mActiveness * (1.0f - windata.hover)); // If it's minimized window or on another desktop and effect is not // fully active, then apply some transparency Client* c = static_cast< Client* >( w->window() ); @@ -219,6 +225,7 @@ void PresentWindowsEffect::calculateWindowTransformationsDumb(ClientList clientl // Row/Col of this window int r = i / cols; int c = i % cols; + mWindowData[client].hover = 0.0f; mWindowData[client].scale = qMin(cellwidth / (float)client->width(), cellheight / (float)client->height()); mWindowData[client].area.setLeft(placementRect.left() + cellwidth * c); mWindowData[client].area.setTop(placementRect.top() + cellheight * r); @@ -375,6 +382,7 @@ void PresentWindowsEffect::calculateWindowTransformationsKompose(ClientList clie geom.setY( geom.y() + topOffset ); mWindowData[client].area = geom; mWindowData[client].scale = geom.width() / (float)client->width(); + mWindowData[client].hover = 0.0f; kDebug() << k_funcinfo << "Window '" << client->caption() << "' gets moved to (" << mWindowData[client].area.left() << "; " << mWindowData[client].area.right() << diff --git a/effects/presentwindows.h b/effects/presentwindows.h index 8483b1001b..71c73ab450 100644 --- a/effects/presentwindows.h +++ b/effects/presentwindows.h @@ -74,6 +74,7 @@ class PresentWindowsEffect { QRect area; float scale; + float hover; }; QHash mWindowData; };