Merge lp:~azzar1/compiz-core/fix-919139 into lp:compiz-core

Proposed by Andrea Azzarone
Status: Merged
Merged at revision: 3083
Proposed branch: lp:~azzar1/compiz-core/fix-919139
Merge into: lp:compiz-core
Diff against target: 87 lines (+9/-51)
2 files modified
plugins/scale/CMakeLists.txt (+1/-1)
plugins/scale/src/scale.cpp (+8/-50)
To merge this branch: bzr merge lp:~azzar1/compiz-core/fix-919139
Reviewer Review Type Date Requested Status
Daniel van Vugt Approve
Review via email: mp+100156@code.launchpad.net

Commit message

Change the behavior of the option "On all output devices."

Description of the change

== The problem ==
In multi-monitor environment, windows should spread on the monitor in which they reside.

== The fix ==
Change the behavior of the option "On all output devices."

== Test ==
Not yet implemented. I'd love to write unit-tests but I need to use CompWindow and I can't find an easy way to create a fake CompWindow (CompWindow has a private ctor) or to mock it.

To post a comment you must log in.
lp:~azzar1/compiz-core/fix-919139 updated
3081. By Andrea Azzarone

Fix coding style.

3082. By Andrea Azzarone

Don't use c++0x.

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

/home/dan/bzr/compiz-core/spread/plugins/scale/src/scale.cpp: In member function ‘SlotArea::vector PrivateScaleScreen::getSlotAreas()’:
/home/dan/bzr/compiz-core/spread/plugins/scale/src/scale.cpp:491:39: error: comparison between signed and unsigned integer expressions [-Werror=sign-compare]

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

Although, I can confirm after fixing the above error, it works perfectly. Windows do spread on the monitor they started on.

I'll fix the build failure when I merge.

review: Approve
Revision history for this message
Andrea Azzarone (azzar1) wrote :

We wanted to add tests, I'll do it in another branch :)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plugins/scale/CMakeLists.txt'
2--- plugins/scale/CMakeLists.txt 2009-03-15 05:09:18 +0000
3+++ plugins/scale/CMakeLists.txt 2012-03-30 14:49:34 +0000
4@@ -2,4 +2,4 @@
5
6 include (CompizPlugin)
7
8-compiz_plugin(scale PLUGINDEPS composite opengl)
9\ No newline at end of file
10+compiz_plugin(scale PLUGINDEPS composite opengl)
11
12=== modified file 'plugins/scale/src/scale.cpp'
13--- plugins/scale/src/scale.cpp 2012-01-18 17:05:12 +0000
14+++ plugins/scale/src/scale.cpp 2012-03-30 14:49:34 +0000
15@@ -477,64 +477,22 @@
16 SlotArea::vector
17 PrivateScaleScreen::getSlotAreas ()
18 {
19- unsigned int i = 0;
20- CompRect workArea;
21- std::vector<float> size;
22- float sizePerWindow, sum = 0.0f;
23- int left;
24- SlotArea::vector slotAreas;
25+ SlotArea::vector slotAreas;
26
27 slotAreas.resize (screen->outputDevs ().size ());
28- size.resize (screen->outputDevs ().size ());
29-
30- left = windows.size ();
31-
32+
33+ unsigned int i = 0;
34 foreach (CompOutput &o, screen->outputDevs ())
35 {
36- /* determine the size of the workarea for each output device */
37- workArea = CompRect (o.workArea ());
38-
39- size[i] = workArea.width () * workArea.height ();
40- sum += size[i];
41-
42 slotAreas[i].nWindows = 0;
43- slotAreas[i].workArea = workArea;
44-
45- i++;
46- }
47-
48- /* calculate size available for each window */
49- sizePerWindow = sum / windows.size ();
50-
51- for (i = 0; i < screen->outputDevs ().size () && left; i++)
52- {
53- /* fill the areas with windows */
54- int nw = floor (size[i] / sizePerWindow);
55-
56- nw = MIN (nw, left);
57- size[i] -= nw * sizePerWindow;
58- slotAreas[i].nWindows = nw;
59- left -= nw;
60- }
61-
62- /* add left windows to output devices with the biggest free space */
63- while (left > 0)
64- {
65- int num = 0;
66- float big = 0;
67-
68- for (i = 0; i < screen->outputDevs ().size (); i++)
69+ foreach (ScaleWindow *window, windows)
70 {
71- if (size[i] > big)
72- {
73- num = i;
74- big = size[i];
75- }
76+ CompWindow *cw = window->priv->window;
77+ if (cw->outputDevice () == o.id ())
78+ slotAreas[i].nWindows++;
79 }
80
81- size[num] -= sizePerWindow;
82- slotAreas[num].nWindows++;
83- left--;
84+ slotAreas[i++].workArea = o.workArea ();
85 }
86
87 return slotAreas;

Subscribers

People subscribed via source and target branches