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
Daniel van Vugt Needs Fixing
Alan Griffiths Approve
Review via email: mp+103832@code.launchpad.net

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

This proposal has been superseded by a proposal from 2012-05-15.

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

conflicts fixed.

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

Deduplicated bugs. This is now bug 755842.

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

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

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

Hum, I'll try again

Revision history for this message
Alan Griffiths (alan-griffiths) :
review: Approve
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

I'm still trying to test the prerequisite wall fix, but am delayed by new cmake/precise bugs.

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

Contains a few nontrivial conflicts. Please fix.

review: Needs Fixing
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-27 08:46:21 +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 ViewPort493struct 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-27 08:46:21 +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,6 +179,15 @@
175 MOCK_CONST_METHOD0(createFailed, bool ());179 MOCK_CONST_METHOD0(createFailed, bool ());
176};180};
177181
182class MockViewportRetreival :
183 public compiz::private_screen::ViewportRetrievalInterface
184{
185 public:
186
187 MOCK_CONST_METHOD0(getCurrentViewport, const CompPoint & ());
188 MOCK_CONST_METHOD0(viewportDimentions, const CompSize & ());
189};
190
178class StubActivePluginsOption : public CoreOptions191class StubActivePluginsOption : public CoreOptions
179{192{
180public:193public:
@@ -723,3 +736,156 @@
723736
724 em.init(0);737 em.init(0);
725}738}
739
740TEST(privatescreen_ViewportGeometryTest, PickCurrent)
741{
742 CompPoint vp;
743 compiz::window::Geometry g (250, 250, 500, 500, 0);
744 MockViewportRetreival mvp;
745
746 CompPoint current (0, 0);
747 CompSize dimentions (1, 1);
748
749 EXPECT_CALL (mvp, getCurrentViewport ()).WillOnce (ReturnRef (current));
750 EXPECT_CALL (mvp, viewportDimentions ()).WillOnce (ReturnRef (dimentions));
751
752 compiz::private_screen::viewports::viewportForGeometry (g, vp, &mvp, CompSize (1000, 1000));
753
754 EXPECT_EQ (vp, CompPoint (0, 0));
755}
756
757TEST(privatescreen_ViewportGeometryTest, PickRight)
758{
759 CompPoint vp;
760 compiz::window::Geometry g (1250, 0, 500, 500, 0);
761 MockViewportRetreival mvp;
762
763 CompPoint current (0, 0);
764 CompSize dimentions (2, 1);
765
766 EXPECT_CALL (mvp, getCurrentViewport ()).WillOnce (ReturnRef (current));
767 EXPECT_CALL (mvp, viewportDimentions ()).WillOnce (ReturnRef (dimentions));
768
769 compiz::private_screen::viewports::viewportForGeometry (g, vp, &mvp, CompSize (1000, 1000));
770
771 EXPECT_EQ (vp, CompPoint (1, 0));
772}
773
774TEST(privatescreen_ViewportGeometryTest, PickLeft)
775{
776 CompPoint vp;
777 compiz::window::Geometry g (-750, 0, 500, 500, 0);
778 MockViewportRetreival mvp;
779
780 CompPoint current (1, 0);
781 CompSize dimentions (2, 1);
782
783 EXPECT_CALL (mvp, getCurrentViewport ()).WillOnce (ReturnRef (current));
784 EXPECT_CALL (mvp, viewportDimentions ()).WillOnce (ReturnRef (dimentions));
785
786 compiz::private_screen::viewports::viewportForGeometry (g, vp, &mvp, CompSize (1000, 1000));
787
788 EXPECT_EQ (vp, CompPoint (0, 0));
789}
790
791TEST(privatescreen_ViewportGeometryTest, PickBottom)
792{
793 CompPoint vp;
794 compiz::window::Geometry g (0, 1250, 500, 500, 0);
795 MockViewportRetreival mvp;
796
797 CompPoint current (0, 0);
798 CompSize dimentions (1, 2);
799
800 EXPECT_CALL (mvp, getCurrentViewport ()).WillOnce (ReturnRef (current));
801 EXPECT_CALL (mvp, viewportDimentions ()).WillOnce (ReturnRef (dimentions));
802
803 compiz::private_screen::viewports::viewportForGeometry (g, vp, &mvp, CompSize (1000, 1000));
804
805 EXPECT_EQ (vp, CompPoint (0, 1));
806}
807
808TEST(privatescreen_ViewportGeometryTest, PickTop)
809{
810 CompPoint vp;
811 compiz::window::Geometry g (0, -750, 500, 500, 0);
812 MockViewportRetreival mvp;
813
814 CompPoint current (0, 1);
815 CompSize dimentions (1, 2);
816
817 EXPECT_CALL (mvp, getCurrentViewport ()).WillOnce (ReturnRef (current));
818 EXPECT_CALL (mvp, viewportDimentions ()).WillOnce (ReturnRef (dimentions));
819
820 compiz::private_screen::viewports::viewportForGeometry (g, vp, &mvp, CompSize (1000, 1000));
821
822 EXPECT_EQ (vp, CompPoint (0, 0));
823}
824
825TEST(privatescreen_ViewportGeometryTest, PickTopWhenJustAbove)
826{
827 CompPoint vp;
828 compiz::window::Geometry g (0, -251, 500, 500, 0);
829 MockViewportRetreival mvp;
830
831 CompPoint current (0, 1);
832 CompSize dimentions (1, 2);
833
834 EXPECT_CALL (mvp, getCurrentViewport ()).WillOnce (ReturnRef (current));
835 EXPECT_CALL (mvp, viewportDimentions ()).WillOnce (ReturnRef (dimentions));
836
837 compiz::private_screen::viewports::viewportForGeometry (g, vp, &mvp, CompSize (1000, 1000));
838
839 EXPECT_EQ (vp, CompPoint (0, 0));
840}
841
842TEST(privatescreen_ViewportGeometryTest, PickRightWhenJustRight)
843{
844 CompPoint vp;
845 compiz::window::Geometry g (751, 0, 500, 500, 0);
846 MockViewportRetreival mvp;
847
848 CompPoint current (0, 0);
849 CompSize dimentions (2, 1);
850
851 EXPECT_CALL (mvp, getCurrentViewport ()).WillOnce (ReturnRef (current));
852 EXPECT_CALL (mvp, viewportDimentions ()).WillOnce (ReturnRef (dimentions));
853
854 compiz::private_screen::viewports::viewportForGeometry (g, vp, &mvp, CompSize (1000, 1000));
855
856 EXPECT_EQ (vp, CompPoint (1, 0));
857}
858
859TEST(privatescreen_ViewportGeometryTest, PickLeftWhenJustLeft)
860{
861 CompPoint vp;
862 compiz::window::Geometry g (-251, 0, 500, 500, 0);
863 MockViewportRetreival mvp;
864
865 CompPoint current (1, 0);
866 CompSize dimentions (2, 1);
867
868 EXPECT_CALL (mvp, getCurrentViewport ()).WillOnce (ReturnRef (current));
869 EXPECT_CALL (mvp, viewportDimentions ()).WillOnce (ReturnRef (dimentions));
870
871 compiz::private_screen::viewports::viewportForGeometry (g, vp, &mvp, CompSize (1000, 1000));
872
873 EXPECT_EQ (vp, CompPoint (0, 0));
874}
875
876TEST(privatescreen_ViewportGeometryTest, PickBottomWhenJustBelow)
877{
878 CompPoint vp;
879 compiz::window::Geometry g (0, 751, 500, 500, 0);
880 MockViewportRetreival mvp;
881
882 CompPoint current (0, 0);
883 CompSize dimentions (1, 2);
884
885 EXPECT_CALL (mvp, getCurrentViewport ()).WillOnce (ReturnRef (current));
886 EXPECT_CALL (mvp, viewportDimentions ()).WillOnce (ReturnRef (dimentions));
887
888 compiz::private_screen::viewports::viewportForGeometry (g, vp, &mvp, CompSize (1000, 1000));
889
890 EXPECT_EQ (vp, CompPoint (0, 1));
891}
726892
=== modified file 'src/screen.cpp'
--- src/screen.cpp 2012-04-25 09:21:24 +0000
+++ src/screen.cpp 2012-04-27 08:46:21 +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