Merge lp:~brandontschaefer/compiz/window-max-semi-animation into lp:compiz/0.9.9

Proposed by Brandon Schaefer
Status: Merged
Approved by: Daniel van Vugt
Approved revision: 3580
Merged at revision: 3568
Proposed branch: lp:~brandontschaefer/compiz/window-max-semi-animation
Merge into: lp:compiz/0.9.9
Diff against target: 241 lines (+103/-2)
3 files modified
plugins/grid/grid.xml.in (+11/-0)
plugins/grid/src/grid.cpp (+86/-2)
plugins/grid/src/grid.h (+6/-0)
To merge this branch: bzr merge lp:~brandontschaefer/compiz/window-max-semi-animation
Reviewer Review Type Date Requested Status
Daniel van Vugt Approve
PS Jenkins bot (community) continuous-integration Approve
Brandon Schaefer (community) Approve
Sam Spilsbury Abstain
MC Return Approve
Review via email: mp+143163@code.launchpad.net

Commit message

Adds an animation to the grid plugin. The animation takes the current window,
renders it to the growing grid box and slowly fades out into the default
orange glow box.

Also adds 2 options ccsm for the grid, one to turn this animation off, and
another to change the grid animation duration.

This also changes the default grid duration from 250 ms, to 350ms.

(LP: #689792)

To post a comment you must log in.
Revision history for this message
MC Return (mc-return) wrote :

LGTM. :)
Compiles, works and is a nice addition.
+1 for making it configurable.
Another +1 for adding an option to adjust the length of the preview.

One note though:
Maybe
"Draw window resize preview animation."
would be better than
"Draw window preview where the window will be resized"

and
"Resize preview animation duration (in ms)."
better than
"Draw Resize Duration in Milliseconds"

I noticed other tooltips could also be formatted nicer,
so this are only cosmetic suggestions of course...

review: Approve
3566. By Brandon Schaefer

* Change the tooltip strings

Revision history for this message
Sam Spilsbury (smspillaz) wrote :

The code is fine, asides from some whitespace changes that don't need to be there:

39 -
40 +
41 switch (gw->resizeCount)
42 {
43 case 1:
44 @@ -384,11 +385,11 @@
45 gw->isGridMaximized = false;
46 }
47
48 - int dw = (lastBorder.left + lastBorder.right) -
49 + int dw = (lastBorder.left + lastBorder.right) -
50 (gw->window->border ().left +
51 gw->window->border ().right);
52 -
53 - int dh = (lastBorder.top + lastBorder.bottom) -
54 +
55 + int dh = (lastBorder.top + lastBorder.bottom) -
56 (gw->window->border ().top +
57 gw->window->border ().bottom);

This also never returns NULL:

71 + GLWindow *glWindow = GLWindow::get(cw);
72 +
73 + if (!glWindow)
74 + return;

And better is to use borderRect () here:

95 + int width = cw->width() + cw->border().left + cw->border().right;
96 + int height = cw->height() + cw->border().top + cw->border().bottom;

Also a space between the bracket and function needs to be added here (and above):

animations.at (current).duration = optionGetDrawDuration();

The functionality also works correctly.

However, I note my general opposition to implementing unity-like features inside of compiz. Compiz is an upstream project and its functionality needs to be kept separate. This feature could be implemented fine within unity, and satisfies the requisite that we don't depend on any particular window management paradigm unique to compiz.

As such, my vote is "abstain".

review: Abstain
3567. By Brandon Schaefer

* Fixes reviews comment

3568. By Brandon Schaefer

* Missed space between ()

Revision history for this message
Daniel van Vugt (vanvugt) wrote :

I think this is in the right place. It's a feature that users of upstream compiz might like. And it makes the most sense to live in the grid plugin. Proper review coming... another day probably. Sorry.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Looks really nice, but...

1. It should be off be default... Maybe? We don't usually like to change default behaviour. And enable it for Ubuntu in debian/patches/ubuntu-config.patch
Maybe...

