From 9063b72a6debbe59a56f4e7879f85a7dadb61b3e Mon Sep 17 00:00:00 2001 From: Volker Ruppert Date: Sat, 7 Oct 2006 10:01:20 +0000 Subject: [PATCH] - don't crash Bochs when closing window (simulation window now stops the simulation, dialogs treat the event like the ESC button) --- bochs/gui/x.cc | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/bochs/gui/x.cc b/bochs/gui/x.cc index fb50f091a..551670c85 100644 --- a/bochs/gui/x.cc +++ b/bochs/gui/x.cc @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////// -// $Id: x.cc,v 1.104 2006-10-03 08:13:27 vruppert Exp $ +// $Id: x.cc,v 1.105 2006-10-07 10:01:20 vruppert Exp $ ///////////////////////////////////////////////////////////////////////// // // Copyright (C) 2002 MandrakeSoft S.A. @@ -544,6 +544,8 @@ bx_x_gui_c::specific_init(int argc, char **argv, unsigned tilewidth, unsigned ti &class_hints); XFree(windowName.value); XFree(iconName.value); + Atom wm_delete = XInternAtom(bx_x_display, "WM_DELETE_WINDOW", 1); + XSetWMProtocols(bx_x_display, win, &wm_delete, 1); } /* Select event types wanted */ @@ -925,6 +927,12 @@ bx_x_gui_c::handle_events(void) //retval = 1; break; + case ClientMessage: + if (!strcmp(XGetAtomName(bx_x_display, report.xclient.message_type), "WM_PROTOCOLS")) { + bx_stop_simulation(); + } + break; + default: // (mch) Ignore... BX_DEBUG(("XXX: default Xevent type")); @@ -2032,6 +2040,8 @@ int x11_ask_dialog(BxEvent *event) dialog = XCreateSimpleWindow(bx_x_display, RootWindow(bx_x_display,bx_x_screen_num), hint.x, hint.y, hint.width, hint.height, 4, black_pixel, white_pixel); XSetStandardProperties(bx_x_display, dialog, name, name, None, NULL, 0, &hint); + Atom wm_delete = XInternAtom(bx_x_display, "WM_DELETE_WINDOW", 1); + XSetWMProtocols(bx_x_display, dialog, &wm_delete, 1); gc = XCreateGC(bx_x_display, dialog, 0, 0); gc_inv = XCreateGC(bx_x_display, dialog, 0, 0); @@ -2120,6 +2130,12 @@ int x11_ask_dialog(BxEvent *event) done = 1; } break; + case ClientMessage: + if (!strcmp(XGetAtomName(bx_x_display, xevent.xclient.message_type), "WM_PROTOCOLS")) { + control = num_ctrls - 1; + done = 1; + } + break; } if (control != oldctrl) { XDrawRectangle(bx_x_display, dialog, gc_inv, button_x[oldctrl], 78, 69, 24); @@ -2158,6 +2174,8 @@ int x11_string_dialog(bx_param_string_c *param) dialog = XCreateSimpleWindow(bx_x_display, RootWindow(bx_x_display,bx_x_screen_num), hint.x, hint.y, hint.width, hint.height, 4, black_pixel, white_pixel); XSetStandardProperties(bx_x_display, dialog, name, name, None, NULL, 0, &hint); + Atom wm_delete = XInternAtom(bx_x_display, "WM_DELETE_WINDOW", 1); + XSetWMProtocols(bx_x_display, dialog, &wm_delete, 1); gc = XCreateGC(bx_x_display, dialog, 0, 0); gc_inv = XCreateGC(bx_x_display, dialog, 0, 0); @@ -2244,6 +2262,12 @@ int x11_string_dialog(bx_param_string_c *param) } } break; + case ClientMessage: + if (!strcmp(XGetAtomName(bx_x_display, xevent.xclient.message_type), "WM_PROTOCOLS")) { + control = 2; + done = 1; + } + break; } if (control != oldctrl) { if (oldctrl > 0) {