Skip to content

Commit

Permalink
window_manager: fix dangling empty window bug
Browse files Browse the repository at this point in the history
Previously, some program might unmap their window(s) but didn't
destory them, leaving some empty windows in the workspace.

Example:
1. KDE's systemsettings5 -> Font -> Font selection window
2. WPS office sign in window

Some empty windows can't even be closed, so initially I simply
use XDestroyWindow to brutally close them, and I broke my entire KDE
config, lots of GUI applications segfaults.

A safer way I came up with is to send an X Event with WM_DELETE to close
a window, call XSync (to make sure the event we just sent has been
processed) and then call XDestroyWindow to make sure this danling bitch is
really closed.
  • Loading branch information
aesophor committed Aug 15, 2019
1 parent 8566e3c commit 9e387f4
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/window_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ void WindowManager::OnUnmapNotify(const XUnmapEvent& e) {
// by the user, then we will remove them for user.
Client* c = it->second;
if (!c->has_unmap_req_from_user()) {
//c->workspace()->Remove(c->window());

This comment has been minimized.

Copy link
@aesophor

aesophor Aug 15, 2019

Author Owner

Previously I wrote XDestoryWindow(c->window()) here, and tested it on KDE's systemsettings5's font selection window, and then I broke my entire KDE config. Lots of GUI application segfaults, even my god damn urxvt segfaults.

PS: Just ignore this line, it makes no sense.

KillClient(c->window());
} else {
c->set_has_unmap_req_from_user(false);
}
Expand Down Expand Up @@ -680,6 +680,8 @@ void WindowManager::KillClient(Window window) {
msg.xclient.format = 32;
msg.xclient.data.l[0] = prop_->wm[atom::WM_DELETE];
XSendEvent(dpy_, window, false, 0, &msg);
XSync(dpy_, false); // make sure the event we just sent has been processed by server
XDestroyWindow(dpy_, window); // make sure the window is really destroyed
} else {
XKillClient(dpy_, window);
}
Expand Down

0 comments on commit 9e387f4

Please sign in to comment.