Merge lp:~sil2100/compiz/quickfix_1141079_trunk into lp:compiz/0.9.10

Proposed by Sam Spilsbury
Status: Merged
Approved by: Łukasz Zemczak
Approved revision: 3646
Merged at revision: 3649
Proposed branch: lp:~sil2100/compiz/quickfix_1141079_trunk
Merge into: lp:compiz/0.9.10
Diff against target: 242 lines (+137/-22)
5 files modified
src/event.cpp (+21/-19)
tests/system/xorg-gtest/tests/compiz_xorg_gtest_configure_window.cpp (+99/-0)
tests/xorg-gtest/include/compiz-xorg-gtest.h (+2/-1)
tests/xorg-gtest/plugins/testhelper/src/testhelper.cpp (+1/-0)
tests/xorg-gtest/src/compiz-xorg-gtest.cpp (+14/-2)
To merge this branch: bzr merge lp:~sil2100/compiz/quickfix_1141079_trunk
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Compiz Maintainers Pending
Review via email: mp+157084@code.launchpad.net

This proposal supersedes a proposal from 2013-04-03.

Commit message

Qt is stupid since it uses the stupid X11 protocol - let's not set all the attributes (especially override_redirect) every time, only in cases when it's actually needed (LP: #1141079)

Description of the change

- Problem:

The fix introduced in revision 3606 triggers a regression with Qt menus. It seems that passing on the override_redirect state from xcreatewindow results in this regression happening. Pop-up menus in Qt apps sometimes are detected as a separate window.

- Fix:

We try not to invalidly unnecessarily pass the additional attributes to the event when there is no need. This way the override_redirect attribute is not corrupted and all is cool.

- Tests:

Attached related gtest tests.

(once this branch gets approved, please approve the raring one as well:
https://code.launchpad.net/~sil2100/compiz/quickfix_1141079/+merge/153427 )

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
Sam Spilsbury (smspillaz) wrote :

I am resubmitting this for now to get a green CI result - there is a race condition which can cause multiple builds' tests to fail due to the way xorg-gtest works.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Łukasz Zemczak (sil2100) wrote :

I'm triggering a rebuild again.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/event.cpp'
2--- src/event.cpp 2013-02-10 05:01:50 +0000
3+++ src/event.cpp 2013-04-04 11:55:39 +0000
4@@ -1285,19 +1285,20 @@
5 * the window to the window list as we might get configure requests
6 * which require us to stack other windows relative to it. Setting
7 * some default values if this is the case. */
8- if (!XGetWindowAttributes (privateScreen.dpy, event->xcreatewindow.window, &wa))
9+ if (!XGetWindowAttributes (privateScreen.dpy, event->xcreatewindow.window, &wa)) {
10 privateScreen.setDefaultWindowAttributes (&wa);
11
12- /* That being said, we should store as much information as possible
13- * about it. There may be requests relative to this window that could
14- * use the data in the XCreateWindowEvent structure, especially the
15- * override redirect state */
16- wa.x = event->xcreatewindow.x;
17- wa.y = event->xcreatewindow.y;
18- wa.width = event->xcreatewindow.width;
19- wa.height = event->xcreatewindow.height;
20- wa.border_width = event->xcreatewindow.border_width;
21- wa.override_redirect = event->xcreatewindow.override_redirect;
22+ /* That being said, we should store as much information as possible
23+ * about it. There may be requests relative to this window that could
24+ * use the data in the XCreateWindowEvent structure, especially the
25+ * override redirect state */
26+ wa.x = event->xcreatewindow.x;
27+ wa.y = event->xcreatewindow.y;
28+ wa.width = event->xcreatewindow.width;
29+ wa.height = event->xcreatewindow.height;
30+ wa.border_width = event->xcreatewindow.border_width;
31+ wa.override_redirect = event->xcreatewindow.override_redirect;
32+ }
33
34 foreach (CompWindow *w, screen->windows ())
35 {
36@@ -1475,16 +1476,17 @@
37 * the window to the window list as we might get configure requests
38 * which require us to stack other windows relative to it. Setting
39 * some default values if this is the case. */
40- if (!XGetWindowAttributes (privateScreen.dpy, event->xcreatewindow.window, &wa))
41+ if (!XGetWindowAttributes (privateScreen.dpy, event->xcreatewindow.window, &wa)) {
42 privateScreen.setDefaultWindowAttributes (&wa);
43
44- /* That being said, we should store as much information as possible
45- * about it. There may be requests relative to this window that could
46- * use the data in the XCreateWindowEvent structure, especially the
47- * override redirect state */
48- wa.x = event->xreparent.x;
49- wa.y = event->xreparent.y;
50- wa.override_redirect = event->xreparent.override_redirect;
51+ /* That being said, we should store as much information as possible
52+ * about it. There may be requests relative to this window that could
53+ * use the data in the XCreateWindowEvent structure, especially the
54+ * override redirect state */
55+ wa.x = event->xreparent.x;
56+ wa.y = event->xreparent.y;
57+ wa.override_redirect = event->xreparent.override_redirect;
58+ }
59
60 PrivateWindow::createCompWindow (getTopWindow ()->id (), getTopServerWindow ()->id (), wa, event->xreparent.window);
61 break;
62
63=== modified file 'tests/system/xorg-gtest/tests/compiz_xorg_gtest_configure_window.cpp'
64--- tests/system/xorg-gtest/tests/compiz_xorg_gtest_configure_window.cpp 2013-03-11 06:38:17 +0000
65+++ tests/system/xorg-gtest/tests/compiz_xorg_gtest_configure_window.cpp 2013-04-04 11:55:39 +0000
66@@ -212,6 +212,14 @@
67 bool VerifySetFrameExtentsResponse (Window w, int left, int right, int top, int bottom);
68 bool VerifyWindowSize (Window w, int x, int y, int width, int height);
69
70+ /* Helper functions for the Create*WindowOverrideRedirect* tests */
71+ Window GrabAndCreateWindowWithAttrs (::Display *dpy,
72+ XSetWindowAttributes &attr);
73+ void UngrabSyncAndTestOverride (::Display *dpy,
74+ Window w,
75+ bool overrideAssert);
76+
77+
78 protected:
79
80 ReparentedWindow CreateWindow (::Display *);
81@@ -720,6 +728,7 @@
82 currentHeight));
83
84 SendSetFrameExtentsRequest (client, left, right, top, bottom);
85+
86 ASSERT_TRUE (VerifySetFrameExtentsResponse (client, left, right, top, bottom));
87
88 /* Map the window */
89@@ -750,3 +759,93 @@
90 currentWidth,
91 currentHeight));
92 }
93+
94+
95+Window
96+CompizXorgSystemConfigureWindowTest::GrabAndCreateWindowWithAttrs (::Display *dpy,
97+ XSetWindowAttributes &attr)
98+{
99+ /* NOTE: We need to ungrab the server after this function */
100+ XGrabServer (dpy);
101+
102+ /* Create a window with our custom attributes */
103+ return XCreateWindow (dpy, DefaultRootWindow (dpy),
104+ 0, 0, 100, 100, 0, CopyFromParent,
105+ InputOutput, CopyFromParent, CWOverrideRedirect,
106+ &attr);
107+}
108+
109+void
110+CompizXorgSystemConfigureWindowTest::UngrabSyncAndTestOverride (::Display *dpy,
111+ Window w,
112+ bool overrideAssert)
113+{
114+ XSync (dpy, false);
115+
116+ XUngrabServer (dpy);
117+
118+ XSync (dpy, false);
119+
120+ /* Check if the created window had the attributes passed correctly */
121+ std::vector <long> data = WaitForWindowCreation (w);
122+ EXPECT_EQ (overrideAssert, IsOverrideRedirect (data));
123+}
124+
125+
126+TEST_F (CompizXorgSystemConfigureWindowTest, CreateDestroyWindowOverrideRedirectTrue)
127+{
128+ ::Display *dpy = Display ();
129+ XSetWindowAttributes attr;
130+ attr.override_redirect = 1;
131+
132+ Window w = GrabAndCreateWindowWithAttrs (dpy, attr);
133+
134+ XDestroyWindow (dpy, w);
135+
136+ UngrabSyncAndTestOverride (dpy, w, true);
137+}
138+
139+TEST_F (CompizXorgSystemConfigureWindowTest, CreateDestroyWindowOverrideRedirectFalse)
140+{
141+ ::Display *dpy = Display ();
142+ XSetWindowAttributes attr;
143+ attr.override_redirect = 0;
144+
145+ Window w = GrabAndCreateWindowWithAttrs (dpy, attr);
146+
147+ XDestroyWindow (dpy, w);
148+
149+ UngrabSyncAndTestOverride (dpy, w, false);
150+}
151+
152+TEST_F (CompizXorgSystemConfigureWindowTest, CreateChangeWindowOverrideRedirectTrue)
153+{
154+ ::Display *dpy = Display ();
155+ XSetWindowAttributes attr;
156+ attr.override_redirect = 0;
157+
158+ Window w = GrabAndCreateWindowWithAttrs (dpy, attr);
159+
160+ attr.override_redirect = 1;
161+ XChangeWindowAttributes (dpy, w, CWOverrideRedirect, &attr);
162+
163+ UngrabSyncAndTestOverride (dpy, w, true);
164+
165+ XDestroyWindow (dpy, w);
166+}
167+
168+TEST_F (CompizXorgSystemConfigureWindowTest, CreateChangeWindowOverrideRedirectFalse)
169+{
170+ ::Display *dpy = Display ();
171+ XSetWindowAttributes attr;
172+ attr.override_redirect = 1;
173+
174+ Window w = GrabAndCreateWindowWithAttrs (dpy, attr);
175+
176+ attr.override_redirect = 0;
177+ XChangeWindowAttributes (dpy, w, CWOverrideRedirect, &attr);
178+
179+ UngrabSyncAndTestOverride (dpy, w, false);
180+
181+ XDestroyWindow (dpy, w);
182+}
183
184=== modified file 'tests/xorg-gtest/include/compiz-xorg-gtest.h'
185--- tests/xorg-gtest/include/compiz-xorg-gtest.h 2013-02-23 10:47:18 +0000
186+++ tests/xorg-gtest/include/compiz-xorg-gtest.h 2013-04-04 11:55:39 +0000
187@@ -214,7 +214,8 @@
188 protected:
189
190 Atom FetchAtom (const char *);
191- void WaitForWindowCreation (Window w);
192+ std::vector <long> WaitForWindowCreation (Window w);
193+ bool IsOverrideRedirect (std::vector <long> &data);
194
195 virtual int GetEventMask ();
196
197
198=== modified file 'tests/xorg-gtest/plugins/testhelper/src/testhelper.cpp'
199--- tests/xorg-gtest/plugins/testhelper/src/testhelper.cpp 2013-02-14 12:12:53 +0000
200+++ tests/xorg-gtest/plugins/testhelper/src/testhelper.cpp 2013-04-04 11:55:39 +0000
201@@ -192,6 +192,7 @@
202
203 std::vector <long> data;
204 data.push_back (static_cast <long> (window->id ()));
205+ data.push_back (static_cast <long> (window->overrideRedirect ()));
206 ct::SendClientMessage (screen->dpy (),
207 ts->fetchAtom (ctm::TEST_HELPER_WINDOW_READY),
208 screen->root (),
209
210=== modified file 'tests/xorg-gtest/src/compiz-xorg-gtest.cpp'
211--- tests/xorg-gtest/src/compiz-xorg-gtest.cpp 2013-02-23 08:23:05 +0000
212+++ tests/xorg-gtest/src/compiz-xorg-gtest.cpp 2013-04-04 11:55:39 +0000
213@@ -738,7 +738,7 @@
214 std::auto_ptr <ct::MessageAtoms> mMessages;
215 };
216
217-void
218+std::vector <long>
219 ct::AutostartCompizXorgSystemTestWithTestHelper::WaitForWindowCreation (Window w)
220 {
221 ::Display *dpy = Display ();
222@@ -758,7 +758,19 @@
223
224 }
225
226- ASSERT_TRUE (requestAcknowledged);
227+ EXPECT_TRUE (requestAcknowledged);
228+
229+ std::vector <long> data;
230+ for (int i = 0; i < 5; ++i)
231+ data.push_back(static_cast <long> (event.xclient.data.l[i]));
232+
233+ return data;
234+}
235+
236+bool
237+ct::AutostartCompizXorgSystemTestWithTestHelper::IsOverrideRedirect (std::vector <long> &data)
238+{
239+ return (data[1] > 0) ? true : false;
240 }
241
242 Atom

Subscribers

People subscribed via source and target branches