Merge lp:~sjakthol/compiz/fix-1066187 into lp:compiz/0.9.9

Proposed by Sami Jaktholm
Status: Merged
Approved by: Daniel van Vugt
Approved revision: 3416
Merged at revision: 3419
Proposed branch: lp:~sjakthol/compiz/fix-1066187
Merge into: lp:compiz/0.9.9
Diff against target: 84 lines (+30/-7)
2 files modified
plugins/ezoom/src/ezoom.cpp (+22/-6)
plugins/ezoom/src/ezoom.h (+8/-1)
To merge this branch: bzr merge lp:~sjakthol/compiz/fix-1066187
Reviewer Review Type Date Requested Status
Daniel van Vugt Approve
MC Return Approve
PS Jenkins bot continuous-integration Pending
Review via email: mp+129556@code.launchpad.net

Commit message

Problem:
Specific Zoom Factor settings were ignored by the Enhanced Zoom Desktop
(LP: #1066187) because the values were only read once during initial load of
the plugin probably before the user defined configuration was read (and thus
it always used the default values).

Fix:
Instead of sending the (original) value of the initiated zoom level, send a
zoom level identifier. The identifier is used to determine which zoom level
the user wants and a fresh setting for that zoom level is used.

.

Description of the change

Tested the changes locally and they seem to compile and work fine. Please let me know if there's any problems with the coding style or implementation and I'll try to fix them.

Test case:
1. Open CCSM
2. Choose 'Enhanced Zoom Desktop' plugin (and make sure it's in use)
3. Go to 'Specific Zoom' tab
4. Add key bindings for Specific Zoom Level 1, 2 and 3
5. Set same values to Specific Zoom factor 2 and 3 (e.g. 0.7)
6. Press the key binding for Specific Zoom Level 2
7. Press the key binding for Specific Zoom Level 3
8. Change the zoom factors and test what happens by pressing the corresponding key bindings

You might want to keep the factor 1 at 1.00 so that you can reset the zoom once done.

Current behavior:
At (6) the screen gets zoomed in (like it should) but at (7) screen is zoomed even more (incorrect behavior, the values were the same). At (8) you'll see how the zoom for a certain level (factor 1 = 1.00, factor 2 = 0.5, factor 3 = 0.2) is always the same no matter what your input is.

Behavior with the fix:
At (6) the screen gets zoomed in (like it should) and at (7) nothing happens (correct behavior as the zoom factors were the same). At (8) the zoom clearly depends on the values you specified.

Possible problems:
Not sure if this is possible but if something outside ezoom plugin is directly calling EZoomScreen::zoomSpecific they will be broken as the input variable type of the target changed.

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

sampo555, great :)
Thanks a lot for your fix. I have yet to test it until I can approve it, but looks quite ok to me.

Regarding coding style: Compiz uses C++11 coding style, mixing spaces with tabs.

The first indent are 4 spaces, then a tab 8 spaces wide, then a mix of a tab and 4 spaces.
If you intend to help more with Compiz coding and want to use QTCreator, I am sure we can share the QTC settings file with you to make it easier to follow this style.

Otherwise I can take over your branch and fix the indentation there, before we merge this.

Thanks a lot for your contribution - you are very welcome to eliminate more of those nasty small bugs ;).
(I'll try to test and approve your fix ASAP.)

Revision history for this message
MC Return (mc-return) wrote :

I have tested this fix now and can confirm that it works like intended. :)

Regarding possible problems: It seems no other plug-in in current trunk requires ezoom (<requirement>), also a search for EZoomScreen::zoomSpecific through the code did not find any results except the ones in plugins/ezoom/src/ezoom.cpp.

The only stopper before merge, that I can spot, is the wrong indentation.

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

Verified, the fix works.

Please just change the opening braces on lines 16 and 65 to match the Compiz convention. So:
    foo {
should be:
    foo
    {

review: Needs Fixing
lp:~sjakthol/compiz/fix-1066187 updated
3416. By Sami Jaktholm

Fix brackets.

Revision history for this message
Sami Jaktholm (sjakthol) wrote :

Fixed.

Revision history for this message
MC Return (mc-return) wrote :

LGTM.

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

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plugins/ezoom/src/ezoom.cpp'
2--- plugins/ezoom/src/ezoom.cpp 2012-09-04 15:33:44 +0000
3+++ plugins/ezoom/src/ezoom.cpp 2012-10-15 12:54:23 +0000
4@@ -1544,17 +1544,33 @@
5 EZoomScreen::zoomSpecific (CompAction *action,
6 CompAction::State state,
7 CompOption::Vector options,
8- float target)
9+ SpecificZoomTarget target)
10 {
11 int out = screen->outputDeviceForPoint (pointerX, pointerY);
12+ float zoom_level;
13 CompWindow *w;
14
15- if (target == 1.0f && zooms.at (out).newZoom == 1.0f)
16+ switch (target)
17+ {
18+ case ZoomTargetFirst:
19+ zoom_level = optionGetZoomSpec1 ();
20+ break;
21+ case ZoomTargetSecond:
22+ zoom_level = optionGetZoomSpec2 ();
23+ break;
24+ case ZoomTargetThird:
25+ zoom_level = optionGetZoomSpec3 ();
26+ break;
27+ default:
28+ return false;
29+ }
30+
31+ if (zoom_level == 1.0f && zooms.at (out).newZoom == 1.0f)
32 return false;
33 if (screen->otherGrabExist (NULL))
34 return false;
35
36- setScale (out, target);
37+ setScale (out, zoom_level);
38
39 w = screen->findWindow (screen->activeWindow ());
40 if (optionGetSpecTargetFocus ()
41@@ -1915,13 +1931,13 @@
42
43 optionSetZoomSpecific1KeyInitiate (boost::bind (&EZoomScreen::zoomSpecific,
44 this, _1, _2, _3,
45- optionGetZoomSpec1 ()));
46+ ZoomTargetFirst));
47 optionSetZoomSpecific2KeyInitiate (boost::bind (&EZoomScreen::zoomSpecific,
48 this, _1, _2, _3,
49- optionGetZoomSpec2 ()));
50+ ZoomTargetSecond));
51 optionSetZoomSpecific3KeyInitiate (boost::bind (&EZoomScreen::zoomSpecific,
52 this, _1, _2, _3,
53- optionGetZoomSpec3 ()));
54+ ZoomTargetThird));
55
56 optionSetPanLeftKeyInitiate (boost::bind (&EZoomScreen::zoomPan, this, _1,
57 _2, _3, -1, 0));
58
59=== modified file 'plugins/ezoom/src/ezoom.h'
60--- plugins/ezoom/src/ezoom.h 2012-09-04 15:33:44 +0000
61+++ plugins/ezoom/src/ezoom.h 2012-10-15 12:54:23 +0000
62@@ -49,6 +49,13 @@
63
64 #include <cmath>
65
66+enum SpecificZoomTarget
67+{
68+ ZoomTargetFirst = 0,
69+ ZoomTargetSecond,
70+ ZoomTargetThird
71+};
72+
73 class EZoomScreen :
74 public PluginClassHandler <EZoomScreen, CompScreen>,
75 public EzoomOptions,
76@@ -314,7 +321,7 @@
77 zoomSpecific (CompAction *action,
78 CompAction::State state,
79 CompOption::Vector options,
80- float target);
81+ SpecificZoomTarget target);
82
83 bool
84 zoomToWindow (CompAction *action,

Subscribers

People subscribed via source and target branches