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
=== modified file 'src/privatescreen.h'
--- src/privatescreen.h 2012-04-25 09:21:24 +0000
+++ src/privatescreen.h 2012-04-26 11:00:27 +0000
@@ -478,15 +478,41 @@
478 unsigned int activeNum;478 unsigned int activeNum;
479};479};
480480
481class ViewportRetrievalInterface
482{
483 public:
484
485 virtual ~ViewportRetrievalInterface () {}
486
487 virtual const CompPoint & getCurrentViewport () const = 0;
488 virtual const CompSize & viewportDimentions () const = 0;
489};
490
481// Apart from a use by StartupSequence::addSequence this data491// Apart from a use by StartupSequence::addSequence this data
482// is only used by CompScreenImpl - like the OrphanData struct492// is only used by CompScreenImpl - like the OrphanData struct
483struct ViewPort493class ViewPort :
494 public ViewportRetrievalInterface
484{495{
485 ViewPort();496 public:
486 CompPoint vp;497
487 CompSize vpSize;498 ViewPort();
499 CompPoint vp;
500 CompSize vpSize;
501
502 private:
503
504 const CompPoint & getCurrentViewport () const { return vp; }
505 const CompSize & viewportDimentions () const { return vpSize; }
488};506};
489507
508namespace viewports
509{
510 void viewportForGeometry (const CompWindow::Geometry &gm,
511 CompPoint &viewport,
512 ViewportRetrievalInterface *viewports,
513 const CompSize &screenSize);
514}
515
490class StartupSequence : boost::noncopyable,516class StartupSequence : boost::noncopyable,
491 public ViewPort517 public ViewPort
492{518{
493519
=== modified file 'src/privatescreen/tests/test-privatescreen.cpp'
--- src/privatescreen/tests/test-privatescreen.cpp 2012-04-24 14:34:19 +0000
+++ src/privatescreen/tests/test-privatescreen.cpp 2012-04-26 11:00:27 +0000
@@ -10,6 +10,10 @@
1010
11#include <stdlib.h>11#include <stdlib.h>
1212
13using ::testing::Return;
14using ::testing::ReturnRef;
15using ::testing::_;
16
13namespace {17namespace {
1418
15class MockCompScreen : public CompScreen19class MockCompScreen : public CompScreen
@@ -175,7 +179,20 @@
175 MOCK_CONST_METHOD0(createFailed, bool ());179 MOCK_CONST_METHOD0(createFailed, bool ());
176};180};
177181
182<<<<<<< TREE
178class StubActivePluginsOption : public CoreOptions183class StubActivePluginsOption : public CoreOptions
184=======
185class MockViewportRetreival :
186 public compiz::private_screen::ViewportRetrievalInterface
187{
188 public:
189
190 MOCK_CONST_METHOD0(getCurrentViewport, const CompPoint & ());
191 MOCK_CONST_METHOD0(viewportDimentions, const CompSize & ());
192};
193
194class StubActivePluginsOption
195>>>>>>> MERGE-SOURCE
179{196{
180public:197public:
181 StubActivePluginsOption() : CoreOptions(false)198 StubActivePluginsOption() : CoreOptions(false)
@@ -723,3 +740,156 @@
723740
724 em.init(0);741 em.init(0);
725}742}
743
744TEST(privatescreen_ViewportGeometryTest, PickCurrent)
745{
746 CompPoint vp;
747 compiz::window::Geometry g (250, 250, 500, 500, 0);
748 MockViewportRetreival mvp;
749
750 CompPoint current (0, 0);
751 CompSize dimentions (1, 1);
752
753 EXPECT_CALL (mvp, getCurrentViewport ()).WillOnce (ReturnRef (current));
754 EXPECT_CALL (mvp, viewportDimentions ()).WillOnce (ReturnRef (dimentions));
755
756 compiz::private_screen::viewports::viewportForGeometry (g, vp, &mvp, CompSize (1000, 1000));
757
758 EXPECT_EQ (vp, CompPoint (0, 0));
759}
760
761TEST(privatescreen_ViewportGeometryTest, PickRight)
762{
763 CompPoint vp;
764 compiz::window::Geometry g (1250, 0, 500, 500, 0);
765 MockViewportRetreival mvp;
766
767 CompPoint current (0, 0);
768 CompSize dimentions (2, 1);
769
770 EXPECT_CALL (mvp, getCurrentViewport ()).WillOnce (ReturnRef (current));
771 EXPECT_CALL (mvp, viewportDimentions ()).WillOnce (ReturnRef (dimentions));
772
773 compiz::private_screen::viewports::viewportForGeometry (g, vp, &mvp, CompSize (1000, 1000));
774
775 EXPECT_EQ (vp, CompPoint (1, 0));
776}
777
778TEST(privatescreen_ViewportGeometryTest, PickLeft)
779{
780 CompPoint vp;
781 compiz::window::Geometry g (-750, 0, 500, 500, 0);
782 MockViewportRetreival mvp;
783
784 CompPoint current (1, 0);
785 CompSize dimentions (2, 1);
786
787 EXPECT_CALL (mvp, getCurrentViewport ()).WillOnce (ReturnRef (current));
788 EXPECT_CALL (mvp, viewportDimentions ()).WillOnce (ReturnRef (dimentions));
789
790 compiz::private_screen::viewports::viewportForGeometry (g, vp, &mvp, CompSize (1000, 1000));
791
792 EXPECT_EQ (vp, CompPoint (0, 0));
793}
794
795TEST(privatescreen_ViewportGeometryTest, PickBottom)
796{
797 CompPoint vp;
798 compiz::window::Geometry g (0, 1250, 500, 500, 0);
799 MockViewportRetreival mvp;
800
801 CompPoint current (0, 0);
802 CompSize dimentions (1, 2);
803
804 EXPECT_CALL (mvp, getCurrentViewport ()).WillOnce (ReturnRef (current));
805 EXPECT_CALL (mvp, viewportDimentions ()).WillOnce (ReturnRef (dimentions));
806
807 compiz::private_screen::viewports::viewportForGeometry (g, vp, &mvp, CompSize (1000, 1000));
808
809 EXPECT_EQ (vp, CompPoint (0, 1));
810}
811
812TEST(privatescreen_ViewportGeometryTest, PickTop)
813{
814 CompPoint vp;
815 compiz::window::Geometry g (0, -750, 500, 500, 0);
816 MockViewportRetreival mvp;
817
818 CompPoint current (0, 1);
819 CompSize dimentions (1, 2);
820
821 EXPECT_CALL (mvp, getCurrentViewport ()).WillOnce (ReturnRef (current));
822 EXPECT_CALL (mvp, viewportDimentions ()).WillOnce (ReturnRef (dimentions));
823
824 compiz::private_screen::viewports::viewportForGeometry (g, vp, &mvp, CompSize (1000, 1000));
825
826 EXPECT_EQ (vp, CompPoint (0, 0));
827}
828
829TEST(privatescreen_ViewportGeometryTest, PickTopWhenJustAbove)
830{
831 CompPoint vp;
832 compiz::window::Geometry g (0, -251, 500, 500, 0);
833 MockViewportRetreival mvp;
834
835 CompPoint current (0, 1);
836 CompSize dimentions (1, 2);
837
838 EXPECT_CALL (mvp, getCurrentViewport ()).WillOnce (ReturnRef (current));
839 EXPECT_CALL (mvp, viewportDimentions ()).WillOnce (ReturnRef (dimentions));
840
841 compiz::private_screen::viewports::viewportForGeometry (g, vp, &mvp, CompSize (1000, 1000));
842
843 EXPECT_EQ (vp, CompPoint (0, 0));
844}
845
846TEST(privatescreen_ViewportGeometryTest, PickRightWhenJustRight)
847{
848 CompPoint vp;
849 compiz::window::Geometry g (751, 0, 500, 500, 0);
850 MockViewportRetreival mvp;
851
852 CompPoint current (0, 0);
853 CompSize dimentions (2, 1);
854
855 EXPECT_CALL (mvp, getCurrentViewport ()).WillOnce (ReturnRef (current));
856 EXPECT_CALL (mvp, viewportDimentions ()).WillOnce (ReturnRef (dimentions));
857
858 compiz::private_screen::viewports::viewportForGeometry (g, vp, &mvp, CompSize (1000, 1000));
859
860 EXPECT_EQ (vp, CompPoint (1, 0));
861}
862
863TEST(privatescreen_ViewportGeometryTest, PickLeftWhenJustLeft)
864{
865 CompPoint vp;
866 compiz::window::Geometry g (-251, 0, 500, 500, 0);
867 MockViewportRetreival mvp;
868
869 CompPoint current (1, 0);
870 CompSize dimentions (2, 1);
871
872 EXPECT_CALL (mvp, getCurrentViewport ()).WillOnce (ReturnRef (current));
873 EXPECT_CALL (mvp, viewportDimentions ()).WillOnce (ReturnRef (dimentions));
874
875 compiz::private_screen::viewports::viewportForGeometry (g, vp, &mvp, CompSize (1000, 1000));
876
877 EXPECT_EQ (vp, CompPoint (0, 0));
878}
879
880TEST(privatescreen_ViewportGeometryTest, PickBottomWhenJustBelow)
881{
882 CompPoint vp;
883 compiz::window::Geometry g (0, 751, 500, 500, 0);
884 MockViewportRetreival mvp;
885
886 CompPoint current (0, 0);
887 CompSize dimentions (1, 2);
888
889 EXPECT_CALL (mvp, getCurrentViewport ()).WillOnce (ReturnRef (current));
890 EXPECT_CALL (mvp, viewportDimentions ()).WillOnce (ReturnRef (dimentions));
891
892 compiz::private_screen::viewports::viewportForGeometry (g, vp, &mvp, CompSize (1000, 1000));
893
894 EXPECT_EQ (vp, CompPoint (0, 1));
895}
726896
=== modified file 'src/screen.cpp'
--- src/screen.cpp 2012-04-25 09:21:24 +0000
+++ src/screen.cpp 2012-04-26 11:00:27 +0000
@@ -4065,22 +4065,32 @@
4065 is currently computed as the viewport where the center of the window is4065 is currently computed as the viewport where the center of the window is
4066 located. */4066 located. */
4067void4067void
4068CompScreenImpl::viewportForGeometry (const CompWindow::Geometry& gm,4068compiz::private_screen::viewports::viewportForGeometry (const CompWindow::Geometry &gm,
4069 CompPoint& viewport)4069 CompPoint &viewport,
4070 ViewportRetrievalInterface *viewports,
4071 const CompSize & screenSize)
4070{4072{
4071 CompRect rect (gm);4073 CompRect rect (gm);
4072 int offset;4074 int offset;
40734075
4076 const CompPoint &vp = viewports->getCurrentViewport ();
4077 const CompSize &vpSize = viewports->viewportDimentions ();
4078
4074 rect.setWidth (gm.widthIncBorders ());4079 rect.setWidth (gm.widthIncBorders ());
4075 rect.setHeight (gm.heightIncBorders ());4080 rect.setHeight (gm.heightIncBorders ());
40764081
4077 offset = rect.centerX () < 0 ? -1 : 0;4082 offset = rect.centerX () < 0 ? -1 : 0;
4078 viewport.setX (priv->vp.x () + ((rect.centerX () / width ()) + offset) %4083 viewport.setX (compiz::core::screen::wraparound_mod (vp.x () + ((rect.centerX () / screenSize.width ()) + offset), vpSize.width ()));
4079 priv->vpSize.width ());
40804084
4081 offset = rect.centerY () < 0 ? -1 : 0;4085 offset = rect.centerY () < 0 ? -1 : 0;
4082 viewport.setY (priv->vp.y () + ((rect.centerY () / height ()) + offset ) %4086 viewport.setY (compiz::core::screen::wraparound_mod (vp.y () + ((rect.centerY () / screenSize.height ()) + offset), vpSize.height ()));
4083 priv->vpSize.height ());4087}
4088
4089void
4090CompScreenImpl::viewportForGeometry (const CompWindow::Geometry& gm,
4091 CompPoint& viewport)
4092{
4093 compiz::private_screen::viewports::viewportForGeometry (gm, viewport, priv.get (), *this);
4084}4094}
40854095
4086int4096int

Subscribers

People subscribed via source and target branches