2. #include "math.h" should be #include <cmath>

3. The option names are not very descriptive. "Window Preview" is too vague. I don't think it needs more words but better words. Something mentioning "stretch" or "expand".

4. The preview should be painted from a custom version of GLWindow::glPaint(), never glPaintOutput.

5. wAttrib needs to be initialized to the attrib from glPaint. So it looks right with windows that are starting translucent etc. Same for the mask and transform parameters. Always initialize from the parameters of glPaint.

6. I don't think it makes sense to limit the duration between 250 and 1000ms. There should be no limit other than zero, unless you have a good computational reason.

7. This is redundant. Conversion to float will be automatic and does not need casting:
float scaleX = (float)...

8. Maybe the opacity equation should be configurable. Maybe not...?
powf(25,...

review: Needs Fixing
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

9. Please wrap code at column 78 if possible.

Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Hmm, maybe we do have to call from GridScreen::glPaintOutput. That's a problem. Because if a window is transformed, translucent, darkened etc, you need to get all that info from glPaint (or glDraw).

Revision history for this message
Sam Spilsbury (smspillaz) wrote :

On Wed, Jan 16, 2013 at 9:42 AM, Daniel van Vugt
<email address hidden> wrote:
> Hmm, maybe we do have to call from GridScreen::glPaintOutput. That's a problem. Because if a window is transformed, translucent, darkened etc, you need to get all that info from glPaint (or glDraw).

You can use gWindow->lastPaintAttrib () for that.

> --
> https://code.launchpad.net/~brandontschaefer/compiz/window-max-semi-animation/+merge/143163
> You are reviewing the proposed merge of lp:~brandontschaefer/compiz/window-max-semi-animation into lp:compiz.

--
Sam Spilsbury

Revision history for this message
Brandon Schaefer (brandontschaefer) wrote :

1, 2, 3, 6, 7, 8

All those make sense to me, and Ill fix those now.

4.

Im not sure how/what you mean by making a custom version of GLWindow::glPaint() unless you mean I should make a subclass of a GLWindow ... but I need to look if glPaint is virtual function... from there im not sure where it would fit into grid.cpp, as glPaintRectangle is being called in glPaintOutput (which is why I put it there)

5.

Im assuming that is from the params of glPaint/Draw, so that should be easy if we figure out 4.

9.

Do you mean wrap any code that is longer then 78 chars?

Revision history for this message
Brandon Schaefer (brandontschaefer) wrote :

Cant I also get the paint attributes directly from the glWindow?

opengl.h GLWindowPaintAttrib & paintAttrib ();

or

        GLWindowPaintAttrib & lastPaintAttrib ();

Though im not srue where I would get the translate data from.

Revision history for this message
Sam Spilsbury (smspillaz) wrote :

On Wed, Jan 16, 2013 at 10:06 AM, Brandon Schaefer
<email address hidden> wrote:
> Cant I also get the paint attributes directly from the glWindow?
>
> opengl.h GLWindowPaintAttrib & paintAttrib ();
>
> or
>
> GLWindowPaintAttrib & lastPaintAttrib ();
>
>
> Though im not srue where I would get the translate data from.

You won't need the translation or scale data. Calling glPaint or
glDraw effectively just draws the the window vertex mesh with the
window texture while providing a set of opacity/brightness/saturation
parameters and affine transformation matrix to the fragment and vertex
shader respectively.

> --
> https://code.launchpad.net/~brandontschaefer/compiz/window-max-semi-animation/+merge/143163
> You are reviewing the proposed merge of lp:~brandontschaefer/compiz/window-max-semi-animation into lp:compiz.

--
Sam Spilsbury

Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Yeah you need to inherit from GLWindow, implement glPaint and call w->gWindow->glPaintSetEnabled(w, true)
That's what I was suggesting right from the beginning.

It wasn't important for grid before because the old grid rectangle reused none of the attributes of the window in question. However now you need to. Just try loading obs, changing the opacity/brightness/saturation of a window and try it. The preview will look wrong. You need to keep the window attributes (in the least) from glPaint().

Yeah please wrap all code around column 78 because it's not only common industry practice to use 80 column windows, but also improves readability. Think how many paper books you've seen that have lines much longer than 80 columns. Or a newspaper. Keeping that limit aids readability.

Revision history for this message
Daniel van Vugt (vanvugt) wrote :

And no you can't use lastPaintAttrib because that's the attribute from before plugins started being called back. You have to use the parameter version of attrib, mask and transform to ensure changes from other plugins still get applied.

Revision history for this message
Sam Spilsbury (smspillaz) wrote :

On Wed, Jan 16, 2013 at 10:24 AM, Daniel van Vugt
<email address hidden> wrote:
> And no you can't use lastPaintAttrib because that's the attribute from before plugins started being called back. You have to use the parameter version of attrib, mask and transform to ensure changes from other plugins still get applied.

*shrug* it should be good enough. It will lag one frame behind, sure.

Another alternative is to use paintAttrib () after the call to
gScreen->glPaintOutput () in GridScreen::glPaintOutput. paintAttrib ()
will be up-to-date by that point, as glPaintOutput calls into
paintOutputRegion, which then draws all of the windows.

> --
> https://code.launchpad.net/~brandontschaefer/compiz/window-max-semi-animation/+merge/143163
> You are reviewing the proposed merge of lp:~brandontschaefer/compiz/window-max-semi-animation into lp:compiz.

--
Sam Spilsbury

3569. By Brandon Schaefer

* Fixes 1, 2, 3, 6, 9 from Daniels review
* Number 7 needs to be kept this way because we need to do float divison, not int.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
3570. By Brandon Schaefer

* Move the glPaintStreachedWindow to GridWindow, and made a custom glPaint instead

3571. By Brandon Schaefer

* Opps, missed 2 extra spaces

Revision history for this message
Brandon Schaefer (brandontschaefer) wrote :

Alright, everything is fixed expect number:

8. Maybe the opacity equation should be configurable. Maybe not...?
powf(25,...

Soo here... hmm should we consider a few different options or make it completely customizable?

So for options, we could have just Accelerating (x^4), Decelerating (which is what I have now, 25^-x, it could be better...) ... Linear (op * (1.0 - x)) etc. ?

Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Yeah don't worry about customization of the curve right now. It's a common issue that all plugins employing some kind of sigmoid curve do not make it configurable.

Revision history for this message
Daniel van Vugt (vanvugt) wrote :

From within the GridWindow class, you should change:
    CompWindow *cw = screen->findWindow (screen->activeWindow ());
to:
    CompWindow *cw = this->window;

review: Needs Fixing
3572. By Brandon Schaefer

* Remove grabbing the active window the comp window because the grid window already has one

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
3573. By Brandon Schaefer

* Change to drawing the stretched window ontop of the window.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Also, you should scale the glow/outline opacity by the inverse of the stretch opacity (1.0f - curve). So it's always balanced and adds up to 1.0. Visually, this means the glow does not overpower the start of the stretch animation, so it's more visible. I just prototyped this and it looks better. It's actually what I was suggesting from the beginning.

review: Needs Fixing
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Also if you cancel the maximize, the glow keeps growing but the stretch suddenly vanishes. They should behave the same.

review: Needs Fixing
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Back to my first comment about never changing the default appearance. That's just a guideline. In cases like this where we can all agree the change makes things more beautiful then I think just enable it by default.

3574. By Brandon Schaefer

* Apply the inverse of the curve function to the glow box
* Remove the !fadeOut so the stretched window is still drawn with the glow box

3575. By Brandon Schaefer

* Enable animation by default

Revision history for this message
Brandon Schaefer (brandontschaefer) wrote :

Added the scaling to the glow box, fixed the sudden vanishing of the window, and re-enabled the animation by default :)

3576. By Brandon Schaefer

* Remove magic numbers, and change the curve number from 25 to 35
  as it creates a smother fade.

Revision history for this message
Brandon Schaefer (brandontschaefer) wrote :

I also changed the 25 to 35, as its a smother fade when the animation is done.

Revision history for this message
Brandon Schaefer (brandontschaefer) wrote :

Also note this change:

109 - duration = 250;
110 + duration = 0;

Setting that to 0, because we are setting this when the animation is made.

Also note I've changed the default time from 250 -> 350. If this should be revert let me know! (It allows more time to see the animation :)

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

FAILED: Continuous integration, rev:3573
http://jenkins.qa.ubuntu.com/job/compiz-ci/369/
Executed test runs:

Click here to trigger a rebuild:
http://jenkins.qa.ubuntu.com/job/compiz-ci/369//rebuild/?

review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Hmm... this is wrong, but not your fault :)
   colorData[0..2] = alpha * color[0..2];
