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

Proposed by Sam Spilsbury
Status: Merged
Merged at revision: 2855
Proposed branch: lp:~compiz-team/compiz-core/compiz-core.fix_865863
Merge into: lp:compiz-core/0.9.5
Diff against target: 119 lines (+56/-49)
1 file modified
src/event.cpp (+56/-49)
To merge this branch: bzr merge lp:~compiz-team/compiz-core/compiz-core.fix_865863
Reviewer Review Type Date Requested Status
Compiz Maintainers Pending
Review via email: mp+78033@code.launchpad.net

This proposal supersedes a proposal from 2011-10-04.

Description of the change

Fixes Bug 865863

Handle windows that reparent into the root window correclty

To post a comment you must log in.
Revision history for this message
Tim Penhey (thumper) wrote :

Do you really need to create the CoreWindow on the stack?

Could you do this:

CoreWindow cw(event->xcreatewindow.window);
cw.manage (priv->getTopWindow (), wa);
priv->createdWindows.remove (&cw);
break;

// NOTE: no delete needed.

Revision history for this message
Sam Spilsbury (smspillaz) wrote :

Yes, because CoreWindow's constructor adds itself to priv->createdWindows. Yeah, I know, that's bad, but I plan to kill CoreWindow anyways

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 2011-10-02 07:17:59 +0000
3+++ src/event.cpp 2011-10-04 03:34:34 +0000
4@@ -1240,59 +1240,66 @@
5 }
6 break;
7 case ReparentNotify:
8+
9 w = findWindow (event->xreparent.window);
10
11- /* It is possible that some plugin might call
12- * w->destroy () before the window actually receives
13- * its first ReparentNotify event which would mean
14- * that it is already in the list of destroyed
15- * windows, so check that list too */
16+ /* If this window isn't part of our tracked window
17+ * list and was reparented into the root window then
18+ * we need to track it */
19 if (!w)
20 {
21- foreach (CompWindow *dw, screen->priv->destroyedWindows)
22- {
23- if (dw->priv->serverId == event->xdestroywindow.window)
24- {
25- w = dw;
26- break;
27- }
28- }
29- }
30-
31- if (!w && event->xreparent.parent == priv->root)
32- {
33- /* Failure means that window has been destroyed. We still have to add
34- * the window to the window list as we might get configure requests
35- * which require us to stack other windows relative to it. Setting
36- * some default values if this is the case. */
37- if (!XGetWindowAttributes (priv->dpy, event->xcreatewindow.window, &wa))
38- priv->setDefaultWindowAttributes (&wa);
39-
40- CoreWindow *cw = new CoreWindow (event->xcreatewindow.window);
41- cw->manage (priv->getTopWindow (), wa);
42-
43- priv->createdWindows.remove (cw);
44- delete cw;
45- }
46- else if (!(event->xreparent.parent == priv->root))
47- {
48- /* This is the only case where a window is removed but not
49- destroyed. We must remove our event mask and all passive
50- grabs. */
51-
52- if (w)
53- {
54- if (event->xreparent.parent != w->priv->wrapper)
55- {
56- w->moveInputFocusToOtherWindow ();
57- w->destroy ();
58-
59- XSelectInput (priv->dpy, w->id (), NoEventMask);
60- XShapeSelectInput (priv->dpy, w->id (), NoEventMask);
61- XUngrabButton (priv->dpy, AnyButton, AnyModifier, w->id ());
62- }
63- }
64- }
65+ if (event->xreparent.parent == priv->root)
66+ {
67+ /* Failure means that window has been destroyed. We still have to add
68+ * the window to the window list as we might get configure requests
69+ * which require us to stack other windows relative to it. Setting
70+ * some default values if this is the case. */
71+ if (!XGetWindowAttributes (priv->dpy, event->xcreatewindow.window, &wa))
72+ priv->setDefaultWindowAttributes (&wa);
73+
74+ CoreWindow *cw = new CoreWindow (event->xcreatewindow.window);
75+ cw->manage (priv->getTopWindow (), wa);
76+
77+ priv->createdWindows.remove (cw);
78+ delete cw;
79+ break;
80+ }
81+ else
82+ {
83+ /* It is possible that some plugin might call
84+ * w->destroy () before the window actually receives
85+ * its first ReparentNotify event which would mean
86+ * that it is already in the list of destroyed
87+ * windows, so check that list too */
88+
89+ foreach (CompWindow *dw, screen->priv->destroyedWindows)
90+ {
91+ if (dw->priv->serverId == event->xreparent.window)
92+ {
93+ w = dw;
94+ break;
95+ }
96+ }
97+ }
98+ }
99+
100+ /* This is the only case where a window is removed but not
101+ destroyed. We must remove our event mask and all passive
102+ grabs. */
103+
104+ if (w)
105+ {
106+ if (event->xreparent.parent != w->priv->wrapper)
107+ {
108+ w->moveInputFocusToOtherWindow ();
109+ w->destroy ();
110+
111+ XSelectInput (priv->dpy, w->id (), NoEventMask);
112+ XShapeSelectInput (priv->dpy, w->id (), NoEventMask);
113+ XUngrabButton (priv->dpy, AnyButton, AnyModifier, w->id ());
114+ }
115+ }
116+
117 break;
118 case CirculateNotify:
119 w = findWindow (event->xcirculate.window);

Subscribers

People subscribed via source and target branches