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
1=== modified file 'plugins/grid/grid.xml.in'
2--- plugins/grid/grid.xml.in 2012-10-15 10:31:51 +0000
3+++ plugins/grid/grid.xml.in 2013-01-18 18:12:20 +0000
4@@ -539,6 +539,17 @@
5 <_long>Draw Window Resize Indicator</_long>
6 <default>true</default>
7 </option>
8+ <option name="draw_stretched_window" type="bool">
9+ <_short>Draw Stretched Window</_short>
10+ <_long>Draw stretched window animation</_long>
11+ <default>true</default>
12+ </option>
13+ <option name="animation_duration" type="int">
14+ <_short>Animation Duration</_short>
15+ <_long>Grid animation duration (in ms)</_long>
16+ <default>350</default>
17+ <min>0</min>
18+ </option>
19 <option name="outline_color" type="color">
20 <_short>Outline Color</_short>
21 <_long>Color of the resize indicator outline</_long>
22
23=== modified file 'plugins/grid/src/grid.cpp'
24--- plugins/grid/src/grid.cpp 2013-01-03 15:43:56 +0000
25+++ plugins/grid/src/grid.cpp 2013-01-18 18:12:20 +0000
26@@ -23,6 +23,7 @@
27 */
28
29 #include <boost/bind.hpp>
30+#include <cmath>
31 #include "grid.h"
32 #include "grabhandler.h"
33
34@@ -31,6 +32,8 @@
35
36 static std::map <unsigned int, GridProps> gridProps;
37
38+static int const CURVE_ANIMATION = 35;
39+
40 void
41 GridScreen::handleCompizEvent(const char* plugin,
42 const char* event,
43@@ -453,6 +456,8 @@
44 for (iter = animations.begin (); iter != animations.end () && animating; ++iter)
45 {
46 Animation& anim = *iter;
47+
48+ float curve = powf (CURVE_ANIMATION, -anim.progress);
49 float alpha = ((float) optionGetFillColorAlpha () / 65535.0f) * anim.opacity;
50 color = optionGetFillColor ();
51
52@@ -461,6 +466,9 @@
53 colorData[2] = alpha * color[2];
54 colorData[3] = alpha * 65535.0f;
55
56+ if (optionGetDrawStretchedWindow ())
57+ colorData[3] *= (1.0 - curve);
58+
59 vertexData[0] = anim.currentRect.x1 ();
60 vertexData[1] = anim.currentRect.y1 ();
61 vertexData[2] = 0.0f;
62@@ -496,6 +504,9 @@
63 colorData[2] = alpha * color[2];
64 colorData[3] = alpha * 65535.0f;
65
66+ if (optionGetDrawStretchedWindow ())
67+ colorData[3] *= (1.0 - curve);
68+
69 vertexData[0] = anim.currentRect.x1 ();
70 vertexData[1] = anim.currentRect.y1 ();
71 vertexData[3] = anim.currentRect.x1 ();
72@@ -782,8 +793,10 @@
73 int current = animations.size () - 1;
74 animations.at (current).fromRect = cw->serverBorderRect ();
75 animations.at (current).currentRect = cw->serverBorderRect ();
76+ animations.at (current).duration = optionGetAnimationDuration ();
77 animations.at (current).timer = animations.at (current).duration;
78 animations.at (current).targetRect = desiredSlot;
79+ animations.at (current).window = cw->id();
80
81 if (lastEdge == NoEdge || !animating)
82 {
83@@ -1023,6 +1036,14 @@
84 anim.progress = (anim.duration - anim.timer) / anim.duration;
85 }
86
87+ if (optionGetDrawStretchedWindow ())
88+ {
89+ CompWindow *cw = screen->findWindow (screen->activeWindow ());
90+ GRID_WINDOW (cw);
91+
92+ gw->gWindow->glPaintSetEnabled (gw, true);
93+ }
94+
95 cScreen->preparePaint (msSinceLastPaint);
96 }
97
98@@ -1050,6 +1071,14 @@
99 animating = false;
100 }
101
102+ if (optionGetDrawStretchedWindow ())
103+ {
104+ CompWindow *cw = screen->findWindow (screen->activeWindow ());
105+ GRID_WINDOW (cw);
106+
107+ gw->gWindow->glPaintSetEnabled (gw, false);
108+ }
109+
110 cScreen->damageScreen ();
111
112 cScreen->donePaint ();
113@@ -1063,9 +1092,10 @@
114 currentRect = CompRect (0, 0, 0, 0);
115 opacity = 0.0f;
116 timer = 0.0f;
117- duration = 250;
118+ duration = 0;
119 complete = false;
120 fadingOut = false;
121+ window = 0;
122 }
123
124
125@@ -1131,6 +1161,7 @@
126 GridWindow::GridWindow (CompWindow *window) :
127 PluginClassHandler <GridWindow, CompWindow> (window),
128 window (window),
129+ gWindow (GLWindow::get(window)),
130 gScreen (GridScreen::get (screen)),
131 isGridResized (false),
132 isGridMaximized (false),
133@@ -1138,9 +1169,11 @@
134 pointerBufDx (0),
135 pointerBufDy (0),
136 resizeCount (0),
137- lastTarget (GridUnknown)
138+ lastTarget (GridUnknown),
139+ sizeHintsFlags (0)
140 {
141 WindowInterface::setHandler (window);
142+ GLWindowInterface::setHandler (gWindow, false);
143 }
144
145 GridWindow::~GridWindow ()
146@@ -1153,6 +1186,57 @@
147 gScreen->o[0].value ().set (0);
148 }
149
150+bool
151+GridWindow::glPaint (const GLWindowPaintAttrib& attrib, const GLMatrix& matrix,
152+ const CompRegion& region, const unsigned int mask)
153+{
154+ bool status = gWindow->glPaint (attrib, matrix, region, mask);
155+
156+ std::vector<Animation>::iterator iter;
157+
158+ for (iter = gScreen->animations.begin ();
159+ iter != gScreen->animations.end () && gScreen->animating; ++iter)
160+ {
161+ Animation& anim = *iter;
162+
163+ if (anim.timer > 0.0f && anim.window == window->id())
164+ {
165+ GLWindowPaintAttrib wAttrib(attrib);
166+ GLMatrix wTransform (matrix);
167+ unsigned int wMask(mask);
168+
169+ float curve = powf (CURVE_ANIMATION, -anim.progress);
170+ wAttrib.opacity *= curve;
171+
172+ wMask |= PAINT_WINDOW_TRANSFORMED_MASK;
173+ wMask |= PAINT_WINDOW_TRANSLUCENT_MASK;
174+ wMask |= PAINT_WINDOW_BLEND_MASK;
175+
176+ float scaleX = (anim.currentRect.x2 () - anim.currentRect.x1 ()) /
177+ (float) window->borderRect ().width ();
178+
179+ float scaleY = (anim.currentRect.y2 () - anim.currentRect.y1 ()) /
180+ (float) window->borderRect ().height ();
181+
182+ float translateX = (anim.currentRect.x1 () - window->x ()) +
183+ window->border ().left * scaleX;
184+
185+ float translateY = (anim.currentRect.y1 () - window->y ()) +
186+ window->border ().top * scaleY;
187+
188+ wTransform.translate (window->x (), window->y (), 0.0f);
189+ wTransform.scale (scaleX, scaleY, 1.0f);
190+ wTransform.translate (translateX / scaleX - window->x (),
191+ translateY / scaleY - window->y (), 0.0f);
192+
193+
194+ gWindow->glPaint (wAttrib, wTransform, region, wMask);
195+ }
196+ }
197+
198+ return status;
199+}
200+
201 /* Initial plugin init function called. Checks to see if we are ABI
202 * compatible with core, otherwise unload */
203
204
205=== modified file 'plugins/grid/src/grid.h'
206--- plugins/grid/src/grid.h 2012-11-05 00:54:07 +0000
207+++ plugins/grid/src/grid.h 2013-01-18 18:12:20 +0000
208@@ -99,6 +99,7 @@
209 CompRect currentRect;
210 GLfloat opacity;
211 GLfloat timer;
212+ Window window;
213 int duration;
214 bool complete;
215 bool fadingOut;
216@@ -169,6 +170,7 @@
217
218 class GridWindow :
219 public WindowInterface,
220+ public GLWindowInterface,
221 public PluginClassHandler <GridWindow, CompWindow>
222 {
223 public:
224@@ -176,6 +178,7 @@
225 GridWindow (CompWindow *);
226 ~GridWindow ();
227 CompWindow *window;
228+ GLWindow *gWindow;
229 GridScreen *gScreen;
230
231 bool isGridResized;
232@@ -189,6 +192,9 @@
233 GridType lastTarget;
234 unsigned int sizeHintsFlags;
235
236+ bool glPaint (const GLWindowPaintAttrib&, const GLMatrix&,
237+ const CompRegion&, unsigned int);
238+
239 void grabNotify (int, int, unsigned int, unsigned int);
240
241 void ungrabNotify ();

Subscribers

People subscribed via source and target branches