void MagScreen::preparePaint (int time) { if (adjust) { int steps; float amount, chunk; amount = time * 0.35f * optionGetSpeed (); steps = amount / (0.5f * optionGetTimestep ()); if (!steps) steps = 1; chunk = amount / (float) steps; while (steps--) { adjust = adjustZoom (chunk); if (adjust) break; } } if (zoom != 1.0) { if (!poller.active ()) { CompPoint pos; pos = poller.getCurrentPosition (); posX = pos.x (); posY = pos.y (); poller.start (); } damageRegion (); } cScreen->preparePaint (time); }
void RotateScreen::preparePaint (int msSinceLastPaint) { float oldXrot = mXrot + mBaseXrot; if (mGrabIndex || mMoving) { float amount = msSinceLastPaint * 0.05f * optionGetSpeed (); int steps = amount / (0.5f * optionGetTimestep ()); if (!steps) steps = 1; float chunk = amount / (float) steps; while (steps--) { mXrot += mXVelocity * chunk; mYrot += mYVelocity * chunk; if (mXrot > 360.0f / screen->vpSize ().width ()) { mBaseXrot += 360.0f / screen->vpSize ().width (); mXrot -= 360.0f / screen->vpSize ().width (); } else if (mXrot < 0.0f) { mBaseXrot -= 360.0f / screen->vpSize ().width (); mXrot += 360.0f / screen->vpSize ().width (); } if (cubeScreen->invert () == -1) { if (mYrot > 45.0f) { mYVelocity = 0.0f; mYrot = 45.0f; } else if (mYrot < -45.0f) { mYVelocity = 0.0f; mYrot = -45.0f; } } else { if (mYrot > 100.0f) { mYVelocity = 0.0f; mYrot = 100.0f; } else if (mYrot < -100.0f) { mYVelocity = 0.0f; mYrot = -100.0f; } } if (mGrabbed) { mXVelocity /= 1.25f; mYVelocity /= 1.25f; if (fabs (mXVelocity) < 0.01f) mXVelocity = 0.0f; if (fabs (mYVelocity) < 0.01f) mYVelocity = 0.0f; } else if (adjustVelocity (screen->vpSize ().width (), cubeScreen->invert ())) { mXVelocity = 0.0f; mYVelocity = 0.0f; if (fabs (mYrot) < 0.1f) { CompOption::Vector o (0); int tx; float xrot = mBaseXrot + mXrot; if (xrot < 0.0f) tx = (screen->vpSize ().width () * xrot / 360.0f) - 0.5f; else tx = (screen->vpSize ().width () * xrot / 360.0f) + 0.5f; /* flag end of rotation */ cubeScreen->rotationState (CubeScreen::RotationNone); screen->moveViewport (tx, 0, true); mBaseXrot = mMoveTo = mXrot = mYrot = 0.0f; mMoving = false; if (mGrabIndex) { screen->removeGrab (mGrabIndex, &mSavedPointer); mGrabIndex = 0; } if (mMoveWindow) { CompWindow *w = screen->findWindow (mMoveWindow); if (w) w->move (mMoveWindowX - w->x (), 0); } /* only focus default window if switcher isn't active */ else if (!screen->grabExist ("switcher")) screen->focusDefaultWindow (); mMoveWindow = 0; screen->handleCompizEvent ("rotate", "end_viewport_switch", o); } break; } } if (mMoveWindow) { CompWindow *w = screen->findWindow (mMoveWindow); if (w) { float xrot = (screen->vpSize ().width () * (mBaseXrot + mXrot)) / 360.0f; w->moveToViewportPosition (mMoveWindowX - xrot * screen->width (), w->y (), false); } } } if (mMoving) { if (fabs (mXrot + mBaseXrot + mMoveTo) <= 180 / screen->vpSize ().width ()) mProgress = fabs (mXrot + mBaseXrot + mMoveTo) / 180 / screen->vpSize ().width (); else if (fabs (mXrot + mBaseXrot) <= 180 / screen->vpSize ().width ()) mProgress = fabs (mXrot + mBaseXrot) / 180 / screen->vpSize ().width (); else { mProgress += fabs (mXrot + mBaseXrot - oldXrot) / 180 / (screen->vpSize ().width ()); mProgress = MIN (mProgress, 1.0); } } else if (mProgress != 0.0f || mGrabbed) { float amount = msSinceLastPaint * 0.05f * optionGetSpeed (); int steps = amount / (0.5f * optionGetTimestep ()); if (!steps) steps = 1; float chunk = amount / (float) steps; while (steps--) { float dt; if (mGrabbed) dt = 1.0 - mProgress; else dt = 0.0f - mProgress; float adjust = dt * 0.15f; float tamount = fabs (dt) * 1.5f; if (tamount < 0.2f) tamount = 0.2f; else if (tamount > 2.0f) tamount = 2.0f; mProgressVelocity = (tamount * mProgressVelocity + adjust) / (tamount + 1.0f); mProgress += mProgressVelocity * chunk; if (fabs (dt) < 0.01f && fabs (mProgressVelocity) < 0.0001f) { if (mGrabbed) mProgress = 1.0f; else mProgress = 0.0f; break; } } } if (cubeScreen->invert () == 1 && !cubeScreen->unfolded ()) mZoomTranslate = optionGetZoom () * mProgress; else mZoomTranslate = 0.0; cScreen->preparePaint (msSinceLastPaint); }
void PrivateCubeScreen::preparePaint (int msSinceLastPaint) { int opt; float x, progress; unsigned short *topColor, *bottomColor; if (mGrabIndex) { int steps; float amount, chunk; amount = msSinceLastPaint * 0.2f * optionGetSpeed (); steps = amount / (0.5f * optionGetTimestep ()); if (!steps) steps = 1; chunk = amount / (float) steps; while (steps--) { mUnfold += mUnfoldVelocity * chunk; if (mUnfold > 1.0f) mUnfold = 1.0f; if (adjustVelocity ()) { if (mUnfold < 0.5f) { if (mGrabIndex) { screen->removeGrab (mGrabIndex, NULL); mGrabIndex = 0; } mUnfold = 0.0f; } break; } } } memset (mCleared, 0, sizeof (Bool) * screen->outputDevs ().size ()); memset (mCapsPainted, 0, sizeof (Bool) * screen->outputDevs ().size ()); /* Transparency handling */ if (mRotationState == CubeScreen::RotationManual || (mRotationState == CubeScreen::RotationChange && !optionGetTransparentManualOnly ())) { opt = mLastOpacityIndex = CubeOptions::ActiveOpacity; } else if (mRotationState == CubeScreen::RotationChange) { opt = mLastOpacityIndex = CubeOptions::InactiveOpacity; } else { opt = CubeOptions::InactiveOpacity; } mToOpacity = (mOptions[opt].value ().f () / 100.0f) * OPAQUE; cubeScreen->cubeGetRotation (x, x, progress); if (mDesktopOpacity != mToOpacity || (progress > 0.0 && progress < 1.0)) { mDesktopOpacity = (optionGetInactiveOpacity () - ((optionGetInactiveOpacity () - mOptions[mLastOpacityIndex].value ().f ()) * progress)) / 100.0f * OPAQUE; } topColor = optionGetTopColor (); bottomColor = optionGetBottomColor (); mPaintAllViewports = (mDesktopOpacity != OPAQUE || topColor[3] != OPAQUE || bottomColor[3] != OPAQUE); cScreen->preparePaint (msSinceLastPaint); }