summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Spilsbury <sam.spilsbury@canonical.com>2011-07-17 01:19:34 +0800
committerSam Spilsbury <sam.spilsbury@canonical.com>2011-07-17 01:19:34 +0800
commitf1f91f4e2bc96ddf58161ba13f0e878aa69025b1 (patch)
treee54f1b9006487e2f31f57626e15606c0057fef6d
parent7f4ec20c3b9182cc3a5f5188b93f3189d949c4c9 (diff)
downloadlocker-f1f91f4e2bc96ddf58161ba13f0e878aa69025b1.tar.gz
locker-f1f91f4e2bc96ddf58161ba13f0e878aa69025b1.tar.bz2
Add a prettier animation
-rw-r--r--src/locker.cpp48
1 files changed, 30 insertions, 18 deletions
diff --git a/src/locker.cpp b/src/locker.cpp
index 0c78a4c..34355ca 100644
--- a/src/locker.cpp
+++ b/src/locker.cpp
@@ -183,7 +183,7 @@ LockerScreen::handleEvent (XEvent *event)
break;
case KeyRelease:
wake ();
- if (lockWindow && lockWindow->needsGrab ())
+ if (lockWindow && lockWindow->needsGrab () && mAnimationState == AnimationStateLocked)
processed = lockWindow->handleKeyRelease ((XKeyEvent *) event);
break;
case MotionNotify:
@@ -206,6 +206,9 @@ LockerScreen::preparePaint (int ms)
if (mAnimationProgress >= 1.0f)
mAnimationProgress = 1.0f;
+
+ foreach (CompWindow *w, screen->windows ())
+ LockerWindow::get (w)->setAnimationProgress (mAnimationProgress);
}
if (mAnimationState == AnimationStateUnlocking)
@@ -214,10 +217,10 @@ LockerScreen::preparePaint (int ms)
if (mAnimationProgress <= 0.0f)
mAnimationProgress = 0.0f;
- }
- foreach (CompWindow *w, screen->windows ())
- LockerWindow::get (w)->setAnimationProgress (mAnimationProgress);
+ foreach (CompWindow *w, screen->windows ())
+ LockerWindow::get (w)->setAnimationProgress (mAnimationProgress);
+ }
cScreen->preparePaint (ms);
}
@@ -233,9 +236,13 @@ LockerScreen::glPaintOutput (const GLScreenPaintAttrib &attrib,
LockerLockBackground *lockScreen = LockerLockBackground::Default ();
bool status;
- if (mAnimationState != AnimationStateIdle ||
+ if (mAnimationState != AnimationStateIdle &&
mAnimationState != AnimationStateLocked)
+ {
mask |= PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS_MASK;
+ mask |= PAINT_SCREEN_TRANSFORMED_MASK;
+ mask |= PAINT_SCREEN_CLEAR_MASK;
+ }
/* Nothing shall pass - clear the entire backbuffer and short circuit
* the paint chain and then paint our locker windows, we absolutely do
@@ -311,17 +318,19 @@ LockerScreen::donePaint ()
cScreen->damageScreen ();
}
-
- if (lockWindow)
+ else if (mAnimationState == AnimationStateLocked)
{
- cScreen->damageRegion (lockWindow->damage ());
- lockWindow->damage () = CompRegion ();
- }
+ if (lockWindow)
+ {
+ cScreen->damageRegion (lockWindow->damage ());
+ lockWindow->damage () = CompRegion ();
+ }
- if (lockBackground)
- {
- cScreen->damageRegion (lockBackground->damage ());
- lockBackground->damage () = CompRegion ();
+ if (lockBackground)
+ {
+ cScreen->damageRegion (lockBackground->damage ());
+ lockBackground->damage () = CompRegion ();
+ }
}
cScreen->donePaint ();
@@ -406,21 +415,24 @@ LockerWindow::glPaint (const GLWindowPaintAttrib &attrib,
unsigned int mask)
{
GLWindowPaintAttrib wAttrib (attrib);
+ GLMatrix wTransform (transform);
/* A simple fade in / out will do */
if (isAnimatedWindow ())
{
wAttrib.brightness = (int) ((1.0f - mAnimationProgress) * (float) attrib.brightness);
+ wTransform.translate (0.0f, 0.0f, -mAnimationProgress * 0.05);
+
+ mask |= PAINT_WINDOW_TRANSFORMED_MASK;
}
- return gWindow->glPaint (wAttrib, transform, region, mask);
+ return gWindow->glPaint (wAttrib, wTransform, region, mask);
}
bool
LockerWindow::isAnimatedWindow ()
{
- if (!window->invisible () &&
- window->isViewable ())
+ if (window->isViewable ())
return true;
return false;
@@ -444,7 +456,7 @@ LockerScreen::LockerScreen (CompScreen *s) :
LockerLockBackground::SetDefault (mSLB);
mWaitTimer.setCallback (boost::bind (&LockerScreen::lock, this));
- mWaitTimer.setTimes (optionGetTimeout () * 1000, optionGetTimeout () * 1000);
+ mWaitTimer.setTimes (optionGetTimeout () * 100, optionGetTimeout () * 100);
mWaitTimer.start ();
}