소스 검색

close-request-event

David Rose 20 년 전
부모
커밋
de052535d4
1개의 변경된 파일21개의 추가작업 그리고 7개의 파일을 삭제
  1. 21 7
      panda/src/windisplay/winGraphicsWindow.cxx

+ 21 - 7
panda/src/windisplay/winGraphicsWindow.cxx

@@ -25,6 +25,7 @@
 #include "mouseButton.h"
 #include "mouseButton.h"
 #include "clockObject.h"
 #include "clockObject.h"
 #include "config_util.h"
 #include "config_util.h"
+#include "throw_event.h"
 
 
 #include <tchar.h>
 #include <tchar.h>
 
 
@@ -998,13 +999,26 @@ window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) {
       }
       }
     
     
       case WM_CLOSE:
       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;
         break;
     
     
       case WM_ACTIVATE:
       case WM_ACTIVATE: