Merge lp:~smspillaz/compiz-core/compiz-core.fix_939228 into lp:compiz-core/0.9.8

Proposed by Sam Spilsbury
Status: Superseded
Proposed branch: lp:~smspillaz/compiz-core/compiz-core.fix_939228
Merge into: lp:compiz-core/0.9.8
Diff against target: 285 lines (+216/-10) (has conflicts)
3 files modified
src/privatescreen.h (+30/-4)
src/privatescreen/tests/test-privatescreen.cpp (+170/-0)
src/screen.cpp (+16/-6)
Text conflict in src/privatescreen/tests/test-privatescreen.cpp
To merge this branch: bzr merge lp:~smspillaz/compiz-core/compiz-core.fix_939228
Reviewer Review Type Date Requested Status
Alan Griffiths Pending
Daniel van Vugt Pending
Review via email: mp+103662@code.launchpad.net

This proposal supersedes a proposal from 2012-04-24.

This proposal has been superseded by a proposal from 2012-04-27.

Description of the change

== Problem ==

See LP#939288 - windows would jump if you had them on screen edges

== Solution ==

Don't return negative values for CompScreen::viewportForGeometry

== Test ==

Included.

To post a comment you must log in.
Revision history for this message
Alan Griffiths (alan-griffiths) wrote : Posted in a previous version of this proposal

why change "class" to "struct" when it behaves like a struct?

Revision history for this message
Alan Griffiths (alan-griffiths) wrote : Posted in a previous version of this proposal

LGTM

review: Approve
Revision history for this message
Daniel van Vugt (vanvugt) wrote : Posted in a previous version of this proposal

The fix works if I follow the test case that I just documented in bug 939228. However the opposite way around is still broken;

1. Move a window to the far left workspace so that it overlaps the left side of the screen a little.
2. Switch to the far right workspace where you can see a little of the overlapping window.
3. Alt-Tab to the window.

Observed: Window jumps to being entirely on the far left workspace.
Expected: Window stays where it was.

review: Needs Fixing
Revision history for this message
Sam Spilsbury (smspillaz) wrote :

Hi,

I am unable to reproduce the issue you mentioned. Are you running with lp:~smspillaz/compiz-wall-plugin/compiz-wall-plugin.fix_939228 ?

3113. By Sam Spilsbury

Merge lp:compiz-core

3114. By Sam Spilsbury

Merge lp:compiz-core

3115. By Sam Spilsbury

Merged lp:compiz-core

3116. By Sam Spilsbury

Revert to the old behaviour with a note about possible bugs

Unmerged revisions

3116. By Sam Spilsbury

Revert to the old behaviour with a note about possible bugs

3115. By Sam Spilsbury

Merged lp:compiz-core

3114. By Sam Spilsbury

Merge lp:compiz-core

3113. By Sam Spilsbury

Merge lp:compiz-core

3112. By Sam Spilsbury

s/class/struct/

3111. By Sam Spilsbury

Don't return a negative value for CompScreen::viewportForGeometry

