Also, a bit of work that was removed, in ezoom. The reason for the removal of this code is still pending, even though it happened 4 years ago.
http://sprunge.us/GSaU commit 624ebd62db00d7b9d2273ab8b42d1d4a3269939b Author: Scott Moreau <ore...@gmail.com> Date: Tue Sep 14 20:20:46 2010 -0600 Fix uninitialized variable. diff --git a/src/ezoom.cpp b/src/ezoom.cpp index fe91e40..f22fbcf 100644 --- a/src/ezoom.cpp +++ b/src/ezoom.cpp @@ -826,6 +826,8 @@ EZoomScreen::convertToZoomedTarget (int out, *resultY = y; } + o = &screen->outputDevs ().at (out); + ZoomArea &za = zooms.at (out); x -= o->x1 (); commit 5cf8515d741880d49e9ce03798f551c2afd79814 Author: Scott Moreau <ore...@gmail.com> Date: Wed Aug 18 05:49:07 2010 -0600 Add theater mode. diff --git a/ezoom.xml.in b/ezoom.xml.in index 3eda311..2f6e5ed 100644 --- a/ezoom.xml.in +++ b/ezoom.xml.in @@ -50,6 +50,18 @@ <_long>Zoom in on a boxed area</_long> <default><Super>Button2</default> </option> + <option name="theater_mode" type="bool"> + <_short>Theater mode</_short> + <_long>Black out any area not selected by Zoom Box.</_long> + <default>false</default> + </option> + <option type="int" name="theater_fade_timeout"> + <_short>Theater fade timeout</_short> + <_long>Time in ms for fade in/out.</_long> + <default>2000</default> + <min>1</min> + <max>8000</max> + </option> </group> <group> <_short>Mouse Behaviour</_short> diff --git a/src/ezoom.cpp b/src/ezoom.cpp index 07a90d9..a35a4ee 100644 --- a/src/ezoom.cpp +++ b/src/ezoom.cpp @@ -136,6 +136,13 @@ isZoomed (int out) return false; } +void +EZoomScreen::terminateTheater () +{ + tFadingIn = false; + tFadingOut = true; +} + /* Returns the distance to the defined edge in zoomed pixels. */ int EZoomScreen::distanceToEdge (int out, EZoomScreen::ZoomEdge edge) @@ -304,6 +311,43 @@ EZoomScreen::adjustXYVelocity (int out, float chunk) (zooms.at (out).yVelocity * chunk) / cScreen->redrawTime (); } +void +EZoomScreen::updateTheater (int ms) +{ + + if (tFadingIn || tFadingOut) + tAlpha = (1.0 - ((tDuration - tTimer) / (float) tDuration)) * OPAQUE; + + if (tAlpha < 0) + tAlpha = 0; + + if (tTimer >= tDuration || tAlpha > OPAQUE) + { + tAlpha = OPAQUE; + tFadingIn = false; + tTimer = tDuration; + } + + if (tTimer <= 0) + { + theaterZoomActive = false; + tAlpha = 0; + tFadingOut = false; + tTimer = 0; + } + else + theaterZoomActive = true; + + if (tFadingIn) + tTimer += ms; + + if (tFadingOut) + tTimer -= ms; + + if (tAlpha == 0 || tTimer == 0) + tFadingOut = false; +} + /* Animate the movement (if any) in preparation of a paint screen. */ void EZoomScreen::preparePaint (int msSinceLastPaint) @@ -334,7 +378,7 @@ EZoomScreen::preparePaint (int msSinceLastPaint) zooms.at (out).xVelocity = zooms.at (out).yVelocity = 0.0f; grabbed &= ~(1 << zooms.at (out).output); - if (!grabbed) + if (!grabbed && !tFadingIn && !tFadingOut) { cScreen->damageScreen (); toggleFunctions (false); @@ -346,6 +390,9 @@ EZoomScreen::preparePaint (int msSinceLastPaint) syncCenterToMouse (); } + if (optionGetTheaterMode ()) + updateTheater (msSinceLastPaint); + cScreen->preparePaint (msSinceLastPaint); } @@ -367,9 +414,12 @@ EZoomScreen::donePaint () } else if (grabIndex) cScreen->damageScreen (); - else + else if (!tFadingIn && !tFadingOut) toggleFunctions (false); + if (tFadingIn || tFadingOut) + cScreen->damageScreen (); + cScreen->donePaint (); } /* Draws a box from the screen coordinates inx1,iny1 to inx2,iny2 */ @@ -409,6 +459,44 @@ EZoomScreen::drawBox (const GLMatrix &transform, glEnableClientState (GL_TEXTURE_COORD_ARRAY); glPopMatrix (); } + +void +EZoomScreen::drawTheater (const GLScreenPaintAttrib &sAttrib, + const GLMatrix &transform, + CompOutput *output) +{ + if (!theaterZoomActive || !optionGetTheaterMode ()) + return; + + /* Creates a list of rects to draw storing them in a region + * We want to draw everywhere except for selectedZoomBox */ + CompRegion outputReg (*output); + CompRegion visibleReg (selectedZoomBox); + CompRegion blackReg = outputReg - visibleReg; + + GLMatrix sTransform (transform); + + glPushMatrix (); + + sTransform.toScreenSpace (output, -DEFAULT_Z_CAMERA); + + glLoadMatrixf (sTransform.getMatrix ()); + + glDisableClientState (GL_TEXTURE_COORD_ARRAY); + glEnable (GL_BLEND); + + /* fill rectangles with black */ + glColor4us (0x0000, 0x0000, 0x0000, tAlpha); + foreach (const CompRect &r, blackReg.rects ()) + glRecti (r.x1 (), r.y2 (), r.x2 (), r.y1 ()); + + /* clean up */ + glColor4usv (defaultColor); + glDisable (GL_BLEND); + glEnableClientState (GL_TEXTURE_COORD_ARRAY); + glPopMatrix (); +} + /* Apply the zoom if we are grabbed. * Make sure to use the correct filter. */ @@ -422,7 +510,7 @@ EZoomScreen::glPaintOutput (const GLScreenPaintAttrib &attrib, bool status; int out = output->id (); - if (isActive (out)) + if ((isActive (out) || theaterZoomActive) && out >= 0) { GLScreenPaintAttrib sa = attrib; GLMatrix zTransform = transform; @@ -443,12 +531,18 @@ EZoomScreen::glPaintOutput (const GLScreenPaintAttrib &attrib, drawCursor (output, transform); + drawTheater (attrib, zTransform, output); + + /* If all outputs are inactive, we automatically assume fade out */ + if (zooms.empty ()) + terminateTheater (); } else { status = gScreen->glPaintOutput (attrib, transform, region, output, mask); } + if (grabIndex) drawBox (transform, output, box); @@ -1360,6 +1454,14 @@ EZoomScreen::zoomBoxDeactivate (CompAction *action, width = MAX (box.x1 (), box.x2 ()) - x; height = MAX (box.y1 (), box.y2 ()) - y; + if (optionGetTheaterMode ()) + { + selectedZoomBox.setGeometry (box.x (), box.y (), + box.width (), box.height ()); + tFadingIn = theaterZoomActive = true; + tFadingOut = false; + } + CompWindow::Geometry outGeometry (x, y, width, height, 0); out = screen->outputDeviceForGeometry (outGeometry); @@ -1596,6 +1698,8 @@ EZoomScreen::zoomOut (CompAction *action, zooms.at (out).newZoom * optionGetZoomFactor ()); + terminateTheater (); + toggleFunctions (true); return true; @@ -1742,6 +1846,17 @@ EZoomScreen::CursorTexture::CursorTexture () : } void +EZoomScreen::optionChanged (CompOption *opt, + Options num) +{ + tDuration = optionGetTheaterFadeTimeout (); + terminateTheater (); + + if (!optionGetTheaterMode ()) + tAlpha = tTimer = 0; +} + +void EZoomScreen::postLoad () { if (!grabbed) @@ -1769,6 +1884,13 @@ EZoomScreen::EZoomScreen (CompScreen *screen) : PluginStateWriter <EZoomScreen> (this, screen->root ()), cScreen (CompositeScreen::get (screen)), gScreen (GLScreen::get (screen)), + selectedZoomBox (emptyRegion.boundingRect ()), + theaterZoomActive (false), + tFadingIn (false), + tFadingOut (false), + tAlpha (0), + tTimer (0), + tDuration (optionGetTheaterFadeTimeout ()), grabbed (0), grabIndex (0), lastChange (0), @@ -1857,6 +1979,10 @@ EZoomScreen::EZoomScreen (CompScreen *screen) : optionSetEnsureVisibilityInitiate (boost::bind ( &EZoomScreen::ensureVisibilityAction, this, _1, _2, _3)); + optionSetTheaterFadeTimeoutNotify (boost::bind (&EZoomScreen::optionChanged, + this, _1, _2)); + optionSetTheaterModeNotify (boost::bind (&EZoomScreen::optionChanged, + this, _1, _2)); } diff --git a/src/ezoom.h b/src/ezoom.h index c94f920..d5997c5 100644 --- a/src/ezoom.h +++ b/src/ezoom.h @@ -192,6 +192,27 @@ class EZoomScreen : public: + CompRect selectedZoomBox; + bool theaterZoomActive, tFadingIn, tFadingOut; + int tAlpha, tTimer, tDuration; + + void + drawTheater (const GLScreenPaintAttrib &sAttrib, + const GLMatrix &transform, + CompOutput *output); + + void + updateTheater (int ms); + + void + terminateTheater (); + + void + optionChanged (CompOption *opt, + Options num); + + public: + template <class Archive> void serialize (Archive &ar, const unsigned int version) { commit 187b1a6ebec40beb3e88a6fa980a20bb8adb665e Author: Scott Moreau <ore...@gmail.com> Date: Sat Jul 3 18:00:52 2010 -0600 Use better conditional to avoid constant polling and damage after loading the plugin. diff --git a/src/ezoom.cpp b/src/ezoom.cpp index 82cd347..aaf0fe2 100644 --- a/src/ezoom.cpp +++ b/src/ezoom.cpp @@ -1789,7 +1789,7 @@ EZoomScreen::CursorTexture::CursorTexture () : void EZoomScreen::postLoad () { - if (zooms.empty ()) + if (!grabbed) return; toggleFunctions (true); diff --git a/src/ezoom.h b/src/ezoom.h index 7fc05cf..c94f920 100644 --- a/src/ezoom.h +++ b/src/ezoom.h @@ -197,6 +197,7 @@ class EZoomScreen : { ar & zooms; ar & lastChange; + ar & grabbed; } std::vector <ZoomArea> zooms; // list of zooms (different zooms for - Scott
_______________________________________________ compiz mailing list compiz@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/compiz