Merge lp:~mc-return/compiz/compiz.merge-expo-code-cleanup into lp:compiz/0.9.10
- compiz.merge-expo-code-cleanup
- Merge into 0.9.10
Status: | Merged |
---|---|
Approved by: | Sam Spilsbury |
Approved revision: | 3717 |
Merged at revision: | 3740 |
Proposed branch: | lp:~mc-return/compiz/compiz.merge-expo-code-cleanup |
Merge into: | lp:compiz/0.9.10 |
Diff against target: |
2153 lines (+653/-578) 7 files modified
plugins/expo/src/click_threshold/include/click-threshold.h (+4/-2) plugins/expo/src/click_threshold/src/click-threshold.cpp (+5/-3) plugins/expo/src/expo.cpp (+429/-410) plugins/expo/src/expo.h (+105/-70) plugins/expo/src/glow.cpp (+100/-86) plugins/expo/src/glow.h (+6/-3) plugins/expo/src/wall_offset/src/wall-offset.cpp (+4/-4) |
To merge this branch: | bzr merge lp:~mc-return/compiz/compiz.merge-expo-code-cleanup |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
PS Jenkins bot (community) | continuous-integration | Approve | |
Sam Spilsbury | Approve | ||
Sami Jaktholm (community) | Approve | ||
MC Return | Needs Resubmitting | ||
Review via email: mp+163721@code.launchpad.net |
Commit message
Expo, code cleanup:
Declaration of local variables outside of loops.
Use prefix instead of postfix increments.
Declaration and assignment of local variables in one line, if possible.
Reduced the scope of some variables.
Removed redundant brackets.
Used static_cast <> (type) instead of (type) cast.
Added and removed newlines if appropriate.
Fixed indentation.
Added TODOs.
Expo, speed improvements:
Do not calculate screen->vpSize ().width () and screen->vpSize ().height ()
multiple times, instead save them in the unsigned ints vpCountHorz and
vpCountVert and use those variables instead.
Speed up the curve calculations by using additional variables to save results
to not have to re-calculate those all the time. The new variables introduced
are degToRad, screenWidth, screenWidthSquared, curveDistSquare
pOne2MinusCurve
Also introduced const float halfGapX = gapX / 2.0 and used this variable in the
calculations of curveDistance and curveRadius.
Simplified calculations of this type:
(M_PI / 180.0f) * curveAngle / 2.0, which is equal to: (M_PI / 360.0f) * curveAngle
Do not call optionGetGroundSize (); twice, instead save the value in the float
groundSize and use that variable in the following calculations.
Removed the creation of the redundant bool hide, which is just used once in an
if-condition check. It does not help to have this bool.
Try to avoid redundant GL_BLEND state changes, they are expensive - only enable
GL_BLEND if it is disabled and just disable it, if it was disabled before, otherwise
do nothing.
Try to avoid redundant GL filter changes - just query the filter state if the mipmap
option in CCSM is enabled. Also just set back the filter to the previous state if
we actually changed it, otherwise do nothing.
-5.5f * 2 = -11.0f.
No need to calculate M_PI / 180.0f 720 times:
Calculate this value once instead and save it in the const float mpi, use mpi
in the following looped calculations.
Use const int scw in the same loop instead of calling screen->width () 360 times.
glow.cpp:
Massively increased calculation speed of the glow texture:
No need for any macros here -> removed them and replaced them with local variables.
Precalculate values, store them in local variables and use those in the following
calculations (new variables are the ints winRealX, winRealY, winRealWidth, winRealHeight,
halfWinRealWidth, halfWinRealHeight, xPlusHalfWidth, yPlusHalfHeight, xPlusGlowOff,
yPlusGlowOff, xMinusGlowOff, yMinusGlowOff and the float glowPart).
Used w->geometry ().widthIncBorders () and w->geometry ().heightIncBorders ()
to determine winRealWidth and winRealHeight.
Expo, fixes:
Do not force "One wall per output" on the user, if his displays use different
resolutions.
"One big wall" makes a lot of sense for many multi-screen configs, where not
all of the screens have exactly the same resolution, so if the user explicitely
chooses this mode, Compiz should respect the user's choice.
(LP: #1009592)
Description of the change
See a dual-screen screenshot (1920x1200 + 1280x1024) of Expo here: https:/
Note:
This also helps users hitting bug #1041822 (video: https:/
Also it resolves bug #1024373 - Expo Zoom Animation uses wrong path on second screen in multimonitor configurations (video:
https:/
So forcing the user to use "One wall per output" is a very bad idea and leads to additional troubles, which do not occur with "One big wall"...
Another reason why a large wall spanning over multiple screens is important is the size of the miniature viewports itself, which in a typical horizontal monitor configuration logically have a high x to y ratio: 3.2 : 1.2 in my case for example, so in a 4:1 viewport
configuration (needed for the cube for example) this means a ratio of 12.8 : 1.2 (!).
Of course this fits much better onto 3200x1200 than 1280x1024, which would be the small monitor... hard to identify the correct window, everything is that small...
Sam Spilsbury (smspillaz) wrote : | # |
848 + float sx = (float) screen->width () / output->width ();
849 + float sy = (float) screen->height () / output->height ();
The denominator should be casted and not the numerator.
948 - gScreen-
949 + {
950 + /* check the actual filtering */
951 + oldFilter = gScreen-
952 +
953 + /* just change the global filter if necessary */
954 + if (oldFilter != GL_LINEAR_
955 + {
956 + gScreen-
957 + filterChanged = true;
958 + }
959 + }
This change has no effect - setTextureFilter only changes the *next* texture filter any textures will be configured with the next time that they are bound to a texture unit, so checking if the filter is already GL_LINEAR_
1393 - zoomAnim = eScreen-
1394 - ExpoScreen:
1395 - hide = eScreen-
1396 - (window->wmType () & CompWindowTypeD
1397 -
1398 if (eScreen->expoCam > 0.0)
1399 mask |= PAINT_WINDOW_
1400
1401 + float opacity = 1.0;
1402 + bool zoomAnim = eScreen-
1412 - opacity = attrib.opacity *
1413 - (1 - sigmoidProgress (eScreen-
1414 + opacity = attrib.opacity * (1 - sigmoidProgress (eScreen-
1861 + int winRealWidth = w->width () + 2 * w->geometry ().border () + w->border ().left + w->border ().right;
1862 + int winRealHeight = w->height () + 2 * w->geometry ().border () + w->border ().top + w->border ().bottom;
1863 +
The preference for compiz is to where possible keep line lengths under 80 characters.
It is a somewhat artificially small limit, but it assists those who are working on the code in text-based editors.
1407 - if (hide)
1408 + if (eScreen-
1409 + (window->wmType () & CompWindowTypeD
Prefer to keep temporary booleans where they are there for the purpose of aiding readability. The compiler gets rid of them at the optimization phase.
1834 + /* TODO: Make glowSize configurable via CCSM */
1835 + int glowSize = 48;
There is no good reason to make this configurable, especially where the texture itself is hardcoded and scales poorly.
1861 + int winRealWidth = w->width () + 2 * w->geometry ().border ()
compiz:
The other changes seem fine so far. Keep in mind that that size of this review means that I might have missed things and that I might need to go through it again later.
MC Return (mc-return) wrote : | # |
Sam, first I want to say thanks for finding the time for reviewing this. +1
> 848 + float sx = (float) screen->width () / output->width ();
> 849 + float sy = (float) screen->height () / output->height ();
>
> The denominator should be casted and not the numerator.
>
AFAIR I kept what was there already, see:
825 - float sx = (float) screen->width () / output->width ();
826 - float sy = (float) screen->height () / output->height ();
...but I can change that -> no problem.
> 948 - gScreen-
> 949 + {
> 950 + /* check the actual filtering */
> 951 + oldFilter = gScreen-
> 952 +
> 953 + /* just change the global filter if necessary */
> 954 + if (oldFilter != GL_LINEAR_
> 955 + {
> 956 + gScreen-
> 957 + filterChanged = true;
> 958 + }
> 959 + }
>
> This change has no effect - setTextureFilter only changes the *next* texture
> filter any textures will be configured with the next time that they are bound
> to a texture unit, so checking if the filter is already
> GL_LINEAR_
> setTextureFilter doesn't make any.
>
Ah -> good to know, thanks for the info. I did not dive that deep into that
part of the code yet...
So setTextureFilter won't make any changes if the filter we want to set is
already set ?
> 1393 - zoomAnim = eScreen-
> 1394 - ExpoScreen:
> 1395 - hide = eScreen-
> 1396 - (window->wmType () & CompWindowTypeD
> 1397 -
> 1398 if (eScreen->expoCam > 0.0)
> 1399 mask |= PAINT_WINDOW_
> 1400
> 1401 + float opacity = 1.0;
> 1402 + bool zoomAnim = eScreen-
> ExpoScreen:
>
> 1412 - opacity = attrib.opacity *
> 1413 - (1 - sigmoidProgress (eScreen-
> 1414 + opacity = attrib.opacity * (1 - sigmoidProgress
> (eScreen-
>
> 1861 + int winRealWidth = w->width () + 2 * w->geometry
> ().border () + w->border ().left + w->border ().right;
> 1862 + int winRealHeight = w->height () + 2 * w->geometry
> ().border () + w->border ().top + w->border ().bottom;
> 1863 +
>
> The preference for compiz is to where possible keep line lengths under 80
> characters.
>
Yes, I know that of course ;)
Normally I use the rule to just extend over 80 characters, if it massively
improves readability.
Maybe I messed up here -> I'll investigate.
> It is a somewhat artificially small limit, but it assists those who are
> working on the code in text-based editors.
>
> 1407 - if (hide)
> 1408 + if (eScreen-
> 1409 + (window->wmType () & CompWindowTypeD
>
> Prefer to keep temporary booleans where they are there for the purpose of...
MC Return (mc-return) wrote : | # |
>
> "One big wall" is currently the default behavior which makes some sense so
> long as the screens have exactly the same resolution. Its *completely* broken
> for multimonitor configurations with different resolutions.
This is not true, just look at this screenshot, which is 3200x1200 downscaled.
It shows Expo in dual-screen mode with 1920x1200 and 1280x1024 screens:
https:/
> There's just no
> sane way to line the views up so that they look correctly when the wall is
> only rendered in one pass. This change should be reverted.
>
Well, here everything lines up fine, while otherwise since r3320 I am hitting
bug #1041822 (video: https:/
which makes Expo completely unusable in "One wall per output" mode.
> I even have misgivings about the way that it works on multimonitor
> configurations where you have the same resolution and a number of viewports
> that is not evenly divisible amongst the monitors. It results in confusing
> situations where viewports end up partially on one monitor and partially on
> another and does not make for a good user experience.
>
Well, this is no problem here at all, see the screenshot here again:
https:/
I am not promoting to remove the "one wall per output" mode, but letting
the user choose the prefered method. Here this is "One big wall".
> 328 + if (event-
> 329 + moveFocusViewport (-1, 0);
> 330 + else if (event-
> 331 + moveFocusViewport (1, 0);
>
> This is alignment-
> readability but it should be used judiciously and not inflexibly. This just
> makes the code unreadable. There is no reason why there should be that much
> whitespace between an if and brackets.
>
Ok, no problem to remove the few spaces...
> 358 + (unsigned int)optionGetDo
>
> There should be a space between the cast or better yet a static_cast <unsigned
> int> ()
>
Ok, I'll convert all the casts to static_casts.
> 368 + prevClickPoint = CompPoint(
> event->xbutton.y);
>
> Extra whitespace required.
>
Eagle-eye ;)
> 395 + /* TODO: What action to take if expo_key is not
> defined ? */
>
> An action is always bound to it. That's different from whether or not a
> keybinding is assigned. This todo is inaccurate.
>
I am not sure here -> but I'll re-investigate.
AFAIR removing the Expo Initiate key results in not being able to exit Expo...
> 449 + const int scw = screen->width ();
>
> That variable should be renamed to "screenWidth" - "scw" is ambiguous.
>
ok.
> 448 + const float mpi = M_PI / 180.0f;
>
> This should be renamed degreesToRadians
>
ok.
> 475 + scr...
MC Return (mc-return) wrote : | # |
Ok, I hope I got them all in r3716:
http://
MC Return (mc-return) wrote : | # |
>
> "One big wall" is currently the default behavior which makes some sense so
> long as the screens have exactly the same resolution.
We can argue about the best default of course. (have not even looked up what
it is set to in upstream/ubuntu)
> Its *completely* broken
> for multimonitor configurations with different resolutions. There's just no
> sane way to line the views up so that they look correctly when the wall is
> only rendered in one pass. This change should be reverted.
>
> I even have misgivings about the way that it works on multimonitor
> configurations where you have the same resolution and a number of viewports
> that is not evenly divisible amongst the monitors. It results in confusing
> situations where viewports end up partially on one monitor and partially on
> another and does not make for a good user experience.
>
Another response, especially regarding this change:
This change also helps users hitting bug #1041822 (video: https:/
Also it resolves bug #1024373 - Expo Zoom Animation uses wrong path on second screen in multimonitor configurations (video:
https:/
So forcing the user to use "One wall per output" is a very bad idea and leads to additional troubles, which do not occur with "One big wall"...
Another reason why a large wall spanning over multiple screens is important is the size of the miniature viewports itself, which in a typical horizontal monitor configuration logically have a high x to y ratio: 3.2 : 1.2 in my case for example, so in a 4:1 viewport
configuration (needed for the cube for example) this means a ratio of 12.8 : 1.2 (!).
Of course this fits much better onto 3200x1200 than 1280x1024, which would be the small monitor... hard to identify the correct window, everything is that small...
Muuuch better that way:
It shows Expo in dual-screen mode with 1920x1200 and 1280x1024 screens (3200x1200 4x downscaled):
https:/
Sam Spilsbury (smspillaz) wrote : | # |
> >
> > "One big wall" is currently the default behavior which makes some sense so
> > long as the screens have exactly the same resolution.
>
> We can argue about the best default of course. (have not even looked up what
> it is set to in upstream/ubuntu)
>
> > Its *completely* broken
> > for multimonitor configurations with different resolutions. There's just no
> > sane way to line the views up so that they look correctly when the wall is
> > only rendered in one pass. This change should be reverted.
> >
> > I even have misgivings about the way that it works on multimonitor
> > configurations where you have the same resolution and a number of viewports
> > that is not evenly divisible amongst the monitors. It results in confusing
> > situations where viewports end up partially on one monitor and partially on
> > another and does not make for a good user experience.
> >
> Another response, especially regarding this change:
>
> This change also helps users hitting bug #1041822 (video: https:/
> ad.net/
> ), because this bug won't occur in "One big wall" mode.
>
> Also it resolves bug #1024373 - Expo Zoom Animation uses wrong path on second
> screen in multimonitor configurations (video:
> https:/
> WrongPath.mp4 )
>
> So forcing the user to use "One wall per output" is a very bad idea and leads
> to additional troubles, which do not occur with "One big wall"...
>
> Another reason why a large wall spanning over multiple screens is important is
> the size of the miniature viewports itself, which in a typical horizontal
> monitor configuration logically have a high x to y ratio: 3.2 : 1.2 in my case
> for example, so in a 4:1 viewport
> configuration (needed for the cube for example) this means a ratio of 12.8 :
> 1.2 (!).
> Of course this fits much better onto 3200x1200 than 1280x1024, which would be
> the small monitor... hard to identify the correct window, everything is that
> small...
>
> Muuuch better that way:
>
> It shows Expo in dual-screen mode with 1920x1200 and 1280x1024 screens
> (3200x1200 4x downscaled):
> https:/
> /Expo-2screens-
It does appear from the screenshots to be a lot better from what I remember, however screenshots can be misleading. One needs to consider how monitors are positioned in reality. Then again, I can see the argument for allowing it to work so long as the user asked for it - it might just be that the user's monitors are positioned correctly so that it doesn't look misaligned. But there's no way to verify this programatically
What I might suggest is that - how about changing the default in the .xml file to be "one wall per output" and I'll look into any bugs to do with the second output being black (I'm sure its quite simple). Then the user can pick "one big wall" if it would make sense on their particular configuration, as I think it tends to work better in fewer configurations than the former does. Doing it that way, incidentally, h...
Sam Spilsbury (smspillaz) wrote : | # |
Yep, those changes are looking good now, thanks. What are your thoughts on my solution above ?
MC Return (mc-return) wrote : | # |
>
> It does appear from the screenshots to be a lot better from what I remember,
> however screenshots can be misleading. One needs to consider how monitors are
> positioned in reality. Then again, I can see the argument for allowing it to
> work so long as the user asked for it - it might just be that the user's
> monitors are positioned correctly so that it doesn't look misaligned. But
> there's no way to verify this programatically
>
Believe me, I would not use this mode if it would not be better ;)
> What I might suggest is that - how about changing the default in the .xml file
> to be "one wall per output" and I'll look into any bugs to do with the second
> output being black (I'm sure its quite simple). Then the user can pick "one
> big wall" if it would make sense on their particular configuration, as I think
> it tends to work better in fewer configurations than the former does. Doing it
> that way, incidentally, helps to get around some complicated alignment issues
> that happen with unity, and I believe that the workspaces design specification
> mandated independent workspace picking per output.
>
That sounds like a great solution. +1
Thanks for looking into the related bugs, that sounds very good also :)
I will look into the defaults later, but would really prefer to do that in a
follow-up proposal as this sounds like having to do some quilting again and when
doing that I would also fix some other related expo.xml.in bugs, which also need
some quilt magic...
Sami Jaktholm (sjakthol) wrote : | # |
Did not see any errors in the diff and expo seems to work fine.
MC Return (mc-return) wrote : | # |
> Did not see any errors in the diff and expo seems to work fine.
Thanks a lot for your review, Sami. +1
MC Return (mc-return) wrote : | # |
I am happy we have so much support from Canonical.
I do not know what the Compiz project would do without all those coders and reviewers.
I am so happy they promised to continue this excellent support of Compiz until 2017 on Precise...
Sam Spilsbury (smspillaz) : | # |
PS Jenkins bot (ps-jenkins) : | # |
Preview Diff
1 | === modified file 'plugins/expo/src/click_threshold/include/click-threshold.h' |
2 | --- plugins/expo/src/click_threshold/include/click-threshold.h 2012-08-10 12:14:07 +0000 |
3 | +++ plugins/expo/src/click_threshold/include/click-threshold.h 2013-06-16 12:25:34 +0000 |
4 | @@ -30,8 +30,10 @@ |
5 | { |
6 | namespace expo |
7 | { |
8 | - bool clickMovementInThreshold(int previousX, int previousY, |
9 | - int currentX, int currentY); |
10 | + bool clickMovementInThreshold (int previousX, |
11 | + int previousY, |
12 | + int currentX, |
13 | + int currentY); |
14 | } |
15 | } |
16 | |
17 | |
18 | === modified file 'plugins/expo/src/click_threshold/src/click-threshold.cpp' |
19 | --- plugins/expo/src/click_threshold/src/click-threshold.cpp 2012-08-10 12:14:07 +0000 |
20 | +++ plugins/expo/src/click_threshold/src/click-threshold.cpp 2013-06-16 12:25:34 +0000 |
21 | @@ -25,11 +25,13 @@ |
22 | #include "click-threshold.h" |
23 | #include <stdlib.h> |
24 | |
25 | -static const int DND_THRESHOLD = 5; |
26 | +static const unsigned short DND_THRESHOLD = 5; |
27 | |
28 | bool |
29 | -compiz::expo::clickMovementInThreshold(int previousX, int previousY, |
30 | - int currentX, int currentY) |
31 | +compiz::expo::clickMovementInThreshold (int previousX, |
32 | + int previousY, |
33 | + int currentX, |
34 | + int currentY) |
35 | { |
36 | if ((abs (previousX - currentX) <= DND_THRESHOLD) && |
37 | (abs (previousY - currentY) <= DND_THRESHOLD)) |
38 | |
39 | === modified file 'plugins/expo/src/expo.cpp' |
40 | --- plugins/expo/src/expo.cpp 2013-05-13 18:08:52 +0000 |
41 | +++ plugins/expo/src/expo.cpp 2013-06-16 12:25:34 +0000 |
42 | @@ -36,16 +36,16 @@ |
43 | |
44 | COMPIZ_PLUGIN_20090315 (expo, ExpoPluginVTable); |
45 | |
46 | -#define sigmoid(x) (1.0f / (1.0f + exp (-5.5f * 2 * ((x) - 0.5)))) |
47 | +#define sigmoid(x) (1.0f / (1.0f + exp (-11.0f * ((x) - 0.5f)))) |
48 | #define sigmoidProgress(x) ((sigmoid (x) - sigmoid (0)) / \ |
49 | (sigmoid (1) - sigmoid (0))) |
50 | |
51 | #define interpolate(a, b, val) (((val) * (a)) + ((1 - (val)) * (b))) |
52 | |
53 | bool |
54 | -ExpoScreen::dndInit (CompAction *action, |
55 | - CompAction::State state, |
56 | - CompOption::Vector& options) |
57 | +ExpoScreen::dndInit (CompAction *action, |
58 | + CompAction::State state, |
59 | + CompOption::Vector &options) |
60 | { |
61 | if (expoMode) |
62 | { |
63 | @@ -60,9 +60,9 @@ |
64 | } |
65 | |
66 | bool |
67 | -ExpoScreen::dndFini (CompAction *action, |
68 | - CompAction::State state, |
69 | - CompOption::Vector& options) |
70 | +ExpoScreen::dndFini (CompAction *action, |
71 | + CompAction::State state, |
72 | + CompOption::Vector &options) |
73 | { |
74 | if (dndState == DnDDuring || dndState == DnDStart) |
75 | { |
76 | @@ -82,9 +82,9 @@ |
77 | } |
78 | |
79 | bool |
80 | -ExpoScreen::doExpo (CompAction *action, |
81 | - CompAction::State state, |
82 | - CompOption::Vector& options) |
83 | +ExpoScreen::doExpo (CompAction *action, |
84 | + CompAction::State state, |
85 | + CompOption::Vector &options) |
86 | { |
87 | if (screen->otherGrabExist ("expo", NULL)) |
88 | return false; |
89 | @@ -104,9 +104,9 @@ |
90 | dndState = DnDNone; |
91 | dndWindow = NULL; |
92 | |
93 | - selectedVp = screen->vp (); |
94 | - lastSelectedVp = screen->vp (); |
95 | - origVp = screen->vp (); |
96 | + selectedVp = screen->vp (); |
97 | + lastSelectedVp = selectedVp; |
98 | + origVp = selectedVp; |
99 | |
100 | screen->addAction (&optionGetDndButton ()); |
101 | screen->addAction (&optionGetExitButton ()); |
102 | @@ -116,17 +116,15 @@ |
103 | cScreen->damageScreen (); |
104 | } |
105 | else |
106 | - { |
107 | termExpo (action, state, options); |
108 | - } |
109 | |
110 | return true; |
111 | } |
112 | |
113 | bool |
114 | -ExpoScreen::termExpo (CompAction *action, |
115 | - CompAction::State state, |
116 | - CompOption::Vector& options) |
117 | +ExpoScreen::termExpo (CompAction *action, |
118 | + CompAction::State state, |
119 | + CompOption::Vector &options) |
120 | { |
121 | if (!expoMode) |
122 | return true; |
123 | @@ -156,9 +154,9 @@ |
124 | } |
125 | |
126 | bool |
127 | -ExpoScreen::exitExpo (CompAction *action, |
128 | - CompAction::State state, |
129 | - CompOption::Vector& options) |
130 | +ExpoScreen::exitExpo (CompAction *action, |
131 | + CompAction::State state, |
132 | + CompOption::Vector &options) |
133 | { |
134 | if (!expoMode) |
135 | return false; |
136 | @@ -171,22 +169,21 @@ |
137 | } |
138 | |
139 | bool |
140 | -ExpoScreen::nextVp (CompAction *action, |
141 | - CompAction::State state, |
142 | - CompOption::Vector& options) |
143 | +ExpoScreen::nextVp (CompAction *action, |
144 | + CompAction::State state, |
145 | + CompOption::Vector &options) |
146 | { |
147 | - unsigned int newX, newY; |
148 | - |
149 | if (!expoMode) |
150 | return false; |
151 | |
152 | - newX = selectedVp.x () + 1; |
153 | - newY = selectedVp.y (); |
154 | + unsigned int newX = selectedVp.x () + 1; |
155 | + unsigned int newY = selectedVp.y (); |
156 | |
157 | if (newX >= (unsigned int) screen->vpSize ().width ()) |
158 | { |
159 | newX = 0; |
160 | newY = newY + 1; |
161 | + |
162 | if (newY >= (unsigned int) screen->vpSize ().height ()) |
163 | newY = 0; |
164 | } |
165 | @@ -199,22 +196,21 @@ |
166 | } |
167 | |
168 | bool |
169 | -ExpoScreen::prevVp (CompAction *action, |
170 | - CompAction::State state, |
171 | - CompOption::Vector& options) |
172 | +ExpoScreen::prevVp (CompAction *action, |
173 | + CompAction::State state, |
174 | + CompOption::Vector &options) |
175 | { |
176 | - int newX, newY; |
177 | - |
178 | if (!expoMode) |
179 | return false; |
180 | |
181 | - newX = selectedVp.x () - 1; |
182 | - newY = selectedVp.y (); |
183 | + int newX = selectedVp.x () - 1; |
184 | + int newY = selectedVp.y (); |
185 | |
186 | if (newX < 0) |
187 | { |
188 | newX = screen->vpSize ().width () - 1; |
189 | newY = newY - 1; |
190 | + |
191 | if (newY < 0) |
192 | newY = screen->vpSize ().height () - 1; |
193 | } |
194 | @@ -230,15 +226,13 @@ |
195 | ExpoScreen::moveFocusViewport (int dx, |
196 | int dy) |
197 | { |
198 | - int newX, newY; |
199 | - |
200 | lastSelectedVp = selectedVp; |
201 | |
202 | - newX = selectedVp.x () + dx; |
203 | - newY = selectedVp.y () + dy; |
204 | + int newX = selectedVp.x () + dx; |
205 | + int newY = selectedVp.y () + dy; |
206 | |
207 | - newX = MAX (0, MIN ((int) screen->vpSize ().width () - 1, newX)); |
208 | - newY = MAX (0, MIN ((int) screen->vpSize ().height () - 1, newY)); |
209 | + newX = MAX (0, MIN (static_cast <int> (screen->vpSize ().width ()) - 1, newX)); |
210 | + newY = MAX (0, MIN (static_cast <int> (screen->vpSize ().height ()) - 1, newY)); |
211 | |
212 | selectedVp.set (newX, newY); |
213 | cScreen->damageScreen (); |
214 | @@ -260,12 +254,15 @@ |
215 | if (dndWindow->saveMask () & CWX) |
216 | { |
217 | dndWindow->saveWc ().x = dndWindow->saveWc ().x % screen->width (); |
218 | + |
219 | if (dndWindow->saveWc ().x < 0) |
220 | dndWindow->saveWc ().x += screen->width (); |
221 | } |
222 | + |
223 | if (dndWindow->saveMask () & CWY) |
224 | { |
225 | dndWindow->saveWc ().y = dndWindow->saveWc ().y % screen->height (); |
226 | + |
227 | if (dndWindow->saveWc ().y < 0) |
228 | dndWindow->saveWc ().y += screen->height (); |
229 | } |
230 | @@ -277,15 +274,15 @@ |
231 | |
232 | #if 0 /* FIXME: obsolete in the meantime? */ |
233 | { |
234 | - int lastOutput; |
235 | - int centerX, centerY; |
236 | - |
237 | /* make sure we snap to the correct output */ |
238 | - lastOutput = s->currentOutputDev; |
239 | - centerX = (WIN_X (w) + WIN_W (w) / 2) % s->width; |
240 | + int lastOutput = s->currentOutputDev; |
241 | + int centerX = (WIN_X (w) + WIN_W (w) / 2) % s->width; |
242 | + |
243 | if (centerX < 0) |
244 | centerX += s->width; |
245 | - centerY = (WIN_Y (w) + WIN_H (w) / 2) % s->height; |
246 | + |
247 | + int centerY = (WIN_Y (w) + WIN_H (w) / 2) % s->height; |
248 | + |
249 | if (centerY < 0) |
250 | centerY += s->height; |
251 | |
252 | @@ -301,79 +298,90 @@ |
253 | void |
254 | ExpoScreen::handleEvent (XEvent *event) |
255 | { |
256 | - switch (event->type) { |
257 | - case KeyPress: |
258 | - if (expoMode && event->xkey.root == screen->root ()) |
259 | - { |
260 | - if (event->xkey.keycode == leftKey) |
261 | - moveFocusViewport (-1, 0); |
262 | - else if (event->xkey.keycode == rightKey) |
263 | - moveFocusViewport (1, 0); |
264 | - else if (event->xkey.keycode == upKey) |
265 | - moveFocusViewport (0, -1); |
266 | - else if (event->xkey.keycode == downKey) |
267 | - moveFocusViewport (0, 1); |
268 | - } |
269 | - break; |
270 | - |
271 | - case ButtonPress: |
272 | - if (expoMode && event->xbutton.button == Button1 && |
273 | - event->xbutton.root == screen->root ()) |
274 | - { |
275 | - CompPoint pointer (event->xbutton.x_root, event->xbutton.y_root); |
276 | - if (!screen->workArea().contains (pointer)) |
277 | - break; |
278 | - |
279 | - anyClick = true; |
280 | - if (clickTime == 0) |
281 | - { |
282 | - clickTime = event->xbutton.time; |
283 | - } |
284 | - else if (event->xbutton.time - clickTime <= |
285 | - (unsigned int) optionGetDoubleClickTime () && lastSelectedVp == selectedVp) |
286 | - { |
287 | - doubleClick = true; |
288 | - } |
289 | - else |
290 | - { |
291 | - clickTime = event->xbutton.time; |
292 | - doubleClick = false; |
293 | - } |
294 | - cScreen->damageScreen (); |
295 | - prevClickPoint = CompPoint(event->xbutton.x, event->xbutton.y); |
296 | - } |
297 | - break; |
298 | - |
299 | - case ButtonRelease: |
300 | - if (expoMode && event->xbutton.button == Button1 && |
301 | - event->xbutton.root == screen->root ()) |
302 | - { |
303 | - CompPoint pointer (event->xbutton.x_root, event->xbutton.y_root); |
304 | - if (!screen->workArea().contains (pointer)) |
305 | - break; |
306 | - |
307 | - if (event->xbutton.time - clickTime > |
308 | - (unsigned int) optionGetDoubleClickTime ()) |
309 | - { |
310 | - clickTime = 0; |
311 | - doubleClick = false; |
312 | - } |
313 | - else if (doubleClick || |
314 | - compiz::expo::clickMovementInThreshold(prevClickPoint.x (), |
315 | - prevClickPoint.y (), |
316 | - event->xbutton.x, |
317 | - event->xbutton.y)) |
318 | - { |
319 | - CompAction& action = optionGetExpoKey (); |
320 | - |
321 | - clickTime = 0; |
322 | - doubleClick = false; |
323 | - |
324 | - termExpo (&action, 0, noOptions ()); |
325 | + switch (event->type) |
326 | + { |
327 | + case KeyPress: |
328 | + if (expoMode && event->xkey.root == screen->root ()) |
329 | + { |
330 | + if (event->xkey.keycode == leftKey) |
331 | + moveFocusViewport (-1, 0); |
332 | + else if (event->xkey.keycode == rightKey) |
333 | + moveFocusViewport (1, 0); |
334 | + else if (event->xkey.keycode == upKey) |
335 | + moveFocusViewport (0, -1); |
336 | + else if (event->xkey.keycode == downKey) |
337 | + moveFocusViewport (0, 1); |
338 | + } |
339 | + |
340 | + break; |
341 | + |
342 | + case ButtonPress: |
343 | + if (expoMode && |
344 | + event->xbutton.button == Button1 && |
345 | + event->xbutton.root == screen->root ()) |
346 | + { |
347 | + CompPoint pointer (event->xbutton.x_root, event->xbutton.y_root); |
348 | + |
349 | + if (!screen->workArea ().contains (pointer)) |
350 | + break; |
351 | + |
352 | anyClick = true; |
353 | - } |
354 | - } |
355 | - break; |
356 | + |
357 | + if (clickTime == 0) |
358 | + clickTime = event->xbutton.time; |
359 | + else if (event->xbutton.time - clickTime <= |
360 | + static_cast <unsigned int> (optionGetDoubleClickTime ()) && |
361 | + lastSelectedVp == selectedVp) |
362 | + doubleClick = true; |
363 | + else |
364 | + { |
365 | + clickTime = event->xbutton.time; |
366 | + doubleClick = false; |
367 | + } |
368 | + |
369 | + cScreen->damageScreen (); |
370 | + prevClickPoint = CompPoint (event->xbutton.x, event->xbutton.y); |
371 | + } |
372 | + |
373 | + break; |
374 | + |
375 | + case ButtonRelease: |
376 | + if (expoMode && |
377 | + event->xbutton.button == Button1 && |
378 | + event->xbutton.root == screen->root ()) |
379 | + { |
380 | + CompPoint pointer (event->xbutton.x_root, event->xbutton.y_root); |
381 | + |
382 | + if (!screen->workArea ().contains (pointer)) |
383 | + break; |
384 | + |
385 | + if (event->xbutton.time - clickTime > |
386 | + (unsigned int)optionGetDoubleClickTime ()) |
387 | + { |
388 | + clickTime = 0; |
389 | + doubleClick = false; |
390 | + } |
391 | + else if (doubleClick || |
392 | + compiz::expo::clickMovementInThreshold(prevClickPoint.x (), |
393 | + prevClickPoint.y (), |
394 | + event->xbutton.x, |
395 | + event->xbutton.y)) |
396 | + { |
397 | + /* TODO: What action to take if expo_key is not defined ? */ |
398 | + CompAction &action = optionGetExpoKey (); |
399 | + |
400 | + clickTime = 0; |
401 | + doubleClick = false; |
402 | + |
403 | + termExpo (&action, 0, noOptions ()); |
404 | + anyClick = true; |
405 | + } |
406 | + } |
407 | + |
408 | + break; |
409 | + |
410 | + default: |
411 | + break; |
412 | } |
413 | |
414 | screen->handleEvent (event); |
415 | @@ -382,7 +390,8 @@ |
416 | void |
417 | ExpoScreen::preparePaint (int msSinceLastPaint) |
418 | { |
419 | - float val = ((float) msSinceLastPaint / 1000.0) / optionGetZoomTime (); |
420 | + float val = (static_cast <float> (msSinceLastPaint) / 1000.0f) / |
421 | + optionGetZoomTime (); |
422 | |
423 | if (expoMode) |
424 | expoCam = MIN (1.0, expoCam + val); |
425 | @@ -392,21 +401,23 @@ |
426 | if (expoCam) |
427 | { |
428 | unsigned int i, j, vp; |
429 | - unsigned int vpCount = screen->vpSize ().width () * |
430 | - screen->vpSize ().height (); |
431 | + unsigned int vpCountHorz = screen->vpSize ().width (); |
432 | + unsigned int vpCountVert = screen->vpSize ().height (); |
433 | + unsigned int vpCount = vpCountHorz * vpCountVert; |
434 | |
435 | if (vpActivity.size () < vpCount) |
436 | { |
437 | vpActivity.resize (vpCount); |
438 | - foreach (float& activity, vpActivity) |
439 | + |
440 | + foreach (float &activity, vpActivity) |
441 | activity = 1.0f; |
442 | } |
443 | |
444 | - for (i = 0; i < (unsigned int) screen->vpSize ().width (); i++) |
445 | + for (i = 0; i < vpCountHorz; ++i) |
446 | { |
447 | - for (j = 0; j < (unsigned int) screen->vpSize ().height (); j++) |
448 | + for (j = 0; j < vpCountVert; ++j) |
449 | { |
450 | - vp = (j * screen->vpSize ().width ()) + i; |
451 | + vp = j * vpCountHorz + i; |
452 | |
453 | if (CompPoint (i, j) == selectedVp) |
454 | vpActivity[vp] = MIN (1.0, vpActivity[vp] + val); |
455 | @@ -415,15 +426,14 @@ |
456 | } |
457 | } |
458 | |
459 | - for (i = 0; i < 360; i++) |
460 | + const float degToRad = M_PI / 180.0f; |
461 | + const int screenWidth = screen->width (); |
462 | + |
463 | + for (i = 0; i < 360; ++i) |
464 | { |
465 | - float fi = (float) i; |
466 | - |
467 | - vpNormals[i * 3] = (-sin (fi * (M_PI / 180.0f)) / screen->width ()) * |
468 | - expoCam; |
469 | - vpNormals[(i * 3) + 1] = 0.0; |
470 | - vpNormals[(i * 3) + 2] = (-cos (fi * (M_PI / 180.0f)) * expoCam) - |
471 | - (1 - expoCam); |
472 | + vpNormals[i * 3] = (-sin (i * degToRad) / screenWidth) * expoCam; |
473 | + vpNormals[i * 3 + 1] = 0.0; |
474 | + vpNormals[i * 3 + 2] = (-cos (i * degToRad) * expoCam) - (1 - expoCam); |
475 | } |
476 | } |
477 | |
478 | @@ -440,44 +450,27 @@ |
479 | gScreen->glPaintOutputSetEnabled (this, enable); |
480 | gScreen->glPaintTransformedOutputSetEnabled (this, enable); |
481 | |
482 | + ExpoWindow *ew; |
483 | + |
484 | foreach (CompWindow *w, screen->windows ()) |
485 | { |
486 | - ExpoWindow *ew = ExpoWindow::get (w); |
487 | + ew = ExpoWindow::get (w); |
488 | |
489 | - ew->cWindow->damageRectSetEnabled (ew, enable); |
490 | - ew->gWindow->glPaintSetEnabled (ew, enable); |
491 | - ew->gWindow->glDrawSetEnabled (ew, enable); |
492 | + ew->cWindow->damageRectSetEnabled (ew, enable); |
493 | + ew->gWindow->glPaintSetEnabled (ew, enable); |
494 | + ew->gWindow->glDrawSetEnabled (ew, enable); |
495 | ew->gWindow->glAddGeometrySetEnabled (ew, enable); |
496 | ew->gWindow->glDrawTextureSetEnabled (ew, enable); |
497 | } |
498 | } |
499 | |
500 | void |
501 | -ExpoScreen::paint (CompOutput::ptrList& outputs, |
502 | - unsigned int mask) |
503 | +ExpoScreen::paint (CompOutput::ptrList &outputs, |
504 | + unsigned int mask) |
505 | { |
506 | - int width = outputs.front ()->width (); |
507 | - int height = outputs.front ()->height (); |
508 | - bool sizeDiff = false; |
509 | - |
510 | - /* "One big wall" does not make sense where outputs are different |
511 | - * sizes, so force multiple walls in this case |
512 | - * |
513 | - * TODO: Is it possible to re-create "one big wall" using |
514 | - * independent output painting in this case? */ |
515 | - |
516 | - foreach (CompOutput *o, outputs) |
517 | - { |
518 | - if (o->width () != width || o->height () != height) |
519 | - { |
520 | - sizeDiff = true; |
521 | - break; |
522 | - } |
523 | - } |
524 | - |
525 | - if (expoCam > 0.0 && outputs.size () > 1 && |
526 | - optionGetMultioutputMode () == MultioutputModeOneBigWall && |
527 | - !sizeDiff) |
528 | + if (expoCam > 0.0 && |
529 | + outputs.size () > 1 && |
530 | + optionGetMultioutputMode () == MultioutputModeOneBigWall) |
531 | { |
532 | outputs.clear (); |
533 | outputs.push_back (&screen->fullscreenOutput ()); |
534 | @@ -491,24 +484,29 @@ |
535 | { |
536 | CompOption::Vector o(0); |
537 | screen->handleCompizEvent ("expo", "start_viewport_switch", o); |
538 | - switch (vpUpdateMode) { |
539 | - case VPUpdateMouseOver: |
540 | - screen->moveViewport (screen->vp ().x () - selectedVp.x (), |
541 | - screen->vp ().y () - selectedVp.y (), true); |
542 | - screen->focusDefaultWindow (); |
543 | - vpUpdateMode = VPUpdateNone; |
544 | - break; |
545 | - case VPUpdatePrevious: |
546 | - screen->moveViewport (screen->vp ().x () - origVp.x (), |
547 | - screen->vp ().y () - origVp.y (), true); |
548 | - lastSelectedVp = selectedVp; |
549 | - selectedVp = origVp; |
550 | - screen->focusDefaultWindow (); |
551 | - vpUpdateMode = VPUpdateNone; |
552 | - break; |
553 | - default: |
554 | - break; |
555 | + |
556 | + switch (vpUpdateMode) |
557 | + { |
558 | + case VPUpdateMouseOver: |
559 | + screen->moveViewport (screen->vp ().x () - selectedVp.x (), |
560 | + screen->vp ().y () - selectedVp.y (), true); |
561 | + screen->focusDefaultWindow (); |
562 | + vpUpdateMode = VPUpdateNone; |
563 | + break; |
564 | + |
565 | + case VPUpdatePrevious: |
566 | + screen->moveViewport (screen->vp ().x () - origVp.x (), |
567 | + screen->vp ().y () - origVp.y (), true); |
568 | + lastSelectedVp = selectedVp; |
569 | + selectedVp = origVp; |
570 | + screen->focusDefaultWindow (); |
571 | + vpUpdateMode = VPUpdateNone; |
572 | + break; |
573 | + |
574 | + default: |
575 | + break; |
576 | } |
577 | + |
578 | screen->handleCompizEvent ("expo", "end_viewport_switch", o); |
579 | |
580 | if ((expoCam > 0.0f && expoCam < 1.0f) || dndState != DnDNone) |
581 | @@ -516,7 +514,7 @@ |
582 | |
583 | if (expoCam == 1.0f) |
584 | { |
585 | - foreach (float& vp, vpActivity) |
586 | + foreach (float &vp, vpActivity) |
587 | if (vp != 0.0 && vp != 1.0) |
588 | cScreen->damageScreen (); |
589 | } |
590 | @@ -530,8 +528,9 @@ |
591 | |
592 | cScreen->donePaint (); |
593 | |
594 | - switch (dndState) { |
595 | - case DnDDuring: |
596 | + switch (dndState) |
597 | + { |
598 | + case DnDDuring: |
599 | { |
600 | if (dndWindow) |
601 | dndWindow->move (newCursor.x () - prevCursor.x (), |
602 | @@ -541,30 +540,27 @@ |
603 | prevCursor = newCursor; |
604 | cScreen->damageScreen (); |
605 | } |
606 | - break; |
607 | + break; |
608 | |
609 | - case DnDStart: |
610 | + case DnDStart: |
611 | { |
612 | - int xOffset, yOffset; |
613 | - CompWindowList::reverse_iterator iter; |
614 | - |
615 | - xOffset = screen->vpSize ().width () * screen->width (); |
616 | - yOffset = screen->vpSize ().height () * screen->height (); |
617 | + int xOffset = screen->vpSize ().width () * screen->width (); |
618 | + int yOffset = screen->vpSize ().height () * screen->height (); |
619 | |
620 | dndState = DnDNone; |
621 | |
622 | - for (iter = screen->windows ().rbegin (); |
623 | + bool inWindow; |
624 | + int nx, ny; |
625 | + CompWindow *w; |
626 | + |
627 | + for (CompWindowList::reverse_iterator iter = screen->windows ().rbegin (); |
628 | iter != screen->windows ().rend (); ++iter) |
629 | { |
630 | - CompWindow *w = *iter; |
631 | - CompRect input (w->inputRect ()); |
632 | - bool inWindow; |
633 | - int nx, ny; |
634 | - |
635 | - if (w->destroyed ()) |
636 | - continue; |
637 | - |
638 | - if (!w->shaded () && !w->isViewable ()) |
639 | + w = *iter; |
640 | + CompRect input (w->inputRect ()); |
641 | + |
642 | + if (w->destroyed () || |
643 | + (!w->shaded () && !w->isViewable ())) |
644 | continue; |
645 | |
646 | if (w->onAllViewports ()) |
647 | @@ -574,18 +570,16 @@ |
648 | } |
649 | else |
650 | { |
651 | - nx = newCursor.x () - |
652 | - (screen->vp ().x () * screen->width ()); |
653 | - ny = newCursor.y () - |
654 | - (screen->vp ().y () * screen->height ()); |
655 | + nx = newCursor.x () - (screen->vp ().x () * screen->width ()); |
656 | + ny = newCursor.y () - (screen->vp ().y () * screen->height ()); |
657 | } |
658 | |
659 | inWindow = (nx >= input.left () && nx <= input.right ()) || |
660 | - (nx >= (input.left () + xOffset) && |
661 | + (nx >= (input.left () + xOffset) && |
662 | nx <= (input.right () + xOffset)); |
663 | |
664 | inWindow &= (ny >= input.top () && ny <= input.bottom ()) || |
665 | - (ny >= (input.top () + yOffset) && |
666 | + (ny >= (input.top () + yOffset) && |
667 | ny <= (input.bottom () + yOffset)); |
668 | |
669 | if (!inWindow) |
670 | @@ -616,21 +610,28 @@ |
671 | |
672 | prevCursor = newCursor; |
673 | } |
674 | - break; |
675 | - case DnDNone: |
676 | - screen->updateGrab (grabIndex, screen->normalCursor ()); |
677 | - break; |
678 | - default: |
679 | - break; |
680 | + |
681 | + break; |
682 | + |
683 | + case DnDNone: |
684 | + screen->updateGrab (grabIndex, screen->normalCursor ()); |
685 | + break; |
686 | + |
687 | + default: |
688 | + break; |
689 | } |
690 | } |
691 | |
692 | static bool |
693 | -unproject (float winx, float winy, float winz, |
694 | - const GLMatrix &modelview, |
695 | - const GLMatrix &projection, |
696 | - const GLint viewport[4], |
697 | - float *objx, float *objy, float *objz) |
698 | +unproject (float winx, |
699 | + float winy, |
700 | + float winz, |
701 | + const GLMatrix &modelview, |
702 | + const GLMatrix &projection, |
703 | + const GLint viewport[4], |
704 | + float *objx, |
705 | + float *objy, |
706 | + float *objz) |
707 | { |
708 | GLMatrix finalMatrix = projection * modelview; |
709 | float in[4], out[4]; |
710 | @@ -652,7 +653,7 @@ |
711 | in[1] = in[1] * 2 - 1; |
712 | in[2] = in[2] * 2 - 1; |
713 | |
714 | - for (int i = 0; i < 4; i++) |
715 | + for (int i = 0; i < 4; ++i) |
716 | { |
717 | out[i] = in[0] * finalMatrix[i] + |
718 | in[1] * finalMatrix[4 + i] + |
719 | @@ -675,13 +676,13 @@ |
720 | } |
721 | |
722 | void |
723 | -ExpoScreen::invertTransformedVertex (const GLScreenPaintAttrib& attrib, |
724 | - const GLMatrix& transform, |
725 | - CompOutput *output, |
726 | - int vertex[2]) |
727 | +ExpoScreen::invertTransformedVertex (const GLScreenPaintAttrib &attrib, |
728 | + const GLMatrix &transform, |
729 | + CompOutput *output, |
730 | + int vertex[2]) |
731 | { |
732 | GLMatrix sTransform (transform); |
733 | - float p1[3], p2[3], v[3], alpha; |
734 | + float p1[3], p2[3], v[3]; |
735 | GLint viewport[4]; |
736 | |
737 | gScreen->glApplyTransform (attrib, output, &sTransform); |
738 | @@ -690,33 +691,37 @@ |
739 | glGetIntegerv (GL_VIEWPORT, viewport); |
740 | |
741 | unproject (vertex[0], screen->height () - vertex[1], 0, |
742 | - sTransform, *gScreen->projectionMatrix (), viewport, |
743 | - &p1[0], &p1[1], &p1[2]); |
744 | + sTransform, *gScreen->projectionMatrix (), viewport, |
745 | + &p1[0], &p1[1], &p1[2]); |
746 | unproject (vertex[0], screen->height () - vertex[1], -1.0, |
747 | - sTransform, *gScreen->projectionMatrix (), viewport, |
748 | - &p2[0], &p2[1], &p2[2]); |
749 | + sTransform, *gScreen->projectionMatrix (), viewport, |
750 | + &p2[0], &p2[1], &p2[2]); |
751 | |
752 | - for (int i = 0; i < 3; i++) |
753 | + for (int i = 0; i < 3; ++i) |
754 | v[i] = p1[i] - p2[i]; |
755 | |
756 | - alpha = -p1[2] / v[2]; |
757 | + float alpha = -p1[2] / v[2]; |
758 | |
759 | if (optionGetDeform () == DeformCurve && screen->desktopWindowCount ()) |
760 | { |
761 | - const float sws = screen->width () * screen->width (); |
762 | - const float rs = (curveDistance * curveDistance) + 0.25; |
763 | - const float p = ((2.0 * sws * (p1[2] - curveDistance) * v[2]) + |
764 | - (2.0 * p1[0] * v[0]) - |
765 | - (v[0] * (float) screen->width ())) / |
766 | - ((v[2] * v[2] * sws) + (v[0] * v[0])); |
767 | - const float q = (-(sws * rs) + (sws * (p1[2] - curveDistance) * |
768 | - (p1[2] - curveDistance)) + |
769 | - (0.25 * sws) + (p1[0] * p1[0]) - |
770 | - (p1[0] * (float) screen->width ())) / |
771 | - ((v[2] * v[2] * sws) + (v[0] * v[0])); |
772 | - |
773 | - const float rq = (0.25 * p * p) - q; |
774 | - const float ph = -p * 0.5; |
775 | + const float screenWidth = static_cast <float> (screen->width ()); |
776 | + const float screenWidthSquared = screenWidth * screenWidth; |
777 | + const float curveDistSquaredPlusQuarter = curveDistance * curveDistance + 0.25; |
778 | + const float pOne2MinusCurveDist = p1[2] - curveDistance; |
779 | + const float v0Squared = v[0] * v[0]; |
780 | + const float v2Squared = v[2] * v[2]; |
781 | + const float vsv = v2Squared * screenWidthSquared + |
782 | + v0Squared; |
783 | + |
784 | + const float p = (2.0 * screenWidthSquared * pOne2MinusCurveDist * v[2] + |
785 | + 2.0 * p1[0] * v[0] - v[0] * screenWidth) / vsv; |
786 | + const float q = (-screenWidthSquared * curveDistSquaredPlusQuarter + |
787 | + screenWidthSquared * pOne2MinusCurveDist * pOne2MinusCurveDist + |
788 | + 0.25 * screenWidthSquared + |
789 | + p1[0] * p1[0] - p1[0] * screenWidth) / vsv; |
790 | + |
791 | + const float rq = 0.25 * p * p - q; |
792 | + const float ph = -p * 0.5; |
793 | |
794 | if (rq < 0.0) |
795 | { |
796 | @@ -727,6 +732,7 @@ |
797 | else |
798 | { |
799 | alpha = ph + sqrt(rq); |
800 | + |
801 | if (p1[2] + (alpha * v[2]) > 0.0) |
802 | { |
803 | vertex[0] = -1000; |
804 | @@ -741,25 +747,17 @@ |
805 | } |
806 | |
807 | void |
808 | -ExpoScreen::paintWall (const GLScreenPaintAttrib& attrib, |
809 | - const GLMatrix& transform, |
810 | - const CompRegion& region, |
811 | - CompOutput *output, |
812 | - unsigned int mask, |
813 | - bool reflection) |
814 | +ExpoScreen::paintWall (const GLScreenPaintAttrib &attrib, |
815 | + const GLMatrix& transform, |
816 | + const CompRegion& region, |
817 | + CompOutput *output, |
818 | + unsigned int mask, |
819 | + bool reflection) |
820 | { |
821 | - GLfloat vertexData[12]; |
822 | + GLfloat vertexData[12]; |
823 | GLushort colorData[16]; |
824 | GLMatrix sTransformW, sTransform (transform); |
825 | - int i, j, vp; |
826 | - GLenum oldFilter = gScreen->textureFilter (); |
827 | |
828 | - float sx = (float) screen->width () / output->width (); |
829 | - float sy = (float) screen->height () / output->height (); |
830 | - float biasZ; |
831 | - float oScale, rotation = 0.0f, progress, vpp; |
832 | - float aspectX = 1.0f, aspectY = 1.0f; |
833 | - GLVector cam; |
834 | CompPoint vpSize (screen->vpSize ().width (), screen->vpSize ().height ()); |
835 | |
836 | /* amount of gap between viewports */ |
837 | @@ -767,8 +765,7 @@ |
838 | const float gapX = optionGetVpDistance () * 0.1f * screen->height () / |
839 | screen->width () * expoCam; |
840 | |
841 | - int glPaintTransformedOutputIndex = |
842 | - gScreen->glPaintTransformedOutputGetCurrentIndex (); |
843 | + int glPaintTransformedOutputIndex = gScreen->glPaintTransformedOutputGetCurrentIndex (); |
844 | |
845 | GLVertexBuffer *streamingBuffer = GLVertexBuffer::streamingBuffer (); |
846 | |
847 | @@ -782,52 +779,57 @@ |
848 | /* camera position during expo mode */ |
849 | GLVector expoCamPos (0, 0, 0, 0); |
850 | |
851 | + float sx = screen->width () / static_cast <float> (output->width ()); |
852 | + float sy = screen->height () / static_cast <float> (output->height ()); |
853 | + |
854 | if (optionGetDeform () == DeformCurve) |
855 | - { |
856 | - vpCamPos[GLVector::x] = -sx * (0.5 - (((float) output->x () + |
857 | - (output->width () / 2.0)) / |
858 | - (float) screen->width ())); |
859 | - } |
860 | + vpCamPos[GLVector::x] = -sx * (0.5 - ((static_cast <float> (output->x ()) + |
861 | + output->width () / 2.0) / |
862 | + static_cast <float> (screen->width ()))); |
863 | else |
864 | - { |
865 | - vpCamPos[GLVector::x] = (screen->vp ().x () * sx) + 0.5 + |
866 | - (output->x () / output->width ()) - |
867 | - (vpSize.x () * 0.5 * sx) + |
868 | + vpCamPos[GLVector::x] = screen->vp ().x () * sx + 0.5 + |
869 | + output->x () / output->width () - |
870 | + vpSize.x () * 0.5 * sx + |
871 | gapX * screen->vp ().x (); |
872 | - } |
873 | - vpCamPos[GLVector::y] = -((screen->vp ().y () * sy) + 0.5 + |
874 | - (output->y () / output->height ())) + |
875 | - (vpSize.y () * 0.5 * sy) - |
876 | - gapY * screen->vp ().y (); |
877 | - |
878 | - biasZ = MAX (vpSize.x () * sx, vpSize.y () * sy); |
879 | + |
880 | + vpCamPos[GLVector::y] = -(screen->vp ().y () * sy + 0.5 + |
881 | + output->y () / output->height ()) + |
882 | + vpSize.y () * 0.5 * sy - |
883 | + gapY * screen->vp ().y (); |
884 | + |
885 | + float biasZ = MAX (vpSize.x () * sx, vpSize.y () * sy); |
886 | + |
887 | if (optionGetDeform () == DeformTilt || optionGetReflection ()) |
888 | biasZ *= (0.15 + optionGetDistance ()); |
889 | else |
890 | biasZ *= optionGetDistance (); |
891 | |
892 | - progress = sigmoidProgress (expoCam); |
893 | + float progress = sigmoidProgress (expoCam); |
894 | |
895 | if (optionGetDeform () != DeformCurve) |
896 | expoCamPos[GLVector::x] = gapX * (vpSize.x () - 1) * 0.5; |
897 | |
898 | expoCamPos[GLVector::y] = -gapY * (vpSize.y () - 1) * 0.5; |
899 | expoCamPos[GLVector::z] = -DEFAULT_Z_CAMERA + DEFAULT_Z_CAMERA * |
900 | - (MAX (vpSize.x () + (vpSize.x () - 1) * gapX, |
901 | + (MAX (vpSize.x () + (vpSize.x () - 1) * gapX, |
902 | vpSize.y () + (vpSize.y () - 1) * gapY) + |
903 | biasZ); |
904 | |
905 | /* interpolate between vpCamPos and expoCamPos */ |
906 | + GLVector cam; |
907 | + |
908 | cam[GLVector::x] = vpCamPos[GLVector::x] * (1 - progress) + |
909 | - expoCamPos[GLVector::x] * progress; |
910 | + expoCamPos[GLVector::x] * progress; |
911 | cam[GLVector::y] = vpCamPos[GLVector::y] * (1 - progress) + |
912 | - expoCamPos[GLVector::y] * progress; |
913 | + expoCamPos[GLVector::y] * progress; |
914 | cam[GLVector::z] = vpCamPos[GLVector::z] * (1 - progress) + |
915 | - expoCamPos[GLVector::z] * progress; |
916 | + expoCamPos[GLVector::z] * progress; |
917 | + |
918 | + float aspectX = 1.0f, aspectY = 1.0f; |
919 | |
920 | if (vpSize.x () > vpSize.y ()) |
921 | { |
922 | - aspectY = (float) vpSize.x () / (float) vpSize.y (); |
923 | + aspectY = vpSize.x () / static_cast <float> (vpSize.y ()); |
924 | aspectY -= 1.0; |
925 | aspectY *= -optionGetAspectRatio () + 1.0; |
926 | aspectY *= progress; |
927 | @@ -835,7 +837,7 @@ |
928 | } |
929 | else |
930 | { |
931 | - aspectX = (float) vpSize.y () / (float) vpSize.x (); |
932 | + aspectX = vpSize.y () / static_cast <float> (vpSize.x ()); |
933 | aspectX -= 1.0; |
934 | aspectX *= -optionGetAspectRatio () + 1.0; |
935 | aspectX *= progress; |
936 | @@ -844,6 +846,8 @@ |
937 | |
938 | /* End of Zoom animation stuff */ |
939 | |
940 | + float rotation = 0.0f; |
941 | + |
942 | if (optionGetDeform () == DeformTilt) |
943 | { |
944 | if (optionGetExpoAnimation () == ExpoAnimationZoom) |
945 | @@ -852,12 +856,21 @@ |
946 | rotation = 10.0 * expoCam; |
947 | } |
948 | |
949 | + bool filterChanged = false; |
950 | + GLenum oldFilter; |
951 | + |
952 | if (optionGetMipmaps ()) |
953 | + { |
954 | + /* check the actual filtering */ |
955 | + oldFilter = gScreen->textureFilter (); |
956 | + |
957 | gScreen->setTextureFilter (GL_LINEAR_MIPMAP_LINEAR); |
958 | + filterChanged = true; |
959 | + } |
960 | |
961 | /* ALL TRANSFORMATION ARE EXECUTED FROM BOTTOM TO TOP */ |
962 | |
963 | - oScale = 1 / (1 + ((MAX (sx, sy) - 1) * progress)); |
964 | + float oScale = 1 / (1 + ((MAX (sx, sy) - 1) * progress)); |
965 | |
966 | sTransform.scale (oScale, oScale, 1.0); |
967 | |
968 | @@ -891,7 +904,7 @@ |
969 | |
970 | CompPoint offsetInScreenCoords (optionGetXOffset (), |
971 | optionGetYOffset ()); |
972 | - float offsetInWorldCoordX, offsetInWorldCoordY, worldScaleFactorX, worldScaleFactorY; |
973 | + float offsetInWorldCoordX, offsetInWorldCoordY, worldScaleFactorX, worldScaleFactorY; |
974 | |
975 | compiz::expo::calculateWallOffset (*output, |
976 | offsetInScreenCoords, |
977 | @@ -905,7 +918,7 @@ |
978 | |
979 | /* translate expo to center */ |
980 | sTransform.translate (vpSize.x () * sx * -0.5 + offsetInWorldCoordX, |
981 | - vpSize.y () * sy * 0.5 - offsetInWorldCoordY, 0.0f); |
982 | + vpSize.y () * sy * 0.5 - offsetInWorldCoordY, 0.0f); |
983 | sTransform.scale (worldScaleFactorX, worldScaleFactorY, 1.0f); |
984 | |
985 | |
986 | @@ -924,18 +937,23 @@ |
987 | else |
988 | curveAngle = interpolate (180 / vpSize.x (), 1, optionGetCurve ()); |
989 | |
990 | - curveDistance = ((0.5f * sx) + (gapX / 2.0)) / |
991 | - tanf ((M_PI / 180.0f) * curveAngle / 2.0); |
992 | - curveRadius = ((0.5f * sx) + (gapX / 2.0)) / |
993 | - sinf ((M_PI / 180.0f) * curveAngle / 2.0); |
994 | + const float halfGapX = gapX / 2.0; |
995 | + |
996 | + curveDistance = ((0.5f * sx) + halfGapX) / |
997 | + tanf ((M_PI / 360.0f) * curveAngle); |
998 | + curveRadius = ((0.5f * sx) + halfGapX) / |
999 | + sinf ((M_PI / 360.0f) * curveAngle); |
1000 | |
1001 | expoActive = true; |
1002 | |
1003 | - for (j = 0; j < vpSize.y (); j++) |
1004 | + float rotateX, vpp; |
1005 | + int vp; |
1006 | + |
1007 | + for (int j = 0; j < vpSize.y (); ++j) |
1008 | { |
1009 | GLMatrix sTransform2 (sTransform), sTransform3; |
1010 | |
1011 | - for (i = 0; i < vpSize.x (); i++) |
1012 | + for (int i = 0; i < vpSize.x (); ++i) |
1013 | { |
1014 | if (optionGetExpoAnimation () == ExpoAnimationVortex) |
1015 | sTransform2.rotate (360 * expoCam, |
1016 | @@ -943,7 +961,7 @@ |
1017 | |
1018 | sTransform3 = sTransform2; |
1019 | |
1020 | - sTransform3.translate (output->x () / output->width (), |
1021 | + sTransform3.translate ( output->x () / output->width (), |
1022 | -output->y () / output->height (), 0.0); |
1023 | |
1024 | cScreen->setWindowPaintOffset ((screen->vp ().x () - i) * |
1025 | @@ -965,12 +983,11 @@ |
1026 | |
1027 | if (optionGetDeform () == DeformCurve) |
1028 | { |
1029 | - float rotateX; |
1030 | - |
1031 | sTransform3.translate (-vpCamPos[GLVector::x], 0.0f, |
1032 | curveDistance - DEFAULT_Z_CAMERA); |
1033 | |
1034 | - rotateX = -i + interpolate (((float) vpSize.x () / 2.0) - 0.5, |
1035 | + rotateX = -i + interpolate ((static_cast <float> (vpSize.x ()) / 2.0) - |
1036 | + 0.5, |
1037 | screen->vp ().x (), progress); |
1038 | |
1039 | sTransform3.rotate (curveAngle * rotateX, 0.0, 1.0, 0.0); |
1040 | @@ -990,10 +1007,12 @@ |
1041 | invertTransformedVertex (attrib, sTransform3, |
1042 | output, cursor); |
1043 | |
1044 | - if ((cursor[0] > 0) && (cursor[0] < (int) screen->width ()) && |
1045 | - (cursor[1] > 0) && (cursor[1] < (int) screen->height ())) |
1046 | + if (cursor[0] > 0 && |
1047 | + cursor[0] < static_cast <int> (screen->width ()) && |
1048 | + cursor[1] > 0 && |
1049 | + cursor[1] < static_cast <int> (screen->height ())) |
1050 | { |
1051 | - newCursor.setX (i * screen->width () + cursor[0]); |
1052 | + newCursor.setX (i * screen->width () + cursor[0]); |
1053 | newCursor.setY (j * screen->height () + cursor[1]); |
1054 | |
1055 | if (anyClick || dndState != DnDNone) |
1056 | @@ -1001,7 +1020,7 @@ |
1057 | /* Used to save last viewport interaction was in */ |
1058 | lastSelectedVp = selectedVp; |
1059 | selectedVp.set (i, j); |
1060 | - anyClick = false; |
1061 | + anyClick = false; |
1062 | } |
1063 | } |
1064 | } |
1065 | @@ -1019,7 +1038,12 @@ |
1066 | |
1067 | if (reflection) |
1068 | { |
1069 | - glEnable (GL_BLEND); |
1070 | + GLboolean glBlendEnabled = glIsEnabled (GL_BLEND); |
1071 | + |
1072 | + /* just enable blending if it is disabled */ |
1073 | + if (!glBlendEnabled) |
1074 | + glEnable (GL_BLEND); |
1075 | + |
1076 | glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); |
1077 | |
1078 | if (optionGetDeform () != DeformCurve) |
1079 | @@ -1145,10 +1169,12 @@ |
1080 | streamingBuffer->end (); |
1081 | streamingBuffer->render (cTransform); |
1082 | } |
1083 | + |
1084 | glCullFace (GL_BACK); |
1085 | |
1086 | if (optionGetGroundSize () > 0.0) |
1087 | { |
1088 | + float groundSize = optionGetGroundSize (); |
1089 | GLMatrix gTransform; |
1090 | gTransform.translate (0.0, 0.0, -DEFAULT_Z_CAMERA); |
1091 | |
1092 | @@ -1161,10 +1187,10 @@ |
1093 | vertexData[4] = -0.5; |
1094 | vertexData[5] = 0; |
1095 | vertexData[6] = -0.5; |
1096 | - vertexData[7] = -0.5 + optionGetGroundSize (); |
1097 | + vertexData[7] = -0.5 + groundSize; |
1098 | vertexData[8] = 0; |
1099 | vertexData[9] = 0.5; |
1100 | - vertexData[10] = -0.5 + optionGetGroundSize (); |
1101 | + vertexData[10] = -0.5 + groundSize; |
1102 | vertexData[11] = 0; |
1103 | |
1104 | streamingBuffer->addColors (1, optionGetGroundColor1 ()); |
1105 | @@ -1176,8 +1202,12 @@ |
1106 | streamingBuffer->end (); |
1107 | streamingBuffer->render (gTransform); |
1108 | } |
1109 | + |
1110 | glBlendFunc (GL_ONE, GL_ONE_MINUS_SRC_ALPHA); |
1111 | - glDisable (GL_BLEND); |
1112 | + |
1113 | + /* just disable blending if it was disabled before */ |
1114 | + if (!glBlendEnabled) |
1115 | + glDisable (GL_BLEND); |
1116 | } |
1117 | |
1118 | expoActive = false; |
1119 | @@ -1185,15 +1215,18 @@ |
1120 | cScreen->setWindowPaintOffset (0, 0); |
1121 | |
1122 | gScreen->glPaintTransformedOutputSetCurrentIndex (glPaintTransformedOutputIndex); |
1123 | - gScreen->setTextureFilter (oldFilter); |
1124 | + |
1125 | + /* we just need to change the global filter state if we manipulated it before */ |
1126 | + if (filterChanged) |
1127 | + gScreen->setTextureFilter (oldFilter); |
1128 | } |
1129 | |
1130 | bool |
1131 | -ExpoScreen::glPaintOutput (const GLScreenPaintAttrib& attrib, |
1132 | - const GLMatrix& transform, |
1133 | - const CompRegion& region, |
1134 | - CompOutput *output, |
1135 | - unsigned int mask) |
1136 | +ExpoScreen::glPaintOutput (const GLScreenPaintAttrib &attrib, |
1137 | + const GLMatrix &transform, |
1138 | + const CompRegion ®ion, |
1139 | + CompOutput *output, |
1140 | + unsigned int mask) |
1141 | { |
1142 | if (expoCam > 0.0) |
1143 | mask |= PAINT_SCREEN_TRANSFORMED_MASK | PAINT_SCREEN_CLEAR_MASK; |
1144 | @@ -1202,11 +1235,11 @@ |
1145 | } |
1146 | |
1147 | void |
1148 | -ExpoScreen::glPaintTransformedOutput (const GLScreenPaintAttrib& attrib, |
1149 | - const GLMatrix& transform, |
1150 | - const CompRegion& region, |
1151 | - CompOutput *output, |
1152 | - unsigned int mask) |
1153 | +ExpoScreen::glPaintTransformedOutput (const GLScreenPaintAttrib &attrib, |
1154 | + const GLMatrix &transform, |
1155 | + const CompRegion ®ion, |
1156 | + CompOutput *output, |
1157 | + unsigned int mask) |
1158 | { |
1159 | expoActive = false; |
1160 | |
1161 | @@ -1226,14 +1259,10 @@ |
1162 | |
1163 | if (expoCam <= 0 || (expoCam > 0.0 && expoCam < 1.0 && |
1164 | optionGetExpoAnimation () != ExpoAnimationZoom)) |
1165 | - { |
1166 | gScreen->glPaintTransformedOutput (attrib, transform, region, |
1167 | output, mask); |
1168 | - } |
1169 | else |
1170 | - { |
1171 | gScreen->clearOutput (output, GL_COLOR_BUFFER_BIT); |
1172 | - } |
1173 | |
1174 | mask &= ~PAINT_SCREEN_CLEAR_MASK; |
1175 | |
1176 | @@ -1248,20 +1277,18 @@ |
1177 | } |
1178 | |
1179 | bool |
1180 | -ExpoWindow::glDraw (const GLMatrix& transform, |
1181 | - const GLWindowPaintAttrib &attrib, |
1182 | - const CompRegion& region, |
1183 | - unsigned int mask) |
1184 | +ExpoWindow::glDraw (const GLMatrix &transform, |
1185 | + const GLWindowPaintAttrib &attrib, |
1186 | + const CompRegion ®ion, |
1187 | + unsigned int mask) |
1188 | { |
1189 | if (eScreen->expoCam == 0.0f) |
1190 | return gWindow->glDraw (transform, attrib, region, mask); |
1191 | |
1192 | - int expoAnimation; |
1193 | - |
1194 | // Scaling factors to be applied to attrib later in glDrawTexture |
1195 | expoOpacity = 1.0f; |
1196 | |
1197 | - expoAnimation = eScreen->optionGetExpoAnimation (); |
1198 | + int expoAnimation = eScreen->optionGetExpoAnimation (); |
1199 | |
1200 | if (eScreen->expoActive) |
1201 | { |
1202 | @@ -1273,23 +1300,19 @@ |
1203 | { |
1204 | if (expoAnimation == ExpoScreen::ExpoAnimationZoom && |
1205 | eScreen->paintingVp == eScreen->selectedVp) |
1206 | - { |
1207 | expoOpacity = (1.0f - sigmoidProgress (eScreen->expoCam)); |
1208 | - } |
1209 | else |
1210 | - { |
1211 | expoOpacity = 0.0f; |
1212 | - } |
1213 | } |
1214 | } |
1215 | |
1216 | bool status = gWindow->glDraw (transform, attrib, region, mask); |
1217 | |
1218 | if (window->type () & CompWindowTypeDesktopMask && |
1219 | - eScreen->optionGetSelectedColor ()[3] && // colour is visible |
1220 | - mGlowQuads && |
1221 | - eScreen->paintingVp == eScreen->selectedVp && |
1222 | - region.numRects ()) |
1223 | + eScreen->optionGetSelectedColor ()[3] && // colour is visible |
1224 | + mGlowQuads && |
1225 | + eScreen->paintingVp == eScreen->selectedVp && |
1226 | + region.numRects ()) |
1227 | { |
1228 | /* reset geometry and paint */ |
1229 | gWindow->vertexBuffer ()->begin (); |
1230 | @@ -1303,54 +1326,54 @@ |
1231 | static const unsigned short EXPO_GRID_SIZE = 100; |
1232 | |
1233 | void |
1234 | -ExpoWindow::glAddGeometry (const GLTexture::MatrixList& matrices, |
1235 | - const CompRegion& region, |
1236 | - const CompRegion& clip, |
1237 | - unsigned int maxGridWidth, |
1238 | - unsigned int maxGridHeight) |
1239 | +ExpoWindow::glAddGeometry (const GLTexture::MatrixList &matrices, |
1240 | + const CompRegion ®ion, |
1241 | + const CompRegion &clip, |
1242 | + unsigned int maxGridWidth, |
1243 | + unsigned int maxGridHeight) |
1244 | { |
1245 | - if (eScreen->expoCam > 0.0 && |
1246 | - screen->desktopWindowCount () && |
1247 | + if (eScreen->expoCam > 0.0 && |
1248 | + screen->desktopWindowCount () && |
1249 | eScreen->optionGetDeform () == ExpoScreen::DeformCurve) |
1250 | { |
1251 | - int i, oldVCount = gWindow->vertexBuffer ()->countVertices (); |
1252 | - GLfloat *v; |
1253 | - CompPoint offset; |
1254 | - float lastX, lastZ = 0.0; |
1255 | - const float radSquare = pow (eScreen->curveDistance, 2) + 0.25; |
1256 | - float ang; |
1257 | - |
1258 | gWindow->glAddGeometry (matrices, region, clip, |
1259 | - MIN(maxGridWidth , EXPO_GRID_SIZE), |
1260 | + MIN (maxGridWidth, EXPO_GRID_SIZE), |
1261 | maxGridHeight); |
1262 | |
1263 | - int stride = gWindow->vertexBuffer ()->getVertexStride (); |
1264 | - v = gWindow->vertexBuffer ()->getVertices (); |
1265 | + int stride = gWindow->vertexBuffer ()->getVertexStride (); |
1266 | + int oldVCount = gWindow->vertexBuffer ()->countVertices (); |
1267 | + GLfloat *v = gWindow->vertexBuffer ()->getVertices (); |
1268 | + |
1269 | v += stride - 3; |
1270 | v += stride * oldVCount; |
1271 | |
1272 | + CompPoint offset; |
1273 | + |
1274 | if (!window->onAllViewports ()) |
1275 | { |
1276 | offset = eScreen->cScreen->windowPaintOffset (); |
1277 | offset = window->getMovementForOffset (offset); |
1278 | } |
1279 | |
1280 | - lastX = -1000000000.0; |
1281 | + float ang; |
1282 | + float lastX = -1000000000.0f; |
1283 | + float lastZ = 0.0f; |
1284 | + const float radSquare = pow (eScreen->curveDistance, 2) + 0.25; |
1285 | |
1286 | - for (i = oldVCount; i < gWindow->vertexBuffer ()->countVertices (); i++) |
1287 | + for (int i = oldVCount; i < gWindow->vertexBuffer ()->countVertices (); ++i) |
1288 | { |
1289 | if (v[0] == lastX) |
1290 | - { |
1291 | v[2] = lastZ; |
1292 | - } |
1293 | else if (v[0] + offset.x () >= -EXPO_GRID_SIZE && |
1294 | v[0] + offset.x () < screen->width () + EXPO_GRID_SIZE) |
1295 | { |
1296 | - ang = (((v[0] + offset.x ()) / (float) screen->width ()) - 0.5); |
1297 | + ang = ((v[0] + offset.x ()) / |
1298 | + static_cast <float> (screen->width ())) - 0.5; |
1299 | ang *= ang; |
1300 | + |
1301 | if (ang < radSquare) |
1302 | { |
1303 | - v[2] = eScreen->curveDistance - sqrt (radSquare - ang); |
1304 | + v[2] = eScreen->curveDistance - sqrt (radSquare - ang); |
1305 | v[2] *= sigmoidProgress (eScreen->expoCam); |
1306 | } |
1307 | } |
1308 | @@ -1362,34 +1385,30 @@ |
1309 | } |
1310 | } |
1311 | else |
1312 | - { |
1313 | gWindow->glAddGeometry (matrices, region, clip, maxGridWidth, maxGridHeight); |
1314 | - } |
1315 | } |
1316 | |
1317 | void |
1318 | -ExpoWindow::glDrawTexture (GLTexture *texture, |
1319 | - const GLMatrix &transform, |
1320 | - const GLWindowPaintAttrib &attrib, |
1321 | - unsigned int mask) |
1322 | +ExpoWindow::glDrawTexture (GLTexture *texture, |
1323 | + const GLMatrix &transform, |
1324 | + const GLWindowPaintAttrib &attrib, |
1325 | + unsigned int mask) |
1326 | { |
1327 | GLWindowPaintAttrib wAttrib (attrib); |
1328 | |
1329 | if (eScreen->expoCam > 0.0) |
1330 | { |
1331 | - wAttrib.opacity *= expoOpacity; |
1332 | + wAttrib.opacity *= expoOpacity; |
1333 | wAttrib.brightness *= eScreen->vpBrightness; |
1334 | wAttrib.saturation *= eScreen->vpSaturation; |
1335 | } |
1336 | |
1337 | - if (eScreen->expoCam > 0.0 && |
1338 | - eScreen->optionGetDeform () == ExpoScreen::DeformCurve && |
1339 | - eScreen->gScreen->lighting () && |
1340 | + if (eScreen->expoCam > 0.0 && |
1341 | + eScreen->optionGetDeform () == ExpoScreen::DeformCurve && |
1342 | + eScreen->gScreen->lighting () && |
1343 | screen->desktopWindowCount ()) |
1344 | { |
1345 | - CompPoint offset; |
1346 | - GLfloat *v; |
1347 | - GLVertexBuffer *vb = gWindow->vertexBuffer (); |
1348 | + CompPoint offset; |
1349 | |
1350 | if (!window->onAllViewports ()) |
1351 | { |
1352 | @@ -1397,20 +1416,23 @@ |
1353 | offset = window->getMovementForOffset (offset); |
1354 | } |
1355 | |
1356 | - int stride = vb->getVertexStride (); |
1357 | - v = vb->getVertices () + stride - 3; |
1358 | + GLVertexBuffer *vb = gWindow->vertexBuffer (); |
1359 | + int stride = vb->getVertexStride (); |
1360 | + GLfloat *v = vb->getVertices () + stride - 3; |
1361 | + GLfloat normal[3]; |
1362 | + int idx; |
1363 | + float x; |
1364 | |
1365 | - for (int i = 0; i < vb->countVertices (); i++) |
1366 | + for (int i = 0; i < vb->countVertices (); ++i) |
1367 | { |
1368 | - float x = (v[0] + offset.x () - screen->width () / 2) * |
1369 | - eScreen->curveAngle / screen->width (); |
1370 | + x = (v[0] + offset.x () - screen->width () / 2) * |
1371 | + eScreen->curveAngle / screen->width (); |
1372 | |
1373 | while (x < 0) |
1374 | x += 360.0; |
1375 | |
1376 | - int idx = floor (x); |
1377 | + idx = floor (x); |
1378 | |
1379 | - GLfloat normal[3]; |
1380 | normal[0] = -eScreen->vpNormals[idx * 3]; |
1381 | normal[1] = eScreen->vpNormals[(idx * 3) + 1]; |
1382 | normal[2] = eScreen->vpNormals[(idx * 3) + 2]; |
1383 | @@ -1439,25 +1461,22 @@ |
1384 | } |
1385 | |
1386 | bool |
1387 | -ExpoWindow::glPaint (const GLWindowPaintAttrib& attrib, |
1388 | - const GLMatrix& transform, |
1389 | - const CompRegion& region, |
1390 | - unsigned int mask) |
1391 | +ExpoWindow::glPaint (const GLWindowPaintAttrib &attrib, |
1392 | + const GLMatrix &transform, |
1393 | + const CompRegion ®ion, |
1394 | + unsigned int mask) |
1395 | { |
1396 | if (eScreen->expoActive) |
1397 | { |
1398 | - float opacity = 1.0; |
1399 | - bool hide; |
1400 | - bool zoomAnim; |
1401 | - |
1402 | - zoomAnim = eScreen->optionGetExpoAnimation () == |
1403 | - ExpoScreen::ExpoAnimationZoom; |
1404 | - hide = eScreen->optionGetHideDocks () && |
1405 | - (window->wmType () & CompWindowTypeDockMask); |
1406 | - |
1407 | if (eScreen->expoCam > 0.0) |
1408 | mask |= PAINT_WINDOW_TRANSLUCENT_MASK; |
1409 | |
1410 | + float opacity = 1.0; |
1411 | + bool zoomAnim = eScreen->optionGetExpoAnimation () == |
1412 | + ExpoScreen::ExpoAnimationZoom; |
1413 | + bool hide = eScreen->optionGetHideDocks () && |
1414 | + (window->wmType () & CompWindowTypeDockMask); |
1415 | + |
1416 | if (!zoomAnim) |
1417 | opacity = attrib.opacity * eScreen->expoCam; |
1418 | |
1419 | @@ -1479,7 +1498,7 @@ |
1420 | |
1421 | bool |
1422 | ExpoWindow::damageRect (bool initial, |
1423 | - const CompRect& rect) |
1424 | + const CompRect &rect) |
1425 | { |
1426 | if (eScreen->expoCam > 0.0f) |
1427 | eScreen->cScreen->damageScreen (); |
1428 | @@ -1497,21 +1516,21 @@ |
1429 | ExpoScreen::ExpoScreen (CompScreen *s) : |
1430 | PluginClassHandler<ExpoScreen, CompScreen> (s), |
1431 | ExpoOptions (), |
1432 | - cScreen (CompositeScreen::get (s)), |
1433 | - gScreen (GLScreen::get (s)), |
1434 | - expoCam (0.0f), |
1435 | - expoActive (false), |
1436 | - expoMode (false), |
1437 | - dndState (DnDNone), |
1438 | - dndWindow (NULL), |
1439 | - origVp (s->vp ()), |
1440 | - selectedVp (s->vp ()), |
1441 | - lastSelectedVp (s->vp ()), |
1442 | - vpUpdateMode (VPUpdateNone), |
1443 | - clickTime (0), |
1444 | - doubleClick (false), |
1445 | - vpNormals (360 * 3), |
1446 | - grabIndex (0), |
1447 | + cScreen (CompositeScreen::get (s)), |
1448 | + gScreen (GLScreen::get (s)), |
1449 | + expoCam (0.0f), |
1450 | + expoActive (false), |
1451 | + expoMode (false), |
1452 | + dndState (DnDNone), |
1453 | + dndWindow (NULL), |
1454 | + origVp (s->vp ()), |
1455 | + selectedVp (s->vp ()), |
1456 | + lastSelectedVp (s->vp ()), |
1457 | + vpUpdateMode (VPUpdateNone), |
1458 | + clickTime (0), |
1459 | + doubleClick (false), |
1460 | + vpNormals (360 * 3), |
1461 | + grabIndex (0), |
1462 | mGlowTextureProperties (&glowTextureProperties) |
1463 | { |
1464 | leftKey = XKeysymToKeycode (s->dpy (), XStringToKeysym ("Left")); |
1465 | @@ -1552,11 +1571,11 @@ |
1466 | |
1467 | ExpoWindow::ExpoWindow (CompWindow *w) : |
1468 | PluginClassHandler<ExpoWindow, CompWindow> (w), |
1469 | - window (w), |
1470 | - cWindow (CompositeWindow::get (w)), |
1471 | - gWindow (GLWindow::get (w)), |
1472 | - eScreen (ExpoScreen::get (screen)), |
1473 | - mGlowQuads (NULL), |
1474 | + window (w), |
1475 | + cWindow (CompositeWindow::get (w)), |
1476 | + gWindow (GLWindow::get (w)), |
1477 | + eScreen (ExpoScreen::get (screen)), |
1478 | + mGlowQuads (NULL), |
1479 | expoOpacity (1.0f) |
1480 | { |
1481 | CompositeWindowInterface::setHandler (cWindow, false); |
1482 | |
1483 | === modified file 'plugins/expo/src/expo.h' |
1484 | --- plugins/expo/src/expo.h 2012-11-26 07:13:04 +0000 |
1485 | +++ plugins/expo/src/expo.h 2013-06-16 12:25:34 +0000 |
1486 | @@ -40,20 +40,30 @@ |
1487 | public ExpoOptions |
1488 | { |
1489 | public: |
1490 | + |
1491 | ExpoScreen (CompScreen *); |
1492 | ~ExpoScreen (); |
1493 | |
1494 | void handleEvent (XEvent *); |
1495 | |
1496 | void preparePaint (int); |
1497 | - void paint (CompOutput::ptrList&, unsigned int); |
1498 | + |
1499 | + void paint (CompOutput::ptrList &, |
1500 | + unsigned int ); |
1501 | + |
1502 | void donePaint (); |
1503 | |
1504 | - bool glPaintOutput (const GLScreenPaintAttrib&, const GLMatrix&, |
1505 | - const CompRegion&, CompOutput *, unsigned int); |
1506 | - void glPaintTransformedOutput (const GLScreenPaintAttrib&, |
1507 | - const GLMatrix&, const CompRegion&, |
1508 | - CompOutput *, unsigned int); |
1509 | + bool glPaintOutput (const GLScreenPaintAttrib &, |
1510 | + const GLMatrix &, |
1511 | + const CompRegion &, |
1512 | + CompOutput *, |
1513 | + unsigned int ); |
1514 | + |
1515 | + void glPaintTransformedOutput (const GLScreenPaintAttrib &, |
1516 | + const GLMatrix &, |
1517 | + const CompRegion &, |
1518 | + CompOutput *, |
1519 | + unsigned int ); |
1520 | |
1521 | bool dndInit (CompAction *, CompAction::State, CompOption::Vector&); |
1522 | bool dndFini (CompAction *, CompAction::State, CompOption::Vector&); |
1523 | @@ -63,71 +73,81 @@ |
1524 | bool nextVp (CompAction *, CompAction::State, CompOption::Vector&); |
1525 | bool prevVp (CompAction *, CompAction::State, CompOption::Vector&); |
1526 | |
1527 | - typedef enum { |
1528 | + typedef enum |
1529 | + { |
1530 | DnDNone, |
1531 | DnDDuring, |
1532 | DnDStart |
1533 | } DnDState; |
1534 | |
1535 | - typedef enum { |
1536 | + typedef enum |
1537 | + { |
1538 | VPUpdateNone, |
1539 | VPUpdateMouseOver, |
1540 | VPUpdatePrevious |
1541 | } VPUpdateMode; |
1542 | |
1543 | - CompositeScreen *cScreen; |
1544 | - GLScreen *gScreen; |
1545 | - |
1546 | - float expoCam; |
1547 | - bool expoActive; |
1548 | - bool expoMode; |
1549 | - |
1550 | - DnDState dndState; |
1551 | - CompWindow *dndWindow; |
1552 | - |
1553 | - CompPoint prevCursor; |
1554 | - CompPoint newCursor; |
1555 | - CompPoint prevClickPoint; |
1556 | - |
1557 | - CompPoint origVp; |
1558 | - CompPoint selectedVp; |
1559 | - CompPoint lastSelectedVp; |
1560 | - CompPoint paintingVp; |
1561 | - |
1562 | - std::vector<float> vpActivity; |
1563 | - float vpBrightness; |
1564 | - float vpSaturation; |
1565 | - |
1566 | - VPUpdateMode vpUpdateMode; |
1567 | - |
1568 | - bool anyClick; |
1569 | - unsigned int clickTime; |
1570 | - bool doubleClick; |
1571 | - |
1572 | - CompRegion tmpRegion; |
1573 | - |
1574 | - float curveAngle; |
1575 | - float curveDistance; |
1576 | - float curveRadius; |
1577 | - |
1578 | - std::vector<GLfloat> vpNormals; |
1579 | - |
1580 | - CompScreen::GrabHandle grabIndex; |
1581 | - |
1582 | - GLTexture::List outline_texture; |
1583 | - CompSize outline_texture_size; |
1584 | + CompositeScreen *cScreen; |
1585 | + GLScreen *gScreen; |
1586 | + |
1587 | + float expoCam; |
1588 | + bool expoActive; |
1589 | + bool expoMode; |
1590 | + |
1591 | + DnDState dndState; |
1592 | + CompWindow *dndWindow; |
1593 | + |
1594 | + CompPoint prevCursor; |
1595 | + CompPoint newCursor; |
1596 | + CompPoint prevClickPoint; |
1597 | + |
1598 | + CompPoint origVp; |
1599 | + CompPoint selectedVp; |
1600 | + CompPoint lastSelectedVp; |
1601 | + CompPoint paintingVp; |
1602 | + |
1603 | + std::vector<float> vpActivity; |
1604 | + float vpBrightness; |
1605 | + float vpSaturation; |
1606 | + |
1607 | + VPUpdateMode vpUpdateMode; |
1608 | + |
1609 | + bool anyClick; |
1610 | + unsigned int clickTime; |
1611 | + bool doubleClick; |
1612 | + |
1613 | + CompRegion tmpRegion; |
1614 | + |
1615 | + float curveAngle; |
1616 | + float curveDistance; |
1617 | + float curveRadius; |
1618 | + |
1619 | + std::vector<GLfloat> vpNormals; |
1620 | + |
1621 | + CompScreen::GrabHandle grabIndex; |
1622 | + |
1623 | + GLTexture::List outline_texture; |
1624 | + CompSize outline_texture_size; |
1625 | |
1626 | const GlowTextureProperties *mGlowTextureProperties; |
1627 | |
1628 | private: |
1629 | + |
1630 | void moveFocusViewport (int, int); |
1631 | void finishWindowMovement (); |
1632 | void updateWraps (bool); |
1633 | |
1634 | - void invertTransformedVertex (const GLScreenPaintAttrib&, |
1635 | - const GLMatrix&, CompOutput *, int[2]); |
1636 | - void paintWall (const GLScreenPaintAttrib&, const GLMatrix&, |
1637 | - const CompRegion&, CompOutput *, unsigned int, bool); |
1638 | + void invertTransformedVertex (const GLScreenPaintAttrib &, |
1639 | + const GLMatrix &, |
1640 | + CompOutput *, |
1641 | + int[2] ); |
1642 | + |
1643 | + void paintWall (const GLScreenPaintAttrib &, |
1644 | + const GLMatrix &, |
1645 | + const CompRegion &, |
1646 | + CompOutput *, |
1647 | + unsigned int , |
1648 | + bool ); |
1649 | |
1650 | KeyCode leftKey; |
1651 | KeyCode rightKey; |
1652 | @@ -143,25 +163,39 @@ |
1653 | public PluginClassHandler<ExpoWindow, CompWindow> |
1654 | { |
1655 | public: |
1656 | + |
1657 | ExpoWindow (CompWindow *); |
1658 | ~ExpoWindow (); |
1659 | |
1660 | - bool damageRect (bool, const CompRect&); |
1661 | - |
1662 | - bool glDraw (const GLMatrix&, const GLWindowPaintAttrib&, |
1663 | - const CompRegion&, unsigned int); |
1664 | - bool glPaint (const GLWindowPaintAttrib&, const GLMatrix&, |
1665 | - const CompRegion&, unsigned int); |
1666 | - void glAddGeometry (const GLTexture::MatrixList&, |
1667 | - const CompRegion&, const CompRegion&, |
1668 | - unsigned int, unsigned int); |
1669 | - void glDrawTexture (GLTexture*, const GLMatrix&, |
1670 | - const GLWindowPaintAttrib&, unsigned int); |
1671 | + bool damageRect (bool , |
1672 | + const CompRect &); |
1673 | + |
1674 | + bool glDraw (const GLMatrix &, |
1675 | + const GLWindowPaintAttrib &, |
1676 | + const CompRegion &, |
1677 | + unsigned int ); |
1678 | + |
1679 | + bool glPaint (const GLWindowPaintAttrib &, |
1680 | + const GLMatrix &, |
1681 | + const CompRegion &, |
1682 | + unsigned int ); |
1683 | + |
1684 | + void glAddGeometry (const GLTexture::MatrixList &, |
1685 | + const CompRegion &, |
1686 | + const CompRegion &, |
1687 | + unsigned int , |
1688 | + unsigned int ); |
1689 | + |
1690 | + void glDrawTexture (GLTexture *, |
1691 | + const GLMatrix &, |
1692 | + const GLWindowPaintAttrib &, |
1693 | + unsigned int ); |
1694 | + |
1695 | void |
1696 | paintGlow (const GLMatrix &transform, |
1697 | - const GLWindowPaintAttrib &attrib, |
1698 | - const CompRegion &paintRegion, |
1699 | - unsigned int mask); |
1700 | + const GLWindowPaintAttrib &attrib, |
1701 | + const CompRegion &paintRegion, |
1702 | + unsigned int mask); |
1703 | |
1704 | void |
1705 | computeGlowQuads (GLTexture::Matrix *matrix); |
1706 | @@ -172,14 +206,15 @@ |
1707 | ExpoScreen *eScreen; |
1708 | |
1709 | private: |
1710 | - GlowQuad *mGlowQuads; |
1711 | - float expoOpacity; |
1712 | + |
1713 | + GlowQuad *mGlowQuads; |
1714 | + float expoOpacity; |
1715 | }; |
1716 | |
1717 | class ExpoPluginVTable : |
1718 | public CompPlugin::VTableForScreenAndWindow<ExpoScreen, ExpoWindow> |
1719 | { |
1720 | public: |
1721 | + |
1722 | bool init (); |
1723 | }; |
1724 | - |
1725 | |
1726 | === modified file 'plugins/expo/src/glow.cpp' |
1727 | --- plugins/expo/src/glow.cpp 2013-02-03 18:19:21 +0000 |
1728 | +++ plugins/expo/src/glow.cpp 2013-06-16 12:25:34 +0000 |
1729 | @@ -27,14 +27,8 @@ |
1730 | #include "expo.h" |
1731 | #include "group_glow.h" |
1732 | |
1733 | -#define WIN_REAL_X(w) (w->x () - w->border ().left) |
1734 | -#define WIN_REAL_Y(w) (w->y () - w->border ().top) |
1735 | -#define WIN_REAL_WIDTH(w) (w->width () + 2 * w->geometry ().border () + \ |
1736 | - w->border ().left + w->border ().right) |
1737 | -#define WIN_REAL_HEIGHT(w) (w->height () + 2 * w->geometry ().border () + \ |
1738 | - w->border ().top + w->border ().bottom) |
1739 | - |
1740 | -const GlowTextureProperties glowTextureProperties = { |
1741 | +const GlowTextureProperties glowTextureProperties = |
1742 | +{ |
1743 | /* GlowTextureRectangular */ |
1744 | glowTexRect, 32, 21 |
1745 | }; |
1746 | @@ -43,22 +37,21 @@ |
1747 | * GroupWindow::paintGlow |
1748 | * |
1749 | * Takes our glow texture, stretches the appropriate positions in the glow texture, |
1750 | - * adds those geometries (so plugins like wobby and deform this texture correctly) |
1751 | + * adds those geometries (so plugins like wobby deform this texture correctly) |
1752 | * and then draws the glow texture with this geometry (plugins like wobbly and friends |
1753 | * will automatically deform the texture based on our set geometry) |
1754 | */ |
1755 | |
1756 | void |
1757 | ExpoWindow::paintGlow (const GLMatrix &transform, |
1758 | - const GLWindowPaintAttrib &attrib, |
1759 | - const CompRegion &paintRegion, |
1760 | - unsigned int mask) |
1761 | + const GLWindowPaintAttrib &attrib, |
1762 | + const CompRegion &paintRegion, |
1763 | + unsigned int mask) |
1764 | { |
1765 | CompRegion reg; |
1766 | - int i; |
1767 | GLushort colorData[4]; |
1768 | const GLushort *selColorData = ExpoScreen::get (screen)->optionGetSelectedColor (); |
1769 | - float alpha = (float) selColorData[3] / 65535.0f; |
1770 | + float alpha = static_cast <float> (selColorData[3] / 65535.0f); |
1771 | |
1772 | /* Premultiply color */ |
1773 | colorData[0] = selColorData[0] * alpha; |
1774 | @@ -71,7 +64,7 @@ |
1775 | /* There are 8 glow parts of the glow texture which we wish to paint |
1776 | * separately with different transformations |
1777 | */ |
1778 | - for (i = 0; i < NUM_GLOWQUADS; i++) |
1779 | + for (int i = 0; i < NUM_GLOWQUADS; ++i) |
1780 | { |
1781 | /* Using precalculated quads here */ |
1782 | reg = CompRegion (mGlowQuads[i].mBox); |
1783 | @@ -87,8 +80,9 @@ |
1784 | |
1785 | matl.push_back (mGlowQuads[i].mMatrix); |
1786 | /* Add color data for all 6 vertices of the quad */ |
1787 | - for (int n = 0; n < 6; n++) |
1788 | + for (int n = 0; n < 6; ++n) |
1789 | gWindow->vertexBuffer ()->addColors (1, colorData); |
1790 | + |
1791 | gWindow->glAddGeometry (matl, reg, paintRegion); |
1792 | } |
1793 | } |
1794 | @@ -116,7 +110,7 @@ |
1795 | /* |
1796 | * ExpoWindow::computeGlowQuads |
1797 | * |
1798 | - * This function computures the matrix transformation required for each |
1799 | + * This function computes the matrix transformation required for each |
1800 | * part of the glow texture which we wish to stretch to some rectangular |
1801 | * dimensions |
1802 | * |
1803 | @@ -153,12 +147,6 @@ |
1804 | void |
1805 | ExpoWindow::computeGlowQuads (GLTexture::Matrix *matrix) |
1806 | { |
1807 | - CompRect *box; |
1808 | - int x1, x2, y1, y2; |
1809 | - GLTexture::Matrix *quadMatrix; |
1810 | - int glowSize, glowOffset; |
1811 | - CompWindow *w = window; |
1812 | - |
1813 | /* Passing NULL to this function frees the glow quads |
1814 | * (so the window is not painted with glow) */ |
1815 | |
1816 | @@ -166,6 +154,7 @@ |
1817 | { |
1818 | if (!mGlowQuads) |
1819 | mGlowQuads = new GlowQuad[NUM_GLOWQUADS]; |
1820 | + |
1821 | if (!mGlowQuads) |
1822 | return; |
1823 | } |
1824 | @@ -176,23 +165,49 @@ |
1825 | delete[] mGlowQuads; |
1826 | mGlowQuads = NULL; |
1827 | } |
1828 | + |
1829 | return; |
1830 | } |
1831 | |
1832 | - glowSize = 48; |
1833 | - glowOffset = (glowSize * ExpoScreen::get (screen)->mGlowTextureProperties->glowOffset / |
1834 | - ExpoScreen::get (screen)->mGlowTextureProperties->textureSize) + 1; |
1835 | + /* TODO: Make glowSize configurable via CCSM */ |
1836 | + int glowSize = 48; |
1837 | + int glowOffset = (glowSize * ExpoScreen::get (screen)->mGlowTextureProperties->glowOffset / |
1838 | + ExpoScreen::get (screen)->mGlowTextureProperties->textureSize) + 1; |
1839 | |
1840 | /* Top left corner */ |
1841 | - box = &mGlowQuads[GLOWQUAD_TOPLEFT].mBox; |
1842 | + CompRect *box = &mGlowQuads[GLOWQUAD_TOPLEFT].mBox; |
1843 | mGlowQuads[GLOWQUAD_TOPLEFT].mMatrix = *matrix; |
1844 | - quadMatrix = &mGlowQuads[GLOWQUAD_TOPLEFT].mMatrix; |
1845 | + GLTexture::Matrix *quadMatrix = &mGlowQuads[GLOWQUAD_TOPLEFT].mMatrix; |
1846 | + |
1847 | + /* Precalculate some values we need multiple times */ |
1848 | + |
1849 | + CompWindow *w = window; |
1850 | + |
1851 | + int winRealX = w->x () - w->border ().left; |
1852 | + int winRealY = w->y () - w->border ().top; |
1853 | |
1854 | /* Set the desired rect dimensions |
1855 | * for the part of the glow we are painting */ |
1856 | |
1857 | - x1 = WIN_REAL_X (w) - glowSize + glowOffset; |
1858 | - y1 = WIN_REAL_Y (w) - glowSize + glowOffset; |
1859 | + int x1 = winRealX - glowSize + glowOffset; |
1860 | + int y1 = winRealY - glowSize + glowOffset; |
1861 | + |
1862 | + int winRealWidth = w->geometry ().widthIncBorders (); |
1863 | + int winRealHeight = w->geometry ().heightIncBorders (); |
1864 | + |
1865 | + int halfWinRealWidth = winRealWidth / 2; |
1866 | + int halfWinRealHeight = winRealHeight / 2; |
1867 | + |
1868 | + int xPlusHalfWidth = winRealX + halfWinRealWidth; |
1869 | + int yPlusHalfHeight = winRealY + halfWinRealHeight; |
1870 | + |
1871 | + int xPlusGlowOff = winRealX + glowOffset; |
1872 | + int yPlusGlowOff = winRealY + glowOffset; |
1873 | + |
1874 | + int xMinusGlowOff = winRealX - glowOffset; |
1875 | + int yMinusGlowOff = winRealY - glowOffset; |
1876 | + |
1877 | + float glowPart = 1.0f / glowSize; |
1878 | |
1879 | /* 2x2 Matrix here, adjust both x and y scale factors |
1880 | * and the x and y position |
1881 | @@ -205,15 +220,14 @@ |
1882 | * multiplied by the scale factors |
1883 | */ |
1884 | |
1885 | - quadMatrix->xx = 1.0f / glowSize; |
1886 | - quadMatrix->yy = 1.0f / (glowSize); |
1887 | + quadMatrix->xx = quadMatrix->yy = glowPart; |
1888 | quadMatrix->x0 = -(x1 * quadMatrix->xx); |
1889 | quadMatrix->y0 = -(y1 * quadMatrix->yy); |
1890 | |
1891 | - x2 = MIN (WIN_REAL_X (w) + glowOffset, |
1892 | - WIN_REAL_X (w) + (WIN_REAL_WIDTH (w) / 2)); |
1893 | - y2 = MIN (WIN_REAL_Y (w) + glowOffset, |
1894 | - WIN_REAL_Y (w) + (WIN_REAL_HEIGHT (w) / 2)); |
1895 | + int x2 = MIN (xPlusGlowOff, |
1896 | + xPlusHalfWidth); |
1897 | + int y2 = MIN (yPlusGlowOff, |
1898 | + yPlusHalfHeight); |
1899 | |
1900 | *box = CompRect (x1, y1, x2 - x1, y2 - y1); |
1901 | |
1902 | @@ -225,9 +239,9 @@ |
1903 | /* Set the desired rect dimensions |
1904 | * for the part of the glow we are painting */ |
1905 | |
1906 | - x1 = WIN_REAL_X (w) + WIN_REAL_WIDTH (w) - glowOffset; |
1907 | - y1 = WIN_REAL_Y (w) - glowSize + glowOffset; |
1908 | - x2 = WIN_REAL_X (w) + WIN_REAL_WIDTH (w) + glowSize - glowOffset; |
1909 | + x1 = xMinusGlowOff + winRealWidth; |
1910 | + y1 = yPlusGlowOff - glowSize; |
1911 | + x2 = x1 + glowSize; |
1912 | |
1913 | /* 2x2 Matrix here, adjust both x and y scale factors |
1914 | * and the x and y position |
1915 | @@ -242,15 +256,15 @@ |
1916 | * need the inverse of that which is 1 - x1 * xx |
1917 | */ |
1918 | |
1919 | - quadMatrix->xx = -1.0f / glowSize; |
1920 | - quadMatrix->yy = 1.0f / glowSize; |
1921 | - quadMatrix->x0 = 1.0 - (x1 * quadMatrix->xx); |
1922 | + quadMatrix->xx = -glowPart; |
1923 | + quadMatrix->yy = glowPart; |
1924 | + quadMatrix->x0 = 1.0 - (x1 * quadMatrix->xx); |
1925 | quadMatrix->y0 = -(y1 * quadMatrix->yy); |
1926 | |
1927 | - x1 = MAX (WIN_REAL_X (w) + WIN_REAL_WIDTH (w) - glowOffset, |
1928 | - WIN_REAL_X (w) + (WIN_REAL_WIDTH (w) / 2)); |
1929 | - y2 = MIN (WIN_REAL_Y (w) + glowOffset, |
1930 | - WIN_REAL_Y (w) + (WIN_REAL_HEIGHT (w) / 2)); |
1931 | + x1 = MAX (xMinusGlowOff + winRealWidth, |
1932 | + xPlusHalfWidth); |
1933 | + y2 = MIN (yPlusGlowOff, |
1934 | + yPlusHalfHeight); |
1935 | |
1936 | *box = CompRect (x1, y1, x2 - x1, y2 - y1); |
1937 | |
1938 | @@ -259,10 +273,10 @@ |
1939 | mGlowQuads[GLOWQUAD_BOTTOMLEFT].mMatrix = *matrix; |
1940 | quadMatrix = &mGlowQuads[GLOWQUAD_BOTTOMLEFT].mMatrix; |
1941 | |
1942 | - x1 = WIN_REAL_X (w) - glowSize + glowOffset; |
1943 | - y1 = WIN_REAL_Y (w) + WIN_REAL_HEIGHT (w) - glowOffset; |
1944 | - /* x2 = WIN_REAL_X (w) + glowOffset; */ |
1945 | - y2 = WIN_REAL_Y (w) + WIN_REAL_HEIGHT (w) + glowSize - glowOffset; |
1946 | + x1 = xPlusGlowOff - glowSize; |
1947 | + y1 = yMinusGlowOff + winRealHeight; |
1948 | + /* x2 = xPlusGlowOff; */ |
1949 | + y2 = yMinusGlowOff + winRealHeight + glowSize; |
1950 | |
1951 | /* 2x2 Matrix here, adjust both x and y scale factors |
1952 | * and the x and y position |
1953 | @@ -277,15 +291,15 @@ |
1954 | * need the inverse of that which is 1 - y1 * yy |
1955 | */ |
1956 | |
1957 | - quadMatrix->xx = 1.0f / glowSize; |
1958 | - quadMatrix->yy = -1.0f / glowSize; |
1959 | + quadMatrix->xx = glowPart; |
1960 | + quadMatrix->yy = -glowPart; |
1961 | quadMatrix->x0 = -(x1 * quadMatrix->xx); |
1962 | quadMatrix->y0 = 1.0f - (y1 * quadMatrix->yy); |
1963 | |
1964 | - y1 = MAX (WIN_REAL_Y (w) + WIN_REAL_HEIGHT (w) - glowOffset, |
1965 | - WIN_REAL_Y (w) + (WIN_REAL_HEIGHT (w) / 2)); |
1966 | - x2 = MIN (WIN_REAL_X (w) + glowOffset, |
1967 | - WIN_REAL_X (w) + (WIN_REAL_WIDTH (w) / 2)); |
1968 | + y1 = MAX (winRealY + winRealHeight - glowOffset, |
1969 | + yPlusHalfHeight); |
1970 | + x2 = MIN (xPlusGlowOff, |
1971 | + xPlusHalfWidth); |
1972 | |
1973 | *box = CompRect (x1, y1, x2 - x1, y2 - y1); |
1974 | |
1975 | @@ -294,10 +308,10 @@ |
1976 | mGlowQuads[GLOWQUAD_BOTTOMRIGHT].mMatrix = *matrix; |
1977 | quadMatrix = &mGlowQuads[GLOWQUAD_BOTTOMRIGHT].mMatrix; |
1978 | |
1979 | - x1 = WIN_REAL_X (w) + WIN_REAL_WIDTH (w) - glowOffset; |
1980 | - y1 = WIN_REAL_Y (w) + WIN_REAL_HEIGHT (w) - glowOffset; |
1981 | - x2 = WIN_REAL_X (w) + WIN_REAL_WIDTH (w) + glowSize - glowOffset; |
1982 | - y2 = WIN_REAL_Y (w) + WIN_REAL_HEIGHT (w) + glowSize - glowOffset; |
1983 | + x1 = xMinusGlowOff + winRealWidth; |
1984 | + y1 = yMinusGlowOff + winRealHeight; |
1985 | + x2 = x1 + glowSize; |
1986 | + y2 = y1 + glowSize; |
1987 | |
1988 | /* 2x2 Matrix here, adjust both x and y scale factors |
1989 | * and the x and y position |
1990 | @@ -310,15 +324,15 @@ |
1991 | * multiplied by the scale factors |
1992 | */ |
1993 | |
1994 | - quadMatrix->xx = -1.0f / glowSize; |
1995 | - quadMatrix->yy = -1.0f / glowSize; |
1996 | + quadMatrix->xx = -glowPart; |
1997 | + quadMatrix->yy = -glowPart; |
1998 | quadMatrix->x0 = 1.0 - (x1 * quadMatrix->xx); |
1999 | quadMatrix->y0 = 1.0 - (y1 * quadMatrix->yy); |
2000 | |
2001 | - x1 = MAX (WIN_REAL_X (w) + WIN_REAL_WIDTH (w) - glowOffset, |
2002 | - WIN_REAL_X (w) + (WIN_REAL_WIDTH (w) / 2)); |
2003 | - y1 = MAX (WIN_REAL_Y (w) + WIN_REAL_HEIGHT (w) - glowOffset, |
2004 | - WIN_REAL_Y (w) + (WIN_REAL_HEIGHT (w) / 2)); |
2005 | + x1 = MAX (xMinusGlowOff + winRealWidth, |
2006 | + xPlusHalfWidth); |
2007 | + y1 = MAX (yMinusGlowOff + winRealHeight, |
2008 | + yPlusHalfHeight); |
2009 | |
2010 | *box = CompRect (x1, y1, x2 - x1, y2 - y1); |
2011 | |
2012 | @@ -327,10 +341,10 @@ |
2013 | mGlowQuads[GLOWQUAD_TOP].mMatrix = *matrix; |
2014 | quadMatrix = &mGlowQuads[GLOWQUAD_TOP].mMatrix; |
2015 | |
2016 | - x1 = WIN_REAL_X (w) + glowOffset; |
2017 | - y1 = WIN_REAL_Y (w) - glowSize + glowOffset; |
2018 | - x2 = WIN_REAL_X (w) + WIN_REAL_WIDTH (w) - glowOffset; |
2019 | - y2 = WIN_REAL_Y (w) + glowOffset; |
2020 | + x1 = xPlusGlowOff; |
2021 | + y1 = yPlusGlowOff - glowSize; |
2022 | + x2 = xMinusGlowOff + winRealWidth; |
2023 | + y2 = yPlusGlowOff; |
2024 | |
2025 | /* 2x2 Matrix here, adjust both x and y scale factors |
2026 | * and the x and y position |
2027 | @@ -344,7 +358,7 @@ |
2028 | */ |
2029 | |
2030 | quadMatrix->xx = 0.0f; |
2031 | - quadMatrix->yy = 1.0f / glowSize; |
2032 | + quadMatrix->yy = glowPart; |
2033 | quadMatrix->x0 = 1.0; |
2034 | quadMatrix->y0 = -(y1 * quadMatrix->yy); |
2035 | |
2036 | @@ -355,10 +369,10 @@ |
2037 | mGlowQuads[GLOWQUAD_BOTTOM].mMatrix = *matrix; |
2038 | quadMatrix = &mGlowQuads[GLOWQUAD_BOTTOM].mMatrix; |
2039 | |
2040 | - x1 = WIN_REAL_X (w) + glowOffset; |
2041 | - y1 = WIN_REAL_Y (w) + WIN_REAL_HEIGHT (w) - glowOffset; |
2042 | - x2 = WIN_REAL_X (w) + WIN_REAL_WIDTH (w) - glowOffset; |
2043 | - y2 = WIN_REAL_Y (w) + WIN_REAL_HEIGHT (w) + glowSize - glowOffset; |
2044 | + x1 = xPlusGlowOff; |
2045 | + y1 = yMinusGlowOff + winRealHeight; |
2046 | + x2 = xMinusGlowOff + winRealWidth; |
2047 | + y2 = y1 + glowSize; |
2048 | |
2049 | /* 2x2 Matrix here, adjust both x and y scale factors |
2050 | * and the x and y position |
2051 | @@ -372,7 +386,7 @@ |
2052 | */ |
2053 | |
2054 | quadMatrix->xx = 0.0f; |
2055 | - quadMatrix->yy = -1.0f / glowSize; |
2056 | + quadMatrix->yy = -glowPart; |
2057 | quadMatrix->x0 = 1.0; |
2058 | quadMatrix->y0 = 1.0 - (y1 * quadMatrix->yy); |
2059 | |
2060 | @@ -383,10 +397,10 @@ |
2061 | mGlowQuads[GLOWQUAD_LEFT].mMatrix = *matrix; |
2062 | quadMatrix = &mGlowQuads[GLOWQUAD_LEFT].mMatrix; |
2063 | |
2064 | - x1 = WIN_REAL_X (w) - glowSize + glowOffset; |
2065 | - y1 = WIN_REAL_Y (w) + glowOffset; |
2066 | - x2 = WIN_REAL_X (w) + glowOffset; |
2067 | - y2 = WIN_REAL_Y (w) + WIN_REAL_HEIGHT (w) - glowOffset; |
2068 | + x1 = xPlusGlowOff - glowSize; |
2069 | + y1 = yPlusGlowOff; |
2070 | + x2 = xPlusGlowOff; |
2071 | + y2 = yMinusGlowOff + winRealHeight; |
2072 | |
2073 | /* 2x2 Matrix here, adjust both x and y scale factors |
2074 | * and the x and y position |
2075 | @@ -399,7 +413,7 @@ |
2076 | * multiplied by the scale factors |
2077 | */ |
2078 | |
2079 | - quadMatrix->xx = 1.0f / glowSize; |
2080 | + quadMatrix->xx = glowPart; |
2081 | quadMatrix->yy = 0.0f; |
2082 | quadMatrix->x0 = -(x1 * quadMatrix->xx); |
2083 | quadMatrix->y0 = 1.0; |
2084 | @@ -411,10 +425,10 @@ |
2085 | mGlowQuads[GLOWQUAD_RIGHT].mMatrix = *matrix; |
2086 | quadMatrix = &mGlowQuads[GLOWQUAD_RIGHT].mMatrix; |
2087 | |
2088 | - x1 = WIN_REAL_X (w) + WIN_REAL_WIDTH (w) - glowOffset; |
2089 | - y1 = WIN_REAL_Y (w) + glowOffset; |
2090 | - x2 = WIN_REAL_X (w) + WIN_REAL_WIDTH (w) + glowSize - glowOffset; |
2091 | - y2 = WIN_REAL_Y (w) + WIN_REAL_HEIGHT (w) - glowOffset; |
2092 | + x1 = xMinusGlowOff + winRealWidth; |
2093 | + y1 = yPlusGlowOff; |
2094 | + x2 = xMinusGlowOff + winRealWidth + glowSize; |
2095 | + y2 = yMinusGlowOff + winRealHeight; |
2096 | |
2097 | /* 2x2 Matrix here, adjust both x and y scale factors |
2098 | * and the x and y position |
2099 | @@ -427,7 +441,7 @@ |
2100 | * multiplied by the scale factors |
2101 | */ |
2102 | |
2103 | - quadMatrix->xx = -1.0f / glowSize; |
2104 | + quadMatrix->xx = -glowPart; |
2105 | quadMatrix->yy = 0.0f; |
2106 | quadMatrix->x0 = 1.0 - (x1 * quadMatrix->xx); |
2107 | quadMatrix->y0 = 1.0; |
2108 | |
2109 | === modified file 'plugins/expo/src/glow.h' |
2110 | --- plugins/expo/src/glow.h 2012-11-23 08:20:42 +0000 |
2111 | +++ plugins/expo/src/glow.h 2013-06-16 12:25:34 +0000 |
2112 | @@ -42,7 +42,8 @@ |
2113 | * and the size of the texture |
2114 | */ |
2115 | |
2116 | -typedef struct _GlowTextureProperties { |
2117 | +typedef struct _GlowTextureProperties |
2118 | +{ |
2119 | char *textureData; |
2120 | int textureSize; |
2121 | int glowOffset; |
2122 | @@ -55,9 +56,11 @@ |
2123 | * the quad on the glow |
2124 | */ |
2125 | |
2126 | -class GlowQuad { |
2127 | +class GlowQuad |
2128 | +{ |
2129 | public: |
2130 | - CompRect mBox; |
2131 | + |
2132 | + CompRect mBox; |
2133 | GLTexture::Matrix mMatrix; |
2134 | }; |
2135 | |
2136 | |
2137 | === modified file 'plugins/expo/src/wall_offset/src/wall-offset.cpp' |
2138 | --- plugins/expo/src/wall_offset/src/wall-offset.cpp 2012-11-23 09:07:48 +0000 |
2139 | +++ plugins/expo/src/wall_offset/src/wall-offset.cpp 2013-06-16 12:25:34 +0000 |
2140 | @@ -32,10 +32,10 @@ |
2141 | float &worldScaleFactorY, |
2142 | float animationProgress) |
2143 | { |
2144 | - const float sx = screenSize.width () / static_cast <float> (output.width ()); |
2145 | - const float sy = screenSize.height () / static_cast <float> (output.height ()); |
2146 | - offsetInWorldX = 0.0; |
2147 | - offsetInWorldY = 0.0; |
2148 | + const float sx = screenSize.width () / static_cast <float> (output.width ()); |
2149 | + const float sy = screenSize.height () / static_cast <float> (output.height ()); |
2150 | + offsetInWorldX = 0.0; |
2151 | + offsetInWorldY = 0.0; |
2152 | worldScaleFactorX = 1.0f; |
2153 | worldScaleFactorY = 1.0f; |
2154 |
506 - int width = outputs.front ()->width (); utputMode () == MultioutputMode OneBigWall &&
507 - int height = outputs.front ()->height ();
508 - bool sizeDiff = false;
509 -
510 - /* "One big wall" does not make sense where outputs are different
511 - * sizes, so force multiple walls in this case
512 - *
513 - * TODO: Is it possible to re-create "one big wall" using
514 - * independent output painting in this case? */
515 -
516 - foreach (CompOutput *o, outputs)
517 - {
518 - if (o->width () != width || o->height () != height)
519 - {
520 - sizeDiff = true;
521 - break;
522 - }
523 - }
524 -
525 - if (expoCam > 0.0 && outputs.size () > 1 &&
526 - optionGetMultio
527 - !sizeDiff)
> Do not force "One wall per output" on the user, if his displays use different
> resolutions.
> "One big wall" makes a lot of sense for many multi-screen configs, where not
> all of the screens have exactly the same resolution, so if the user explicitely
> chooses this mode, Compiz should respect the user's choice.
"One big wall" is currently the default behavior which makes some sense so long as the screens have exactly the same resolution. Its *completely* broken for multimonitor configurations with different resolutions. There's just no sane way to line the views up so that they look correctly when the wall is only rendered in one pass. This change should be reverted.
I even have misgivings about the way that it works on multimonitor configurations where you have the same resolution and a number of viewports that is not evenly divisible amongst the monitors. It results in confusing situations where viewports end up partially on one monitor and partially on another and does not make for a good user experience.
328 + if (event- >xkey.keycode == leftKey) >xkey.keycode == rightKey)
329 + moveFocusViewport (-1, 0);
330 + else if (event-
331 + moveFocusViewport (1, 0);
This is alignment- formatting taken to its extreme. Alignment can sometimes aid readability but it should be used judiciously and not inflexibly. This just makes the code unreadable. There is no reason why there should be that much whitespace between an if and brackets.
358 + (unsigned int)optionGetDo ubleClickTime ()
There should be a space between the cast or better yet a static_cast <unsigned int> ()
368 + prevClickPoint = CompPoint( event-> xbutton. x, event->xbutton.y);
Extra whitespace required.
395 + /* TODO: What action to take if expo_key is not defined ? */
An action is always bound to it. That's different from whether or not a keybinding is assigned. This todo is inaccurate.
449 + const int scw = screen->width ();
That variable should be renamed to "screenWidth" - "scw" is ambiguous.
448 + const float mpi = M_PI / 180.0f;
This should be renamed degreesToRadians
475 + screen- >handleEventSet Enabled (this, enable); >preparePaintSe tEnabled (this, enable); >paintSetEnable d (this, enable); >donePaintSetEn abled (this, enable); >glPaintOutputS etEnabled (this, enable);
476 + cScreen-
477 + cScreen-
478 + cScreen-
479 + gScreen-
480 ...