Merge lp:~townsend/compiz-core/fix-lp1171878-0.9.7 into lp:compiz-core

Proposed by Christopher Townsend
Status: Merged
Approved by: Brandon Schaefer
Approved revision: 3137
Merged at revision: 3137
Proposed branch: lp:~townsend/compiz-core/fix-lp1171878-0.9.7
Merge into: lp:compiz-core
Diff against target: 112 lines (+51/-0)
4 files modified
include/core/window.h (+2/-0)
src/privatewindow.h (+2/-0)
src/screen.cpp (+14/-0)
src/window.cpp (+33/-0)
To merge this branch: bzr merge lp:~townsend/compiz-core/fix-lp1171878-0.9.7
Reviewer Review Type Date Requested Status
Brandon Schaefer (community) Approve
Review via email: mp+225037@code.launchpad.net

Commit message

Fix issue where having a maximized window on a second monitor, then that monitor gets removed which moves the maximized window to the main monitor, then restoring the maximized window would place it on a different viewport. It should stay on the same viewport. This is a backport of lp:compiz r3845.

Description of the change

Fix issue where having a maximized window on a second monitor, then that monitor gets removed which moves the maximized window to the main monitor, then restoring the maximized window would place it on a different viewport. It should stay on the same viewport. This is a backport of lp:compiz r3845.

To post a comment you must log in.
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 'include/core/window.h'
2--- include/core/window.h 2012-03-22 17:00:51 +0000
3+++ include/core/window.h 2014-06-30 15:44:56 +0000
4@@ -490,6 +490,8 @@
5
6 bool alive ();
7
8+ bool moved () const;
9+
10 bool overrideRedirect ();
11
12 bool isMapped () const;
13
14=== modified file 'src/privatewindow.h'
15--- src/privatewindow.h 2012-03-02 18:02:07 +0000
16+++ src/privatewindow.h 2014-06-30 15:44:56 +0000
17@@ -302,6 +302,8 @@
18 unsigned int lastPong;
19 bool alive;
20
21+ bool moved;
22+
23 CompWindowExtents input;
24 CompWindowExtents serverInput;
25 CompWindowExtents border;
26
27=== modified file 'src/screen.cpp'
28--- src/screen.cpp 2012-11-18 18:06:24 +0000
29+++ src/screen.cpp 2014-06-30 15:44:56 +0000
30@@ -3566,10 +3566,24 @@
31
32 if (workAreaChanged)
33 {
34+ CompWindow::Geometry before, after;
35+
36 /* as work area changed, update all maximized windows on this
37 screen to snap to the new work area */
38 foreach (CompWindow *w, priv->windows)
39+ {
40+ before = w->priv->serverGeometry;
41 w->priv->updateSize ();
42+ after = w->priv->serverGeometry;
43+
44+ /* A maximized window was adjusted for the new workarea size */
45+ if (before != after &&
46+ (w->state () & CompWindowStateMaximizedVertMask ||
47+ w->state () & CompWindowStateMaximizedHorzMask))
48+ {
49+ w->priv->moved = true;
50+ }
51+ }
52 }
53 }
54
55
56=== modified file 'src/window.cpp'
57--- src/window.cpp 2012-11-19 18:26:35 +0000
58+++ src/window.cpp 2014-06-30 15:44:56 +0000
59@@ -3852,6 +3852,31 @@
60 mask |= restoreGeometry (xwc, CWX | CWWidth);
61 }
62
63+ /* Check to see if a monitor has disappeared that had a maximized window and if so,
64+ * adjust the window to restore in the current viewport instead of the
65+ * coordinates of a different viewport. */
66+ if (window->moved () &&
67+ !(state & CompWindowStateMaximizedVertMask || state & CompWindowStateMaximizedHorzMask))
68+ {
69+ if (xwc->x > screen->width () ||
70+ xwc->y > screen->height ())
71+ {
72+ /* The removed monitor may have had a much different resolution than the
73+ * the current monitor, so let's just orient the window in the top left
74+ * of the workarea. */
75+ xwc->x = workArea.x () + window->border ().left;
76+ xwc->y = workArea.y () + window->border ().top;
77+
78+ if (xwc->width > workArea.width ())
79+ xwc->width = workArea.width () - (window->border ().left + window->border ().right);
80+
81+ if (xwc->height > workArea.height ())
82+ xwc->height = workArea.height () - (window->border ().top + window->border ().bottom);
83+
84+ }
85+
86+ window->priv->moved = false;
87+ }
88 /* constrain window width if smaller than minimum width */
89 if (!(mask & CWWidth) && (int) old.width () < sizeHints.min_width)
90 {
91@@ -6530,6 +6555,8 @@
92 lastPong (0),
93 alive (true),
94
95+ moved (false),
96+
97 struts (0),
98
99 icons (0),
100@@ -6677,6 +6704,12 @@
101 return priv->alive;
102 }
103
104+bool
105+CompWindow::moved () const
106+{
107+ return priv->moved;
108+}
109+
110 unsigned int
111 CompWindow::mwmDecor ()
112 {

Subscribers

People subscribed via source and target branches