← Back to team overview

compiz team mailing list archive

[Merge] lp:~unity-team/compiz/trunk.fix_743011 into lp:~unity-team/compiz/trunk

 

David Barth has proposed merging lp:~unity-team/compiz/trunk.fix_743011 into lp:~unity-team/compiz/trunk.

Requested reviews:
  compiz packagers (compiz)
Related bugs:
  Bug #743011 in unity (Ubuntu): "Windows that reparent away from the root before they are mapped can cause other windows to become invisible (and compiz to crash)"
  https://bugs.launchpad.net/ubuntu/+source/unity/+bug/743011

For more details, see:
https://code.launchpad.net/~unity-team/compiz/trunk.fix_743011/+merge/55221

Fixes problems with gitk
-- 
https://code.launchpad.net/~unity-team/compiz/trunk.fix_743011/+merge/55221
Your team compiz packagers is requested to review the proposed merge of lp:~unity-team/compiz/trunk.fix_743011 into lp:~unity-team/compiz/trunk.
=== modified file 'src/event.cpp'
--- src/event.cpp	2011-03-23 14:36:30 +0000
+++ src/event.cpp	2011-03-28 19:53:29 +0000
@@ -1081,6 +1081,7 @@
 		    if (cw)
 		    {
 			w = cw->manage (priv->getTopWindow (), wa);
+			priv->createdWindows.remove (cw);
 			delete cw;
 		    }
 		}
@@ -1122,7 +1123,7 @@
 	 * and then bypassing MapRequest because it *is* override-redirect
 	 * at XMapWindow time, so we need to catch this case and make
 	 * sure that windows are tracked here */
-       
+
 	foreach (CoreWindow *cw, priv->createdWindows)
 	{
 	    if (cw->priv->id == event->xmap.window)
@@ -1138,6 +1139,7 @@
 		    priv->setDefaultWindowAttributes (&wa);
 
 		w = cw->manage (priv->getTopWindow (), wa);
+		priv->createdWindows.remove (cw);
 		delete cw;
 		break;
 	    }
@@ -1236,12 +1238,12 @@
 	    if (cw)
 	    {
 		cw->manage (priv->getTopWindow (), wa);
+		priv->createdWindows.remove (cw);
 		delete cw;
 	    }
 	}
-	else if (!(event->xreparent.parent == priv->root))
+	else if (event->xreparent.parent != priv->root)
 	{
-	    bool     remove = false;
 	    Window   xid = None;
 	    Window   root_return;
 	    unsigned int ui;
@@ -1270,34 +1272,29 @@
 				      &x, &y, &ui, &ui, &ui, &ui);
 		    }
 		    w->destroy ();
-		    remove = true;
+
+		    XSelectInput (priv->dpy, xid, NoEventMask);
+		    XShapeSelectInput (priv->dpy, xid, NoEventMask);
+		    XUngrabButton (priv->dpy, AnyButton, AnyModifier, xid);
+
+		    /* Reparent the window back where it belongs */
+		    if (xid)
+			XReparentWindow (screen->dpy (), xid, event->xreparent.parent,
+					 x, y);
 		}
 	    }
 	    else
 	    {
 		foreach (CoreWindow *cw, screen->priv->createdWindows)
 		{
-		    if (cw->priv->id == event->xreparent.parent)
+		    if (cw->priv->id == event->xreparent.window)
 		    {
 			screen->priv->createdWindows.remove (cw);
 			delete cw;
-			remove = true;
 			break;
 		    }
 		}
 	    }
-
-	    if (remove)
-	    {
-		XSelectInput (priv->dpy, w->id (), NoEventMask);
-		XShapeSelectInput (priv->dpy, w->id (), NoEventMask);
-		XUngrabButton (priv->dpy, AnyButton, AnyModifier, w->id ());
-
-		/* Reparent the window back where it belongs */
-		if (xid)
-		    XReparentWindow (screen->dpy (), xid, event->xreparent.parent,
-				     x, y);
-	    }
 	}
 	break;
     case CirculateNotify:
@@ -1711,6 +1708,7 @@
 	break;
     case MapRequest:
 	/* Create the CompWindow structure here */
+
 	w = NULL;
 
 	foreach (CoreWindow *cw, priv->createdWindows)
@@ -1728,6 +1726,7 @@
 		    priv->setDefaultWindowAttributes (&wa);
 
 		w = cw->manage (priv->getTopWindow (), wa);
+		priv->createdWindows.remove (cw);
 		delete cw;
 		break;
 	    }

=== modified file 'src/screen.cpp'
--- src/screen.cpp	2011-03-13 15:50:39 +0000
+++ src/screen.cpp	2011-03-28 19:53:29 +0000
@@ -4634,6 +4634,7 @@
 	if (cw)
 	{
 	    cw->manage (i ? children[i - 1] : 0, attrib);
+	    priv->createdWindows.remove (cw);
 	    delete cw;
 	}
     }

=== modified file 'src/window.cpp'
--- src/window.cpp	2011-03-23 14:36:30 +0000
+++ src/window.cpp	2011-03-28 19:53:29 +0000
@@ -5107,7 +5107,6 @@
 CompWindow *
 CoreWindow::manage (Window aboveId, XWindowAttributes &wa)
 {
-    screen->priv->createdWindows.remove (this);
     return new CompWindow (aboveId, wa, priv);
 }