~compiz-team/compiz-animation-plugin/oneiric

« back to all changes in this revision

Viewing changes to src/animation.cpp

  • Committer: Sam Spilsbury
  • Date: 2011-09-20 07:42:53 UTC
  • mfrom: (380.3.11 compiz-animation-plugin)
  • Revision ID: sam.spilsbury@canonical.com-20110920074253-sm3hzkby2n49w989
Merge in animation paint list work

Show diffs side-by-side

added added

removed removed

Lines of Context:
317
317
 
318
318
    if (shouldInitPersistentData)
319
319
    {
 
320
        const CompWindowList &pl = pushLockedPaintList ();
320
321
        // Initialize persistent window data for the extension plugin
321
 
        foreach (CompWindow *w, ::screen->windows ())
 
322
        foreach (CompWindow *w, pl)
322
323
        {
323
324
            AnimWindow *aw = AnimWindow::get (w);
324
325
            extensionPluginInfo->initPersistentData (aw);
325
326
        }
 
327
 
 
328
        popLockedPaintList ();
326
329
    }
327
330
}
328
331
 
336
339
PrivateAnimScreen::removeExtension (ExtensionPluginInfo *extensionPluginInfo)
337
340
{
338
341
    // Stop all ongoing animations
339
 
    foreach (CompWindow *w, ::screen->windows ())
 
342
    const CompWindowList &pl = pushLockedPaintList ();
 
343
 
 
344
    foreach (CompWindow *w, pl)
340
345
    {
341
346
        PrivateAnimWindow *aw = AnimWindow::get (w)->priv;
342
347
        if (aw->curAnimation ())
343
348
            aw->postAnimationCleanUp ();
344
349
    }
345
350
 
 
351
    popLockedPaintList ();
 
352
 
346
353
    // Find the matching plugin and delete it
347
354
 
348
355
    ExtensionPluginVector::iterator it = find (mExtensionPlugins.begin (),
390
397
            updateEventEffects ((AnimEvent)e, true);
391
398
    }
392
399
 
 
400
    const CompWindowList &cpl = pushLockedPaintList ();
 
401
 
393
402
    // Destroy persistent window data for the extension plugin
394
 
    foreach (CompWindow *w, ::screen->windows ())
 
403
    foreach (CompWindow *w, cpl)
395
404
    {
396
405
        AnimWindow *aw = AnimWindow::get (w);
397
406
        extensionPluginInfo->destroyPersistentData (aw);
398
407
    }
 
408
 
 
409
    popLockedPaintList ();
399
410
}
400
411
 
401
412
ExtensionPluginInfo::ExtensionPluginInfo (const CompString &name,
1102
1113
        // Animations have finished for all windows
1103
1114
        // (Keep preparePaint enabled)
1104
1115
 
1105
 
        cScreen->getWindowPaintListSetEnabled (this, false);
1106
 
        enablePrePaintWindowsBackToFront (false);
 
1116
        aScreen->enableCustomPaintList (false);
1107
1117
    }
1108
1118
    cScreen->donePaintSetEnabled (this, activating);
1109
1119
    gScreen->glPaintOutputSetEnabled (this, activating);
1229
1239
    if (mAnimInProgress)
1230
1240
    {   
1231
1241
        int msSinceLastPaintActual;
 
1242
        const CompWindowList &pl = pushLockedPaintList ();
 
1243
        CompWindowList       windowsFinishedAnimations;
1232
1244
 
1233
1245
        struct timeval curTime;
1234
1246
        gettimeofday (&curTime, 0);
1248
1260
 
1249
1261
        bool animStillInProgress = false;
1250
1262
 
1251
 
        foreach (CompWindow *w, ::screen->windows ())
 
1263
        /* Paint list includes destroyed windows */
 
1264
        for (CompWindowList::const_reverse_iterator rit = pl.rbegin ();
 
1265
             rit != pl.rend (); rit++)
1252
1266
        {
 
1267
            CompWindow *w = (*rit);
1253
1268
            AnimWindow *animWin = AnimWindow::get (w);
1254
1269
            PrivateAnimWindow *aw = animWin->priv;
1255
1270
            Animation *curAnim = aw->curAnimation ();
1322
1337
 
1323
1338
                bool finished = (curAnim->remainingTime () <= 0);
1324
1339
                if (finished) // Animation is done
1325
 
                {
1326
 
                    aw->notifyAnimation (false);
1327
 
                    aw->postAnimationCleanUp ();
1328
 
                }
 
1340
                    windowsFinishedAnimations.push_back (w);
1329
1341
                else
1330
1342
                    animStillInProgress = true;
1331
1343
            }
1332
1344
        }
1333
1345
 
1334
 
        foreach (CompWindow *w, ::screen->windows ())
 
1346
        popLockedPaintList ();
 
1347
 
 
1348
        foreach (CompWindow *w, windowsFinishedAnimations)
 
1349
        {
 
1350
            AnimWindow *aw = AnimWindow::get (w);
 
1351
            aw->priv->notifyAnimation (false);
 
1352
            aw->priv->postAnimationCleanUp ();
 
1353
        }
 
