Merge lp:~townsend/compiz/fix-lp1304531 into lp:compiz/0.9.11

Proposed by Christopher Townsend
Status: Merged
Approved by: Brandon Schaefer
Approved revision: 3861
Merged at revision: 3866
Proposed branch: lp:~townsend/compiz/fix-lp1304531
Merge into: lp:compiz/0.9.11
Diff against target: 140 lines (+35/-4)
5 files modified
plugins/place/src/place.cpp (+2/-0)
plugins/place/src/screen-size-change/include/screen-size-change.h (+2/-0)
plugins/place/src/screen-size-change/src/screen-size-change.cpp (+6/-3)
plugins/place/src/screen-size-change/tests/screen-size-change/src/test-place-screen-size-change.cpp (+7/-0)
src/window.cpp (+18/-1)
To merge this branch: bzr merge lp:~townsend/compiz/fix-lp1304531
Reviewer Review Type Date Requested Status
Brandon Schaefer (community) Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+220445@code.launchpad.net

Commit message

Fix issue where maximized windows would get moved to different workspaces when disconnecting/connecting an external monitor. Windows should stay in the same workspace they are in when the monitor event occurs.

Description of the change

I'm going to go ahead and propose this to get some review loving.

This is intended to be SRU'd in 14.04, so the goal here is to fix the problem at hand and cause no regressions. The code in these areas is very fragile, so we really need to test this. That said, there are still issues, so when testing, make sure the issue you see is not a regression caused from this code.

Some scenarios when testing also should not use an external monitor since this code is also used for workspace switching and changing workspace geometry such as going to 1 workspace, using 2x2 workspaces, 3x4 workspaces, etc.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Brandon Schaefer (brandontschaefer) wrote :

