From de052535d4536e94fa1bd9988020e27b3f8774a6 Mon Sep 17 00:00:00 2001 From: David Rose Date: Mon, 25 Apr 2005 22:29:46 +0000 Subject: [PATCH] close-request-event --- panda/src/windisplay/winGraphicsWindow.cxx | 28 ++++++++++++++++------ 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/panda/src/windisplay/winGraphicsWindow.cxx b/panda/src/windisplay/winGraphicsWindow.cxx index 138fd8ec00..233fc6742a 100644 --- a/panda/src/windisplay/winGraphicsWindow.cxx +++ b/panda/src/windisplay/winGraphicsWindow.cxx @@ -25,6 +25,7 @@ #include "mouseButton.h" #include "clockObject.h" #include "config_util.h" +#include "throw_event.h" #include @@ -998,13 +999,26 @@ window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { } case WM_CLOSE: - //GraphicsWindow::close_window(); //M.A. changed to the following line - close_window(); - properties.set_open(false); - system_changed_properties(properties); - - // TODO: make sure we release the GSG properly. - windisplay_cat.debug() << "ta ta" << endl; + // This is a message from the system indicating that the user + // has requested to close the window (e.g. alt-f4). + { + string close_request_event = get_close_request_event(); + if (!close_request_event.empty()) { + // In this case, the app has indicated a desire to intercept + // the request and process it directly. + throw_event(close_request_event); + return 0; + + } else { + // In this case, the default case, the app does not intend + // to service the request, so we do by closing the window. + close_window(); + properties.set_open(false); + system_changed_properties(properties); + + // TODO: make sure we release the GSG properly. + } + } break; case WM_ACTIVATE: