From 5c4e88a76535680cbf7971109a07814695c85ac2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Wed, 4 Mar 2015 01:48:11 +0100 Subject: [PATCH] dispvm: close only visible windows during DispVM preparation Closing some invisible window can cause e.g. Firefox crash. Send the message to visible windows and others should be cleaned up by the application. --- misc/close-window.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/misc/close-window.c b/misc/close-window.c index 071527c..645cd7a 100644 --- a/misc/close-window.c +++ b/misc/close-window.c @@ -15,15 +15,26 @@ int close_window(Display *d, XID window) { return XSendEvent(ev.display, ev.window, True, 0, (XEvent *) & ev); } +int is_window_visible(Display *d, XID window) { + XWindowAttributes xwa; + + if (!XGetWindowAttributes(d, window, &xwa)) + return 0; + return xwa.map_state == IsViewable; +} + int main(int argc, char **argv) { int i; Display *d; + XID w; d = XOpenDisplay(NULL); if (!d) exit(1); for (i=1; i