Merge lp:~mc-return/compiz/compiz.merge-ezoom-cleanup into lp:compiz/0.9.10
- compiz.merge-ezoom-cleanup
- Merge into 0.9.10
Status: | Merged |
---|---|
Approved by: | Sam Spilsbury |
Approved revision: | 3673 |
Merged at revision: | 3705 |
Proposed branch: | lp:~mc-return/compiz/compiz.merge-ezoom-cleanup |
Merge into: | lp:compiz/0.9.10 |
Diff against target: |
1868 lines (+488/-445) 4 files modified
debian/patches/ubuntu-config.patch (+38/-35) plugins/ezoom/ezoom.xml.in (+31/-10) plugins/ezoom/src/ezoom.cpp (+401/-385) plugins/ezoom/src/ezoom.h (+18/-15) |
To merge this branch: | bzr merge lp:~mc-return/compiz/compiz.merge-ezoom-cleanup |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
PS Jenkins bot (community) | continuous-integration | Approve | |
Sam Spilsbury | Approve | ||
MC Return | Needs Resubmitting | ||
Review via email: mp+159991@code.launchpad.net |
Commit message
*EZoom (Enhanced Zoom Desktop) code cleanup:
Optimized ABI check.
Use prefix- instead of postfix-increment.
Assignment and declaration of local variables in one line.
Merged if statements.
Removed redundant brackets.
Fixed indentation.
Added and removed newlines to improve readability.
*EZoom (Enhanced Zoom Desktop) code changes:
Replaced #define WIDTH (x2 - x1) with int width = x2 - x1;
and #define HEIGHT (y2 - y1) with int height = y2 - y1;
Replaced WIDTHOK and HEIGHTOK macros with local variables:
WIDTHOK and HEIGHTOK just need to be calculated once and can then
be used for all cases in void EZoomScreen:
static_cast <float> for int denominators in divisions.
Removed these redundant gl calls:
glEnable (GL_TEXTURE_2D);
glDisable (GL_TEXTURE_2D);
Zoom Box fixes:
Enabled GL_BLEND for the zoom box to fix transparency issues.
Made outline and fill color and transparency of the zoom box configurable.
Outline width is 2.0 for the zoom box as well now.
(same like for grid preview and screenshot selector outlines)
Fixed zoom box damage handling.
Minor restructuring in zoom box rendering code.
Minor ezoom.xml.in cleanup and enhancements.
Load after mousepoll.
(fixes LP: #1171665, partially fixes LP: #1051290 and LP: #1051295)
Description of the change
CCSM look of Screenshot plugin:
https:/
Sam Spilsbury (smspillaz) wrote : | # |
MC Return (mc-return) wrote : | # |
> 78 + zooms.at (out).xVelocity ||
> 79 + zooms.at (out).yVelocity ||
> 80 + zooms.at (out).zVelocity ||
>
> It might be better to express these as != 0.0f
>
> Though they are floats - so they really should be compared in terms of
> rounding to avoid floating point comparison errors. But I wouldn't worry about
> that for now as we don't really have a uniform method to compare floats. See
> http://
> double-comparison . We'll need to find a way to do this properly and
> uniformly.
>
Maybe we should do this in a follow-up MP ?
> 110 - {
> 111 zooms.at (out).currentZoom += (zooms.at (out).zVelocity *
> chunk) /
> 112 cScreen->redrawTime ();
> 113 - }
>
> While not strictly necessary, these brackets aid readability for me because
> the code spans two lines. There's no hard and fast rule here though.
>
The indentation was not ideal in this case - I've fixed this now.
> 217 - for (out = 0; out < zooms.size (); out++)
> 218 - {
> 219 + for (unsigned int out = 0; out < zooms.size (); out++)
> 220 if (isInMovement (out) && isActive (out))
> 221 {
> 222 cScreen-
> 223 break;
> 224 }
> 225 - }
>
> As I've mentioned a few times before, please don't remove brackets in control-
> flow statements which have nested control flow statements with brackets. The
> reason is that its confusing to read at a glance.
>
I am sorry, it was from a cleanup that I did, before knowing the style we agreed
on, I just missed it. I have readded the brackets now.
> 251 + GLMatrix zTransform (transform);
> 252 + int inx1, inx2, iny1, iny2;
> 253 + int out = output->id ();
> 254 + GLushort colorData[4];
>
>
> These should probably line up - remove the tab usage in between the "int" and
> the name declaration and just use spaces to line it up.
>
Done. I will use spaces in these cases from now on.
> 295 + const GLMatrix &transform,
> 296 + const CompRegion ®ion,
> 297 + CompOutput *output,
> 298 + unsigned int mask)
>
> Ditto.
>
Done as well.
> #define WIDTHOK (float)(x2-x1) / (float)o->width () < zooms.at (out).newZoom
> #define HEIGHTOK (float)(y2-y1) / (float)o->height () < zooms.at (out).newZoom
>
> ...
>
> 541 if (WIDTHOK &&
> 542 - HEIGHTOK) {
> 543 + HEIGHTOK)
> 544 + {
>
> Its an extraneous point, but remove these macros and replace them with inline
> functions if you can.
>
I'll see what I can do.
> 656 screen->warpPointer ((int) (mouse.x () - pointerX) -
> 657 - (int)
> ((float)diffX * z),
> 658 - ...
MC Return (mc-return) wrote : | # |
>
> #define WIDTHOK (float)(x2-x1) / (float)o->width () < zooms.at (out).newZoom
> #define HEIGHTOK (float)(y2-y1) / (float)o->height () < zooms.at (out).newZoom
>
> ...
>
> 541 if (WIDTHOK &&
> 542 - HEIGHTOK) {
> 543 + HEIGHTOK)
> 544 + {
>
> Its an extraneous point, but remove these macros and replace them with inline
> functions if you can.
>
Looking at it in detail, no inline function is even needed. Replaced those macros
with local bools.
Sam Spilsbury (smspillaz) wrote : | # |
>
> > 1061 + setScaleBigger (out, (float) width / o->width (), (float)
> > 1062 + height / o->height ());
> >
> > The denominator here should be the one that is cast - not the numerator. Eg
> >
> > 1061 + setScaleBigger (out, width / static_cast <float> (o->width
> > ()),
> > 1062 + height / static_cast <float> (o->height
> ()));
> >
> > 1345 + float scale = MAX ((float) width / screen->outputDevs
> > ().at(out).width (),
> > 1346 + (float) height / screen->outputDevs ().at
> > (out).height ());
> >
> > Ditto.
> >
> I think this was done, because width and height are type int...
> > Other than that looks good.
CompRect::width () and CompRect::height () are also integers.
It should be the denominator that's being divided and not the numerator.
MC Return (mc-return) wrote : | # |
>
> It should be the denominator that's being divided and not the numerator.
Hopefully fixed now as well in r3666.
During testing I found bug #1171665 and fixed it as well :)
Sam Spilsbury (smspillaz) wrote : | # |
Hey, thanks for fixing that
As I mentioned before, try to keep separate fixes in separate proposals where possible. There are some comments I have on the fix for LP #1171665 :
432 /* draw outline */
433 alpha = ((float) optionGetOutlin
434 color = optionGetOutlin
435
436 colorData[0] = alpha * color[0];
437 colorData[1] = alpha * color[1];
438 colorData[2] = alpha * color[2];
439 colorData[3] = alpha * 65535.0f;
434440
1. The numerator is being cast in floating point division at 433. This is not necessary.
2. Replace "65535.0f" with static_cast <float> (std::numeric_
const float MaxUShortFloat = std::numeric_limits <unsigned short>::max ();
MC Return (mc-return) wrote : | # |
> Hey, thanks for fixing that
>
No problem.
> As I mentioned before, try to keep separate fixes in separate proposals where
> possible. There are some comments I have on the fix for LP #1171665 :
>
Urgh - sorry -> sometimes I can't help myself -> I stumbled upon this bug during
testing and I knew how to fix it -> so I did. Sorry again.
> 432 /* draw outline */
> 433 alpha = ((float) optionGetOutlin
> 434 color = optionGetOutlin
> 435
> 436 colorData[0] = alpha * color[0];
> 437 colorData[1] = alpha * color[1];
> 438 colorData[2] = alpha * color[2];
> 439 colorData[3] = alpha * 65535.0f;
> 434440
>
> 1. The numerator is being cast in floating point division at 433. This is not
> necessary.
> 2. Replace "65535.0f" with static_cast <float> (std::numeric_
> short>::max ()). That is a bit verbose, so you can assign it to a const if
> necessary, eg:
>
> const float MaxUShortFloat = std::numeric_limits <unsigned short>::max ();
If I am not totally mistaken we already have constants for this, I think they are
named COLOR ? I have to check...
If we do not have global constants, we should create those, because this are values
constantly used throughout the code...
MC Return (mc-return) wrote : | # |
> 1. The numerator is being cast in floating point division at 433. This is not
> necessary.
Very good catch. Fixed in r3667.
> 2. Replace "65535.0f" with static_cast <float> (std::numeric_
> short>::max ()). That is a bit verbose, so you can assign it to a const if
> necessary, eg:
>
> const float MaxUShortFloat = std::numeric_limits <unsigned short>::max ();
Don't we have global constants for things like that ?
I also noticed PI getting defined by several plugins - we should have global
constants for values like these, which get used several times throughout our
code...
In composite.h I found:
#define OPAQUE 0xffff
#define COLOR 0xffff
#define BRIGHT 0xffff
for example...
Maybe use COLOR in our case ?
Sam Spilsbury (smspillaz) wrote : | # |
>
> > 1. The numerator is being cast in floating point division at 433. This is
> not
> > necessary.
>
> Very good catch. Fixed in r3667.
>
> > 2. Replace "65535.0f" with static_cast <float> (std::numeric_
> <unsigned
> > short>::max ()). That is a bit verbose, so you can assign it to a const if
> > necessary, eg:
> >
> > const float MaxUShortFloat = std::numeric_limits <unsigned short>::max ();
>
> Don't we have global constants for things like that ?
> I also noticed PI getting defined by several plugins - we should have global
> constants for values like these, which get used several times throughout our
> code...
>
> In composite.h I found:
>
> #define OPAQUE 0xffff
> #define COLOR 0xffff
> #define BRIGHT 0xffff
>
> for example...
>
> Maybe use COLOR in our case ?
So 0xffff is basically MAX_USHRT. It would be better to switch those over to be actual constants one day, but not here. The better place to use those #defines is where you're modifying a CompWindowPaint
MC Return (mc-return) wrote : | # |
Okay, all done :)
Also replaced postfix increments with prefix ones, because those are more efficient and faster...
MC Return (mc-return) wrote : | # |
I just want to note here, that EZoom is still far from being perfect, the overdrawing of the zoom box is also an issue
here (the same problem like screenshot), also EZoom still misses damage rectangle calculation and handling for the
zoom box - currently there is no damage during zoom box drawing applied at all...
So a follow-up MP or (looking at the options list of EZoom) multiple ones will be necessary to make EZoom shine perfectly...
MC Return (mc-return) wrote : | # |
Hmm, I have a fix for the missing zoom box damage handling, this would be the diff:
=== modified file 'plugins/
@@ -464,6 +466,12 @@
streamingB
glDisable (GL_BLEND);
+
+ /* Damage the zoom selection box region during draw */
+ cScreen-
+ y1 - 1,
+ x2 - x1 + 1,
+ y2 - y1 + 1));
}
Do we want this separated ?
Sam Spilsbury (smspillaz) wrote : | # |
The correct fix for the zoom-box handling would be to call damageRegion for the last and current zoom box rectangle. So at least you're on the right track there, but yes, please do it separately. For now I'm fine with this as-is.
MC Return (mc-return) wrote : | # |
> The correct fix for the zoom-box handling would be to call damageRegion for
> the last and current zoom box rectangle. So at least you're on the right track
> there, but yes, please do it separately. For now I'm fine with this as-is.
Cool, thanks. I am working on the follow-up...
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Autolanding.
More details in the following jenkins job:
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
MC Return (mc-return) wrote : | # |
*Urgh*
The "Applying patch ubuntu-
Let's quilt-fix this... Sooner or later quilt patching has to be done anyway...
MC Return (mc-return) wrote : | # |
Grmpf, I already got the follow-up ready :(
MC Return (mc-return) wrote : | # |
Hmm, investigation shows that the ubuntu quilt patch just removes all default EZoom shortcuts, namely
the predefined shortcuts to zoom in/out, invoke the zoom box and to zoom to a specific window.
I guess this was done, because all "Super+holdanykey" combinations conflict with Unity's default behaviour
(display help overlay/
if you are interested in details).
The removal of these standard-shortcuts was completely unnecessary for Ubuntu anyway, as EZoom is disabled
per default in Ubuntu anyway AFAIK.
I vote for removing this ugly patch from EZoom completely as it is not needed anyway and massively complicates
development.
Sam Spilsbury (smspillaz) wrote : | # |
> Hmm, investigation shows that the ubuntu quilt patch just removes all default
> EZoom shortcuts, namely
> the predefined shortcuts to zoom in/out, invoke the zoom box and to zoom to a
> specific window.
>
> I guess this was done, because all "Super+holdanykey" combinations conflict
> with Unity's default behaviour
> (display help overlay/
> problem in itself (see bug #1069158
> if you are interested in details).
>
> The removal of these standard-shortcuts was completely unnecessary for Ubuntu
> anyway, as EZoom is disabled
> per default in Ubuntu anyway AFAIK.
>
> I vote for removing this ugly patch from EZoom completely as it is not needed
> anyway and massively complicates
> development.
Ask didrocks about it on IRC then.
Sam Spilsbury (smspillaz) wrote : | # |
I saw there was some discussion yesterday - was there an outcome from this?
MC Return (mc-return) wrote : | # |
> I saw there was some discussion yesterday - was there an outcome from this?
Reconstruction shows:
Apr 25 10:08:23 <MCR> didrocks, I would like to remove the quilt patch from EZoom xml.
Apr 25 10:08:51 <didrocks> MCR: is it upstream?
Apr 25 10:09:13 <MCR> The ubuntu quilt patch just removes 4 shortcuts from EZoom.
Apr 25 10:09:18 <didrocks> MCR: right
Apr 25 10:09:24 <MCR> No, it will affect Ubuntu
Apr 25 10:09:27 <MCR> but not really
Apr 25 10:09:36 <didrocks> MCR: so no, this patch is there for a usability reason
Apr 25 10:09:37 <MCR> as EZoom is turned off by default
Apr 25 10:09:49 <didrocks> MCR: usability testing showed that people hit that by mistake
Apr 25 10:09:55 <didrocks> then, they feel "stuck"
Apr 25 10:10:00 <didrocks> and reboot their machine
Apr 25 10:10:05 <didrocks> not a nice experience :/
Apr 25 10:10:10 <didrocks> hence the patch
Apr 25 10:10:13 <MCR> how can someone hit this by mistake ?
Apr 25 10:10:23 <didrocks> MCR: it seems it happens a lot
Apr 25 10:10:29 <MCR> you have to enable EZoom manually first
Apr 25 10:10:30 <didrocks> especially super + scrollwheel
Apr 25 10:10:36 <didrocks> MCR: it's enabled by default
Apr 25 10:10:39 <MCR> ah
Apr 25 10:10:45 <MCR> my fault then
Apr 25 10:10:53 <didrocks> no worry :)
Apr 25 10:11:08 <MCR> How about changing the upstream shortcuts to something else then ?
Apr 25 10:11:42 <didrocks> MCR: I think the shortcut makes default
Apr 25 10:12:06 <MCR> didrocks, it is completely useless to have an enabled EZoom without any shortcuts...
Apr 25 10:12:19 <MCR> why is it enabled in the first place ?
Apr 25 10:12:21 <didrocks> MCR: the idea is to avoid people enabling/disabling plugin (which is risky)
Apr 25 10:12:30 <didrocks> then, having an option to enable the shortcuts
Apr 25 10:12:35 <didrocks> MCR: want to tackle that? :)
Apr 25 10:12:40 <MCR> didrocks, soon it won't be risky anymore
Apr 25 10:16:34 <MCR> didrocks, I want to reduce Ubuntu-
We now know:
1. EZoom is enabled by default, because enabling it manually in CCSM once had a high risk of crashing Compiz.
2. Although EZoom is enabled by default all 4 standard shortcuts are removed from Ubuntu, because they conflict
with "Super" (see bug #1069158 if you are interested in details).
So IMHO this means that one solution would be to remove the EZoom Ubuntu patch that is removing the shortcuts and
to disable EZoom by default, while making sure to reduce the chance of a crashing Compiz, if users enable or disable
plugins there.
IMHO we are 1000x more stable in CCSM now, then we were when this patching was designed...
What is your opinion on this matter ?
Sam Spilsbury (smspillaz) wrote : | # |
On Fri, Apr 26, 2013 at 2:55 PM, MC Return <email address hidden> wrote:
> Review: Needs Information
>
>> I saw there was some discussion yesterday - was there an outcome from this?
...
>
> We now know:
>
> 1. EZoom is enabled by default, because enabling it manually in CCSM once had a high risk of crashing Compiz.
> 2. Although EZoom is enabled by default all 4 standard shortcuts are removed from Ubuntu, because they conflict
> with "Super" (see bug #1069158 if you are interested in details).
>
> So IMHO this means that one solution would be to remove the EZoom Ubuntu patch that is removing the shortcuts and
> to disable EZoom by default, while making sure to reduce the chance of a crashing Compiz, if users enable or disable
> plugins there.
> IMHO we are 1000x more stable in CCSM now, then we were when this patching was designed...
>
> What is your opinion on this matter ?
I think we should add an autopilot test to enable and disable the unity plugin.
That could get tricky though - I'll have to check Lukasz about whether
or not that's possible.
In any case, are you able to refresh the distro patches and unblock
this merge review?
> --
> https:/
> You are reviewing the proposed merge of lp:~mc-return/compiz/compiz.merge-ezoom-cleanup into lp:compiz.
--
Sam Spilsbury
MC Return (mc-return) wrote : | # |
>
> In any case, are you able to refresh the distro patches and unblock
> this merge review?
>
Probably yes, but I hate horror-trips.
You really could do me a *big* favor if you could do it. Sooner or later I'll have to quilt again, but I really would prefer later... ;)
The follow-up of this MP with the corrected damage handling is also ready here locally, so it would be appreciated to get this in.
(the float comparisons also still need fixing)
Sam Spilsbury (smspillaz) wrote : | # |
>
> >
> > In any case, are you able to refresh the distro patches and unblock
> > this merge review?
> >
> Probably yes, but I hate horror-trips.
>
> You really could do me a *big* favor if you could do it. Sooner or later I'll
> have to quilt again, but I really would prefer later... ;)
My time is very limited these days with study commitments. I can't be writing code for other people. Can you please try to do it yourself?
Alternatively, separate the xml changes out into another merge proposal so that we can unblock this one.
>
> The follow-up of this MP with the corrected damage handling is also ready here
> locally, so it would be appreciated to get this in.
>
> (the float comparisons also still need fixing)
MC Return (mc-return) wrote : | # |
>
> My time is very limited these days with study commitments. I can't be writing
> code for other people. Can you please try to do it yourself?
>
> Alternatively, separate the xml changes out into another merge proposal so
> that we can unblock this one.
>
Not that easy to separate those as changes to both files are needed.
I will get to it one day. Set to WIP for now...
MC Return (mc-return) wrote : | # |
This plugin is a good example for unnecessary patching. The quilt patch here just removes the standard shortcuts completely, while still having the plugin enabled by default in Ubuntu. That makes *no* *sense* *at* *all*.
The correct solution would be:
1. Remove the quilt patch from ezoom completely
2. Disable EZoom for Ubuntu per default
Why is this the better solution you might ask:
1. The plugin does not get loaded at all, which improves memory usage, boot speed and Compiz start speed, while not changing any functionality for the Ubuntu user.
2. The stupid quilt patch is removed from lp:compiz, making hacking and testing the code much easier.
3. It is easier for the user to re-enable EZoom, because they do not have to manually add all the shortcuts to make the plugin usable again, instead they just have to enable the plugin.
MC Return (mc-return) wrote : | # |
r3670 fully fixes damage handling of the zoom box and also improves the ABI logic for this plugin.
MC Return (mc-return) wrote : | # |
Info (for easier review): This was all that was needed to be added to fix damage handling here:
470 /* Damage the zoom selection box region during draw */
471 cScreen-
472 y1 - 1,
473 x2 - x1 + 1,
474 y2 - y1 + 1));
The other changes in r3670 are added comments and a improved ABI check as discussed in the other MP already.
MC Return (mc-return) wrote : | # |
Now IMHO all that is needed to be done for this to land is to remove EZoom from the list of plugins, which are enabled by default and to remove the quilt patching of ezoom...
Sam Spilsbury (smspillaz) wrote : | # |
Please revert this change as I mentioned before:
1673 - if (!CompPlugin:
1674 - !CompPlugin:
1675 - !CompPlugin:
1676 - !CompPlugin:
1677 - return false;
1678 + if (CompPlugin:
1679 + CompPlugin:
1680 + CompPlugin:
1681 + CompPlugin:
1682 + return true;
1683
1684 - return true;
1685 + return false;
I'd also really prefer it if changes to plugins were done in separate branches for each semantic change - it makes review a lot easier and means that we don't have to hold up whole branches because of some unrelated change which doesn't fit with the broader project goals. I won't require it here, but please keep this in mind in future.
Other than the ABI change, the other changes seem fine to me, keep up the good work.
MC Return (mc-return) wrote : | # |
> Please revert this change as I mentioned before:
>
> 1673 - if (!CompPlugin:
> 1674 - !CompPlugin:
> 1675 - !CompPlugin:
> 1676 - !CompPlugin:
> 1677 - return false;
> 1678 + if (CompPlugin:
> 1679 + CompPlugin:
> 1680 + CompPlugin:
> 1681 + CompPlugin:
> 1682 + return true;
> 1683
> 1684 - return true;
> 1685 + return false;
>
Ack, will propose those separately as stated in the other MP already.
> I'd also really prefer it if changes to plugins were done in separate branches
> for each semantic change - it makes review a lot easier and means that we
> don't have to hold up whole branches because of some unrelated change which
> doesn't fit with the broader project goals. I won't require it here, but
> please keep this in mind in future.
>
The real problem here is that this will fail to autoland, because of the quilt patching.
So this MP "Needs Information" on how to continue with this:
The correct solution would be:
1. Remove the quilt patch from ezoom completely
2. Disable EZoom for Ubuntu per default
Why is this the better solution you might ask:
1. The plugin does not get loaded at all, which improves memory usage, boot speed and Compiz start speed, while not changing any functionality for the Ubuntu user.
2. The stupid quilt patch is removed from lp:compiz, making hacking and testing the code much easier.
3. It is easier for the user to re-enable EZoom, because they do not have to manually add all the shortcuts to make the plugin usable again, instead they just have to enable the plugin.
> Other than the ABI change, the other changes seem fine to me, keep up the good
> work.
I'll revert the ABI logic change here as well.
Sam Spilsbury (smspillaz) wrote : | # |
> The real problem here is that this will fail to autoland, because of the quilt
> patching.
> So this MP "Needs Information" on how to continue with this:
>
> The correct solution would be:
> 1. Remove the quilt patch from ezoom completely
> 2. Disable EZoom for Ubuntu per default
>
> Why is this the better solution you might ask:
>
> 1. The plugin does not get loaded at all, which improves memory usage, boot
> speed and Compiz start speed, while not changing any functionality for the
> Ubuntu user.
> 2. The stupid quilt patch is removed from lp:compiz, making hacking and
> testing the code much easier.
> 3. It is easier for the user to re-enable EZoom, because they do not have to
> manually add all the shortcuts to make the plugin usable again, instead they
> just have to enable the plugin.
>
It should be possible to just refresh the patches. Was there anything preventing you from doing that?
MC Return (mc-return) wrote : | # |
> > The real problem here is that this will fail to autoland, because of the
> quilt
> > patching.
> > So this MP "Needs Information" on how to continue with this:
> >
> > The correct solution would be:
> > 1. Remove the quilt patch from ezoom completely
> > 2. Disable EZoom for Ubuntu per default
> >
> > Why is this the better solution you might ask:
> >
> >
>
>
> It should be possible to just refresh the patches. Was there anything
> preventing you from doing that?
Yes, 4 reasons:
1. Because the correct solution would be:
* Remove the quilt patch from ezoom completely
* Disable EZoom for Ubuntu per default
Why ?
Reason 2: The plugin does not get loaded at all, which improves memory usage, boot
speed and Compiz start speed, while not changing any functionality for the
Ubuntu user.
Reason 3: The stupid quilt patch is removed from lp:compiz, making hacking and
testing the code much easier, without having to think about quilt.
Reason 4: It is easier for the user to re-enable EZoom, because they do not have to
manually add all the shortcuts to make the plugin usable again, instead they
just have to enable the plugin.
Reason 5: For users who already have their own EZoom configuration set up the removed
quilt patch also makes no difference.
Are there *any* reasons to keep the quilt patch for EZoom ? I do not see any...
MC Return (mc-return) wrote : | # |
*5 reasons ^^ -> typo ;)
Sam Spilsbury (smspillaz) wrote : | # |
> Yes, 4 reasons:
>
> 1. Because the correct solution would be:
> * Remove the quilt patch from ezoom completely
> * Disable EZoom for Ubuntu per default
>
> Why ?
>
> Reason 2: The plugin does not get loaded at all, which improves memory usage, boot
> speed and Compiz start speed, while not changing any functionality for the
> Ubuntu user.
>
> Reason 3: The stupid quilt patch is removed from lp:compiz, making hacking and
> testing the code much easier, without having to think about quilt.
>
> Reason 4: It is easier for the user to re-enable EZoom, because they do not have to
> manually add all the shortcuts to make the plugin usable again, instead they
> just have to enable the plugin.
>
> Reason 5: For users who already have their own EZoom configuration set up the removed
> quilt patch also makes no difference.
>
> Are there *any* reasons to keep the quilt patch for EZoom ? I do not see any...
>
I think didrocks made it quite clear why we patch the xml files in the
distribution. I don't think its worth going over those arguments
again. What I want to know is - is there any reason why you are not
able to refresh the patches? It seems like a fairly straightforward
thing to do.
--
Sam Spilsbury
MC Return (mc-return) wrote : | # |
>
> I think didrocks made it quite clear why we patch the xml files in the
> distribution. I don't think its worth going over those arguments
> again. What I want to know is - is there any reason why you are not
> able to refresh the patches? It seems like a fairly straightforward
> thing to do.
>
> --
> Sam Spilsbury
Sam, maybe I misunderstood didrocks here:
Apr 25 10:12:35 <didrocks> MCR: want to tackle that? :)
Apr 25 10:12:40 <MCR> didrocks, soon it won't be risky anymore
Apr 25 10:16:34 <MCR> didrocks, I want to reduce Ubuntu-
He explained the rationale behind 'why it is as it is', which is that it once was risky to enable ezoom in CCSM making Compiz crash by doing it. To prevent this crash from happening it was left enabled by default,
while removing the shortcuts, which make sense as they are in upstream and thus should not be changed, but would conflict with Unity.
To enable EZoom the user then just had to make new shortcuts to reenable EZoom.
I will have to do quilting anyway for the other plugins' changes, but I think we really should use quilt patching just for things that are inevitable and need quilt to be solved, here this is simply not the case at all...
MC Return (mc-return) wrote : | # |
Further investigation also shows, that there is no other way than CCSM or GConf Editor to change the shortcuts (ezoom shortcuts are not even in gnome/unity keyboard shortcut settings) -> which means the user needs CCSM or some other editor in any case to change the shortcuts of ezoom...
MC Return (mc-return) wrote : | # |
Here I still propose the no-quilt-
(just needs the okay to be implemented)
Sam Spilsbury (smspillaz) wrote : | # |
> Here I still propose the no-quilt-
> (just needs the okay to be implemented)
Just refresh the patches. Its really not hard and I really don't want to be involved in yet another debate about how we should change ubuntu policy over this.
MC Return (mc-return) wrote : | # |
>
> Just refresh the patches. Its really not hard and I really don't want to be
> involved in yet another debate about how we should change ubuntu policy over
> this.
I can talk to didrocks again to ask for the green light here, I really would prefer eliminating the quilt patch in this case, because it makes things worse, not better...
All 5 arguments against the patch are still valid.
MC Return (mc-return) wrote : | # |
Talked with didrocks again, short summary:
1. Default should not be changed.
2. If possible the EZoom settings should be exposed in gcc, which they are currently not.
Instead some gnome-zoom settings are exposed in gcc, which of course do not work at all ("Zoom in/Zoom out" and "Turn zoom on or off"), because they seem to be designed for gnome-shell only.
So I will have to refresh the patch in our case here for now, so this can finally land...
WIP
MC Return (mc-return) wrote : | # |
Finally ready and re-quilted.
Sam Spilsbury (smspillaz) wrote : | # |
All good now, thanks!
PS Jenkins bot (ps-jenkins) : | # |
Preview Diff
1 | === modified file 'debian/patches/ubuntu-config.patch' |
2 | --- debian/patches/ubuntu-config.patch 2013-05-12 15:39:28 +0000 |
3 | +++ debian/patches/ubuntu-config.patch 2013-05-14 21:54:27 +0000 |
4 | @@ -337,41 +337,6 @@ |
5 | </option> |
6 | <option name="ground_color1" type="color"> |
7 | <_short>Ground color(near)</_short> |
8 | ---- a/plugins/ezoom/ezoom.xml.in |
9 | -+++ b/plugins/ezoom/ezoom.xml.in |
10 | -@@ -29,7 +29,6 @@ |
11 | - <option type="button" name="zoom_in_button"> |
12 | - <_short>Zoom In</_short> |
13 | - <_long>Zoom In</_long> |
14 | -- <default><Super>Button4</default> |
15 | - </option> |
16 | - <option type="key" name="zoom_in_key"> |
17 | - <_short>Zoom In</_short> |
18 | -@@ -38,7 +37,6 @@ |
19 | - <option type="button" name="zoom_out_button"> |
20 | - <_short>Zoom Out</_short> |
21 | - <_long>Zoom Out</_long> |
22 | -- <default><Super>Button5</default> |
23 | - </option> |
24 | - <option type="key" name="zoom_out_key"> |
25 | - <_short>Zoom Out</_short> |
26 | -@@ -47,7 +45,6 @@ |
27 | - <option type="button" name="zoom_box_button"> |
28 | - <_short>Zoom Box</_short> |
29 | - <_long>Zoom in on a boxed area</_long> |
30 | -- <default><Super>Button2</default> |
31 | - </option> |
32 | - </group> |
33 | - <group> |
34 | -@@ -141,7 +138,7 @@ |
35 | - <option type="key" name="fit_to_window_key"> |
36 | - <_short>Fit zoomed area to window</_short> |
37 | - <_long>Zooms in/out so the focused window is zoomed to the maximum while still being fully visible.</_long> |
38 | -- <default><Super>r</default> |
39 | -+ <default></default> |
40 | - </option> |
41 | - </subgroup> |
42 | - </group> |
43 | --- a/plugins/fade/fade.xml.in |
44 | +++ b/plugins/fade/fade.xml.in |
45 | @@ -10,6 +10,7 @@ |
46 | @@ -835,3 +800,41 @@ |
47 | </option> |
48 | </group> |
49 | <group> |
50 | +--- a/plugins/ezoom/ezoom.xml.in |
51 | ++++ b/plugins/ezoom/ezoom.xml.in |
52 | +@@ -30,7 +30,7 @@ |
53 | + <option type="button" name="zoom_in_button"> |
54 | + <_short>Zoom In Button</_short> |
55 | + <_long>Mouse button shortcut to invoke zooming in.</_long> |
56 | +- <default><Super>Button4</default> |
57 | ++ <default></default> |
58 | + </option> |
59 | + <option type="key" name="zoom_in_key"> |
60 | + <_short>Zoom In Key</_short> |
61 | +@@ -39,7 +39,7 @@ |
62 | + <option type="button" name="zoom_out_button"> |
63 | + <_short>Zoom Out Button</_short> |
64 | + <_long>Mouse button shortcut to invoke zooming out.</_long> |
65 | +- <default><Super>Button5</default> |
66 | ++ <default></default> |
67 | + </option> |
68 | + <option type="key" name="zoom_out_key"> |
69 | + <_short>Zoom Out Key</_short> |
70 | +@@ -48,7 +48,7 @@ |
71 | + <option type="button" name="zoom_box_button"> |
72 | + <_short>Invoke Zoom Box Button</_short> |
73 | + <_long>Define a rectangle area and zoom into it.</_long> |
74 | +- <default><Super>Button2</default> |
75 | ++ <default></default> |
76 | + </option> |
77 | + <option name="zoom_box_outline_color" type="color"> |
78 | + <_short>Zoom Box Outline Color</_short> |
79 | +@@ -162,7 +162,7 @@ |
80 | + <option type="key" name="fit_to_window_key"> |
81 | + <_short>Fit zoomed area to window</_short> |
82 | + <_long>Zooms in/out so the focused window is zoomed to the maximum while still being fully visible.</_long> |
83 | +- <default><Super>r</default> |
84 | ++ <default></default> |
85 | + </option> |
86 | + </subgroup> |
87 | + </group> |
88 | |
89 | === modified file 'plugins/ezoom/ezoom.xml.in' |
90 | --- plugins/ezoom/ezoom.xml.in 2012-05-16 17:40:27 +0000 |
91 | +++ plugins/ezoom/ezoom.xml.in 2013-05-14 21:54:27 +0000 |
92 | @@ -6,6 +6,7 @@ |
93 | <plugin>opengl</plugin> |
94 | <plugin>expo</plugin> |
95 | <plugin>decor</plugin> |
96 | + <plugin>mousepoll</plugin> |
97 | </relation> |
98 | <relation type="before"> |
99 | <plugin>staticswitcher</plugin> |
100 | @@ -27,28 +28,48 @@ |
101 | <option type="action" name="ensure_visibility"> |
102 | </option> |
103 | <option type="button" name="zoom_in_button"> |
104 | - <_short>Zoom In</_short> |
105 | - <_long>Zoom In</_long> |
106 | + <_short>Zoom In Button</_short> |
107 | + <_long>Mouse button shortcut to invoke zooming in.</_long> |
108 | <default><Super>Button4</default> |
109 | </option> |
110 | <option type="key" name="zoom_in_key"> |
111 | - <_short>Zoom In</_short> |
112 | - <_long>Zoom In</_long> |
113 | + <_short>Zoom In Key</_short> |
114 | + <_long>Key shortcut to invoke zooming in.</_long> |
115 | </option> |
116 | <option type="button" name="zoom_out_button"> |
117 | - <_short>Zoom Out</_short> |
118 | - <_long>Zoom Out</_long> |
119 | + <_short>Zoom Out Button</_short> |
120 | + <_long>Mouse button shortcut to invoke zooming out.</_long> |
121 | <default><Super>Button5</default> |
122 | </option> |
123 | <option type="key" name="zoom_out_key"> |
124 | - <_short>Zoom Out</_short> |
125 | - <_long>Zoom Out</_long> |
126 | + <_short>Zoom Out Key</_short> |
127 | + <_long>Key shortcut to invoke zooming in.</_long> |
128 | </option> |
129 | <option type="button" name="zoom_box_button"> |
130 | - <_short>Zoom Box</_short> |
131 | - <_long>Zoom in on a boxed area</_long> |
132 | + <_short>Invoke Zoom Box Button</_short> |
133 | + <_long>Define a rectangle area and zoom into it.</_long> |
134 | <default><Super>Button2</default> |
135 | </option> |
136 | + <option name="zoom_box_outline_color" type="color"> |
137 | + <_short>Zoom Box Outline Color</_short> |
138 | + <_long>Color and opacity of the zoom box outline.</_long> |
139 | + <default> |
140 | + <red>0x2fff</red> |
141 | + <green>0x2fff</green> |
142 | + <blue>0x4fff</blue> |
143 | + <alpha>0x9fff</alpha> |
144 | + </default> |
145 | + </option> |
146 | + <option name="zoom_box_fill_color" type="color"> |
147 | + <_short>Zoom Box Fill Color</_short> |
148 | + <_long>Fill color and opacity of the zoom box.</_long> |
149 | + <default> |
150 | + <red>0x2fff</red> |
151 | + <green>0x2fff</green> |
152 | + <blue>0x2fff</blue> |
153 | + <alpha>0x4fff</alpha> |
154 | + </default> |
155 | + </option> |
156 | </group> |
157 | <group> |
158 | <_short>Mouse Behaviour</_short> |
159 | |
160 | === modified file 'plugins/ezoom/src/ezoom.cpp' |
161 | --- plugins/ezoom/src/ezoom.cpp 2013-05-09 13:43:07 +0000 |
162 | +++ plugins/ezoom/src/ezoom.cpp 2013-05-14 21:54:27 +0000 |
163 | @@ -79,7 +79,7 @@ |
164 | |
165 | /* |
166 | * This toggles paint functions. We don't need to continually run code when we |
167 | - * are not doing anything |
168 | + * are not doing anything. |
169 | */ |
170 | static inline void |
171 | toggleFunctions (bool state) |
172 | @@ -102,6 +102,7 @@ |
173 | return false; |
174 | else if ((unsigned int) out >= zs->zooms.size ()) |
175 | zs->zooms.resize (screen->outputDevs ().size ()); |
176 | + |
177 | return true; |
178 | } |
179 | |
180 | @@ -113,13 +114,15 @@ |
181 | |
182 | if (!outputIsZoomArea (out)) |
183 | return false; |
184 | + |
185 | if (zs->grabbed & (1 << zs->zooms.at (out).output)) |
186 | return true; |
187 | + |
188 | return false; |
189 | } |
190 | |
191 | /* Check if we are zoomed out and not going anywhere |
192 | - * (similar to isActive but based on actual zoom, not grab) |
193 | + * (similar to isActive but based on actual zoom, not grab). |
194 | */ |
195 | static inline bool |
196 | isZoomed (int out) |
197 | @@ -129,11 +132,9 @@ |
198 | if (!outputIsZoomArea (out)) |
199 | return false; |
200 | |
201 | - if (zs->zooms.at (out).currentZoom != 1.0f |
202 | - || zs->zooms.at (out).newZoom != 1.0f) |
203 | - return true; |
204 | - |
205 | - if (zs->zooms.at (out).zVelocity != 0.0f) |
206 | + if (zs->zooms.at (out).currentZoom != 1.0f || |
207 | + zs->zooms.at (out).newZoom != 1.0f || |
208 | + zs->zooms.at (out).zVelocity != 0.0f) |
209 | return true; |
210 | |
211 | return false; |
212 | @@ -143,11 +144,12 @@ |
213 | int |
214 | EZoomScreen::distanceToEdge (int out, EZoomScreen::ZoomEdge edge) |
215 | { |
216 | - int x1,y1,x2,y2; |
217 | + int x1, y1, x2, y2; |
218 | CompOutput *o = &screen->outputDevs ().at (out); |
219 | |
220 | if (!isActive (out)) |
221 | return 0; |
222 | + |
223 | convertToZoomedTarget (out, o->region ()->extents.x2, |
224 | o->region ()->extents.y2, &x2, &y2); |
225 | convertToZoomedTarget (out, o->region ()->extents.x1, |
226 | @@ -162,7 +164,7 @@ |
227 | return 0; // Never reached. |
228 | } |
229 | |
230 | -/* Update/set translations based on zoom level and real translate. */ |
231 | +/* Update/set translations based on zoom level and real translate. */ |
232 | void |
233 | EZoomScreen::ZoomArea::updateActualTranslates () |
234 | { |
235 | @@ -178,17 +180,19 @@ |
236 | bool |
237 | EZoomScreen::isInMovement (int out) |
238 | { |
239 | - if (zooms.at (out).currentZoom == 1.0f && |
240 | - zooms.at (out).newZoom == 1.0f && |
241 | + if (zooms.at (out).currentZoom == 1.0f && |
242 | + zooms.at (out).newZoom == 1.0f && |
243 | zooms.at (out).zVelocity == 0.0f) |
244 | return false; |
245 | - if (zooms.at (out).currentZoom != zooms.at (out).newZoom || |
246 | - zooms.at (out).xVelocity || zooms.at (out).yVelocity || |
247 | - zooms.at (out).zVelocity) |
248 | - return true; |
249 | - if (zooms.at (out).xTranslate != zooms.at (out).realXTranslate || |
250 | + |
251 | + if (zooms.at (out).currentZoom != zooms.at (out).newZoom || |
252 | + zooms.at (out).xVelocity || |
253 | + zooms.at (out).yVelocity || |
254 | + zooms.at (out).zVelocity || |
255 | + zooms.at (out).xTranslate != zooms.at (out).realXTranslate || |
256 | zooms.at (out).yTranslate != zooms.at (out).realYTranslate) |
257 | return true; |
258 | + |
259 | return false; |
260 | } |
261 | |
262 | @@ -225,16 +229,15 @@ |
263 | locked (false) |
264 | { |
265 | } |
266 | -/* Adjust the velocity in the z-direction. */ |
267 | +/* Adjust the velocity in the z-direction. */ |
268 | void |
269 | EZoomScreen::adjustZoomVelocity (int out, float chunk) |
270 | { |
271 | - float d, adjust, amount; |
272 | - |
273 | - d = (zooms.at (out).newZoom - zooms.at (out).currentZoom) * 75.0f; |
274 | - |
275 | - adjust = d * 0.002f; |
276 | - amount = fabs (d); |
277 | + float d = (zooms.at (out).newZoom - zooms.at (out).currentZoom) * 75.0f; |
278 | + |
279 | + float adjust = d * 0.002f; |
280 | + float amount = fabs (d); |
281 | + |
282 | if (amount < 1.0f) |
283 | amount = 1.0f; |
284 | else if (amount > 5.0f) |
285 | @@ -249,10 +252,8 @@ |
286 | zooms.at (out).zVelocity = 0.0f; |
287 | } |
288 | else |
289 | - { |
290 | zooms.at (out).currentZoom += (zooms.at (out).zVelocity * chunk) / |
291 | - cScreen->redrawTime (); |
292 | - } |
293 | + cScreen->redrawTime (); |
294 | } |
295 | |
296 | /* Adjust the X/Y velocity based on target translation and real |
297 | @@ -260,32 +261,28 @@ |
298 | void |
299 | EZoomScreen::adjustXYVelocity (int out, float chunk) |
300 | { |
301 | - float xdiff, ydiff; |
302 | - float xadjust, yadjust; |
303 | - float xamount, yamount; |
304 | - |
305 | zooms.at (out).xVelocity /= 1.25f; |
306 | zooms.at (out).yVelocity /= 1.25f; |
307 | - xdiff = |
308 | - (zooms.at (out).xTranslate - zooms.at (out).realXTranslate) * |
309 | - 75.0f; |
310 | - ydiff = |
311 | - (zooms.at (out).yTranslate - zooms.at (out).realYTranslate) * |
312 | - 75.0f; |
313 | - xadjust = xdiff * 0.002f; |
314 | - yadjust = ydiff * 0.002f; |
315 | - xamount = fabs (xdiff); |
316 | - yamount = fabs (ydiff); |
317 | + |
318 | + float xdiff = |
319 | + (zooms.at (out).xTranslate - zooms.at (out).realXTranslate) * 75.0f; |
320 | + float ydiff = |
321 | + (zooms.at (out).yTranslate - zooms.at (out).realYTranslate) * 75.0f; |
322 | + |
323 | + float xadjust = xdiff * 0.002f; |
324 | + float yadjust = ydiff * 0.002f; |
325 | + float xamount = fabs (xdiff); |
326 | + float yamount = fabs (ydiff); |
327 | |
328 | if (xamount < 1.0f) |
329 | - xamount = 1.0f; |
330 | + xamount = 1.0f; |
331 | else if (xamount > 5.0) |
332 | - xamount = 5.0f; |
333 | + xamount = 5.0f; |
334 | |
335 | if (yamount < 1.0f) |
336 | - yamount = 1.0f; |
337 | + yamount = 1.0f; |
338 | else if (yamount > 5.0) |
339 | - yamount = 5.0f; |
340 | + yamount = 5.0f; |
341 | |
342 | zooms.at (out).xVelocity = |
343 | (xamount * zooms.at (out).xVelocity + xadjust) / (xamount + 1.0f); |
344 | @@ -308,24 +305,23 @@ |
345 | (zooms.at (out).yVelocity * chunk) / cScreen->redrawTime (); |
346 | } |
347 | |
348 | -/* Animate the movement (if any) in preparation of a paint screen. */ |
349 | +/* Animate the movement (if any) in preparation of a paint screen. */ |
350 | void |
351 | -EZoomScreen::preparePaint (int msSinceLastPaint) |
352 | +EZoomScreen::preparePaint (int msSinceLastPaint) |
353 | { |
354 | if (grabbed) |
355 | { |
356 | - int steps; |
357 | - float amount, chunk; |
358 | + float amount = msSinceLastPaint * 0.05f * optionGetSpeed (); |
359 | + int steps = amount / (0.5f * optionGetTimestep ()); |
360 | |
361 | - amount = msSinceLastPaint * 0.05f * optionGetSpeed (); |
362 | - steps = amount / (0.5f * optionGetTimestep ()); |
363 | if (!steps) |
364 | - steps = 1; |
365 | - chunk = amount / (float) steps; |
366 | + steps = 1; |
367 | + |
368 | + float chunk = amount / (float) steps; |
369 | + |
370 | while (steps--) |
371 | { |
372 | - unsigned int out; |
373 | - for (out = 0; out < zooms.size (); out++) |
374 | + for (unsigned int out = 0; out < zooms.size (); ++out) |
375 | { |
376 | if (!isInMovement (out) || !isActive (out)) |
377 | continue; |
378 | @@ -333,11 +329,13 @@ |
379 | adjustXYVelocity (out, chunk); |
380 | adjustZoomVelocity (out, chunk); |
381 | zooms.at (out).updateActualTranslates (); |
382 | + |
383 | if (!isZoomed (out)) |
384 | { |
385 | zooms.at (out).xVelocity = zooms.at (out).yVelocity = |
386 | 0.0f; |
387 | grabbed &= ~(1 << zooms.at (out).output); |
388 | + |
389 | if (!grabbed) |
390 | { |
391 | cScreen->damageScreen (); |
392 | @@ -353,14 +351,13 @@ |
393 | cScreen->preparePaint (msSinceLastPaint); |
394 | } |
395 | |
396 | -/* Damage screen if we're still moving. */ |
397 | +/* Damage screen if we're still moving. */ |
398 | void |
399 | EZoomScreen::donePaint () |
400 | { |
401 | if (grabbed) |
402 | { |
403 | - unsigned int out; |
404 | - for (out = 0; out < zooms.size (); out++) |
405 | + for (unsigned int out = 0; out < zooms.size (); ++out) |
406 | { |
407 | if (isInMovement (out) && isActive (out)) |
408 | { |
409 | @@ -372,41 +369,48 @@ |
410 | else if (grabIndex) |
411 | cScreen->damageScreen (); |
412 | else |
413 | - toggleFunctions (false); |
414 | + toggleFunctions (false); |
415 | |
416 | cScreen->donePaint (); |
417 | } |
418 | -/* Draws a box from the screen coordinates inx1,iny1 to inx2,iny2 */ |
419 | + |
420 | +/* Draws a box from the screen coordinates inx1, iny1 to inx2, iny2. */ |
421 | void |
422 | EZoomScreen::drawBox (const GLMatrix &transform, |
423 | - CompOutput *output, |
424 | - CompRect box) |
425 | + CompOutput *output, |
426 | + CompRect box) |
427 | { |
428 | - GLMatrix zTransform (transform); |
429 | - int x1,x2,y1,y2; |
430 | - int inx1, inx2, iny1, iny2; |
431 | - int out = output->id (); |
432 | - GLushort colorData[4]; |
433 | - GLfloat vertexData[12]; |
434 | + GLMatrix zTransform (transform); |
435 | + int inx1, inx2, iny1, iny2; |
436 | + int out = output->id (); |
437 | + GLushort colorData[4]; |
438 | + GLushort *color; |
439 | + GLfloat vertexData[12]; |
440 | GLVertexBuffer *streamingBuffer = GLVertexBuffer::streamingBuffer (); |
441 | |
442 | zTransform.toScreenSpace (output, -DEFAULT_Z_CAMERA); |
443 | convertToZoomed (out, box.x1 (), box.y1 (), &inx1, &iny1); |
444 | convertToZoomed (out, box.x2 (), box.y2 (), &inx2, &iny2); |
445 | |
446 | - x1 = MIN (inx1, inx2); |
447 | - y1 = MIN (iny1, iny2); |
448 | - x2 = MAX (inx1, inx2); |
449 | - y2 = MAX (iny1, iny2); |
450 | - |
451 | - streamingBuffer->begin (GL_TRIANGLE_STRIP); |
452 | - |
453 | - colorData[0] = 0x2fff; |
454 | - colorData[1] = 0x2fff; |
455 | - colorData[2] = 0x2fff; |
456 | - colorData[3] = 0x4fff; |
457 | - |
458 | - streamingBuffer->addColors (1, colorData); |
459 | + /* We can move in both directions from our starting point |
460 | + * so we need to calculate the right coordinates first. */ |
461 | + int x1 = MIN (inx1, inx2); |
462 | + int y1 = MIN (iny1, iny2); |
463 | + int x2 = MAX (inx1, inx2); |
464 | + int y2 = MAX (iny1, iny2); |
465 | + |
466 | + const float MaxUShortFloat = std::numeric_limits <unsigned short>::max (); |
467 | + |
468 | + glEnable (GL_BLEND); |
469 | + |
470 | + /* Draw filled rectangle */ |
471 | + float alpha = optionGetZoomBoxFillColorAlpha () / MaxUShortFloat; |
472 | + color = optionGetZoomBoxFillColor (); |
473 | + |
474 | + colorData[0] = alpha * color[0]; |
475 | + colorData[1] = alpha * color[1]; |
476 | + colorData[2] = alpha * color[2]; |
477 | + colorData[3] = alpha * MaxUShortFloat; |
478 | |
479 | vertexData[0] = x1; |
480 | vertexData[1] = y1; |
481 | @@ -421,20 +425,22 @@ |
482 | vertexData[10] = y2; |
483 | vertexData[11] = 0.0f; |
484 | |
485 | + streamingBuffer->begin (GL_TRIANGLE_STRIP); |
486 | + |
487 | + streamingBuffer->addColors (1, colorData); |
488 | streamingBuffer->addVertices (4, vertexData); |
489 | |
490 | streamingBuffer->end (); |
491 | streamingBuffer->render (zTransform); |
492 | |
493 | - |
494 | - streamingBuffer->begin (GL_LINE_LOOP); |
495 | - |
496 | - colorData[0] = 0x2fff; |
497 | - colorData[1] = 0x2fff; |
498 | - colorData[2] = 0x4fff; |
499 | - colorData[3] = 0x9fff; |
500 | - |
501 | - streamingBuffer->addColors (1, colorData); |
502 | + /* Draw outline */ |
503 | + alpha = optionGetZoomBoxOutlineColorAlpha () / MaxUShortFloat; |
504 | + color = optionGetZoomBoxOutlineColor (); |
505 | + |
506 | + colorData[0] = alpha * color[0]; |
507 | + colorData[1] = alpha * color[1]; |
508 | + colorData[2] = alpha * color[2]; |
509 | + colorData[3] = alpha * MaxUShortFloat; |
510 | |
511 | vertexData[0] = x1; |
512 | vertexData[1] = y1; |
513 | @@ -449,20 +455,34 @@ |
514 | vertexData[10] = y2; |
515 | vertexData[11] = 0.0f; |
516 | |
517 | + glLineWidth (2.0); |
518 | + |
519 | + streamingBuffer->begin (GL_LINE_LOOP); |
520 | + |
521 | + streamingBuffer->addColors (1, colorData); |
522 | streamingBuffer->addVertices (4, vertexData); |
523 | |
524 | streamingBuffer->end (); |
525 | streamingBuffer->render (zTransform); |
526 | + |
527 | + glDisable (GL_BLEND); |
528 | + |
529 | + /* Damage the zoom selection box region during draw. */ |
530 | + cScreen->damageRegion (CompRegion (x1 - 1, |
531 | + y1 - 1, |
532 | + x2 - x1 + 1, |
533 | + y2 - y1 + 1)); |
534 | } |
535 | + |
536 | /* Apply the zoom if we are grabbed. |
537 | * Make sure to use the correct filter. |
538 | */ |
539 | bool |
540 | EZoomScreen::glPaintOutput (const GLScreenPaintAttrib &attrib, |
541 | - const GLMatrix &transform, |
542 | - const CompRegion ®ion, |
543 | - CompOutput *output, |
544 | - unsigned int mask) |
545 | + const GLMatrix &transform, |
546 | + const CompRegion ®ion, |
547 | + CompOutput *output, |
548 | + unsigned int mask) |
549 | { |
550 | bool status; |
551 | int out = output->id (); |
552 | @@ -476,8 +496,8 @@ |
553 | mask |= PAINT_SCREEN_CLEAR_MASK; |
554 | |
555 | zTransform.scale (1.0f / zooms.at (out).currentZoom, |
556 | - 1.0f / zooms.at (out).currentZoom, |
557 | - 1.0f); |
558 | + 1.0f / zooms.at (out).currentZoom, |
559 | + 1.0f); |
560 | zTransform.translate (zooms.at (out).xtrans, |
561 | zooms.at (out).ytrans, |
562 | 0); |
563 | @@ -490,10 +510,9 @@ |
564 | |
565 | } |
566 | else |
567 | - { |
568 | status = gScreen->glPaintOutput (attrib, transform, region, output, |
569 | - mask); |
570 | - } |
571 | + mask); |
572 | + |
573 | if (grabIndex) |
574 | drawBox (transform, output, box); |
575 | |
576 | @@ -502,14 +521,13 @@ |
577 | |
578 | /* Makes sure we're not attempting to translate too far. |
579 | * We are restricted to 0.5 to not go beyond the end |
580 | - * of the screen/head. */ |
581 | + * of the screen/head. */ |
582 | static inline void |
583 | constrainZoomTranslate () |
584 | { |
585 | - unsigned int out; |
586 | ZOOM_SCREEN (screen); |
587 | |
588 | - for (out = 0; out < zs->zooms.size (); out++) |
589 | + for (unsigned int out = 0; out < zs->zooms.size (); ++out) |
590 | { |
591 | if (zs->zooms.at (out).xTranslate > 0.5f) |
592 | zs->zooms.at (out).xTranslate = 0.5f; |
593 | @@ -526,7 +544,7 @@ |
594 | /* Functions for adjusting the zoomed area. |
595 | * These are the core of the zoom plug-in; Anything wanting |
596 | * to adjust the zoomed area must use setCenter or setZoomArea |
597 | - * and setScale or front ends to them. */ |
598 | + * and setScale or front ends to them. */ |
599 | |
600 | /* Sets the center of the zoom area to X,Y. |
601 | * We have to be able to warp the pointer here: If we are moved by |
602 | @@ -568,20 +586,19 @@ |
603 | * The math could probably be cleaned up, but should be correct now. */ |
604 | void |
605 | EZoomScreen::setZoomArea (int x, |
606 | - int y, |
607 | - int width, |
608 | - int height, |
609 | - bool instant) |
610 | + int y, |
611 | + int width, |
612 | + int height, |
613 | + bool instant) |
614 | { |
615 | CompWindow::Geometry outGeometry (x, y, width, height, 0); |
616 | int out = screen->outputDeviceForGeometry (outGeometry); |
617 | CompOutput *o = &screen->outputDevs ().at (out); |
618 | |
619 | - if (zooms.at (out).newZoom == 1.0f) |
620 | + if (zooms.at (out).newZoom == 1.0f || |
621 | + zooms.at (out).locked) |
622 | return; |
623 | |
624 | - if (zooms.at (out).locked) |
625 | - return; |
626 | zooms.at (out).xTranslate = |
627 | (float) -((o->width () / 2) - (x + (width / 2) - o->x1 ())) |
628 | / (o->width ()); |
629 | @@ -607,9 +624,9 @@ |
630 | void |
631 | EZoomScreen::areaToWindow (CompWindow *w) |
632 | { |
633 | - int left = w->serverX () - w->border ().left; |
634 | - int width = w->width () + w->border ().left + w->border ().right; |
635 | - int top = w->serverY () - w->border ().top; |
636 | + int left = w->serverX () - w->border ().left; |
637 | + int width = w->width () + w->border ().left + w->border ().right; |
638 | + int top = w->serverY () - w->border ().top; |
639 | int height = w->height () + w->border ().top + w->border ().bottom; |
640 | |
641 | setZoomArea (left, top, width, height, false); |
642 | @@ -620,9 +637,7 @@ |
643 | void |
644 | EZoomScreen::panZoom (int xvalue, int yvalue) |
645 | { |
646 | - unsigned int out; |
647 | - |
648 | - for (out = 0; out < zooms.size (); out++) |
649 | + for (unsigned int out = 0; out < zooms.size (); ++out) |
650 | { |
651 | zooms.at (out).xTranslate += |
652 | optionGetPanFactor () * xvalue * |
653 | @@ -661,6 +676,7 @@ |
654 | { |
655 | if (!pollHandle.active ()) |
656 | enableMousePolling (); |
657 | + |
658 | grabbed |= (1 << zooms.at (out).output); |
659 | cursorZoomActive (out); |
660 | } |
661 | @@ -702,23 +718,22 @@ |
662 | void |
663 | EZoomScreen::syncCenterToMouse () |
664 | { |
665 | - int x, y; |
666 | - int out; |
667 | CompOutput *o; |
668 | |
669 | - out = screen->outputDeviceForPoint (mouse.x (), mouse.y ()); |
670 | + int out = screen->outputDeviceForPoint (mouse.x (), mouse.y ()); |
671 | o = &screen->outputDevs ().at (out); |
672 | |
673 | if (!isInMovement (out)) |
674 | return; |
675 | |
676 | - x = (int) ((zooms.at (out).realXTranslate * o->width ()) + |
677 | - (o->width () / 2) + o->x1 ()); |
678 | - y = (int) ((zooms.at (out).realYTranslate * o->height ()) + |
679 | - (o->height () / 2) + o->y1 ()); |
680 | + int x = (int) ((zooms.at (out).realXTranslate * o->width ()) + |
681 | + (o->width () / 2) + o->x1 ()); |
682 | + int y = (int) ((zooms.at (out).realYTranslate * o->height ()) + |
683 | + (o->height () / 2) + o->y1 ()); |
684 | |
685 | - if ((x != mouse.x () || y != mouse.y ()) |
686 | - && grabbed && zooms.at (out).newZoom != 1.0f) |
687 | + if ((x != mouse.x () || y != mouse.y ()) && |
688 | + grabbed && |
689 | + zooms.at (out).newZoom != 1.0f) |
690 | { |
691 | screen->warpPointer (x - pointerX , y - pointerY ); |
692 | mouse.setX (x); |
693 | @@ -726,13 +741,13 @@ |
694 | } |
695 | } |
696 | |
697 | -/* Convert the point X,Y to where it would be when zoomed. */ |
698 | +/* Convert the point X, Y to where it would be when zoomed. */ |
699 | void |
700 | EZoomScreen::convertToZoomed (int out, |
701 | - int x, |
702 | - int y, |
703 | - int *resultX, |
704 | - int *resultY) |
705 | + int x, |
706 | + int y, |
707 | + int *resultX, |
708 | + int *resultY) |
709 | { |
710 | CompOutput *o; |
711 | |
712 | @@ -747,25 +762,26 @@ |
713 | |
714 | x -= o->x1 (); |
715 | y -= o->y1 (); |
716 | + |
717 | *resultX = x - (za.realXTranslate * |
718 | (1.0f - za.currentZoom) * o->width ()) - o->width () / 2; |
719 | *resultX /= za.currentZoom; |
720 | *resultX += o->width () / 2; |
721 | *resultX += o->x1 (); |
722 | *resultY = y - (za.realYTranslate * |
723 | - (1.0f - za.currentZoom) * o->height ()) - o->height ()/ 2; |
724 | + (1.0f - za.currentZoom) * o->height ()) - o->height () / 2; |
725 | *resultY /= za.currentZoom; |
726 | - *resultY += o->height ()/ 2; |
727 | + *resultY += o->height () / 2; |
728 | *resultY += o->y1 (); |
729 | } |
730 | |
731 | -/* Same but use targeted translation, not real */ |
732 | +/* Same but use targeted translation, not real one. */ |
733 | void |
734 | EZoomScreen::convertToZoomedTarget (int out, |
735 | - int x, |
736 | - int y, |
737 | - int *resultX, |
738 | - int *resultY) |
739 | + int x, |
740 | + int y, |
741 | + int *resultX, |
742 | + int *resultY) |
743 | { |
744 | CompOutput *o = &screen->outputDevs ().at (out); |
745 | |
746 | @@ -779,13 +795,14 @@ |
747 | |
748 | x -= o->x1 (); |
749 | y -= o->y1 (); |
750 | + |
751 | *resultX = x - (za.xTranslate * |
752 | (1.0f - za.newZoom) * o->width ()) - o->width () / 2; |
753 | *resultX /= za.newZoom; |
754 | *resultX += o->width () / 2; |
755 | *resultX += o->x1 (); |
756 | *resultY = y - (za.yTranslate * |
757 | - (1.0f - za.newZoom) * o->height ()) - o->height ()/2; |
758 | + (1.0f - za.newZoom) * o->height ()) - o->height () / 2; |
759 | *resultY /= za.newZoom; |
760 | *resultY += o->height () / 2; |
761 | *resultY += o->y1 (); |
762 | @@ -799,16 +816,17 @@ |
763 | EZoomScreen::ensureVisibility (int x, int y, int margin) |
764 | { |
765 | int zoomX, zoomY; |
766 | - int out; |
767 | CompOutput *o; |
768 | |
769 | - out = screen->outputDeviceForPoint (x, y); |
770 | + int out = screen->outputDeviceForPoint (x, y); |
771 | + |
772 | if (!isActive (out)) |
773 | return false; |
774 | |
775 | o = &screen->outputDevs ().at (out); |
776 | convertToZoomedTarget (out, x, y, &zoomX, &zoomY); |
777 | ZoomArea &za = zooms.at (out); |
778 | + |
779 | if (za.locked) |
780 | return false; |
781 | |
782 | @@ -846,24 +864,23 @@ |
783 | */ |
784 | void |
785 | EZoomScreen::ensureVisibilityArea (int x1, |
786 | - int y1, |
787 | - int x2, |
788 | - int y2, |
789 | - int margin, |
790 | - ZoomGravity gravity) |
791 | + int y1, |
792 | + int x2, |
793 | + int y2, |
794 | + int margin, |
795 | + ZoomGravity gravity) |
796 | { |
797 | int targetX, targetY, targetW, targetH; |
798 | - int out; |
799 | - CompOutput *o; |
800 | - |
801 | - out = screen->outputDeviceForPoint (x1 + (x2-x1/2), y1 + (y2-y1/2)); |
802 | - o = &screen->outputDevs ().at (out); |
803 | - |
804 | -#define WIDTHOK (float)(x2-x1) / (float)o->width () < zooms.at (out).newZoom |
805 | -#define HEIGHTOK (float)(y2-y1) / (float)o->height () < zooms.at (out).newZoom |
806 | - |
807 | - if (WIDTHOK && |
808 | - HEIGHTOK) { |
809 | + |
810 | + int out = screen->outputDeviceForPoint (x1 + (x2 - x1 / 2), y1 + (y2 - y1 / 2)); |
811 | + CompOutput *o = &screen->outputDevs ().at (out); |
812 | + |
813 | + bool widthOkay = (float)(x2-x1) / (float)o->width () < zooms.at (out).newZoom; |
814 | + bool heightOkay = (float)(y2-y1) / (float)o->height () < zooms.at (out).newZoom; |
815 | + |
816 | + if (widthOkay && |
817 | + heightOkay) |
818 | + { |
819 | ensureVisibility (x1, y1, margin); |
820 | ensureVisibility (x2, y2, margin); |
821 | return; |
822 | @@ -874,18 +891,23 @@ |
823 | case NORTHWEST: |
824 | targetX = x1; |
825 | targetY = y1; |
826 | - if (WIDTHOK) |
827 | + |
828 | + if (widthOkay) |
829 | targetW = x2 - x1; |
830 | else |
831 | targetW = o->width () * zooms.at (out).newZoom; |
832 | - if (HEIGHTOK) |
833 | + |
834 | + if (heightOkay) |
835 | targetH = y2 - y1; |
836 | else |
837 | targetH = o->height () * zooms.at (out).newZoom; |
838 | + |
839 | break; |
840 | + |
841 | case NORTHEAST: |
842 | targetY = y1; |
843 | - if (WIDTHOK) |
844 | + |
845 | + if (widthOkay) |
846 | { |
847 | targetX = x1; |
848 | targetW = x2-x1; |
849 | @@ -896,18 +918,22 @@ |
850 | targetW = o->width () * zooms.at (out).newZoom; |
851 | } |
852 | |
853 | - if (HEIGHTOK) |
854 | + if (heightOkay) |
855 | targetH = y2-y1; |
856 | else |
857 | targetH = o->height () * zooms.at (out).newZoom; |
858 | + |
859 | break; |
860 | + |
861 | case SOUTHWEST: |
862 | targetX = x1; |
863 | - if (WIDTHOK) |
864 | + |
865 | + if (widthOkay) |
866 | targetW = x2-x1; |
867 | else |
868 | targetW = o->width () * zooms.at (out).newZoom; |
869 | - if (HEIGHTOK) |
870 | + |
871 | + if (heightOkay) |
872 | { |
873 | targetY = y1; |
874 | targetH = y2-y1; |
875 | @@ -917,9 +943,11 @@ |
876 | targetY = y2 - (o->width () * zooms.at (out).newZoom); |
877 | targetH = o->width () * zooms.at (out).newZoom; |
878 | } |
879 | + |
880 | break; |
881 | + |
882 | case SOUTHEAST: |
883 | - if (WIDTHOK) |
884 | + if (widthOkay) |
885 | { |
886 | targetX = x1; |
887 | targetW = x2-x1; |
888 | @@ -930,7 +958,7 @@ |
889 | targetX = x2 - targetW; |
890 | } |
891 | |
892 | - if (HEIGHTOK) |
893 | + if (heightOkay) |
894 | { |
895 | targetY = y1; |
896 | targetH = y2 - y1; |
897 | @@ -940,15 +968,19 @@ |
898 | targetH = o->height () * zooms.at (out).newZoom; |
899 | targetY = y2 - targetH; |
900 | } |
901 | + |
902 | break; |
903 | + |
904 | case CENTER: |
905 | default: |
906 | setCenter (x1 + (x2 - x1 / 2), y1 + (y2 - y1 / 2), false); |
907 | return; |
908 | + |
909 | break; |
910 | } |
911 | |
912 | setZoomArea (targetX, targetY, targetW, targetH, false); |
913 | + |
914 | return ; |
915 | } |
916 | |
917 | @@ -960,18 +992,16 @@ |
918 | void |
919 | EZoomScreen::restrainCursor (int out) |
920 | { |
921 | - int x1, y1, x2, y2, margin; |
922 | + int x1, y1, x2, y2; |
923 | int diffX = 0, diffY = 0; |
924 | - int north, south, east, west; |
925 | - float z; |
926 | CompOutput *o = &screen->outputDevs ().at (out); |
927 | |
928 | - z = zooms.at (out).newZoom; |
929 | - margin = optionGetRestrainMargin (); |
930 | - north = distanceToEdge (out, NORTH); |
931 | - south = distanceToEdge (out, SOUTH); |
932 | - east = distanceToEdge (out, EAST); |
933 | - west = distanceToEdge (out, WEST); |
934 | + float z = zooms.at (out).newZoom; |
935 | + int margin = optionGetRestrainMargin (); |
936 | + int north = distanceToEdge (out, NORTH); |
937 | + int south = distanceToEdge (out, SOUTH); |
938 | + int east = distanceToEdge (out, EAST); |
939 | + int west = distanceToEdge (out, WEST); |
940 | |
941 | if (zooms.at (out).currentZoom == 1.0f) |
942 | { |
943 | @@ -990,6 +1020,7 @@ |
944 | if ((x2 - x1 > o->x2 () - o->x1 ()) || |
945 | (y2 - y1 > o->y2 () - o->y1 ())) |
946 | return; |
947 | + |
948 | if (x2 > o->x2 () - margin && east > 0) |
949 | diffX = x2 - o->x2 () + margin; |
950 | else if (x1 < o->x1 () + margin && west > 0) |
951 | @@ -1002,9 +1033,9 @@ |
952 | |
953 | if (abs(diffX)*z > 0 || abs(diffY)*z > 0) |
954 | screen->warpPointer ((int) (mouse.x () - pointerX) - |
955 | - (int) ((float)diffX * z), |
956 | - (int) (mouse.y () - pointerY) - |
957 | - (int) ((float)diffY * z)); |
958 | + (int) ((float)diffX * z), |
959 | + (int) (mouse.y () - pointerY) - |
960 | + (int) ((float)diffY * z)); |
961 | } |
962 | |
963 | /* Check if the cursor is still visible. |
964 | @@ -1016,16 +1047,14 @@ |
965 | void |
966 | EZoomScreen::cursorMoved () |
967 | { |
968 | - int out; |
969 | + int out = screen->outputDeviceForPoint (mouse.x (), mouse.y ()); |
970 | |
971 | - out = screen->outputDeviceForPoint (mouse.x (), mouse.y ()); |
972 | if (isActive (out)) |
973 | { |
974 | if (optionGetRestrainMouse ()) |
975 | restrainCursor (out); |
976 | |
977 | if (optionGetZoomMode () == EzoomOptions::ZoomModePanArea) |
978 | - { |
979 | ensureVisibilityArea (mouse.x () - cursor.hotX, |
980 | mouse.y () - cursor.hotY, |
981 | mouse.x () + cursor.width - |
982 | @@ -1034,14 +1063,11 @@ |
983 | cursor.hotY, |
984 | optionGetRestrainMargin (), |
985 | NORTHWEST); |
986 | - } |
987 | |
988 | cursorZoomActive (out); |
989 | } |
990 | else |
991 | - { |
992 | cursorZoomInactive (); |
993 | - } |
994 | } |
995 | |
996 | /* Update the mouse position. |
997 | @@ -1051,14 +1077,16 @@ |
998 | void |
999 | EZoomScreen::updateMousePosition (const CompPoint &p) |
1000 | { |
1001 | - int out; |
1002 | mouse.setX (p.x ()); |
1003 | mouse.setY (p.y ()); |
1004 | - out = screen->outputDeviceForPoint (mouse.x (), mouse.y ()); |
1005 | + |
1006 | + int out = screen->outputDeviceForPoint (mouse.x (), mouse.y ()); |
1007 | lastChange = time(NULL); |
1008 | + |
1009 | if (optionGetZoomMode () == EzoomOptions::ZoomModeSyncMouse && |
1010 | - !isInMovement (out)) |
1011 | + !isInMovement (out)) |
1012 | setCenter (mouse.x (), mouse.y (), true); |
1013 | + |
1014 | cursorMoved (); |
1015 | cScreen->damageScreen (); |
1016 | } |
1017 | @@ -1073,6 +1101,7 @@ |
1018 | if (!grabbed) |
1019 | { |
1020 | cursorMoved (); |
1021 | + |
1022 | if (pollHandle.active ()) |
1023 | pollHandle.stop (); |
1024 | } |
1025 | @@ -1092,25 +1121,25 @@ |
1026 | |
1027 | /* Translate into place and draw the scaled cursor. */ |
1028 | void |
1029 | -EZoomScreen::drawCursor (CompOutput *output, |
1030 | - const GLMatrix &transform) |
1031 | +EZoomScreen::drawCursor (CompOutput *output, |
1032 | + const GLMatrix &transform) |
1033 | { |
1034 | - int out = output->id (); |
1035 | + int out = output->id (); |
1036 | |
1037 | if (cursor.isSet) |
1038 | { |
1039 | - GLMatrix sTransform = transform; |
1040 | - float scaleFactor; |
1041 | - int ax, ay, x, y; |
1042 | - GLfloat textureData[8]; |
1043 | - GLfloat vertexData[12]; |
1044 | + GLMatrix sTransform = transform; |
1045 | + float scaleFactor; |
1046 | + int ax, ay; |
1047 | + GLfloat textureData[8]; |
1048 | + GLfloat vertexData[12]; |
1049 | GLVertexBuffer *streamingBuffer = GLVertexBuffer::streamingBuffer (); |
1050 | |
1051 | /* |
1052 | * XXX: expo knows how to handle mouse when zoomed, so we back off |
1053 | * when expo is active. |
1054 | */ |
1055 | - if (screen->grabExist ( "expo")) |
1056 | + if (screen->grabExist ("expo")) |
1057 | { |
1058 | cursorZoomInactive (); |
1059 | return; |
1060 | @@ -1126,11 +1155,10 @@ |
1061 | scaleFactor = 1.0f / optionGetScaleMouseStatic (); |
1062 | |
1063 | sTransform.scale (scaleFactor, scaleFactor, 1.0f); |
1064 | - x = -cursor.hotX; |
1065 | - y = -cursor.hotY; |
1066 | + int x = -cursor.hotX; |
1067 | + int y = -cursor.hotY; |
1068 | |
1069 | glEnable (GL_BLEND); |
1070 | - glEnable (GL_TEXTURE_2D); |
1071 | glBindTexture (GL_TEXTURE_2D, cursor.texture); |
1072 | |
1073 | streamingBuffer->begin (GL_TRIANGLE_STRIP); |
1074 | @@ -1165,45 +1193,40 @@ |
1075 | streamingBuffer->render (sTransform); |
1076 | |
1077 | glBindTexture (GL_TEXTURE_2D, 0); |
1078 | - glDisable (GL_TEXTURE_2D); |
1079 | glDisable (GL_BLEND); |
1080 | } |
1081 | } |
1082 | |
1083 | /* Create (if necessary) a texture to store the cursor, |
1084 | - * fetch the cursor with XFixes. Store it. */ |
1085 | + * fetch the cursor with XFixes. Store it. */ |
1086 | void |
1087 | EZoomScreen::updateCursor (CursorTexture * cursor) |
1088 | { |
1089 | unsigned char *pixels; |
1090 | - int i; |
1091 | - Display *dpy = screen->dpy (); |
1092 | + int i; |
1093 | + Display *dpy = screen->dpy (); |
1094 | |
1095 | if (!cursor->isSet) |
1096 | { |
1097 | cursor->isSet = true; |
1098 | cursor->screen = screen; |
1099 | |
1100 | - glEnable (GL_TEXTURE_2D); |
1101 | glGenTextures (1, &cursor->texture); |
1102 | glBindTexture (GL_TEXTURE_2D, cursor->texture); |
1103 | |
1104 | glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); |
1105 | glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); |
1106 | glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, |
1107 | - gScreen->textureFilter ()); |
1108 | - glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, |
1109 | - gScreen->textureFilter ()); |
1110 | - } |
1111 | - else { |
1112 | - glEnable (GL_TEXTURE_2D); |
1113 | + gScreen->textureFilter ()); |
1114 | + glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, |
1115 | + gScreen->textureFilter ()); |
1116 | } |
1117 | |
1118 | XFixesCursorImage *ci = XFixesGetCursorImage (dpy); |
1119 | |
1120 | if (ci) |
1121 | { |
1122 | - cursor->width = ci->width; |
1123 | + cursor->width = ci->width; |
1124 | cursor->height = ci->height; |
1125 | cursor->hotX = ci->xhot; |
1126 | cursor->hotY = ci->yhot; |
1127 | @@ -1215,7 +1238,7 @@ |
1128 | return; |
1129 | } |
1130 | |
1131 | - for (i = 0; i < ci->width * ci->height; i++) |
1132 | + for (i = 0; i < ci->width * ci->height; ++i) |
1133 | { |
1134 | unsigned long pix = ci->pixels[i]; |
1135 | pixels[i * 4] = pix & 0xff; |
1136 | @@ -1240,7 +1263,7 @@ |
1137 | if (!pixels) |
1138 | return; |
1139 | |
1140 | - for (i = 0; i < cursor->width * cursor->height; i++) |
1141 | + for (i = 0; i < cursor->width * cursor->height; ++i) |
1142 | { |
1143 | unsigned long pix = 0x00ffffff; |
1144 | pixels[i * 4] = pix & 0xff; |
1145 | @@ -1256,8 +1279,7 @@ |
1146 | glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA, cursor->width, |
1147 | cursor->height, 0, GL_BGRA, GL_UNSIGNED_BYTE, pixels); |
1148 | glBindTexture (GL_TEXTURE_2D, 0); |
1149 | - glDisable (GL_TEXTURE_2D); |
1150 | - |
1151 | + |
1152 | free (pixels); |
1153 | } |
1154 | |
1155 | @@ -1275,9 +1297,7 @@ |
1156 | } |
1157 | |
1158 | if (cursor.isSet) |
1159 | - { |
1160 | freeCursor (&cursor); |
1161 | - } |
1162 | |
1163 | if (cursorHidden) |
1164 | { |
1165 | @@ -1300,7 +1320,6 @@ |
1166 | /* Force cursor hiding and mouse panning if this output is locked |
1167 | * and cursor hiding is not enabled and we are syncing the mouse |
1168 | */ |
1169 | - |
1170 | if (!optionGetScaleMouse () && |
1171 | (optionGetZoomMode () == EzoomOptions::ZoomModeSyncMouse && |
1172 | optionGetHideOriginalMouse () && |
1173 | @@ -1314,6 +1333,7 @@ |
1174 | XFixesDisplayCursorNotifyMask); |
1175 | updateCursor (&cursor); |
1176 | } |
1177 | + |
1178 | if (canHideCursor && !cursorHidden && |
1179 | (optionGetHideOriginalMouse () || |
1180 | zooms.at (out).locked)) |
1181 | @@ -1336,39 +1356,40 @@ |
1182 | */ |
1183 | bool |
1184 | EZoomScreen::setZoomAreaAction (CompAction *action, |
1185 | - CompAction::State state, |
1186 | - CompOption::Vector options) |
1187 | + CompAction::State state, |
1188 | + CompOption::Vector options) |
1189 | { |
1190 | - int x1, y1, x2, y2, out; |
1191 | - bool scale, restrain; |
1192 | CompOutput *o; |
1193 | |
1194 | - x1 = CompOption::getIntOptionNamed (options, "x1", -1); |
1195 | - y1 = CompOption::getIntOptionNamed (options, "y1", -1); |
1196 | - x2 = CompOption::getIntOptionNamed (options, "x2", -1); |
1197 | - y2 = CompOption::getIntOptionNamed (options, "y2", -1); |
1198 | - scale = CompOption::getBoolOptionNamed (options, "scale", false); |
1199 | - restrain = CompOption::getBoolOptionNamed (options, "restrain", false); |
1200 | + int x1 = CompOption::getIntOptionNamed (options, "x1", -1); |
1201 | + int y1 = CompOption::getIntOptionNamed (options, "y1", -1); |
1202 | + int x2 = CompOption::getIntOptionNamed (options, "x2", -1); |
1203 | + int y2 = CompOption::getIntOptionNamed (options, "y2", -1); |
1204 | + |
1205 | + bool scale = CompOption::getBoolOptionNamed (options, "scale", false); |
1206 | + bool restrain = CompOption::getBoolOptionNamed (options, "restrain", false); |
1207 | |
1208 | if (x1 < 0 || y1 < 0) |
1209 | - return false; |
1210 | + return false; |
1211 | |
1212 | if (x2 < 0) |
1213 | - x2 = x1 + 1; |
1214 | + x2 = x1 + 1; |
1215 | |
1216 | if (y2 < 0) |
1217 | - y2 = y1 + 1; |
1218 | - |
1219 | - out = screen->outputDeviceForPoint (x1, y1); |
1220 | -#define WIDTH (x2 - x1) |
1221 | -#define HEIGHT (y2 - y1) |
1222 | - setZoomArea (x1, y1, WIDTH, HEIGHT, false); |
1223 | + y2 = y1 + 1; |
1224 | + |
1225 | + int out = screen->outputDeviceForPoint (x1, y1); |
1226 | + |
1227 | + int width = x2 - x1; |
1228 | + int height = y2 - y1; |
1229 | + |
1230 | + setZoomArea (x1, y1, width, height, false); |
1231 | o = &screen->outputDevs (). at(out); |
1232 | - if (scale && WIDTH && HEIGHT) |
1233 | - setScaleBigger (out, (float) WIDTH / o->width (), |
1234 | - (float) HEIGHT / o->height ()); |
1235 | -#undef WIDTH |
1236 | -#undef HEIGHT |
1237 | + |
1238 | + if (scale && width && height) |
1239 | + setScaleBigger (out, width / static_cast <float> (o->width ()), |
1240 | + height / static_cast <float> (o->height ())); |
1241 | + |
1242 | if (restrain) |
1243 | restrainCursor (out); |
1244 | |
1245 | @@ -1389,36 +1410,40 @@ |
1246 | */ |
1247 | bool |
1248 | EZoomScreen::ensureVisibilityAction (CompAction *action, |
1249 | - CompAction::State state, |
1250 | - CompOption::Vector options) |
1251 | + CompAction::State state, |
1252 | + CompOption::Vector options) |
1253 | { |
1254 | - int x1, y1, x2, y2, margin, out; |
1255 | - bool scale, restrain; |
1256 | CompOutput *o; |
1257 | |
1258 | - x1 = CompOption::getIntOptionNamed (options, "x1", -1); |
1259 | - y1 = CompOption::getIntOptionNamed (options, "y1", -1); |
1260 | - x2 = CompOption::getIntOptionNamed (options, "x2", -1); |
1261 | - y2 = CompOption::getIntOptionNamed (options, "y2", -1); |
1262 | - margin = CompOption::getBoolOptionNamed (options, "margin", 0); |
1263 | - scale = CompOption::getBoolOptionNamed (options, "scale", false); |
1264 | - restrain = CompOption::getBoolOptionNamed (options, "restrain", false); |
1265 | + int x1 = CompOption::getIntOptionNamed (options, "x1", -1); |
1266 | + int y1 = CompOption::getIntOptionNamed (options, "y1", -1); |
1267 | + int x2 = CompOption::getIntOptionNamed (options, "x2", -1); |
1268 | + int y2 = CompOption::getIntOptionNamed (options, "y2", -1); |
1269 | + int margin = CompOption::getBoolOptionNamed (options, "margin", 0); |
1270 | + bool scale = CompOption::getBoolOptionNamed (options, "scale", false); |
1271 | + bool restrain = CompOption::getBoolOptionNamed (options, "restrain", false); |
1272 | + |
1273 | if (x1 < 0 || y1 < 0) |
1274 | - return false; |
1275 | + return false; |
1276 | + |
1277 | if (x2 < 0) |
1278 | - y2 = y1 + 1; |
1279 | - out = screen->outputDeviceForPoint (x1, y1); |
1280 | + y2 = y1 + 1; |
1281 | + |
1282 | + int out = screen->outputDeviceForPoint (x1, y1); |
1283 | ensureVisibility (x1, y1, margin); |
1284 | + |
1285 | if (x2 >= 0 && y2 >= 0) |
1286 | - ensureVisibility (x2, y2, margin); |
1287 | + ensureVisibility (x2, y2, margin); |
1288 | + |
1289 | o = &screen->outputDevs (). at(out); |
1290 | -#define WIDTH (x2 - x1) |
1291 | -#define HEIGHT (y2 - y1) |
1292 | - if (scale && WIDTH && HEIGHT) |
1293 | - setScaleBigger (out, (float) WIDTH / o->width (), |
1294 | - (float) HEIGHT / o->height ()); |
1295 | -#undef WIDTH |
1296 | -#undef HEIGHT |
1297 | + |
1298 | + int width = x2 - x1; |
1299 | + int height = y2 - y1; |
1300 | + |
1301 | + if (scale && width && height) |
1302 | + setScaleBigger (out, width / static_cast <float> (o->width ()), |
1303 | + height / static_cast <float> (o->height ())); |
1304 | + |
1305 | if (restrain) |
1306 | restrainCursor (out); |
1307 | |
1308 | @@ -1431,15 +1456,16 @@ |
1309 | |
1310 | bool |
1311 | EZoomScreen::zoomBoxActivate (CompAction *action, |
1312 | - CompAction::State state, |
1313 | - CompOption::Vector options) |
1314 | + CompAction::State state, |
1315 | + CompOption::Vector options) |
1316 | { |
1317 | grabIndex = screen->pushGrab (None, "ezoom"); |
1318 | clickPos.setX (pointerX); |
1319 | clickPos.setY (pointerY); |
1320 | box.setGeometry (pointerX, pointerY, 0, 0); |
1321 | + |
1322 | if (state & CompAction::StateInitButton) |
1323 | - action->setState (action->state () | CompAction::StateTermButton); |
1324 | + action->setState (action->state () | CompAction::StateTermButton); |
1325 | |
1326 | toggleFunctions (true); |
1327 | |
1328 | @@ -1448,50 +1474,44 @@ |
1329 | |
1330 | bool |
1331 | EZoomScreen::zoomBoxDeactivate (CompAction *action, |
1332 | - CompAction::State state, |
1333 | - CompOption::Vector options) |
1334 | + CompAction::State state, |
1335 | + CompOption::Vector options) |
1336 | { |
1337 | if (grabIndex) |
1338 | { |
1339 | - int out; |
1340 | - int x, y, width, height; |
1341 | - CompOutput *o; |
1342 | - |
1343 | - screen->removeGrab (grabIndex, NULL); |
1344 | - grabIndex = 0; |
1345 | - |
1346 | - if (pointerX < clickPos.x ()) |
1347 | - { |
1348 | + CompOutput *o; |
1349 | + |
1350 | + screen->removeGrab (grabIndex, NULL); |
1351 | + grabIndex = 0; |
1352 | + |
1353 | + if (pointerX < clickPos.x ()) |
1354 | + { |
1355 | box.setX (pointerX); |
1356 | box.setWidth (clickPos.x () - pointerX); |
1357 | - } |
1358 | - else |
1359 | - { |
1360 | + } |
1361 | + else |
1362 | box.setWidth (pointerX - clickPos.x ()); |
1363 | - } |
1364 | |
1365 | - if (pointerY < clickPos.y ()) |
1366 | - { |
1367 | + if (pointerY < clickPos.y ()) |
1368 | + { |
1369 | box.setY (pointerY); |
1370 | box.setHeight (clickPos.y () - pointerY); |
1371 | - } |
1372 | - else |
1373 | - { |
1374 | + } |
1375 | + else |
1376 | box.setHeight (pointerY - clickPos.y ()); |
1377 | - } |
1378 | - |
1379 | - x = MIN (box.x1 (), box.x2 ()); |
1380 | - y = MIN (box.y1 (), box.y2 ()); |
1381 | - width = MAX (box.x1 (), box.x2 ()) - x; |
1382 | - height = MAX (box.y1 (), box.y2 ()) - y; |
1383 | - |
1384 | - CompWindow::Geometry outGeometry (x, y, width, height, 0); |
1385 | - |
1386 | - out = screen->outputDeviceForGeometry (outGeometry); |
1387 | - o = &screen->outputDevs (). at (out); |
1388 | - setScaleBigger (out, (float) width/o->width (), (float) |
1389 | - height/o->height ()); |
1390 | - setZoomArea (x,y,width,height,false); |
1391 | + |
1392 | + int x = MIN (box.x1 (), box.x2 ()); |
1393 | + int y = MIN (box.y1 (), box.y2 ()); |
1394 | + int width = MAX (box.x1 (), box.x2 ()) - x; |
1395 | + int height = MAX (box.y1 (), box.y2 ()) - y; |
1396 | + |
1397 | + CompWindow::Geometry outGeometry (x, y, width, height, 0); |
1398 | + |
1399 | + int out = screen->outputDeviceForGeometry (outGeometry); |
1400 | + o = &screen->outputDevs (). at (out); |
1401 | + setScaleBigger (out, width / static_cast <float> (o->width ()), |
1402 | + height / static_cast <float> (o->height ())); |
1403 | + setZoomArea (x, y, width, height, false); |
1404 | } |
1405 | |
1406 | toggleFunctions (true); |
1407 | @@ -1503,14 +1523,14 @@ |
1408 | */ |
1409 | bool |
1410 | EZoomScreen::zoomIn (CompAction *action, |
1411 | - CompAction::State state, |
1412 | - CompOption::Vector options) |
1413 | + CompAction::State state, |
1414 | + CompOption::Vector options) |
1415 | { |
1416 | int out = screen->outputDeviceForPoint (pointerX, pointerY); |
1417 | |
1418 | if (optionGetZoomMode () == EzoomOptions::ZoomModeSyncMouse && |
1419 | !isInMovement (out)) |
1420 | - setCenter (pointerX, pointerY, true); |
1421 | + setCenter (pointerX, pointerY, true); |
1422 | |
1423 | setScale (out, |
1424 | zooms.at (out).newZoom / |
1425 | @@ -1525,8 +1545,8 @@ |
1426 | */ |
1427 | bool |
1428 | EZoomScreen::lockZoomAction (CompAction *action, |
1429 | - CompAction::State state, |
1430 | - CompOption::Vector options) |
1431 | + CompAction::State state, |
1432 | + CompOption::Vector options) |
1433 | { |
1434 | int out = screen->outputDeviceForPoint (pointerX, pointerY); |
1435 | zooms.at (out).locked = !zooms.at (out).locked; |
1436 | @@ -1543,12 +1563,12 @@ |
1437 | */ |
1438 | bool |
1439 | EZoomScreen::zoomSpecific (CompAction *action, |
1440 | - CompAction::State state, |
1441 | - CompOption::Vector options, |
1442 | - SpecificZoomTarget target) |
1443 | + CompAction::State state, |
1444 | + CompOption::Vector options, |
1445 | + SpecificZoomTarget target) |
1446 | { |
1447 | - int out = screen->outputDeviceForPoint (pointerX, pointerY); |
1448 | - float zoom_level; |
1449 | + int out = screen->outputDeviceForPoint (pointerX, pointerY); |
1450 | + float zoom_level; |
1451 | CompWindow *w; |
1452 | |
1453 | switch (target) |
1454 | @@ -1556,34 +1576,36 @@ |
1455 | case ZoomTargetFirst: |
1456 | zoom_level = optionGetZoomSpec1 (); |
1457 | break; |
1458 | + |
1459 | case ZoomTargetSecond: |
1460 | zoom_level = optionGetZoomSpec2 (); |
1461 | break; |
1462 | + |
1463 | case ZoomTargetThird: |
1464 | zoom_level = optionGetZoomSpec3 (); |
1465 | break; |
1466 | + |
1467 | default: |
1468 | return false; |
1469 | } |
1470 | |
1471 | if (zoom_level == 1.0f && zooms.at (out).newZoom == 1.0f) |
1472 | - return false; |
1473 | + return false; |
1474 | + |
1475 | if (screen->otherGrabExist (NULL)) |
1476 | - return false; |
1477 | + return false; |
1478 | |
1479 | setScale (out, zoom_level); |
1480 | |
1481 | w = screen->findWindow (screen->activeWindow ()); |
1482 | - if (optionGetSpecTargetFocus () |
1483 | - && w) |
1484 | - { |
1485 | - areaToWindow (w); |
1486 | - } |
1487 | + |
1488 | + if (optionGetSpecTargetFocus () && w) |
1489 | + areaToWindow (w); |
1490 | else |
1491 | { |
1492 | - int x = CompOption::getIntOptionNamed (options, "x", 0); |
1493 | - int y = CompOption::getIntOptionNamed (options, "y", 0); |
1494 | - setCenter (x, y, false); |
1495 | + int x = CompOption::getIntOptionNamed (options, "x", 0); |
1496 | + int y = CompOption::getIntOptionNamed (options, "y", 0); |
1497 | + setCenter (x, y, false); |
1498 | } |
1499 | |
1500 | toggleFunctions (true); |
1501 | @@ -1598,24 +1620,24 @@ |
1502 | */ |
1503 | bool |
1504 | EZoomScreen::zoomToWindow (CompAction *action, |
1505 | - CompAction::State state, |
1506 | - CompOption::Vector options) |
1507 | + CompAction::State state, |
1508 | + CompOption::Vector options) |
1509 | { |
1510 | - int width, height, out; |
1511 | - Window xid; |
1512 | CompWindow *w; |
1513 | CompOutput *o; |
1514 | |
1515 | - xid = CompOption::getIntOptionNamed (options, "window", 0); |
1516 | + Window xid = CompOption::getIntOptionNamed (options, "window", 0); |
1517 | w = screen->findWindow (xid); |
1518 | + |
1519 | if (!w) |
1520 | return true; |
1521 | - width = w->width () + w->border ().left + w->border ().right; |
1522 | - height = w->height () + w->border ().top + w->border ().bottom; |
1523 | - out = screen->outputDeviceForGeometry (w->geometry ()); |
1524 | + |
1525 | + int width = w->width () + w->border ().left + w->border ().right; |
1526 | + int height = w->height () + w->border ().top + w->border ().bottom; |
1527 | + int out = screen->outputDeviceForGeometry (w->geometry ()); |
1528 | o = &screen->outputDevs ().at (out); |
1529 | - setScaleBigger (out, (float) width/o->width (), |
1530 | - (float) height/o->height ()); |
1531 | + setScaleBigger (out, width / static_cast <float> (o->width ()), |
1532 | + height / static_cast <float> (o->height ())); |
1533 | areaToWindow (w); |
1534 | toggleFunctions (true); |
1535 | |
1536 | @@ -1624,10 +1646,10 @@ |
1537 | |
1538 | bool |
1539 | EZoomScreen::zoomPan (CompAction *action, |
1540 | - CompAction::State state, |
1541 | - CompOption::Vector options, |
1542 | - float horizAmount, |
1543 | - float vertAmount) |
1544 | + CompAction::State state, |
1545 | + CompOption::Vector options, |
1546 | + float horizAmount, |
1547 | + float vertAmount) |
1548 | { |
1549 | panZoom (horizAmount, vertAmount); |
1550 | |
1551 | @@ -1641,18 +1663,16 @@ |
1552 | CompAction::State state, |
1553 | CompOption::Vector options) |
1554 | { |
1555 | - int out; |
1556 | - |
1557 | - |
1558 | - out = screen->outputDeviceForPoint (pointerX, pointerY); |
1559 | - screen->warpPointer ((int) (screen->outputDevs ().at (out).width ()/2 + |
1560 | - screen->outputDevs ().at (out).x1 () - pointerX) |
1561 | + int out = screen->outputDeviceForPoint (pointerX, pointerY); |
1562 | + |
1563 | + screen->warpPointer ((int) (screen->outputDevs ().at (out).width () / 2 + |
1564 | + screen->outputDevs ().at (out).x1 () - pointerX) |
1565 | + ((float) screen->outputDevs ().at (out).width () * |
1566 | - -zooms.at (out).xtrans), |
1567 | - (int) (screen->outputDevs ().at (out).height ()/2 + |
1568 | + -zooms.at (out).xtrans), |
1569 | + (int) (screen->outputDevs ().at (out).height () / 2 + |
1570 | screen->outputDevs ().at (out).y1 () - pointerY) |
1571 | + ((float) screen->outputDevs ().at (out).height () * |
1572 | - zooms.at (out).ytrans)); |
1573 | + zooms.at (out).ytrans)); |
1574 | return true; |
1575 | } |
1576 | |
1577 | @@ -1663,10 +1683,9 @@ |
1578 | */ |
1579 | bool |
1580 | EZoomScreen::zoomFitWindowToZoom (CompAction *action, |
1581 | - CompAction::State state, |
1582 | - CompOption::Vector options) |
1583 | + CompAction::State state, |
1584 | + CompOption::Vector options) |
1585 | { |
1586 | - int out; |
1587 | unsigned int mask = CWWidth | CWHeight; |
1588 | XWindowChanges xwc; |
1589 | CompWindow *w; |
1590 | @@ -1676,7 +1695,7 @@ |
1591 | if (!w) |
1592 | return true; |
1593 | |
1594 | - out = screen->outputDeviceForGeometry (w->geometry ()); |
1595 | + int out = screen->outputDeviceForGeometry (w->geometry ()); |
1596 | xwc.x = w->serverX (); |
1597 | xwc.y = w->serverY (); |
1598 | xwc.width = (int) (screen->outputDevs ().at (out).width () * |
1599 | @@ -1691,7 +1710,6 @@ |
1600 | &xwc.width, |
1601 | &xwc.height); |
1602 | |
1603 | - |
1604 | if (xwc.width == w->serverWidth ()) |
1605 | mask &= ~CWWidth; |
1606 | |
1607 | @@ -1710,8 +1728,8 @@ |
1608 | |
1609 | bool |
1610 | EZoomScreen::initiate (CompAction *action, |
1611 | - CompAction::State state, |
1612 | - CompOption::Vector options) |
1613 | + CompAction::State state, |
1614 | + CompOption::Vector options) |
1615 | { |
1616 | zoomIn (action, state, options); |
1617 | |
1618 | @@ -1728,8 +1746,8 @@ |
1619 | |
1620 | bool |
1621 | EZoomScreen::zoomOut (CompAction *action, |
1622 | - CompAction::State state, |
1623 | - CompOption::Vector options) |
1624 | + CompAction::State state, |
1625 | + CompOption::Vector options) |
1626 | { |
1627 | int out = screen->outputDeviceForPoint (pointerX, pointerY); |
1628 | |
1629 | @@ -1747,14 +1765,12 @@ |
1630 | CompAction::State state, |
1631 | CompOption::Vector options) |
1632 | { |
1633 | - int out; |
1634 | - |
1635 | - out = screen->outputDeviceForPoint (pointerX, pointerY); |
1636 | + int out = screen->outputDeviceForPoint (pointerX, pointerY); |
1637 | |
1638 | if (grabbed) |
1639 | { |
1640 | - zooms.at (out).newZoom = 1.0f; |
1641 | - cScreen->damageScreen (); |
1642 | + zooms.at (out).newZoom = 1.0f; |
1643 | + cScreen->damageScreen (); |
1644 | } |
1645 | |
1646 | toggleFunctions (true); |
1647 | @@ -1777,7 +1793,6 @@ |
1648 | void |
1649 | EZoomScreen::focusTrack (XEvent *event) |
1650 | { |
1651 | - int out; |
1652 | static Window lastMapped = 0; |
1653 | |
1654 | CompWindow *w; |
1655 | @@ -1790,31 +1805,34 @@ |
1656 | else if (event->type != FocusIn) |
1657 | return; |
1658 | |
1659 | - if ((event->xfocus.mode != NotifyNormal) |
1660 | - && (lastMapped != event->xfocus.window)) |
1661 | + if ((event->xfocus.mode != NotifyNormal) && |
1662 | + (lastMapped != event->xfocus.window)) |
1663 | return; |
1664 | |
1665 | lastMapped = 0; |
1666 | w = screen->findWindow (event->xfocus.window); |
1667 | - if (w == NULL || w->id () == screen->activeWindow ()) |
1668 | - return; |
1669 | |
1670 | - if (time(NULL) - lastChange < optionGetFollowFocusDelay () || |
1671 | + if (w == NULL || |
1672 | + w->id () == screen->activeWindow () || |
1673 | + time(NULL) - lastChange < optionGetFollowFocusDelay () || |
1674 | !optionGetFollowFocus ()) |
1675 | return; |
1676 | |
1677 | - out = screen->outputDeviceForGeometry (w->geometry ()); |
1678 | + int out = screen->outputDeviceForGeometry (w->geometry ()); |
1679 | + |
1680 | if (!isActive (out) && |
1681 | !optionGetAlwaysFocusFitWindow ()) |
1682 | return; |
1683 | + |
1684 | if (optionGetFocusFitWindow ()) |
1685 | { |
1686 | int width = w->width () + w->border ().left + w->border ().right; |
1687 | int height = w->height () + w->border ().top + w->border ().bottom; |
1688 | - float scale = MAX ((float) width/screen->outputDevs ().at(out).width (), |
1689 | - (float) height/screen->outputDevs ().at (out).height ()); |
1690 | + float scale = MAX (width / static_cast <float> (screen->outputDevs ().at(out).width ()), |
1691 | + height / static_cast <float> (screen->outputDevs ().at (out).height ())); |
1692 | + |
1693 | if (scale > optionGetAutoscaleMin ()) |
1694 | - setScale (out, scale); |
1695 | + setScale (out, scale); |
1696 | } |
1697 | |
1698 | areaToWindow (w); |
1699 | @@ -1822,35 +1840,32 @@ |
1700 | toggleFunctions (true); |
1701 | } |
1702 | |
1703 | - |
1704 | /* Event handler. Pass focus-related events on and handle XFixes events. */ |
1705 | void |
1706 | EZoomScreen::handleEvent (XEvent *event) |
1707 | { |
1708 | - switch (event->type) { |
1709 | + switch (event->type) |
1710 | + { |
1711 | case MotionNotify: |
1712 | if (grabIndex) |
1713 | { |
1714 | - if (pointerX < clickPos.x ()) |
1715 | - { |
1716 | + if (pointerX < clickPos.x ()) |
1717 | + { |
1718 | box.setX (pointerX); |
1719 | box.setWidth (clickPos.x () - pointerX); |
1720 | - } |
1721 | - else |
1722 | - { |
1723 | + } |
1724 | + else |
1725 | box.setWidth (pointerX - clickPos.x ()); |
1726 | - } |
1727 | |
1728 | - if (pointerY < clickPos.y ()) |
1729 | - { |
1730 | + if (pointerY < clickPos.y ()) |
1731 | + { |
1732 | box.setY (pointerY); |
1733 | box.setHeight (clickPos.y () - pointerY); |
1734 | - } |
1735 | - else |
1736 | - { |
1737 | + } |
1738 | + else |
1739 | box.setHeight (pointerY - clickPos.y ()); |
1740 | - } |
1741 | - cScreen->damageScreen (); |
1742 | + |
1743 | + cScreen->damageScreen (); |
1744 | } |
1745 | break; |
1746 | |
1747 | @@ -1858,13 +1873,14 @@ |
1748 | case MapNotify: |
1749 | focusTrack (event); |
1750 | break; |
1751 | + |
1752 | default: |
1753 | if (event->type == fixesEventBase + XFixesCursorNotify) |
1754 | { |
1755 | //XFixesCursorNotifyEvent *cev = (XFixesCursorNotifyEvent *) |
1756 | - //event; |
1757 | - if (cursor.isSet) |
1758 | - updateCursor (&cursor); |
1759 | + //event; |
1760 | + if (cursor.isSet) |
1761 | + updateCursor (&cursor); |
1762 | } |
1763 | break; |
1764 | } |
1765 | @@ -1900,6 +1916,7 @@ |
1766 | |
1767 | int major, minor; |
1768 | unsigned int n; |
1769 | + |
1770 | fixesSupported = |
1771 | XFixesQueryExtension(screen->dpy (), |
1772 | &fixesEventBase, |
1773 | @@ -1914,11 +1931,12 @@ |
1774 | |
1775 | n = screen->outputDevs ().size (); |
1776 | |
1777 | - for (unsigned int i = 0; i < n; i++) |
1778 | + for (unsigned int i = 0; i < n; ++i) |
1779 | { |
1780 | /* zs->grabbed is a mask ... Thus this limit */ |
1781 | if (i > sizeof (long int) * 8) |
1782 | break; |
1783 | + |
1784 | ZoomArea za (i); |
1785 | zooms.push_back (za); |
1786 | } |
1787 | @@ -1962,7 +1980,6 @@ |
1788 | &EZoomScreen::zoomFitWindowToZoom, this, |
1789 | _1, _2, _3)); |
1790 | |
1791 | - |
1792 | optionSetLockZoomKeyInitiate (boost::bind (&EZoomScreen::lockZoomAction, |
1793 | this, _1, _2, _3)); |
1794 | optionSetZoomBoxButtonInitiate (boost::bind (&EZoomScreen::zoomBoxActivate, |
1795 | @@ -1976,7 +1993,6 @@ |
1796 | optionSetEnsureVisibilityInitiate (boost::bind ( |
1797 | &EZoomScreen::ensureVisibilityAction, this, |
1798 | _1, _2, _3)); |
1799 | - |
1800 | } |
1801 | |
1802 | EZoomScreen::~EZoomScreen () |
1803 | |
1804 | === modified file 'plugins/ezoom/src/ezoom.h' |
1805 | --- plugins/ezoom/src/ezoom.h 2012-10-15 12:51:26 +0000 |
1806 | +++ plugins/ezoom/src/ezoom.h 2013-05-14 21:54:27 +0000 |
1807 | @@ -75,7 +75,8 @@ |
1808 | |
1809 | public: |
1810 | |
1811 | - typedef enum { |
1812 | + typedef enum |
1813 | + { |
1814 | NORTHEAST, |
1815 | NORTHWEST, |
1816 | SOUTHEAST, |
1817 | @@ -83,7 +84,8 @@ |
1818 | CENTER |
1819 | } ZoomGravity; |
1820 | |
1821 | - typedef enum { |
1822 | + typedef enum |
1823 | + { |
1824 | NORTH, |
1825 | SOUTH, |
1826 | EAST, |
1827 | @@ -135,6 +137,7 @@ |
1828 | GLfloat xtrans; |
1829 | GLfloat ytrans; |
1830 | bool locked; |
1831 | + |
1832 | public: |
1833 | |
1834 | ZoomArea (int out); |
1835 | @@ -146,21 +149,21 @@ |
1836 | |
1837 | public: |
1838 | |
1839 | - std::vector <ZoomArea> zooms; // list of zooms (different zooms for |
1840 | + std::vector <ZoomArea> zooms; // list of zooms (different zooms for |
1841 | // each output |
1842 | - CompPoint mouse; // we get this from mousepoll |
1843 | - unsigned long int grabbed; |
1844 | - CompScreen::GrabHandle grabIndex; // for zoomBox |
1845 | - time_t lastChange; |
1846 | - CursorTexture cursor; // the texture for the faux-cursor |
1847 | - // we paint to do fake input |
1848 | - // handling |
1849 | - bool cursorInfoSelected; |
1850 | - bool cursorHidden; |
1851 | - CompRect box; |
1852 | - CompPoint clickPos; |
1853 | + CompPoint mouse; // we get this from mousepoll |
1854 | + unsigned long int grabbed; |
1855 | + CompScreen::GrabHandle grabIndex; // for zoomBox |
1856 | + time_t lastChange; |
1857 | + CursorTexture cursor; // the texture for the faux-cursor |
1858 | + // we paint to do fake input |
1859 | + // handling |
1860 | + bool cursorInfoSelected; |
1861 | + bool cursorHidden; |
1862 | + CompRect box; |
1863 | + CompPoint clickPos; |
1864 | |
1865 | - MousePoller pollHandle; // mouse poller object |
1866 | + MousePoller pollHandle; // mouse poller object |
1867 | |
1868 | private: |
1869 |
78 + zooms.at (out).xVelocity ||
79 + zooms.at (out).yVelocity ||
80 + zooms.at (out).zVelocity ||
It might be better to express these as != 0.0f
Though they are floats - so they really should be compared in terms of rounding to avoid floating point comparison errors. But I wouldn't worry about that for now as we don't really have a uniform method to compare floats. See http:// stackoverflow. com/questions/ 17333/most- effective- way-for- float-and- double- comparison . We'll need to find a way to do this properly and uniformly.
110 - {
111 zooms.at (out).currentZoom += (zooms.at (out).zVelocity * chunk) /
112 cScreen->redrawTime ();
113 - }
While not strictly necessary, these brackets aid readability for me because the code spans two lines. There's no hard and fast rule here though.
217 - for (out = 0; out < zooms.size (); out++) >damageScreen ();
218 - {
219 + for (unsigned int out = 0; out < zooms.size (); out++)
220 if (isInMovement (out) && isActive (out))
221 {
222 cScreen-
223 break;
224 }
225 - }
As I've mentioned a few times before, please don't remove brackets in control-flow statements which have nested control flow statements with brackets. The reason is that its confusing to read at a glance.
251 + GLMatrix zTransform (transform);
252 + int inx1, inx2, iny1, iny2;
253 + int out = output->id ();
254 + GLushort colorData[4];
These should probably line up - remove the tab usage in between the "int" and the name declaration and just use spaces to line it up.
295 + const GLMatrix &transform,
296 + const CompRegion ®ion,
297 + CompOutput *output,
298 + unsigned int mask)
Ditto.
#define WIDTHOK (float)(x2-x1) / (float)o->width () < zooms.at (out).newZoom
#define HEIGHTOK (float)(y2-y1) / (float)o->height () < zooms.at (out).newZoom
...
541 if (WIDTHOK &&
542 - HEIGHTOK) {
543 + HEIGHTOK)
544 + {
Its an extraneous point, but remove these macros and replace them with inline functions if you can.
656 screen->warpPointer ((int) (mouse.x () - pointerX) -
657 - (int) ((float)diffX * z),
658 - (int) (mouse.y () - pointerY) -
659 + (int) ((float)diffX * z),
660 + (int) (mouse.y () - pointerY) -
661 (int) ((float)diffY * z));
If we're editing whitespace here, the rule in compiz is that the following line in a wrapped statement should be four spaces from where the first started, eg:
int foo = bar -
var;
baz -
769 +// glDisable (GL_BLEND);
...
826 +// glDisable (GL_TEXTURE_2D);
Take note of what I said in the other review about BLEND enable / disable. It should be turned on and off whenever blending is actually needed and not left on at the end of the function. As for removing code - just remove it, don't comment it out.
897 #define WIDTH (x2 - x1)
898 #define HEIGHT (y2 - y1)
Replace those with variables.
1061 + setScaleBigger (out, (float) width / o->width (), (float)
1062 + height / o->height ());
The denominator here should be the one that is cast - not the numerator. Eg
1061 + setScaleBigger ...