1354
 
 
1355
        const CompWindowList &ppl = pushLockedPaintList ();
 
1356
 
 
1357
        foreach (CompWindow *w, ppl)
1335
1358
        {
1336
1359
            PrivateAnimWindow *aw = AnimWindow::get (w)->priv;
1337
1360
            if (aw->curAnimation ())
1348
1371
                static_cast<ExtensionPluginAnimation *> (mExtensionPlugins[0]);
1349
1372
            extPlugin->resetStackingInfo ();
1350
1373
        }
 
1374
 
 
1375
        popLockedPaintList ();
1351
1376
    }
1352
1377
 
1353
1378
    foreach (ExtensionPluginInfo *extPlugin, mExtensionPlugins)
1572
1597
    return status;
1573
1598
}
1574
1599
 
 
1600
const CompWindowList &
 
1601
PrivateAnimScreen::pushLockedPaintList ()
 
1602
{
 
1603
    if (!mLockedPaintListCnt)
 
1604
    {
 
1605
        mLockedPaintList = &cScreen->getWindowPaintList ();
 
1606
 
 
1607
        if (!mGetWindowPaintListEnableCnt)
 
1608
        {
 
1609
            mGetWindowPaintListEnableCnt++;
 
1610
            cScreen->getWindowPaintListSetEnabled (this, true);
 
1611
        }
 
1612
    }
 
1613
 
 
1614
    mLockedPaintListCnt++;
 
1615
    return *mLockedPaintList;
 
1616
}
 
1617
 
 
1618
void
 
1619
PrivateAnimScreen::popLockedPaintList ()
 
1620
{
 
1621
    mLockedPaintListCnt--;
 
1622
 
 
1623
    if (!mLockedPaintListCnt)
 
1624
    {
 
1625
        mLockedPaintList = NULL;
 
1626
 
 
1627
        mGetWindowPaintListEnableCnt--;
 
1628
 
 
1629
        if (!mGetWindowPaintListEnableCnt)
 
1630
            cScreen->getWindowPaintListSetEnabled (this, false);
 
1631
    }
 
1632
}
 
1633
 
1575
1634
/// This is enabled only during restack animations.
 
1635
/// or when we need to lock it
1576
1636
const CompWindowList &
1577
1637
PrivateAnimScreen::getWindowPaintList ()
1578
1638
{
 
1639
    if (mLockedPaintList)
 
1640
        return *mLockedPaintList;
 
1641
 
1579
1642
    ExtensionPluginAnimation *extPlugin =
1580
1643
        static_cast<ExtensionPluginAnimation *> (mExtensionPlugins[0]);
1581
1644
    return extPlugin->getWindowPaintList ();
1599
1662
}
1600
1663
 
1601
1664
void
 
1665
PrivateAnimScreen::pushPaintList ()
 
1666
{
 
1667
    if (!mGetWindowPaintListEnableCnt)
 
1668
        cScreen->getWindowPaintListSetEnabled (this, true);
 
1669
 
 
1670
    mGetWindowPaintListEnableCnt++;
 
1671
}
 
1672
 
 
1673
void
 
1674
PrivateAnimScreen::popPaintList ()
 
1675
{
 
1676
    mGetWindowPaintListEnableCnt--;
 
1677
 
 
1678
    if (!mGetWindowPaintListEnableCnt)
 
1679
        cScreen->getWindowPaintListSetEnabled (this, false);
 
1680
}
 
1681
 
 
1682
void
1602
1683
AnimScreen::enableCustomPaintList (bool enabled)
1603
1684
{
1604
 
    priv->cScreen->getWindowPaintListSetEnabled (priv, enabled);
 
1685
    enabled ? priv->pushPaintList () : priv->popPaintList ();
 
1686
 
1605
1687
    priv->enablePrePaintWindowsBackToFront (enabled);
1606
1688
}
1607
1689
 
2258
2340
PrivateAnimScreen::updateAnimStillInProgress ()
2259
2341
{
2260
2342
    bool animStillInProgress = false;
2261
 
    foreach (CompWindow *w, ::screen->windows ())
 
2343
    const CompWindowList &pl = pushLockedPaintList ();
 
2344
 
 
2345
    foreach (CompWindow *w, pl)
2262
2346
    {
2263
2347
        PrivateAnimWindow *aw = AnimWindow::get (w)->priv;
2264
2348
        if (aw->curAnimation () &&
2273
2357
        }
2274
2358
    }
2275
2359
 
 
2360
    popLockedPaintList ();
 
2361
 
2276
2362
    if (!animStillInProgress)
2277
2363
        activateEvent (false);
2278
2364
}
2400
2486
    mAnimInProgress (false),
2401
2487
    mStartingNewPaintRound (false),
2402
2488
    mPrePaintWindowsBackToFrontEnabled (false),
2403
 
    mOutput (0)
 
2489
    mOutput (0),
 
2490
    mLockedPaintList (NULL),
 
2491
    mLockedPaintListCnt (0),
 
2492
    mGetWindowPaintListEnableCnt (0)
2404
2493
{
2405
2494
    for (int i = 0; i < WatchedScreenPluginNum; i++)
2406
2495
        mPluginActive[i] = false;