It should be:
   colorData[0..2] = color[0..2];
Because alpha should only apply to alpha ([3]).

Just worth remembering. Not to be fixed here.

Revision history for this message
Brandon Schaefer (brandontschaefer) wrote :

I can make another branch after this one lands to fix this issue.

Revision history for this message
Daniel van Vugt (vanvugt) wrote :

That's weird. With slow animations enabled I can see two different textures being stretched. Near the end of the animation a second texture appears briefly.

review: Needs Fixing
Revision history for this message
Brandon Schaefer (brandontschaefer) wrote :

Hmm im not seeing this. The only thing I see that should be fixed is when it is fading out and the stretched window doesn't smoothly fade away....other then that I don't see a second texture appear anymore (after rev 3574 of this branch)

Revision history for this message
Daniel van Vugt (vanvugt) wrote :

All seems OK now. I will review again tomorrow.

If anything just needs "static" on CURVE_ANIMATION and indentation fixing in grid.h.

review: Needs Fixing
3577. By Brandon Schaefer

* (1.0 - curve) isn't doing anything....the glow box already starts off very
  slow.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Sam Spilsbury (smspillaz) wrote :

On Jan 17, 2013 9:12 AM, "Daniel van Vugt" <email address hidden>
wrote:
>
> Hmm... this is wrong, but not your fault :)
> colorData[0..2] = alpha * color[0..2];
> It should be:
> colorData[0..2] = color[0..2];
> Because alpha should only apply to alpha ([3]).

