Merge lp:~compiz-team/compiz-core/compiz-core.server_windows into lp:compiz-core/0.9.5

Proposed by Sam Spilsbury
Status: Rejected
Rejected by: Sam Spilsbury
Proposed branch: lp:~compiz-team/compiz-core/compiz-core.server_windows
Merge into: lp:compiz-core/0.9.5
Diff against target: 311 lines (+105/-67)
6 files modified
include/core/core.h (+1/-1)
include/core/screen.h (+4/-1)
include/core/window.h (+4/-1)
src/privatescreen.h (+5/-0)
src/screen.cpp (+71/-0)
src/window.cpp (+20/-64)
To merge this branch: bzr merge lp:~compiz-team/compiz-core/compiz-core.server_windows
Reviewer Review Type Date Requested Status
Compiz Maintainers Pending
Review via email: mp+73231@code.launchpad.net

Description of the change

Adds a serverWindows and serverNext + serverPrev members. Update serverWindows whenever we send stacking requests to the X Server. This should fix race conditions where the server is slow to send us stacking updates and we have messed up the internal stacking order.

To post a comment you must log in.
Revision history for this message
Sam Spilsbury (smspillaz) wrote :

This is dead code

Unmerged revisions

2798. By Sam Spilsbury

Add window list of windows last sent to server and update this list whenever
a call to XLowerWindow, XRaiseWindow or XConfigureWindow is made.

This breaks the API, and plugins that wish to call a->restackAbove (b);
and then read the window list should probably read screen->serverWindows () instead.

Do not use CompScreen::serverInsertWindow and CompScreen::serverUnhookWindow, these
will be removed.

Should fix some stacking race conditions (but not all of them)

2797. By Sam Spilsbury

