diff --git a/ChangeLog b/ChangeLog index 71c453de6..49a7d3e62 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ +2009-02-20 Holger Vogt + * x11disp.c: allow closing of help windows with WM x-button + 2009-02-14 Dietmar Warning * src/spicelib/parser/inpdomod.c: map level 10 to bsimsoi4 and map ancient version 4.0 and 4.1 of bsim4 to available version 4.2 diff --git a/src/frontend/help/x11disp.c b/src/frontend/help/x11disp.c index 43a4ddb74..10199802c 100644 --- a/src/frontend/help/x11disp.c +++ b/src/frontend/help/x11disp.c @@ -25,6 +25,24 @@ static bool started = FALSE; static topic *topics = NULL; void newtopic(Widget w, caddr_t client_data, caddr_t call_data), delete(Widget w, caddr_t client_data, caddr_t call_data), quit(Widget w, caddr_t client_data, caddr_t call_data); static void sputline(char *buf, char *s); +/* atoms for catching window delet by WM x-button */ +static Atom atom_wm_delete_window; +static Atom atom_wm_protocols; +static Display *display; + +/* callback function for catching window deletion by WM x-button */ +static void handle_wm_messages(Widget w, XtPointer client_data, XEvent *event, Boolean *cont) { + topic *top = (topic *) client_data; + + if (event->type == ClientMessage + && event->xclient.message_type == atom_wm_protocols + && event->xclient.data.l[0] == atom_wm_delete_window) + { + hlp_killfamily(top); + hlp_fixchildren(top); + } +} + /* Create a new window... */ bool @@ -191,6 +209,14 @@ hlp_xdisplay(topic *top) top->winlink = topics; topics = top; + + /* WM_DELETE_WINDOW protocol */ + display = XtDisplay(top->shellwidget); + atom_wm_protocols = XInternAtom(display, "WM_PROTOCOLS", False); + atom_wm_delete_window = XInternAtom(display, "WM_DELETE_WINDOW", False); + XtAddEventHandler(top->shellwidget, NoEventMask, True, handle_wm_messages, top); + XSetWMProtocols(display, XtWindow(top->shellwidget), &atom_wm_delete_window, 1); + return (TRUE); }