On Sat, 2009-01-03 at 18:00 +0100, Julien Cristau wrote: > On Fri, Jan 2, 2009 at 15:30:01 +0000, Ben Hutchings wrote: > > > #508126: x11-utils: xprop -spy does not handle destruction properly > > > the xprop patch looks reasonable afaict, so go ahead and NMU. somebody > should also forward that patch to bugs.freedesktop.org.
Thanks, done. The NMU-diff follows. Ben. diff -Nru x11-utils-7.3+2/debian/changelog x11-utils-7.3+2+nmu1/debian/changelog --- x11-utils-7.3+2/debian/changelog 2008-05-30 15:21:43.000000000 +0100 +++ x11-utils-7.3+2+nmu1/debian/changelog 2009-01-03 22:22:41.000000000 +0000 @@ -1,3 +1,11 @@ +x11-utils (7.3+2+nmu1) unstable; urgency=low + + * Non-maintainer upload. + * Make xprop -spy exit cleanly when target window is destroyed + (closes: #508126) + + -- Ben Hutchings <b...@decadent.org.uk> Sat, 03 Jan 2009 22:22:40 +0000 + x11-utils (7.3+2) unstable; urgency=low * Relax Replaces on xutils and xbase-clients to allow further updates. diff -Nru x11-utils-7.3+2/debian/patches/05_xprop_spy_exit_on_destroy.diff x11-utils-7.3+2+nmu1/debian/patches/05_xprop_spy_exit_on_destroy.diff --- x11-utils-7.3+2/debian/patches/05_xprop_spy_exit_on_destroy.diff 1970-01-01 01:00:00.000000000 +0100 +++ x11-utils-7.3+2+nmu1/debian/patches/05_xprop_spy_exit_on_destroy.diff 2009-01-03 22:21:48.000000000 +0000 @@ -0,0 +1,50 @@ +This patch by Ben Hutchings <b...@decadent.org.uk>. + +xprop -spy should exit cleanly when the target window is destroyed. +The current behaviour is that it sometimes dies with a BadWindow error +and sometimes hangs around after the target has been destroyed. + +We fix this by listening for destroy events but also catching +BadWindow errors (and BadMatch, which may sometimes be received +instead of BadWindow). We print a new-line before exiting from the +error handler, since we may have generated partial output for a +property change. + +--- x11-utils.orig/xprop/xprop.c ++++ x11-utils/xprop/xprop.c +@@ -1596,6 +1596,19 @@ + + static int spy = 0; + ++static int (*old_error_handler)(Display *dpy, XErrorEvent *ev); ++ ++static int spy_error_handler(Display *dpy, XErrorEvent *ev) ++{ ++ if (ev->error_code == BadWindow || ev->error_code == BadMatch) { ++ /* Window was destroyed */ ++ puts(""); ++ exit(0); ++ } ++ ++ return old_error_handler(dpy, ev); ++} ++ + int + main (int argc, char **argv) + { +@@ -1738,9 +1750,14 @@ + XEvent event; + const char *format, *dformat; + +- XSelectInput(dpy, target_win, PropertyChangeMask); ++ XSelectInput(dpy, target_win, PropertyChangeMask | StructureNotifyMask); ++ old_error_handler = XSetErrorHandler(spy_error_handler); + for (;;) { + XNextEvent(dpy, &event); ++ if (event.type == DestroyNotify) ++ break; ++ if (event.type != PropertyNotify) ++ continue; + format = dformat = NULL; + if (props) { + int i; diff -Nru x11-utils-7.3+2/debian/patches/series x11-utils-7.3+2+nmu1/debian/patches/series --- x11-utils-7.3+2/debian/patches/series 2008-02-01 00:21:49.000000000 +0000 +++ x11-utils-7.3+2+nmu1/debian/patches/series 2009-01-03 22:22:05.000000000 +0000 @@ -1,2 +1,3 @@ 02_xev_flush_standard_output.diff 04_xlsfonts_do_not_spew_usage_on_connection_error.diff -p0 +05_xprop_spy_exit_on_destroy.diff --- END --- -- Ben Hutchings The world is coming to an end. Please log off.
signature.asc
Description: This is a digitally signed message part