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: 280 lines (+212/-10)
3 files modified
src/privatescreen.h (+30/-4)
src/privatescreen/tests/test-privatescreen.cpp (+166/-0)
src/screen.cpp (+16/-6)
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+103798@code.launchpad.net

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

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 : Posted in a previous version of this proposal

Hi,

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

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

conflicts fixed.

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

Deduplicated bugs. This is now bug 755842.

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

If the other branch is a prereq, can we mark it as such? (even though it's a different project)

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

> conflicts fixed.

But not pushed to LP yet. The conflict is still there :)
Though it's simple enough for anyone to fix that I won't say Needs Fixing.

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

Hum, I'll try again

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-27 08:45:24 +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+struct 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-27 08:45:24 +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,6 +179,15 @@
66 MOCK_CONST_METHOD0(createFailed, bool ());
67 };
68
69+class MockViewportRetreival :
70+ public compiz::private_screen::ViewportRetrievalInterface
71+{
72+ public:
73+
74+ MOCK_CONST_METHOD0(getCurrentViewport, const CompPoint & ());
75+ MOCK_CONST_METHOD0(viewportDimentions, const CompSize & ());
76+};
77+
78 class StubActivePluginsOption : public CoreOptions
79 {
80 public:
81@@ -723,3 +736,156 @@
82
83 em.init(0);
84 }
85+
86+TEST(privatescreen_ViewportGeometryTest, PickCurrent)
87+{
88+ CompPoint vp;
89+ compiz::window::Geometry g (250, 250, 500, 500, 0);
90+ MockViewportRetreival mvp;
91+
92+ CompPoint current (0, 0);
93+ CompSize dimentions (1, 1);
94+
95+ EXPECT_CALL (mvp, getCurrentViewport ()).WillOnce (ReturnRef (current));
96+ EXPECT_CALL (mvp, viewportDimentions ()).WillOnce (ReturnRef (dimentions));
97+
98+ compiz::private_screen::viewports::viewportForGeometry (g, vp, &mvp, CompSize (1000, 1000));
99+
100+ EXPECT_EQ (vp, CompPoint (0, 0));
101+}
102+
103+TEST(privatescreen_ViewportGeometryTest, PickRight)
104+{
105+ CompPoint vp;
106+ compiz::window::Geometry g (1250, 0, 500, 500, 0);
107+ MockViewportRetreival mvp;
108+
109+ CompPoint current (0, 0);
110+ CompSize dimentions (2, 1);
111+
112+ EXPECT_CALL (mvp, getCurrentViewport ()).WillOnce (ReturnRef (current));
113+ EXPECT_CALL (mvp, viewportDimentions ()).WillOnce (ReturnRef (dimentions));
114+
115+ compiz::private_screen::viewports::viewportForGeometry (g, vp, &mvp, CompSize (1000, 1000));
116+
117+ EXPECT_EQ (vp, CompPoint (1, 0));
118+}
119+
120+TEST(privatescreen_ViewportGeometryTest, PickLeft)
121+{
122+ CompPoint vp;
123+ compiz::window::Geometry g (-750, 0, 500, 500, 0);
124+ MockViewportRetreival mvp;
125+
126+ CompPoint current (1, 0);
127+ CompSize dimentions (2, 1);
128+
129+ EXPECT_CALL (mvp, getCurrentViewport ()).WillOnce (ReturnRef (current));
130+ EXPECT_CALL (mvp, viewportDimentions ()).WillOnce (ReturnRef (dimentions));
131+
132+ compiz::private_screen::viewports::viewportForGeometry (g, vp, &mvp, CompSize (1000, 1000));
133+
134+ EXPECT_EQ (vp, CompPoint (0, 0));
135+}
136+
137+TEST(privatescreen_ViewportGeometryTest, PickBottom)
138+{
139+ CompPoint vp;
140+ compiz::window::Geometry g (0, 1250, 500, 500, 0);
141+ MockViewportRetreival mvp;
142+
143+ CompPoint current (0, 0);
144+ CompSize dimentions (1, 2);
145+
146+ EXPECT_CALL (mvp, getCurrentViewport ()).WillOnce (ReturnRef (current));
147+ EXPECT_CALL (mvp, viewportDimentions ()).WillOnce (ReturnRef (dimentions));
148+
149+ compiz::private_screen::viewports::viewportForGeometry (g, vp, &mvp, CompSize (1000, 1000));
150+
151+ EXPECT_EQ (vp, CompPoint (0, 1));
152+}
153+
154+TEST(privatescreen_ViewportGeometryTest, PickTop)
155+{
156+ CompPoint vp;
157+ compiz::window::Geometry g (0, -750, 500, 500, 0);
158+ MockViewportRetreival mvp;
159+
160+ CompPoint current (0, 1);
161+ CompSize dimentions (1, 2);
162+
163+ EXPECT_CALL (mvp, getCurrentViewport ()).WillOnce (ReturnRef (current));
164+ EXPECT_CALL (mvp, viewportDimentions ()).WillOnce (ReturnRef (dimentions));
165+
166+ compiz::private_screen::viewports::viewportForGeometry (g, vp, &mvp, CompSize (1000, 1000));
167+
168+ EXPECT_EQ (vp, CompPoint (0, 0));
169+}
170+
171+TEST(privatescreen_ViewportGeometryTest, PickTopWhenJustAbove)
172+{
173+ CompPoint vp;
174+ compiz::window::Geometry g (0, -251, 500, 500, 0);
175+ MockViewportRetreival mvp;
176+
177+ CompPoint current (0, 1);
178+ CompSize dimentions (1, 2);
179+
180+ EXPECT_CALL (mvp, getCurrentViewport ()).WillOnce (ReturnRef (current));
181+ EXPECT_CALL (mvp, viewportDimentions ()).WillOnce (ReturnRef (dimentions));
182+
183+ compiz::private_screen::viewports::viewportForGeometry (g, vp, &mvp, CompSize (1000, 1000));
184+
185+ EXPECT_EQ (vp, CompPoint (0, 0));
186+}
187+
188+TEST(privatescreen_ViewportGeometryTest, PickRightWhenJustRight)
189+{
190+ CompPoint vp;
191+ compiz::window::Geometry g (751, 0, 500, 500, 0);
192+ MockViewportRetreival mvp;
193+
194+ CompPoint current (0, 0);
195+ CompSize dimentions (2, 1);
196+
197+ EXPECT_CALL (mvp, getCurrentViewport ()).WillOnce (ReturnRef (current));
198+ EXPECT_CALL (mvp, viewportDimentions ()).WillOnce (ReturnRef (dimentions));
199+
200+ compiz::private_screen::viewports::viewportForGeometry (g, vp, &mvp, CompSize (1000, 1000));
201+
202+ EXPECT_EQ (vp, CompPoint (1, 0));
203+}
204+
205+TEST(privatescreen_ViewportGeometryTest, PickLeftWhenJustLeft)
206+{
207+ CompPoint vp;
208+ compiz::window::Geometry g (-251, 0, 500, 500, 0);
209+ MockViewportRetreival mvp;
210+
211+ CompPoint current (1, 0);
212+ CompSize dimentions (2, 1);
213+
214+ EXPECT_CALL (mvp, getCurrentViewport ()).WillOnce (ReturnRef (current));
215+ EXPECT_CALL (mvp, viewportDimentions ()).WillOnce (ReturnRef (dimentions));
216+
217+ compiz::private_screen::viewports::viewportForGeometry (g, vp, &mvp, CompSize (1000, 1000));
218+
219+ EXPECT_EQ (vp, CompPoint (0, 0));
220+}
221+
222+TEST(privatescreen_ViewportGeometryTest, PickBottomWhenJustBelow)
223+{
224+ CompPoint vp;
225+ compiz::window::Geometry g (0, 751, 500, 500, 0);
226+ MockViewportRetreival mvp;
227+
228+ CompPoint current (0, 0);
229+ CompSize dimentions (1, 2);
230+
231+ EXPECT_CALL (mvp, getCurrentViewport ()).WillOnce (ReturnRef (current));
232+ EXPECT_CALL (mvp, viewportDimentions ()).WillOnce (ReturnRef (dimentions));
233+
234+ compiz::private_screen::viewports::viewportForGeometry (g, vp, &mvp, CompSize (1000, 1000));
235+
236+ EXPECT_EQ (vp, CompPoint (0, 1));
237+}
238
239=== modified file 'src/screen.cpp'
240--- src/screen.cpp 2012-04-25 09:21:24 +0000
241+++ src/screen.cpp 2012-04-27 08:45:24 +0000
242@@ -4065,22 +4065,32 @@
243 is currently computed as the viewport where the center of the window is
244 located. */
245 void
246-CompScreenImpl::viewportForGeometry (const CompWindow::Geometry& gm,
247- CompPoint& viewport)
248+compiz::private_screen::viewports::viewportForGeometry (const CompWindow::Geometry &gm,
249+ CompPoint &viewport,
250+ ViewportRetrievalInterface *viewports,
251+ const CompSize & screenSize)
252 {
253 CompRect rect (gm);
254 int offset;
255
256+ const CompPoint &vp = viewports->getCurrentViewport ();
257+ const CompSize &vpSize = viewports->viewportDimentions ();
258+
259 rect.setWidth (gm.widthIncBorders ());
260 rect.setHeight (gm.heightIncBorders ());
261
262 offset = rect.centerX () < 0 ? -1 : 0;
263- viewport.setX (priv->vp.x () + ((rect.centerX () / width ()) + offset) %
264- priv->vpSize.width ());
265+ viewport.setX (compiz::core::screen::wraparound_mod (vp.x () + ((rect.centerX () / screenSize.width ()) + offset), vpSize.width ()));
266
267 offset = rect.centerY () < 0 ? -1 : 0;
268- viewport.setY (priv->vp.y () + ((rect.centerY () / height ()) + offset ) %
269- priv->vpSize.height ());
270+ viewport.setY (compiz::core::screen::wraparound_mod (vp.y () + ((rect.centerY () / screenSize.height ()) + offset), vpSize.height ()));
271+}
272+
273+void
274+CompScreenImpl::viewportForGeometry (const CompWindow::Geometry& gm,
275+ CompPoint& viewport)
276+{
277+ compiz::private_screen::viewports::viewportForGeometry (gm, viewport, priv.get (), *this);
278 }
279
280 int

Subscribers

People subscribed via source and target branches