Package: xsok Version: 1.02-13 Tags: patch Followup-For: Bug #288143 This patch adds support for the WM_DELETE_WINDOW protocol, so that closing xsok windows with the window manager's close button works properly. No large changes were needed, I just added the required X magic.
Peter De Wachter -- System Information: Debian Release: testing/unstable Architecture: i386 (i686) Kernel: Linux 2.6.9 Locale: LANG=nl_BE.UTF-8, LC_CTYPE=nl_BE.UTF-8 Versions of packages xsok depends on: ii libc6 2.3.2.ds1-13ubuntu2.2 GNU C Library: Shared libraries an ii libice6 4.3.0.dfsg.1-6ubuntu25.1 Inter-Client Exchange library ii libsm6 4.3.0.dfsg.1-6ubuntu25.1 X Window System Session Management ii libx11-6 6.8.1-1ubuntu10 X Window System protocol client li ii libxaw7 4.3.0.dfsg.1-6ubuntu25.1 X Athena widget set library ii libxext6 4.3.0.dfsg.1-6ubuntu25.1 X Window System miscellaneous exte ii libxmu6 4.3.0.dfsg.1-6ubuntu25.1 X Window System miscellaneous util ii libxpm4 4.3.0.dfsg.1-6ubuntu25.1 X pixmap library ii libxt6 4.3.0.dfsg.1-6ubuntu25.1 X Toolkit Intrinsics ii xlibs 4.3.0.dfsg.1-6ubuntu25.1 X Window System client libraries m -- no debconf information
Only in xsok-hack/src: Makefile diff -ur xsok-1.02/src/Xaw-help.c xsok-hack/src/Xaw-help.c --- xsok-1.02/src/Xaw-help.c 1994-11-24 12:00:00.000000000 +0100 +++ xsok-hack/src/Xaw-help.c 2005-01-15 07:50:57.000000000 +0100 @@ -24,9 +24,12 @@ #include <X11/Xaw/SmeBSB.h> static int help_active = 0; -static Widget help, helppaned, helppanel, helptext, helpclose; +Widget help; +static Widget helppaned, helppanel, helptext, helpclose; extern const char *keyfilename; /* from X-widget.c */ +static void popdown_help_cb(Widget w, XtPointer a, XtPointer b); + static void selecttopic(Widget w, XtPointer number, XtPointer garbage) { char filename[200]; const char *s = XtName(w); @@ -51,7 +54,7 @@ topicsbutton = XtCreateManagedWidget("Topic", menuButtonWidgetClass, helppanel, Args, 1); topicsmenu = XtCreatePopupShell("topicsmenu", simpleMenuWidgetClass, topicsbutton, NULL, ZERO); helpclose = XtCreateManagedWidget("Close Help", commandWidgetClass, helppanel, NULL, ZERO); - XtAddCallback(helpclose, XtNcallback, popdown_help, NULL); + XtAddCallback(helpclose, XtNcallback, popdown_help_cb, NULL); XtSetArg(Args[0], XtNlabel, TXT_HELP_KEYS); w = XtCreateManagedWidget("Help0", smeBSBObjectClass, topicsmenu, Args, 1); @@ -67,6 +70,7 @@ } } + XtRealizeWidget(help); } void popup_help(void) { @@ -76,11 +80,15 @@ XtPopup(help, XtGrabNone); } -void popdown_help(Widget w, XtPointer a, XtPointer b) { +void popdown_help(void) { if (!help_active) return; /* request pending => deny another one */ help_active = 0; XtPopdown(help); } +static void popdown_help_cb(Widget w, XtPointer a, XtPointer b) { + popdown_help(); +} + #endif diff -ur xsok-1.02/src/Xaw-main.c xsok-hack/src/Xaw-main.c --- xsok-1.02/src/Xaw-main.c 1995-10-14 18:22:28.000000000 +0100 +++ xsok-hack/src/Xaw-main.c 2005-01-15 07:46:29.000000000 +0100 @@ -21,6 +21,8 @@ static Widget messagebox, container, desktop; static Widget dialog, popup, paned; static Window mainwindow; +static Atom atom_wm_protocols; +static Atom atom_wm_delete_window; void show_message(const char *str, ...) { @@ -112,6 +114,21 @@ popup_confirm(prompt); } +static void handle_wm_messages(Widget w, XtPointer client_data, XEvent *event, Boolean *cont) { + if (event->type == ClientMessage + && event->xclient.message_type == atom_wm_protocols + && event->xclient.data.l[0] == atom_wm_delete_window) { + if (w == toplevel) + rq_LeaveSok(); + else if (w == popup) + cmd_Cancel(); +#ifdef ONLINE_HELP + else if (w == help) + popdown_help(); +#endif + } +} + static String fallback_resources[] = { "*beNiceToColormap: false", "*shapeStyle: Rectangle", @@ -325,23 +342,37 @@ sound = XtCreateManagedWidget("Sound", toggleWidgetClass, buttonpanel, NULL, 0); #endif + graphic.width = graphic.height = 0; + graphic.autolayout = 1; + XtRealizeWidget(toplevel); + XSync(dpy, 0); + mainwindow = XtWindow(toplevel); + XSetIconName(dpy, mainwindow, "xsok"); + SetTitle(); + table = XtWindow(desktop); + /* OK. Now do the pop-up shells */ popup = XtCreatePopupShell("prompt", transientShellWidgetClass, toplevel, NULL, 0); dialog = XtCreateManagedWidget("dialog", dialogWidgetClass, popup, NULL, 0); XawDialogAddButton(dialog, "ok", Ok, (XtPointer)dialog); XawDialogAddButton(dialog, "cancel", Cancel, (XtPointer)dialog); + XtRealizeWidget(popup); #ifdef ONLINE_HELP create_help(); #endif - graphic.width = graphic.height = 0; - graphic.autolayout = 1; - XtRealizeWidget(toplevel); - XSync(dpy, 0); - mainwindow = XtWindow(toplevel); - XSetIconName(dpy, mainwindow, "xsok"); - SetTitle(); - table = XtWindow(desktop); + + /* WM_DELETE_WINDOW protocol */ + atom_wm_protocols = XInternAtom(XtDisplay(toplevel), "WM_PROTOCOLS", False); + atom_wm_delete_window = XInternAtom(XtDisplay(toplevel), "WM_DELETE_WINDOW", False); + XtAddEventHandler(toplevel, NoEventMask, True, handle_wm_messages, NULL); + XSetWMProtocols(XtDisplay(toplevel), XtWindow(toplevel), &atom_wm_delete_window, 1); + XtAddEventHandler(popup, NoEventMask, True, handle_wm_messages, NULL); + XSetWMProtocols(XtDisplay(popup), XtWindow(popup), &atom_wm_delete_window, 1); +#ifdef ONLINE_HELP + XtAddEventHandler(help, NoEventMask, True, handle_wm_messages, NULL); + XSetWMProtocols(XtDisplay(help), XtWindow(help), &atom_wm_delete_window, 1); +#endif read_gametypes(); { const char **rp; @@ -353,7 +384,6 @@ } graphics_control(Enable); - XtRealizeWidget(popup); XtAppMainLoop(app_con); /* does not return */ return 0; /* keep compiler happy */ } diff -ur xsok-1.02/src/xsok.h xsok-hack/src/xsok.h --- xsok-1.02/src/xsok.h 1996-03-16 19:04:36.000000000 +0100 +++ xsok-hack/src/xsok.h 2005-01-15 07:47:37.000000000 +0100 @@ -282,7 +282,7 @@ /* void create_help(Widget); void popup_help(void); -void popdown_help(Widget, XtPointer, XtPointer); +void popdown_help(void); */ /* Xaw-main.c */ diff -ur xsok-1.02/src/X-sok.h xsok-hack/src/X-sok.h --- xsok-1.02/src/X-sok.h 1996-03-16 17:58:58.000000000 +0100 +++ xsok-hack/src/X-sok.h 2005-01-15 07:47:47.000000000 +0100 @@ -45,6 +45,9 @@ extern Display *dpy; extern Window table; extern Widget toplevel; +#ifdef ONLINE_HELP +extern Widget help; +#endif #define DX 32 /* size of one square. we could even read this from the xpm file */ #define DY 32 @@ -56,7 +59,7 @@ #ifdef ONLINE_HELP void create_help(void); void popup_help(void); -void popdown_help(Widget, XtPointer, XtPointer); +void popdown_help(void); #endif /* Xaw-main.c */