Merge lp:~compiz-team/compiz-core/compiz-core.fix_831987

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'include/core/core.h'
2--- include/core/core.h 2011-07-04 07:35:02 +0000
3+++ include/core/core.h 2011-08-29 13:21:25 +0000
4@@ -27,7 +27,7 @@
5 #define _COMPIZ_CORE_H
6
7
8-#define CORE_ABIVERSION 20110703
9+#define CORE_ABIVERSION 20110828
10
11 #include <stdio.h>
12 #include <assert.h>
13
14=== modified file 'include/core/screen.h'
15--- include/core/screen.h 2011-06-25 02:31:02 +0000
16+++ include/core/screen.h 2011-08-29 13:21:25 +0000
17@@ -250,6 +250,8 @@
18
19 CompWindowList & windows ();
20
21+ CompWindowList & serverWindows ();
22+
23 void warpPointer (int dx, int dy);
24
25 Time getCurrentTime ();
26@@ -261,8 +263,9 @@
27 void focusDefaultWindow ();
28
29 void insertWindow (CompWindow *w, Window aboveId);
30-
31+ void insertServerWindow (CompWindow *w, Window aboveId);
32 void unhookWindow (CompWindow *w);
33+ void unhookServerWindow (CompWindow *w);
34
35 Cursor normalCursor ();
36
37
38=== modified file 'include/core/window.h'
39--- include/core/window.h 2011-04-30 14:07:20 +0000
40+++ include/core/window.h 2011-08-29 13:21:25 +0000
41@@ -272,7 +272,7 @@
42 * A mutable object about the dimensions and location of a CompWindow.
43 */
44 class Geometry : public CompRect
45- {
46+ {
47 public:
48 Geometry ();
49 Geometry (int, int, int, int, int);
50@@ -293,6 +293,9 @@
51 CompWindow *next;
52 CompWindow *prev;
53
54+ CompWindow *serverNext;
55+ CompWindow *serverPrev;
56+
57 public:
58 ~CompWindow ();
59
60
61=== modified file 'src/privatescreen.h'
62--- src/privatescreen.h 2011-08-19 14:25:11 +0000
63+++ src/privatescreen.h 2011-08-29 13:21:25 +0000
64@@ -362,6 +362,11 @@
65 CompScreen *screen;
66
67 std::list <CoreWindow *> createdWindows;
68+
69+ /* Window list last sent to server */
70+ CompWindowList serverWindows;
71+
72+ /* Window list last recv from server */
73 CompWindowList windows;
74 CompWindow::Map windowsMap;
75
76
77=== modified file 'src/screen.cpp'
78--- src/screen.cpp 2011-08-23 06:16:21 +0000
79+++ src/screen.cpp 2011-08-29 13:21:25 +0000
80@@ -2560,6 +2560,56 @@
81 }
82
83 void
84+CompScreen::insertServerWindow (CompWindow *w, Window aboveId)
85+{
86+ w->serverPrev = NULL;
87+ w->serverNext = NULL;
88+
89+ if (!aboveId || priv->serverWindows.empty ())
90+ {
91+ if (!priv->serverWindows.empty ())
92+ {
93+ priv->serverWindows.front ()->prev = w;
94+ w->serverNext = priv->serverWindows.front ();
95+ }
96+ priv->serverWindows.push_front (w);
97+
98+ return;
99+ }
100+
101+ CompWindowList::iterator it = priv->serverWindows.begin ();
102+
103+ while (it != priv->serverWindows.end ())
104+ {
105+ if ((*it)->id () == aboveId ||
106+ ((*it)->frame () && (*it)->frame () == aboveId))
107+ {
108+ break;
109+ }
110+ it++;
111+ }
112+
113+ if (it == priv->serverWindows.end ())
114+ {
115+#ifdef DEBUG
116+ abort ();
117+#endif
118+ return;
119+ }
120+
121+ w->serverNext = (*it)->serverNext;
122+ w->serverPrev = (*it);
123+ (*it)->serverNext = w;
124+
125+ if (w->serverNext)
126+ {
127+ w->serverNext->serverPrev = w;
128+ }
129+
130+ priv->serverWindows.insert (++it, w);
131+}
132+
133+void
134 PrivateScreen::eraseWindowFromMap (Window id)
135 {
136 if (id != 1)
137@@ -2588,6 +2638,27 @@
138 lastFoundWindow = NULL;
139 }
140
141+void
142+CompScreen::unhookServerWindow (CompWindow *w)
143+{
144+ CompWindowList::iterator it =
145+ std::find (priv->serverWindows.begin (), priv->serverWindows.end (), w);
146+
147+ priv->serverWindows.erase (it);
148+
149+ if (w->serverNext)
150+ w->serverNext->serverPrev = w->serverPrev;
151+
152+ if (w->serverPrev)
153+ w->serverPrev->serverNext = w->serverNext;
154+
155+ w->serverNext = NULL;
156+ w->serverPrev = NULL;
157+
158+ if (w == lastFoundWindow)
159+ lastFoundWindow = NULL;
160+}
161+
162 Cursor
163 CompScreen::normalCursor ()
164 {
165
166=== modified file 'src/window.cpp'
167--- src/window.cpp 2011-08-23 13:15:20 +0000
168+++ src/window.cpp 2011-08-29 13:21:25 +0000
169@@ -2493,37 +2493,27 @@
170 xwc->y = 0;
171 }
172
173- XConfigureWindow (screen->dpy (), id, valueMask, xwc);
174-
175- /* Compiz's window list is immediately restacked on reconfigureXWindow
176- in order to ensure correct operation of the raise, lower and restacking
177- functions. This function should only recieve stack_mode == Above
178- but warn incase something else does get through, to make the cause
179- of any potential misbehaviour obvious. */
180+ /* Update the server side window list on raise, lower and restack functions.
181+ * This function should only recieve stack_mode == Above
182+ * but warn incase something else does get through, to make the cause
183+ * of any potential misbehaviour obvious. */
184 if (valueMask & (CWSibling | CWStackMode))
185 {
186 if (xwc->stack_mode == Above)
187 {
188- /* FIXME: We shouldn't need to sync here, however
189- * considering the fact that we are immediately
190- * restacking the windows, we need to ensure
191- * that when a client tries to restack a window
192- * relative to this window that the window
193- * actually goes where the client expects it to go
194- * and not anywhere else
195- *
196- * The real solution here is to have a list of windows
197- * last sent to server and a list of windows last
198- * received from server or to have a sync () function
199- * on the stack which looks through the last recieved
200- * window stack and the current window stack then
201- * sends the changes */
202- XSync (screen->dpy (), false);
203- restack (xwc->sibling);
204+ if (xwc->sibling)
205+ {
206+ CompWindow *w = screen->findWindow (id);
207+
208+ screen->unhookServerWindow (w);
209+ screen->insertServerWindow (w, xwc->sibling);
210+ }
211 }
212 else
213 compLogMessage ("core", CompLogLevelWarn, "restack_mode not Above");
214 }
215+
216+ XConfigureWindow (screen->dpy (), id, valueMask, xwc);
217 }
218
219 bool
220@@ -3193,26 +3183,9 @@
221 XLowerWindow (screen->dpy (), frame);
222 XLowerWindow (screen->dpy (), id);
223
224- /* Restacking of compiz's window list happens
225- * immediately and since this path doesn't call
226- * reconfigureXWindow, restack must be called here.
227- *
228- * FIXME: We shouldn't need to sync here, however
229- * considering the fact that we are immediately
230- * restacking the windows, we need to ensure
231- * that when a client tries to restack a window
232- * relative to this window that the window
233- * actually goes where the client expects it to go
234- * and not anywhere else
235- *
236- * The real solution here is to have a list of windows
237- * last sent to server and a list of windows last
238- * received from server or to have a sync () function
239- * on the stack which looks through the last recieved
240- * window stack and the current window stack then
241- * sends the changes */
242- XSync (screen->dpy (), false);
243- restack (0);
244+ /* Update the list of windows last sent to the server */
245+ screen->unhookServerWindow (window);
246+ screen->insertServerWindow (window, 0);
247 }
248 else if (sibling->priv->id != window->prev->priv->id)
249 {
250@@ -3258,9 +3231,9 @@
251 PrivateScreen::focusTopMostWindow ()
252 {
253 CompWindow *focus = NULL;
254- CompWindowList::reverse_iterator it = windows.rbegin ();
255+ CompWindowList::reverse_iterator it = serverWindows.rbegin ();
256
257- for (; it != windows.rend (); it++)
258+ for (; it != serverWindows.rend (); it++)
259 {
260 CompWindow *w = *it;
261
262@@ -3301,10 +3274,7 @@
263 the click-to-focus option is on */
264 if ((screen->priv->optionGetClickToFocus ()))
265 {
266- Window aboveWindowId = prev ? prev->id () : None;
267- screen->unhookWindow (this);
268 CompWindow *focusedWindow = screen->priv->focusTopMostWindow ();
269- screen->insertWindow (this , aboveWindowId);
270
271 /* if the newly focused window is a desktop window,
272 give the focus back to w */
273@@ -3491,22 +3461,6 @@
274 it was created */
275 if (mask & CWStackMode)
276 {
277- /* FIXME: We shouldn't need to sync here, however
278- * considering the fact that we are immediately
279- * restacking the windows, we need to ensure
280- * that when a client tries to restack a window
281- * relative to this window that the window
282- * actually goes where the client expects it to go
283- * and not anywhere else
284- *
285- * The real solution here is to have a list of windows
286- * last sent to server and a list of windows last
287- * received from server or to have a sync () function
288- * on the stack which looks through the last recieved
289- * window stack and the current window stack then
290- * sends the changes */
291- XSync (screen->dpy (), false);
292-
293 Window above = (mask & CWSibling) ? xwc.sibling : 0;
294 priv->restack (above);
295 }
296@@ -5314,6 +5268,7 @@
297 priv->window = this;
298
299 screen->insertWindow (this, aboveId);
300+ screen->insertServerWindow (this, aboveId);
301
302 priv->attrib = wa;
303 priv->serverGeometry.set (priv->attrib.x, priv->attrib.y,
304@@ -5498,6 +5453,7 @@
305 CompWindow::~CompWindow ()
306 {
307 screen->unhookWindow (this);
308+ screen->unhookServerWindow (this);
309
310 if (!priv->destroyed)
311 {

Subscribers

People subscribed via source and target branches