LGTM

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plugins/place/src/place.cpp'
2--- plugins/place/src/place.cpp 2013-07-22 17:19:59 +0000
3+++ plugins/place/src/place.cpp 2014-05-21 12:42:10 +0000
4@@ -123,6 +123,8 @@
5 state |= compiz::place::WindowAbove;
6 if (window->state () & CompWindowStateBelowMask)
7 state |= compiz::place::WindowBelow;
8+ if (window->state () & CompWindowStateMaximizedVertMask || window->state () & CompWindowStateMaximizedHorzMask)
9+ state |= compiz::place::WindowMaximized;
10
11 return state;
12 }
13
14=== modified file 'plugins/place/src/screen-size-change/include/screen-size-change.h'
15--- plugins/place/src/screen-size-change/include/screen-size-change.h 2012-01-20 06:27:10 +0000
16+++ plugins/place/src/screen-size-change/include/screen-size-change.h 2014-05-21 12:42:10 +0000
17@@ -36,6 +36,7 @@
18 {
19 namespace place
20 {
21+ const unsigned int WindowMaximized = 1 << 2;
22
23 class ScreenSizeChangeObject
24 {
25@@ -50,6 +51,7 @@
26 virtual const CompPoint & getViewport () const = 0;
27 virtual const CompRect & getWorkarea (const compiz::window::Geometry &g) const = 0;
28 virtual const compiz::window::extents::Extents & getExtents () const = 0;
29+ virtual unsigned int getState () const = 0;
30
31 compiz::window::Geometry adjustForSize (const CompSize &oldSize,
32 const CompSize &newSize);
33
34=== modified file 'plugins/place/src/screen-size-change/src/screen-size-change.cpp'
35--- plugins/place/src/screen-size-change/src/screen-size-change.cpp 2013-04-07 08:45:50 +0000
36+++ plugins/place/src/screen-size-change/src/screen-size-change.cpp 2014-05-21 12:42:10 +0000
37@@ -39,7 +39,7 @@
38 {
39 int vpX, vpY;
40 compiz::window::Geometry g, vpRelRect;
41- int pivotX, pivotY;
42+ int pivotX, pivotY, pivotWidth, pivotHeight;
43
44 g = getGeometry ();
45 compiz::window::Geometry og (g);
46@@ -50,10 +50,13 @@
47 /* FIXME: Should use saved geometry for maximized / fullscreen windows */
48
49 /* calculate target vp x, y index for window's pivot point */
50- vpX = pivotX / oldSize.width ();
51+ pivotWidth = (getState () & compiz::place::WindowMaximized) ? newSize.width () : oldSize.width ();
52+ pivotHeight = (getState () & compiz::place::WindowMaximized) ? newSize.height () : oldSize.height ();
53+
54+ vpX = pivotX / pivotWidth;
55 if (pivotX < 0)
56 vpX -= 1;
57- vpY = pivotY / oldSize.height ();
58+ vpY = pivotY / pivotHeight;
59 if (pivotY < 0)
60 vpY -= 1;
61
62
63=== modified file 'plugins/place/src/screen-size-change/tests/screen-size-change/src/test-place-screen-size-change.cpp'
64--- plugins/place/src/screen-size-change/tests/screen-size-change/src/test-place-screen-size-change.cpp 2013-04-16 04:24:22 +0000
65+++ plugins/place/src/screen-size-change/tests/screen-size-change/src/test-place-screen-size-change.cpp 2014-05-21 12:42:10 +0000
66@@ -62,6 +62,7 @@
67 const CompPoint & getViewport () const;
68 const CompRect & getWorkarea (const cw::Geometry &g) const;
69 const cw::extents::Extents & getExtents () const;
70+ unsigned int getState () const;
71
72 void setVp (const CompPoint &);
73 void setWorkArea (const CompRect &);
74@@ -214,6 +215,12 @@
75 return mCurrentExtents;
76 }
77
78+unsigned int
79+StubScreenSizeChangeObject::getState () const
80+{
81+ return 0;
82+}
83+
84 void
85 StubScreenSizeChangeObject::setVp (const CompPoint &p)
86 {
87
88=== modified file 'src/window.cpp'
89--- src/window.cpp 2014-04-09 15:52:47 +0000
90+++ src/window.cpp 2014-05-21 12:42:10 +0000
91@@ -3553,11 +3553,20 @@
92 int mask = 0;
93 CompPoint viewport;
94
95- if (old.intersects (CompRect (0, 0, screen->width (), screen->height ())))
96+ if (old.intersects (CompRect (0, 0, screen->width (), screen->height ())) &&
97+ !(state & CompWindowStateMaximizedHorzMask || state & CompWindowStateMaximizedVertMask))
98 viewport = screen->vp ();
99+ else if ((state & CompWindowStateMaximizedHorzMask || state & CompWindowStateMaximizedVertMask) &&
100+ window->moved ())
101+ viewport = initialViewport;
102 else
103 screen->viewportForGeometry (old, viewport);
104
105+ if (viewport.x () > screen->vpSize ().width () - 1)
106+ viewport.setX (screen->vpSize ().width () - 1);
107+ if (viewport.y () > screen->vpSize ().height () - 1)
108+ viewport.setY (screen->vpSize ().height () - 1);
109+
110 int x = (viewport.x () - screen->vp ().x ()) * screen->width ();
111 int y = (viewport.y () - screen->vp ().y ()) * screen->height ();
112
113@@ -4021,6 +4030,8 @@
114
115 if (placed)
116 priv->placed = true;
117+
118+ priv->initialViewport = defaultViewport ();
119 }
120
121 bool
122@@ -4674,6 +4685,8 @@
123 if (overrideRedirect ())
124 return;
125
126+ priv->initialViewport = screen->vp ();
127+
128 state = constrainWindowState (state, priv->actions);
129
130 state &= MAXIMIZE_STATE;
131@@ -5832,6 +5845,10 @@
132 xwc.y = serverGeometry ().y () + wy;
133
134 configureXWindow (valueMask, &xwc);
135+
136+ if ((state () & CompWindowStateMaximizedHorzMask || state () & CompWindowStateMaximizedVertMask) &&
137+ (defaultViewport () == screen->vp ()))
138+ priv->initialViewport = screen->vp ();
139 }
140 }
141

Subscribers

People subscribed via source and target branches