Merge lp:~smspillaz/compiz-core/compiz-core.more-sound-reparenting-behaviour into lp:compiz-core

Proposed by Sam Spilsbury
Status: Merged
Merged at revision: 3085
Proposed branch: lp:~smspillaz/compiz-core/compiz-core.more-sound-reparenting-behaviour
Merge into: lp:compiz-core
Diff against target: 110 lines (+10/-45)
3 files modified
src/event.cpp (+2/-1)
src/privatescreen.h (+0/-2)
src/window.cpp (+8/-42)
To merge this branch: bzr merge lp:~smspillaz/compiz-core/compiz-core.more-sound-reparenting-behaviour
Reviewer Review Type Date Requested Status
Daniel van Vugt Approve
Review via email: mp+100720@code.launchpad.net

Description of the change

Stab in the dark.

I think whats going on for bug 940603 is that windows aren't being removed from the window list if they are unreparented by the application itself in very special circumstances (not sure what because I can't reproduce the bug).

This code adds some more sound checks to see where the window is going and destroys it based on that, rather than using the same logic for both reparented and unreparented windows.

Also removed the whole destroyedFrameWindows tracking code which was more or ineffectual and could potentially result in a frame window leak.

To post a comment you must log in.
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

In case you're wondering, I just corrected the bug number in the description.

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

thanks

Revision history for this message
Daniel van Vugt (vanvugt) wrote :

I was optimistically hoping this branch would fix bug 865672. But it doesn't.

Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Seems to work perfectly without any visible regressions.

I cannot confirm it fixes any particular bug at all. And I don't claim to fully understand the code. Based on recent history, that would lead me to abstain. However I strongly support any changes that make the code significantly smaller and easier to maintain. And if there is a chance this fixes bug 940603 then we really want to commit it for the sake of testing at least.

Less importantly, I think it's bad practice to assume None == 0 even though it is true. So this:
  if (priv->serverFrame)
should be written as:
  if (priv->serverFrame != None)

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/event.cpp'
--- src/event.cpp 2012-03-24 09:49:30 +0000
+++ src/event.cpp 2012-04-04 03:23:19 +0000
@@ -1355,7 +1355,8 @@
13551355
1356 if (w)1356 if (w)
1357 {1357 {
1358 if (event->xreparent.parent != w->priv->wrapper)1358 if ((w->priv->wrapper && event->xreparent.parent != w->priv->wrapper) ||
1359 (!w->priv->wrapper && event->xreparent.parent != priv->root))
1359 {1360 {
1360 w->moveInputFocusToOtherWindow ();1361 w->moveInputFocusToOtherWindow ();
1361 w->destroy ();1362 w->destroy ();
13621363
=== modified file 'src/privatescreen.h'
--- src/privatescreen.h 2012-03-29 16:54:46 +0000
+++ src/privatescreen.h 2012-04-04 03:23:19 +0000
@@ -523,8 +523,6 @@
523 CompWindow::Map windowsMap;523 CompWindow::Map windowsMap;
524 std::list<CompGroup *> groups;524 std::list<CompGroup *> groups;
525525
526 std::map <CompWindow *, CompWindow *> detachedFrameWindows;
527
528 CompWindowVector clientList; /* clients in mapping order */526 CompWindowVector clientList; /* clients in mapping order */
529 CompWindowVector clientListStacking; /* clients in stacking order */527 CompWindowVector clientListStacking; /* clients in stacking order */
530528
531529
=== modified file 'src/window.cpp'
--- src/window.cpp 2012-03-30 11:43:20 +0000
+++ src/window.cpp 2012-04-04 03:23:19 +0000
@@ -1441,8 +1441,11 @@
1441 windowNotify (CompWindowNotifyBeforeDestroy);1441 windowNotify (CompWindowNotifyBeforeDestroy);
14421442
1443 /* Don't allow frame windows to block input */1443 /* Don't allow frame windows to block input */
1444 XUnmapWindow (screen->dpy (), priv->serverFrame);1444 if (priv->serverFrame)
1445 XUnmapWindow (screen->dpy (), priv->wrapper);1445 XUnmapWindow (screen->dpy (), priv->serverFrame);
1446
1447 if (priv->wrapper)
1448 XUnmapWindow (screen->dpy (), priv->wrapper);
14461449
1447 oldServerNext = serverNext;1450 oldServerNext = serverNext;
1448 oldServerPrev = serverPrev;1451 oldServerPrev = serverPrev;
@@ -6461,21 +6464,6 @@
6461 dw->serverPrev = this->serverPrev;6464 dw->serverPrev = this->serverPrev;
6462 }6465 }
64636466
6464 /* If this window has a detached frame, destroy it, but only
6465 * using XDestroyWindow since there may be pending restack
6466 * requests relative to it */
6467
6468 std::map <CompWindow *, CompWindow *>::iterator it =
6469 screen->priv->detachedFrameWindows.find (this);
6470
6471 if (it != screen->priv->detachedFrameWindows.end ())
6472 {
6473 CompWindow *fw = (it->second);
6474
6475 XDestroyWindow (screen->dpy (), fw->id ());
6476 screen->priv->detachedFrameWindows.erase (it);
6477 }
6478
6479 if (!priv->destroyed)6467 if (!priv->destroyed)
6480 {6468 {
6481 StackDebugger *dbg = StackDebugger::Default ();6469 StackDebugger *dbg = StackDebugger::Default ();
@@ -6934,22 +6922,6 @@
6934 attr.colormap = cmap;6922 attr.colormap = cmap;
6935 attr.override_redirect = true;6923 attr.override_redirect = true;
69366924
6937 /* Look for existing detached frame windows and reattach them
6938 * in case this window as reparented again after being withdrawn */
6939 std::map <CompWindow *, CompWindow *>::iterator it =
6940 screen->priv->detachedFrameWindows.find (window);
6941
6942 if (it != screen->priv->detachedFrameWindows.end ())
6943 {
6944 /* Trash the old frame window
6945 * TODO: It would be nicer if we could just
6946 * reparent back into it, but there are some
6947 * problems with that */
6948
6949 XDestroyWindow (dpy, (it->second)->id ());
6950 screen->priv->detachedFrameWindows.erase (it);
6951 }
6952
6953 /* We need to know when the frame window is created6925 /* We need to know when the frame window is created
6954 * but that's all */6926 * but that's all */
6955 XSelectInput (dpy, screen->root (), SubstructureNotifyMask);6927 XSelectInput (dpy, screen->root (), SubstructureNotifyMask);
@@ -7192,17 +7164,11 @@
71927164
7193 /* Put the frame window "above" the client window7165 /* Put the frame window "above" the client window
7194 * in the stack */7166 * in the stack */
7195 CompWindow *fw = PrivateWindow::createCompWindow (id, attrib, serverFrame);7167 PrivateWindow::createCompWindow (id, attrib, serverFrame);
7196
7197 /* Put this window in the list of "detached frame windows"
7198 * so that we can reattach it or destroy it when we are
7199 * done with it */
7200
7201 screen->priv->detachedFrameWindows[window] = fw;
7202 }7168 }
72037169
7204 /* Safe to destroy the wrapper but not the frame */7170 /* Issue a DestroyNotify */
7205 XUnmapWindow (screen->dpy (), serverFrame);7171 XDestroyWindow (screen->dpy (), serverFrame);
7206 XDestroyWindow (screen->dpy (), wrapper);7172 XDestroyWindow (screen->dpy (), wrapper);
72077173
7208 window->windowNotify (CompWindowNotifyUnreparent);7174 window->windowNotify (CompWindowNotifyUnreparent);

Subscribers

People subscribed via source and target branches