Nope, the alpha must be premultiplied.

>
> Just worth remembering. Not to be fixed here.
> --
>
https://code.launchpad.net/~brandontschaefer/compiz/window-max-semi-animation/+merge/143163
> You are reviewing the proposed merge of
lp:~brandontschaefer/compiz/window-max-semi-animation into lp:compiz.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Actually, I now realize the function of multiplying RGB by alpha. That is to darken the colour. That's a very bad an inconsistent way to do it. RGB should have just been multiplied by 0.5 (or something), regardless of alpha.

3578. By Brandon Schaefer

* Re-add the (1.0 - curve) to the alpha

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Sam Spilsbury (smspillaz) wrote :

On Fri, Jan 18, 2013 at 3:05 AM, Daniel van Vugt
<email address hidden> wrote:
> Actually, I now realize the function of multiplying RGB by alpha. That is to darken the colour. That's a very bad an inconsistent way to do it. RGB should have just been multiplied by 0.5 (or something), regardless of alpha.

Default blending function, screen.cpp:840: glBlendFunc (GL_ONE,
GL_ONE_MINUS_SRC_ALPHA);

https://www.opengl.org/sdk/docs/man/xhtml/glBlendFunc.xml

-> GL_ONE: scale factors are 1, 1, 1, 1

Eg, not premultiplied for us.

Porter-duff blending operations: https://en.wikipedia.org/wiki/Alpha_compositing

