Sfoglia il codice sorgente

explicit window_handle type for win32

David Rose 16 anni fa
parent
commit
d0d2ac4fa0

+ 1 - 0
direct/src/plugin/p3dInstance.cxx

@@ -195,6 +195,7 @@ P3DInstance(P3D_request_ready_func *func,
       (_fparams.lookup_token_int("width") == 0 ||
        _fparams.lookup_token_int("height") == 0)) {
     P3D_window_handle dummy_handle;
+    memset(&dummy_handle, 0, sizeof(dummy_handle));
     P3DWindowParams wparams(P3D_WT_hidden, 0, 0, 0, 0, dummy_handle);
     set_wparams(wparams);
   }

+ 3 - 1
direct/src/plugin/p3dWinSplashWindow.cxx

@@ -430,7 +430,9 @@ make_window() {
     DWORD window_style = 
       WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS;
 
-    HWND parent_hwnd = _wparams.get_parent_window()._hwnd;
+    const P3D_window_handle &handle = _wparams.get_parent_window();
+    assert(handle._window_handle_type == P3D_WHT_win_hwnd);
+    HWND parent_hwnd = handle._handle._win_hwnd._hwnd;
 
     _hwnd = 
       CreateWindow("panda3d_splash", "Panda3D", window_style,

+ 2 - 1
direct/src/plugin/p3dWindowParams.cxx

@@ -78,7 +78,8 @@ make_xml(P3DInstance *inst) {
     xwparams->SetAttribute("win_width", _win_width);
     xwparams->SetAttribute("win_height", _win_height);
 #ifdef _WIN32
-    xwparams->SetAttribute("parent_hwnd", (int)_parent_window._hwnd);
+    assert(_parent_window._window_handle_type == P3D_WHT_win_hwnd);
+    xwparams->SetAttribute("parent_hwnd", (int)_parent_window._handle._win_hwnd._hwnd);
 
 #elif defined(__APPLE__)
     xwparams->SetAttribute("subprocess_window", inst->_shared_filename);

+ 3 - 1
direct/src/plugin_activex/PPInstance.cpp

@@ -493,7 +493,9 @@ int PPInstance::Start( const std::string& p3dFilename  )
     m_eventStop.ResetEvent();
 
     P3D_window_handle parent_window;
-    parent_window._hwnd = m_parentCtrl.m_hWnd;
+    memset(&parent_window, 0, sizeof(parent_window));
+    parent_window._window_handle_type = P3D_WHT_win_hwnd;
+    parent_window._handle._win_hwnd._hwnd = m_parentCtrl.m_hWnd;
 
     RECT rect;
     GetClientRect( m_parentCtrl.m_hWnd, &rect );

+ 4 - 3
direct/src/plugin_npapi/ppInstance.cxx

@@ -1301,7 +1301,8 @@ send_window() {
     // (0, 0), since the window we were given is already placed in the
     // right spot.
 #ifdef _WIN32
-    parent_window._hwnd = (HWND)(_window.window);
+    parent_window._window_handle_type = P3D_WHT_win_hwnd;
+    parent_window._handle._win_hwnd._hwnd = (HWND)(_window.window);
     x = 0;
     y = 0;
 
@@ -1327,11 +1328,11 @@ send_window() {
     // We have a "windowless" plugin.  Parent our window directly to
     // the browser window.
 #ifdef _WIN32
-    parent_window._hwnd = 0;
     HWND hwnd;
     if (browser->getvalue(_npp_instance, NPNVnetscapeWindow,
                           &hwnd) == NPERR_NO_ERROR) {
-      parent_window._hwnd = hwnd;
+      parent_window._window_handle_type = P3D_WHT_win_hwnd;
+      parent_window._handle._win_hwnd._hwnd = hwnd;
     }
 
 #elif defined(__APPLE__)

+ 8 - 3
direct/src/plugin_standalone/panda3d.cxx

@@ -241,8 +241,11 @@ run_command_line(int argc, char *argv[]) {
       
       // Center the child window(s) within the parent window.
 #ifdef _WIN32
+      assert(_parent_window._window_handle_type == P3D_WHT_win_hwnd);
+      HWND parent_hwnd = _parent_window._handle._win_hwnd._hwnd;
+      
       RECT rect;
-      GetClientRect(_parent_window._hwnd, &rect);
+      GetClientRect(parent_hwnd, &rect);
       
       _win_x = (int)(rect.right * 0.1);
       _win_y = (int)(rect.bottom * 0.1);
@@ -936,8 +939,10 @@ make_parent_window() {
   }
 
   ShowWindow(toplevel_window, SW_SHOWNORMAL);
-  
-  _parent_window._hwnd = toplevel_window;
+
+  memset(&_parent_window, 0, sizeof(_parent_window));
+  _parent_window._window_handle_type = P3D_WHT_win_hwnd;
+  _parent_window._handle._win_hwnd._hwnd = toplevel_window;
 }
 
 #else