Fix LP#939288 - If a window was partially on a viewport which was the last
one in its row or column, and we were on the viewport on the opposite side
of that row or column, compiz would work backwards to find the position
of the window (which would be negative) and return a negative viewport
position. This caused plugins like wall to behave strangely

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/privatescreen.h'
2--- src/privatescreen.h 2012-04-25 09:21:24 +0000
3+++ src/privatescreen.h 2012-04-26 11:00:27 +0000
4@@ -478,15 +478,41 @@
5 unsigned int activeNum;
6 };
7
8+class ViewportRetrievalInterface
9+{
10+ public:
11+
12+ virtual ~ViewportRetrievalInterface () {}
13+
14+ virtual const CompPoint & getCurrentViewport () const = 0;
15+ virtual const CompSize & viewportDimentions () const = 0;
16+};
17+
18 // Apart from a use by StartupSequence::addSequence this data
19 // is only used by CompScreenImpl - like the OrphanData struct
20-struct ViewPort
21+class ViewPort :
22+ public ViewportRetrievalInterface
23 {
24- ViewPort();
25- CompPoint vp;
26- CompSize vpSize;
27+ public:
28+
29+ ViewPort();
30+ CompPoint vp;
31+ CompSize vpSize;
32+
33+ private:
34+
35+ const CompPoint & getCurrentViewport () const { return vp; }
36+ const CompSize & viewportDimentions () const { return vpSize; }
37 };
38
39+namespace viewports
40+{
41+ void viewportForGeometry (const CompWindow::Geometry &gm,
42+ CompPoint &viewport,
43+ ViewportRetrievalInterface *viewports,
44+ const CompSize &screenSize);
45+}
46+
47 class StartupSequence : boost::noncopyable,
48 public ViewPort
49 {
50
51=== modified file 'src/privatescreen/tests/test-privatescreen.cpp'
52--- src/privatescreen/tests/test-privatescreen.cpp 2012-04-24 14:34:19 +0000
53+++ src/privatescreen/tests/test-privatescreen.cpp 2012-04-26 11:00:27 +0000
54@@ -10,6 +10,10 @@
55
56 #include <stdlib.h>
57
58+using ::testing::Return;
59+using ::testing::ReturnRef;
60+using ::testing::_;
61+
62 namespace {
63
64 class MockCompScreen : public CompScreen
65@@ -175,7 +179,20 @@
66 MOCK_CONST_METHOD0(createFailed, bool ());
67 };
68
69+<<<<<<< TREE
70 class StubActivePluginsOption : public CoreOptions
71+=======
72+class MockViewportRetreival :
73+ public compiz::private_screen::ViewportRetrievalInterface
74+{
75+ public:
76+
77+ MOCK_CONST_METHOD0(getCurrentViewport, const CompPoint & ());
78+ MOCK_CONST_METHOD0(viewportDimentions, const CompSize & ());
79+};
80+
81+class StubActivePluginsOption
82+>>>>>>> MERGE-SOURCE
83 {
84 public:
85 StubActivePluginsOption() : CoreOptions(false)
86@@ -723,3 +740,156 @@
87
88 em.init(0);
89 }
90+
91+TEST(privatescreen_ViewportGeometryTest, PickCurrent)
92+{
93+ CompPoint vp;
94+ compiz::window::Geometry g (250, 250, 500, 500, 0);
95+ MockViewportRetreival mvp;
96+
97+ CompPoint current (0, 0);
98+ CompSize dimentions (1, 1);
99+
100+ EXPECT_CALL (mvp, getCurrentViewport ()).WillOnce (ReturnRef (current));
101+ EXPECT_CALL (mvp, viewportDimentions ()).WillOnce (ReturnRef (dimentions));
102+
103+ compiz::private_screen::viewports::viewportForGeometry (g, vp, &mvp, CompSize (1000, 1000));
104+
105+ EXPECT_EQ (vp, CompPoint (0, 0));
106+}
107+
108+TEST(privatescreen_ViewportGeometryTest, PickRight)
109+{
110+ CompPoint vp;
111+ compiz::window::Geometry g (1250, 0, 500, 500, 0);
112+ MockViewportRetreival mvp;
113+
114+ CompPoint current (0, 0);
115+ CompSize dimentions (2, 1);
116+
117+ EXPECT_CALL (mvp, getCurrentViewport ()).WillOnce (ReturnRef (current));
118+ EXPECT_CALL (mvp, viewportDimentions ()).WillOnce (ReturnRef (dimentions));
119+
120+ compiz::private_screen::viewports::viewportForGeometry (g, vp, &mvp, CompSize (1000, 1000));
121+
122+ EXPECT_EQ (vp, CompPoint (1, 0));
123+}
124+
125+TEST(privatescreen_ViewportGeometryTest, PickLeft)
126+{
127+ CompPoint vp;
128+ compiz::window::Geometry g (-750, 0, 500, 500, 0);
129+ MockViewportRetreival mvp;
130+
131+ CompPoint current (1, 0);
132+ CompSize dimentions (2, 1);
133+
134+ EXPECT_CALL (mvp, getCurrentViewport ()).WillOnce (ReturnRef (current));
135+ EXPECT_CALL (mvp, viewportDimentions ()).WillOnce (ReturnRef (dimentions));
136+
137+ compiz::private_screen::viewports::viewportForGeometry (g, vp, &mvp, CompSize (1000, 1000));
138+
139+ EXPECT_EQ (vp, CompPoint (0, 0));
140+}
141+
142+TEST(privatescreen_ViewportGeometryTest, PickBottom)
143+{
144+ CompPoint vp;
145+ compiz::window::Geometry g (0, 1250, 500, 500, 0);
146+ MockViewportRetreival mvp;
147+
148+ CompPoint current (0, 0);
149+ CompSize dimentions (1, 2);
150+
151+ EXPECT_CALL (mvp, getCurrentViewport ()).WillOnce (ReturnRef (current));
152+ EXPECT_CALL (mvp, viewportDimentions ()).WillOnce (ReturnRef (dimentions));
153+
154+ compiz::private_screen::viewports::viewportForGeometry (g, vp, &mvp, CompSize (1000, 1000));
155+
156+ EXPECT_EQ (vp, CompPoint (0, 1));
157+}
158+
159+TEST(privatescreen_ViewportGeometryTest, PickTop)
160+{
161+ CompPoint vp;
162+ compiz::window::Geometry g (0, -750, 500, 500, 0);
163+ MockViewportRetreival mvp;
164+
165+ CompPoint current (0, 1);
166+ CompSize dimentions (1, 2);
167+
168+ EXPECT_CALL (mvp, getCurrentViewport ()).WillOnce (ReturnRef (current));
169+ EXPECT_CALL (mvp, viewportDimentions ()).WillOnce (ReturnRef (dimentions));
170+
171+ compiz::private_screen::viewports::viewportForGeometry (g, vp, &mvp, CompSize (1000, 1000));
172+
173+ EXPECT_EQ (vp, CompPoint (0, 0));
174+}
175+
176+TEST(privatescreen_ViewportGeometryTest, PickTopWhenJustAbove)
177+{
178+ CompPoint vp;
179+ compiz::window::Geometry g (0, -251, 500, 500, 0);
180+ MockViewportRetreival mvp;
181+
182+ CompPoint current (0, 1);
183+ CompSize dimentions (1, 2);
184+
185+ EXPECT_CALL (mvp, getCurrentViewport ()).WillOnce (ReturnRef (current));
186+ EXPECT_CALL (mvp, viewportDimentions ()).WillOnce (ReturnRef (dimentions));
187+
188+ compiz::private_screen::viewports::viewportForGeometry (g, vp, &mvp, CompSize (1000, 1000));
189+
190+ EXPECT_EQ (vp, CompPoint (0, 0));
191+}
192+
193+TEST(privatescreen_ViewportGeometryTest, PickRightWhenJustRight)
194+{
195+ CompPoint vp;
196+ compiz::window::Geometry g (751, 0, 500, 500, 0);
197+ MockViewportRetreival mvp;
198+
199+ CompPoint current (0, 0);
200+ CompSize dimentions (2, 1);
201+
202+ EXPECT_CALL (mvp, getCurrentViewport ()).WillOnce (ReturnRef (current));
203+ EXPECT_CALL (mvp, viewportDimentions ()).WillOnce (ReturnRef (dimentions));
204+
205+ compiz::private_screen::viewports::viewportForGeometry (g, vp, &mvp, CompSize (1000, 1000));
206+
207+ EXPECT_EQ (vp, CompPoint (1, 0));
208+}
209+
210+TEST(privatescreen_ViewportGeometryTest, PickLeftWhenJustLeft)
211+{
212+ CompPoint vp;
213+ compiz::window::Geometry g (-251, 0, 500, 500, 0);
214+ MockViewportRetreival mvp;
215+
216+ CompPoint current (1, 0);
217+ CompSize dimentions (2, 1);
218+
219+ EXPECT_CALL (mvp, getCurrentViewport ()).WillOnce (ReturnRef (current));
220+ EXPECT_CALL (mvp, viewportDimentions ()).WillOnce (ReturnRef (dimentions));
221+
222+ compiz::private_screen::viewports::viewportForGeometry (g, vp, &mvp, CompSize (1000, 1000));
223+
224+ EXPECT_EQ (vp, CompPoint (0, 0));
225+}
226+
227+TEST(privatescreen_ViewportGeometryTest, PickBottomWhenJustBelow)
228+{
229+ CompPoint vp;
230+ compiz::window::Geometry g (0, 751, 500, 500, 0);
231+ MockViewportRetreival mvp;
232+
233+ CompPoint current (0, 0);
234+ CompSize dimentions (1, 2);
235+
236+ EXPECT_CALL (mvp, getCurrentViewport ()).WillOnce (ReturnRef (current));
237+ EXPECT_CALL (mvp, viewportDimentions ()).WillOnce (ReturnRef (dimentions));
238+
239+ compiz::private_screen::viewports::viewportForGeometry (g, vp, &mvp, CompSize (1000, 1000));
240+
241+ EXPECT_EQ (vp, CompPoint (0, 1));
242+}
243
244=== modified file 'src/screen.cpp'
245--- src/screen.cpp 2012-04-25 09:21:24 +0000
246+++ src/screen.cpp 2012-04-26 11:00:27 +0000
247@@ -4065,22 +4065,32 @@
248 is currently computed as the viewport where the center of the window is
249 located. */
250 void
251-CompScreenImpl::viewportForGeometry (const CompWindow::Geometry& gm,
252- CompPoint& viewport)
253+compiz::private_screen::viewports::viewportForGeometry (const CompWindow::Geometry &gm,
254+ CompPoint &viewport,
255+ ViewportRetrievalInterface *viewports,
256+ const CompSize & screenSize)
257 {
258 CompRect rect (gm);
259 int offset;
260
261+ const CompPoint &vp = viewports->getCurrentViewport ();
262+ const CompSize &vpSize = viewports->viewportDimentions ();
263+
264 rect.setWidth (gm.widthIncBorders ());
265 rect.setHeight (gm.heightIncBorders ());
266
267 offset = rect.centerX () < 0 ? -1 : 0;
268- viewport.setX (priv->vp.x () + ((rect.centerX () / width ()) + offset) %
269- priv->vpSize.width ());
270+ viewport.setX (compiz::core::screen::wraparound_mod (vp.x () + ((rect.centerX () / screenSize.width ()) + offset), vpSize.width ()));
271
272 offset = rect.centerY () < 0 ? -1 : 0;
273- viewport.setY (priv->vp.y () + ((rect.centerY () / height ()) + offset ) %
274- priv->vpSize.height ());
275+ viewport.setY (compiz::core::screen::wraparound_mod (vp.y () + ((rect.centerY () / screenSize.height ()) + offset), vpSize.height ()));
276+}
277+
278+void
279+CompScreenImpl::viewportForGeometry (const CompWindow::Geometry& gm,
280+ CompPoint& viewport)
281+{
282+ compiz::private_screen::viewports::viewportForGeometry (gm, viewport, priv.get (), *this);
283 }
284
285 int

Subscribers

People subscribed via source and target branches