-> "If an alpha channel is used in an image, it is common to also
multiply the color by the alpha value, to save on additional
multiplications during compositing. This is usually referred to as
premultiplied alpha."
-> "if this pixel uses premultiplied alpha, all of the RGB values (0,
1, 0) are multiplied by 0.5 and then the alpha is appended to the end
to yield (0, 0.5, 0, 0.5). In this case, the 0.5 value for the G
channel actually indicates 100% green intensity (with 50% opacity)."

Many other places in the source code also do alpha premultiplication,
because that's what opengl expects.

resize.cpp:

 fc[3] = fillColor[3];
 fc[0] = fillColor[0] * (unsigned long)fc[3] / 65535;
 fc[1] = fillColor[1] * (unsigned long)fc[3] / 65535;
 fc[2] = fillColor[2] * (unsigned long)fc[3] / 65535;

cube.cpp:1122

    colorData.push_back (color[0] * opacity / 0xffff);
    colorData.push_back (color[1] * opacity / 0xffff);
    colorData.push_back (color[2] * opacity / 0xffff);
    colorData.push_back (opacity);

resizeinfo, text, etc:

 colorData[0] = opacity * 65535;
 colorData[1] = opacity * 65535;
 colorData[2] = opacity * 65535;
 colorData[3] = opacity * 65535;

If you don't want to use premultiplied alpha, you ask opengl to
multiply the alpha value with the color value:

scaleaddon.cpp:

    glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

Do you really want to do a state switch though?

If you don't believe me then remove the pre-multiplication and enjoy
the eye-burning.

> --
> https://code.launchpad.net/~brandontschaefer/compiz/window-max-semi-animation/+merge/143163
> You are reviewing the proposed merge of lp:~brandontschaefer/compiz/window-max-semi-animation into lp:compiz.

--
Sam Spilsbury

Revision history for this message
Daniel van Vugt (vanvugt) wrote :

It's off topic so sorry I mentioned it. Clearly there are many ways to modify a colour. But the simplest way to darken is to multiple RGB by N where N < 1.0.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

OK, needs fixing:

Sometimes multiple textures are visible in the stretch. Seems the issue is the wrong window can have its glPaintSetEnabled sometimes. Brandon is working on moving glPaintSetEnabled to safer locations.

review: Needs Fixing
3579. By Brandon Schaefer

* Fix double texture drawing (filter the animations based on the window id).
* Moved from glPaint to glDraw
* Move glDrawSetEnabled(ture/false) to ::preparePaint and ::donePaint, so if it
  hits a donePaint, and never hits the prepartPaint it will stop drawing.

Revision history for this message
Brandon Schaefer (brandontschaefer) wrote :

Alright, fixed that issue by adding the window id to each animation so we can filter which window belongs to which animation.

review: Approve
Revision history for this message
Brandon Schaefer (brandontschaefer) wrote :

opps...didn't mean to approve...

Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Now seeing a new bug: The stretching animation is missing the title bar and decorations... !?

review: Needs Fixing
Revision history for this message
Brandon Schaefer (brandontschaefer) wrote :

That is strange...sorry, I keep having you go through this and you keep finding new things...

Revision history for this message
Brandon Schaefer (brandontschaefer) wrote :

Hmm when I switch back to glPaint everything works fine...

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Hmm, yeah go back to glPaint if it keeps decor happier.

3580. By Brandon Schaefer

* Switch back to glPaint, for the decor

Revision history for this message
Brandon Schaefer (brandontschaefer) wrote :

Decor is now happy.

Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Nice. Approved.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'plugins/grid/grid.xml.in'
--- plugins/grid/grid.xml.in 2012-10-15 10:31:51 +0000
+++ plugins/grid/grid.xml.in 2013-01-18 18:12:20 +0000
@@ -539,6 +539,17 @@
539 <_long>Draw Window Resize Indicator</_long>539 <_long>Draw Window Resize Indicator</_long>
540 <default>true</default>540 <default>true</default>
541 </option>541 </option>
542 <option name="draw_stretched_window" type="bool">
543 <_short>Draw Stretched Window</_short>
544 <_long>Draw stretched window animation</_long>
545 <default>true</default>
546 </option>
547 <option name="animation_duration" type="int">
548 <_short>Animation Duration</_short>
549 <_long>Grid animation duration (in ms)</_long>
550 <default>350</default>
551 <min>0</min>
552 </option>
542 <option name="outline_color" type="color">553 <option name="outline_color" type="color">
543 <_short>Outline Color</_short>554 <_short>Outline Color</_short>
544 <_long>Color of the resize indicator outline</_long>555 <_long>Color of the resize indicator outline</_long>
545556
=== modified file 'plugins/grid/src/grid.cpp'
--- plugins/grid/src/grid.cpp 2013-01-03 15:43:56 +0000
+++ plugins/grid/src/grid.cpp 2013-01-18 18:12:20 +0000
@@ -23,6 +23,7 @@
23 */23 */
2424
25#include <boost/bind.hpp>25#include <boost/bind.hpp>
26#include <cmath>
26#include "grid.h"27#include "grid.h"
27#include "grabhandler.h"28#include "grabhandler.h"
2829
@@ -31,6 +32,8 @@
3132
32static std::map <unsigned int, GridProps> gridProps;33static std::map <unsigned int, GridProps> gridProps;
3334
35static int const CURVE_ANIMATION = 35;
36
34void37void
35GridScreen::handleCompizEvent(const char* plugin,38GridScreen::handleCompizEvent(const char* plugin,
36 const char* event,39 const char* event,
@@ -453,6 +456,8 @@
453 for (iter = animations.begin (); iter != animations.end () && animating; ++iter)456 for (iter = animations.begin (); iter != animations.end () && animating; ++iter)
454 {457 {
455 Animation& anim = *iter;458 Animation& anim = *iter;
459
460 float curve = powf (CURVE_ANIMATION, -anim.progress);
456 float alpha = ((float) optionGetFillColorAlpha () / 65535.0f) * anim.opacity;461 float alpha = ((float) optionGetFillColorAlpha () / 65535.0f) * anim.opacity;
457 color = optionGetFillColor ();462 color = optionGetFillColor ();
458463
@@ -461,6 +466,9 @@
461 colorData[2] = alpha * color[2];466 colorData[2] = alpha * color[2];
462 colorData[3] = alpha * 65535.0f;467 colorData[3] = alpha * 65535.0f;
463468
469 if (optionGetDrawStretchedWindow ())
470 colorData[3] *= (1.0 - curve);
471
464 vertexData[0] = anim.currentRect.x1 ();472 vertexData[0] = anim.currentRect.x1 ();
465 vertexData[1] = anim.currentRect.y1 ();473 vertexData[1] = anim.currentRect.y1 ();
466 vertexData[2] = 0.0f;474 vertexData[2] = 0.0f;
@@ -496,6 +504,9 @@
496 colorData[2] = alpha * color[2];504 colorData[2] = alpha * color[2];
497 colorData[3] = alpha * 65535.0f;505 colorData[3] = alpha * 65535.0f;
498506
507 if (optionGetDrawStretchedWindow ())
508 colorData[3] *= (1.0 - curve);
509
499 vertexData[0] = anim.currentRect.x1 ();510 vertexData[0] = anim.currentRect.x1 ();
500 vertexData[1] = anim.currentRect.y1 ();511 vertexData[1] = anim.currentRect.y1 ();
501 vertexData[3] = anim.currentRect.x1 ();512 vertexData[3] = anim.currentRect.x1 ();
@@ -782,8 +793,10 @@
782 int current = animations.size () - 1;793 int current = animations.size () - 1;
783 animations.at (current).fromRect = cw->serverBorderRect ();794 animations.at (current).fromRect = cw->serverBorderRect ();
784 animations.at (current).currentRect = cw->serverBorderRect ();795 animations.at (current).currentRect = cw->serverBorderRect ();
796 animations.at (current).duration = optionGetAnimationDuration ();
785 animations.at (current).timer = animations.at (current).duration;797 animations.at (current).timer = animations.at (current).duration;
786 animations.at (current).targetRect = desiredSlot;798 animations.at (current).targetRect = desiredSlot;
799 animations.at (current).window = cw->id();
787800
788 if (lastEdge == NoEdge || !animating)801 if (lastEdge == NoEdge || !animating)
789 {802 {
@@ -1023,6 +1036,14 @@
1023 anim.progress = (anim.duration - anim.timer) / anim.duration;1036 anim.progress = (anim.duration - anim.timer) / anim.duration;
1024 }1037 }
10251038
1039 if (optionGetDrawStretchedWindow ())
1040 {
1041 CompWindow *cw = screen->findWindow (screen->activeWindow ());
1042 GRID_WINDOW (cw);
1043
1044 gw->gWindow->glPaintSetEnabled (gw, true);
1045 }
1046
1026 cScreen->preparePaint (msSinceLastPaint);1047 cScreen->preparePaint (msSinceLastPaint);
1027}1048}
10281049
@@ -1050,6 +1071,14 @@
1050 animating = false;1071 animating = false;
1051 }1072 }
10521073
1074 if (optionGetDrawStretchedWindow ())
1075 {
1076 CompWindow *cw = screen->findWindow (screen->activeWindow ());
1077 GRID_WINDOW (cw);
1078
1079 gw->gWindow->glPaintSetEnabled (gw, false);
1080 }
1081
1053 cScreen->damageScreen ();1082 cScreen->damageScreen ();
10541083
1055 cScreen->donePaint ();1084 cScreen->donePaint ();
@@ -1063,9 +1092,10 @@
1063 currentRect = CompRect (0, 0, 0, 0);1092 currentRect = CompRect (0, 0, 0, 0);
1064 opacity = 0.0f;1093 opacity = 0.0f;
1065 timer = 0.0f;1094 timer = 0.0f;
1066 duration = 250;1095 duration = 0;
1067 complete = false;1096 complete = false;
1068 fadingOut = false;1097 fadingOut = false;
1098 window = 0;
1069}1099}
10701100
10711101
@@ -1131,6 +1161,7 @@
1131GridWindow::GridWindow (CompWindow *window) :1161GridWindow::GridWindow (CompWindow *window) :
1132 PluginClassHandler <GridWindow, CompWindow> (window),1162 PluginClassHandler <GridWindow, CompWindow> (window),
1133 window (window),1163 window (window),
1164 gWindow (GLWindow::get(window)),
1134 gScreen (GridScreen::get (screen)),1165 gScreen (GridScreen::get (screen)),
1135 isGridResized (false),1166 isGridResized (false),
1136 isGridMaximized (false),1167 isGridMaximized (false),
@@ -1138,9 +1169,11 @@
1138 pointerBufDx (0),1169 pointerBufDx (0),
1139 pointerBufDy (0),1170 pointerBufDy (0),
1140 resizeCount (0), 1171 resizeCount (0),
1141 lastTarget (GridUnknown)1172 lastTarget (GridUnknown),
1173 sizeHintsFlags (0)
1142{1174{
1143 WindowInterface::setHandler (window);1175 WindowInterface::setHandler (window);
1176 GLWindowInterface::setHandler (gWindow, false);
1144}1177}
11451178
1146GridWindow::~GridWindow ()1179GridWindow::~GridWindow ()
@@ -1153,6 +1186,57 @@
1153 gScreen->o[0].value ().set (0);1186 gScreen->o[0].value ().set (0);
1154}1187}
11551188
1189bool
1190GridWindow::glPaint (const GLWindowPaintAttrib& attrib, const GLMatrix& matrix,
1191 const CompRegion& region, const unsigned int mask)
1192{
1193 bool status = gWindow->glPaint (attrib, matrix, region, mask);
1194
1195 std::vector<Animation>::iterator iter;
1196
1197 for (iter = gScreen->animations.begin ();
1198 iter != gScreen->animations.end () && gScreen->animating; ++iter)
1199 {
1200 Animation& anim = *iter;
1201
1202 if (anim.timer > 0.0f && anim.window == window->id())
1203 {
1204 GLWindowPaintAttrib wAttrib(attrib);
1205 GLMatrix wTransform (matrix);
1206 unsigned int wMask(mask);
1207
1208 float curve = powf (CURVE_ANIMATION, -anim.progress);
1209 wAttrib.opacity *= curve;
1210
1211 wMask |= PAINT_WINDOW_TRANSFORMED_MASK;
1212 wMask |= PAINT_WINDOW_TRANSLUCENT_MASK;
1213 wMask |= PAINT_WINDOW_BLEND_MASK;
1214
1215 float scaleX = (anim.currentRect.x2 () - anim.currentRect.x1 ()) /
1216 (float) window->borderRect ().width ();
1217
1218 float scaleY = (anim.currentRect.y2 () - anim.currentRect.y1 ()) /
1219 (float) window->borderRect ().height ();
1220
1221 float translateX = (anim.currentRect.x1 () - window->x ()) +
1222 window->border ().left * scaleX;
1223
1224 float translateY = (anim.currentRect.y1 () - window->y ()) +
1225 window->border ().top * scaleY;
1226
1227 wTransform.translate (window->x (), window->y (), 0.0f);
1228 wTransform.scale (scaleX, scaleY, 1.0f);
1229 wTransform.translate (translateX / scaleX - window->x (),
1230 translateY / scaleY - window->y (), 0.0f);
1231
1232
1233 gWindow->glPaint (wAttrib, wTransform, region, wMask);
1234 }
1235 }
1236
1237 return status;
1238}
1239
1156/* Initial plugin init function called. Checks to see if we are ABI1240/* Initial plugin init function called. Checks to see if we are ABI
1157 * compatible with core, otherwise unload */1241 * compatible with core, otherwise unload */
11581242
11591243
=== modified file 'plugins/grid/src/grid.h'
--- plugins/grid/src/grid.h 2012-11-05 00:54:07 +0000
+++ plugins/grid/src/grid.h 2013-01-18 18:12:20 +0000
@@ -99,6 +99,7 @@
99 CompRect currentRect;99 CompRect currentRect;
100 GLfloat opacity;100 GLfloat opacity;
101 GLfloat timer;101 GLfloat timer;
102 Window window;
102 int duration;103 int duration;
103 bool complete;104 bool complete;
104 bool fadingOut;105 bool fadingOut;
@@ -169,6 +170,7 @@
169170
170class GridWindow :171class GridWindow :
171 public WindowInterface,172 public WindowInterface,
173 public GLWindowInterface,
172 public PluginClassHandler <GridWindow, CompWindow>174 public PluginClassHandler <GridWindow, CompWindow>
173{175{
174 public:176 public:
@@ -176,6 +178,7 @@
176 GridWindow (CompWindow *);178 GridWindow (CompWindow *);
177 ~GridWindow ();179 ~GridWindow ();
178 CompWindow *window;180 CompWindow *window;
181 GLWindow *gWindow;
179 GridScreen *gScreen;182 GridScreen *gScreen;
180183
181 bool isGridResized;184 bool isGridResized;
@@ -189,6 +192,9 @@
189 GridType lastTarget;192 GridType lastTarget;
190 unsigned int sizeHintsFlags;193 unsigned int sizeHintsFlags;
191194
195 bool glPaint (const GLWindowPaintAttrib&, const GLMatrix&,
196 const CompRegion&, unsigned int);
197
192 void grabNotify (int, int, unsigned int, unsigned int);198 void grabNotify (int, int, unsigned int, unsigned int);
193199
194 void ungrabNotify ();200 void ungrabNotify ();

Subscribers

People subscribed via source and target branches