2
0
cxgeorge 24 жил өмнө
parent
commit
6051745d92

+ 1 - 1
panda/src/dxgsg/Sources.pp

@@ -16,7 +16,7 @@
   // need to install these due to external projects that link directly with libpandadx (bartop)  
   #define INSTALL_HEADERS \
     config_dxgsg.h dxGraphicsStateGuardian.I dxGraphicsStateGuardian.h \
-    dxTextureContext.h dxGeomNodeContext.h dxGeomNodeContext.I
+    dxTextureContext.h dxGeomNodeContext.h dxGeomNodeContext.I dxgsgbase.h
 
   // build dxGraphicsStateGuardian separately since its so big
   

+ 1 - 13
panda/src/dxgsg/dxGeomNodeContext.h

@@ -19,25 +19,13 @@
 #ifndef DXGEOMNODECONTEXT_H
 #define DXGEOMNODECONTEXT_H
 
-#include <pandabase.h>
-
-#ifdef WIN32_VC
-// Must include windows.h before dx.h on NT
-#define WIN32_LEAN_AND_MEAN
-#include <windows.h>
-#undef WIN32_LEAN_AND_MEAN
-#endif
+#include "dxgsgbase.h"
 
 #include <geomNodeContext.h>
 #include <geomNode.h>
 #include "pvector.h"
 
-#define D3D_OVERLOADS   //  get D3DVECTOR '+' operator, etc from d3dtypes.h
-#include <d3d.h>
 
-#if DIRECT3D_VERSION != 0x0700
-#error DX7 headers not available, you need to install MS Platform SDK!
-#endif
 
 typedef struct {
      DWORD nVerts;

+ 4 - 9
panda/src/dxgsg/dxGraphicsStateGuardian.cxx

@@ -16,7 +16,9 @@
 //
 ////////////////////////////////////////////////////////////////////
 
-#include <pandabase.h>
+#include "dxGraphicsStateGuardian.h"
+#include "config_dxgsg.h"
+
 #include <directRenderTraverser.h>
 #include <cullTraverser.h>
 #include <displayRegion.h>
@@ -54,20 +56,13 @@
 #include <depthWriteTransition.h>
 #include <cullFaceTransition.h>
 #include <stencilTransition.h>
+#include <mmsystem.h>
 
 #ifdef DO_PSTATS
 #include <pStatTimer.h>
 #include <pStatCollector.h>
 #endif
 
-#include "config_dxgsg.h"
-#include "dxGraphicsStateGuardian.h"
-
-// disable nameless struct 'warning'
-#pragma warning (disable : 4201)
-
-#include <mmsystem.h>
-
 // print out simple drawprim stats every few secs
 //#define COUNT_DRAWPRIMS
 

+ 1 - 87
panda/src/dxgsg/dxGraphicsStateGuardian.h

@@ -19,9 +19,7 @@
 #ifndef DXGRAPHICSSTATEGUARDIAN_H
 #define DXGRAPHICSSTATEGUARDIAN_H
 
-//#define GSG_VERBOSE
-
-#include <pandabase.h>
+#include "dxgsgbase.h"
 #include <graphicsStateGuardian.h>
 #include <geomprimitives.h>
 #include <texture.h>
@@ -37,95 +35,13 @@
 #include <alphaTransformTransition.h>
 #include <pointerToArray.h>
 #include <planeNode.h>
-
 #include "dxGeomNodeContext.h"
 #include "dxTextureContext.h"
 #include <vector>
 
-extern char * ConvD3DErrorToString(const HRESULT &error);   // defined in wdxGraphicsPipe.cxx
-
-typedef struct {
-      LPDIRECT3DDEVICE7 pD3DDevice;
-      LPDIRECTDRAW7     pDD;
-      LPDIRECT3D7       pD3D;
-      LPDIRECTDRAWSURFACE7 pddsPrimary,pddsBack,pddsZBuf;
-      HWND              hWnd;
-      HMONITOR          hMon;
-      DWORD             dwRenderWidth,dwRenderHeight,dwFullScreenBitDepth;
-      RECT              view_rect,clip_rect;
-      DWORD             MaxAvailVidMem;
-      bool              bIsLowVidMemCard;
-      bool              bIsTNLDevice;
-      bool              bIsSWRast;
-      ushort            depth_buffer_bitdepth;  //GetSurfaceDesc is not reliable so must store this explicitly
-      ushort            CardIDNum;  // its posn in DisplayArray, for dbgprint purposes
-      DDDEVICEIDENTIFIER2 DXDeviceID;
-      D3DDEVICEDESC7    D3DDevDesc;
-#ifdef USE_TEXFMTVEC
-      DDPixelFormatVec  TexPixFmts;
-#endif
-} DXScreenData;
-// typedef vector<DXScreenData> ScreenDataVector;
-
 class PlaneNode;
 class Light;
 
-#ifdef GSG_VERBOSE
-ostream &output_gl_enum(ostream &out, GLenum v);
-INLINE ostream &operator << (ostream &out, GLenum v) {
-  return output_gl_enum(out, v);
-}
-#endif
-
-#ifdef DO_PSTATS
-#define DO_PSTATS_STUFF(XX) XX;
-#else
-#define DO_PSTATS_STUFF(XX)
-#endif
-
-#define DX_DECLARE_CLEAN(type, var) \
-    type var;                       \
-    ZeroMemory(&var, sizeof(type)); \
-    var.dwSize = sizeof(type);
-
-// #define DEBUG_RELEASES
-
-// this is bDoDownToZero argument to RELEASE()
-#define RELEASE_DOWN_TO_ZERO true
-
-#ifdef DEBUG_RELEASES
-#define RELEASE(OBJECT,MODULE,DBGSTR,bDoDownToZero)             \
-   if(((OBJECT)!=NULL)&&(!IsBadWritePtr((OBJECT),4))) {         \
-        refcnt = (OBJECT)->Release();                           \
-        MODULE##_cat.debug() << DBGSTR << " released, refcnt = " << refcnt << endl;  \
-        if((bDoDownToZero) && (refcnt>0)) {                     \
-              MODULE##_cat.warning() << DBGSTR << " released but still has a non-zero refcnt(" << refcnt << "), multi-releasing it down to zero!\n"; \
-              do {                                \
-                refcnt = (OBJECT)->Release();     \
-              } while(refcnt>0);                  \
-        }                                         \
-        (OBJECT) = NULL;                          \
-      } else {                                    \
-        MODULE##_cat.debug() << DBGSTR << " not released, ptr == NULL" << endl;  \
-      } 
-
-#define PRINTREFCNT(OBJECT,STR)  {  (OBJECT)->AddRef();  dxgsg_cat.debug() << STR << " refcnt = " << (OBJECT)->Release() << endl; }
-#else
-#define RELEASE(OBJECT,MODULE,DBGSTR,bDoDownToZero)     \
-   if(((OBJECT)!=NULL)&&(!IsBadWritePtr((OBJECT),4))) { \
-        refcnt=(OBJECT)->Release();                     \
-        if((bDoDownToZero) && (refcnt>0)) {             \
-              MODULE##_cat.warning() << DBGSTR << " released but still has a non-zero refcnt(" << refcnt << "), multi-releasing it down to zero!\n"; \
-              do {                                \
-                refcnt = (OBJECT)->Release();     \
-              } while(refcnt>0);                  \
-        }                                         \
-        (OBJECT) = NULL;                          \
-   }
-
-#define PRINTREFCNT(OBJECT,STR)  
-#endif    
-
 //#if defined(NOTIFY_DEBUG) || defined(DO_PSTATS)
 #ifdef _DEBUG
 // This function now serves both to print a debug message to the
@@ -507,8 +423,6 @@ private:
   static TypeHandle _type_handle;
 };
 
-#define ISPOW2(X) (((X) & ((X)-1))==0)
-
 #include "dxGraphicsStateGuardian.I"
 
 #endif

+ 1 - 23
panda/src/dxgsg/dxTextureContext.h

@@ -19,33 +19,11 @@
 #ifndef DXTEXTURECONTEXT_H
 #define DXTEXTURECONTEXT_H
 
-#include <pandabase.h>
-
-#define WIN32_LEAN_AND_MEAN
-#ifndef STRICT
-// enable strict type checking in windows.h, see msdn
-#define STRICT
-#endif
-
-#include <windows.h>
-
-#include <ddraw.h>
-
-#define D3D_OVERLOADS   //  get D3DVECTOR '+' operator, etc from d3dtypes.h
-#include <d3d.h>
-#undef WIN32_LEAN_AND_MEAN
+#include "dxgsgbase.h"
 
 #include <texture.h>
 #include <textureContext.h>
 
-//#define USE_TEXFMTVEC  // doesnt work now, crashes in destructor
-
-#ifdef USE_TEXFMTVEC
-typedef pvector<DDPIXELFORMAT> DDPixelFormatVec;
-#else
-#define MAX_DX_TEXPIXFMTS 20    // should be enough for any card
-#endif
-
 ////////////////////////////////////////////////////////////////////
 //   Class : DXTextureContext
 // Description :

+ 136 - 0
panda/src/dxgsg/dxgsgbase.h

@@ -0,0 +1,136 @@
+// Filename: dxTextureContext.h
+// Created by:  drose (07Oct99)
+//
+////////////////////////////////////////////////////////////////////
+//
+// PANDA 3D SOFTWARE
+// Copyright (c) 2001, Disney Enterprises, Inc.  All rights reserved
+//
+// All use of this software is subject to the terms of the Panda 3d
+// Software license.  You should have received a copy of this license
+// along with this source code; you will also find a current copy of
+// the license at http://www.panda3d.org/license.txt .
+//
+// To contact the maintainers of this program write to
+// [email protected] .
+//
+////////////////////////////////////////////////////////////////////
+
+#ifndef DXGSGBASE_H
+#define DXGSGBASE_H
+
+#include <pandabase.h>
+
+// include win32 defns for everything up to XP, and assume I'm smart enough to
+// use GetProcAddress for backward compat on w95/w98 for newer fns
+#define _WIN32_WINNT 0x0501
+
+#define WIN32_LEAN_AND_MEAN   // get rid of mfc win32 hdr stuff
+#ifndef STRICT
+// enable strict type checking in windows.h, see msdn
+#define STRICT
+#endif
+
+#include <windows.h>
+#include <ddraw.h>
+
+#define D3D_OVERLOADS   //  get D3DVECTOR '+' operator, etc from d3dtypes.h
+#include <d3d.h>
+#undef WIN32_LEAN_AND_MEAN
+
+#if DIRECT3D_VERSION != 0x0700
+#error DX7 headers not available, you need to install MS Platform SDK or DirectX 8+ SDK!
+#endif
+
+// disable nameless struct 'warning'
+#pragma warning (disable : 4201)
+
+//#define USE_TEXFMTVEC
+// USE_TEXFMTVEC caused crash on dealloc
+
+#ifdef USE_TEXFMTVEC
+typedef pvector<DDPIXELFORMAT> DDPixelFormatVec;
+#else
+#define MAX_DX_TEXPIXFMTS 20    // should be enough for any card
+#endif
+
+#define ISPOW2(X) (((X) & ((X)-1))==0)
+
+#define DX_DECLARE_CLEAN(type, var) \
+    type var;                       \
+    ZeroMemory(&var, sizeof(type)); \
+    var.dwSize = sizeof(type);
+
+#define SAFE_DELETE(p)       { if(p) { delete (p);     (p)=NULL; } }
+#define SAFE_DELETE_ARRAY(p) { if(p) { delete[] (p);   (p)=NULL; } }
+
+// this is bDoDownToZero argument to RELEASE()
+#define RELEASE_DOWN_TO_ZERO true
+#define RELEASE_ONCE false
+
+// #define DEBUG_RELEASES
+
+#ifdef DEBUG_RELEASES
+#define RELEASE(OBJECT,MODULE,DBGSTR,bDoDownToZero)             \
+   if(((OBJECT)!=NULL)&&(!IsBadWritePtr((OBJECT),4))) {         \
+        refcnt = (OBJECT)->Release();                           \
+        MODULE##_cat.debug() << DBGSTR << " released, refcnt = " << refcnt << endl;  \
+        if((bDoDownToZero) && (refcnt>0)) {                     \
+              MODULE##_cat.warning() << DBGSTR << " released but still has a non-zero refcnt(" << refcnt << "), multi-releasing it down to zero!\n"; \
+              do {                                \
+                refcnt = (OBJECT)->Release();     \
+              } while(refcnt>0);                  \
+        }                                         \
+        (OBJECT) = NULL;                          \
+      } else {                                    \
+        MODULE##_cat.debug() << DBGSTR << " not released, ptr == NULL" << endl;  \
+      } 
+
+#define PRINTREFCNT(OBJECT,STR)  {  (OBJECT)->AddRef();  dxgsg_cat.debug() << STR << " refcnt = " << (OBJECT)->Release() << endl; }
+#else
+#define RELEASE(OBJECT,MODULE,DBGSTR,bDoDownToZero)     \
+   if(((OBJECT)!=NULL)&&(!IsBadWritePtr((OBJECT),4))) { \
+        refcnt=(OBJECT)->Release();                     \
+        if((bDoDownToZero) && (refcnt>0)) {             \
+              MODULE##_cat.warning() << DBGSTR << " released but still has a non-zero refcnt(" << refcnt << "), multi-releasing it down to zero!\n"; \
+              do {                                \
+                refcnt = (OBJECT)->Release();     \
+              } while(refcnt>0);                  \
+        }                                         \
+        (OBJECT) = NULL;                          \
+   }
+
+#define PRINTREFCNT(OBJECT,STR)  
+#endif    
+
+#ifdef DO_PSTATS
+#define DO_PSTATS_STUFF(XX) XX;
+#else
+#define DO_PSTATS_STUFF(XX)
+#endif
+
+extern char * ConvD3DErrorToString(const HRESULT &error);   // defined in wdxGraphicsPipe.cxx
+
+typedef struct {
+      LPDIRECT3DDEVICE7 pD3DDevice;
+      LPDIRECTDRAW7     pDD;
+      LPDIRECT3D7       pD3D;
+      LPDIRECTDRAWSURFACE7 pddsPrimary,pddsBack,pddsZBuf;
+      HWND              hWnd;
+      HMONITOR          hMon;
+      DWORD             dwRenderWidth,dwRenderHeight,dwFullScreenBitDepth;
+      RECT              view_rect,clip_rect;
+      DWORD             MaxAvailVidMem;
+      bool              bIsLowVidMemCard;
+      bool              bIsTNLDevice;
+      bool              bIsSWRast;
+      WORD              depth_buffer_bitdepth;  //GetSurfaceDesc is not reliable so must store this explicitly
+      WORD              CardIDNum;  // its posn in DisplayArray, for dbgprint purposes
+      DDDEVICEIDENTIFIER2 DXDeviceID;
+      D3DDEVICEDESC7    D3DDevDesc;
+#ifdef USE_TEXFMTVEC
+      DDPixelFormatVec  TexPixFmts;
+#endif
+} DXScreenData;
+#endif
+

+ 1 - 15
panda/src/wdxdisplay/wdxGraphicsPipe.h

@@ -21,24 +21,10 @@
 ////////////////////////////////////////////////////////////////////
 // Includes
 ////////////////////////////////////////////////////////////////////
-#include <pandabase.h>
 
 #include <string>
-#include <interactiveGraphicsPipe.h>
 #include "wdxGraphicsWindow.h"
-
-#ifndef STRICT
-#define STRICT
-#endif
-#define WINDOWS_LEAN_AND_MEAN
-#include <windows.h>
-#undef WINDOWS_LEAN_AND_MEAN
-
-////////////////////////////////////////////////////////////////////
-// Defines
-////////////////////////////////////////////////////////////////////
-
-extern char * ConvD3DErrorToString(const HRESULT &error);
+#include <interactiveGraphicsPipe.h>
 
 ////////////////////////////////////////////////////////////////////
 //       Class : wdxGraphicsPipe

+ 84 - 97
panda/src/wdxdisplay/wdxGraphicsWindow.cxx

@@ -26,17 +26,12 @@
 
 #include <keyboardButton.h>
 #include <mouseButton.h>
-
 #include <throw_event.h>
 
 #ifdef DO_PSTATS
 #include <pStatTimer.h>
 #endif
 
-#define D3D_OVERLOADS
-//#define  INITGUID  dont want this if linking w/dxguid.lib
-#include <d3d.h>
-
 #include <map>
 
 ////////////////////////////////////////////////////////////////////
@@ -58,8 +53,6 @@ wdxGraphicsWindow* global_wdxwinptr = NULL;  // need this for temporary windproc
 
 extern bool dx_full_screen_antialiasing;  // defined in dxgsg_config.cxx
 
-#define MOUSE_ENTERED 0
-#define MOUSE_EXITED 1
 #define PAUSED_TIMER_ID  7   // completely arbitrary choice
 #define DXREADY ((_dxgsg!=NULL)&&(_dxgsg->GetDXReady()))
 
@@ -300,6 +293,23 @@ LONG WINAPI static_window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam
    }
 }
 
+// Note: could use _TrackMouseEvent in comctrl32.dll (part of IE 3.0+) which emulates
+// TrackMouseEvent on w95, but that requires another 500K of memory to hold that DLL,
+// which is lame just to support w95, which probably has other issues anyway
+INLINE void wdxGraphicsWindow::
+track_mouse_leaving(HWND hwnd) {
+  if(_pParentWindowGroup->_pfnTrackMouseEvent==NULL)
+      return;
+
+  TRACKMOUSEEVENT tme = {sizeof(TRACKMOUSEEVENT),TME_LEAVE,hwnd,0};
+  BOOL bSucceeded = _pParentWindowGroup->_pfnTrackMouseEvent(&tme);  // tell win32 to post WM_MOUSELEAVE msgs
+
+  if((!bSucceeded) && wdxdisplay_cat.is_debug())
+     wdxdisplay_cat.debug() << "TrackMouseEvent failed!, LastError=" << GetLastError() << endl;
+
+  _tracking_mouse_leaving=true;
+}
+
 ////////////////////////////////////////////////////////////////////
 //     Function: window_proc
 //       Access:
@@ -314,7 +324,6 @@ window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) {
     case WM_PAINT: {
         PAINTSTRUCT ps;
         BeginPaint(hwnd, &ps);
-    
         if(DXREADY)
             show_frame();
         EndPaint(hwnd, &ps);
@@ -332,19 +341,56 @@ window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) {
                 if(iVal & 0x8000)             \
                   iVal -= 0x10000;            \
         }
+        
+        if(!_tracking_mouse_leaving) {
+            // need to re-call TrackMouseEvent every time mouse re-enters window
+            track_mouse_leaving(hwnd);
+        }
     
         SET_MOUSE_COORD(x,LOWORD(lparam));
         SET_MOUSE_COORD(y,HIWORD(lparam));
     
-        if(mouse_motion_enabled()
-           && wparam & (MK_LBUTTON | MK_MBUTTON | MK_RBUTTON)) {
-            handle_mouse_motion(x, y);
-        } else if(mouse_passive_motion_enabled() &&
-                  ((wparam & (MK_LBUTTON | MK_MBUTTON | MK_RBUTTON)) == 0)) {
+        if(wparam & (MK_LBUTTON | MK_MBUTTON | MK_RBUTTON)) {
             handle_mouse_motion(x, y);
-        }
+        } 
         return 0;
+    
+    // if cursor is invisible, make it visible when moving in the window bars,etc
+    case WM_NCMOUSEMOVE: {
+        if(!_props._bCursorIsVisible) {
+            if(!_cursor_in_windowclientarea) {
+                ShowCursor(true);
+                _cursor_in_windowclientarea=true;
+            }
+        }
+        break;
+    }
 
+    case WM_NCMOUSELEAVE: {
+        if(!_props._bCursorIsVisible) {
+            ShowCursor(false);
+            _cursor_in_windowclientarea=false;
+        }
+        break;
+    }
+    
+    case WM_MOUSELEAVE: {
+       // wdxdisplay_cat.fatal() << "XXXXX WM_MOUSELEAVE received\n";
+
+       _tracking_mouse_leaving=false;  
+       handle_mouse_entry(false,0,0);         
+       break;
+    }
+    
+    case WM_CREATE: {
+      track_mouse_leaving(hwnd);
+    
+      _cursor_in_windowclientarea=false;
+      if(!_props._bCursorIsVisible)
+          ShowCursor(false);
+      break;
+    }
+    
     case WM_IME_NOTIFY:
       if (wparam == IMN_SETOPENSTATUS) {
         HIMC hIMC = ImmGetContext(hwnd);
@@ -356,7 +402,7 @@ window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) {
         ImmReleaseContext(hwnd, hIMC);
       }
       break;
-
+    
     case WM_IME_STARTCOMPOSITION:
       // In case we're running fullscreen mode, we have to turn on
       // explicit DX support for overlay windows now, so we'll be able
@@ -560,14 +606,7 @@ window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) {
                 _WindowAdjustingType = MovingOrResizing;
             }
             break;
-/*
-        case WM_SETCURSOR: {
-            if(!_props._bCursorIsVisible)
-               return true;  // avoid defaultwindproc showing the cursor
-            break;
-//          return false;
-        }
-*/
+
         case WM_DISPLAYCHANGE: {
 #ifdef _DEBUG
             width = LOWORD(lparam);  height = HIWORD(lparam);
@@ -626,7 +665,6 @@ window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) {
             }
 
         case WM_SETFOCUS: {
-            // wdxdisplay_cat.info() << "got WM_SETFOCUS\n";
             if(!DXREADY) {
               break;
             }
@@ -635,9 +673,6 @@ window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) {
             GetCursorPos(&point);
             ScreenToClient(hwnd, &point);
 
-            if(_mouse_entry_enabled)
-                handle_mouse_entry(MOUSE_ENTERED,point.x,point.y);
-
             // this is a hack to make sure common modifier keys have proper state
             // since at focus loss, app may never receive key-up event corresponding to
             // a key-down. it would be better to know the exact set of ModifierButtons the
@@ -652,14 +687,10 @@ window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) {
         }
 
         case WM_KILLFOCUS: {
-            // wdxdisplay_cat.info() << "got WM_KILLFOCUS\n";
             if(!DXREADY) {
               break;
             }
 
-            if(_mouse_entry_enabled)
-                  handle_mouse_entry(MOUSE_EXITED,0,0);
-
             int i;
             for(i=0;i<NUM_MODIFIER_KEYS;i++) {
               if(GetKeyState(hardcoded_modifier_buttons[i]) < 0)
@@ -736,11 +767,6 @@ window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) {
           }
           return 0;
 
-        case WM_CREATE: {
-            if(!_props._bCursorIsVisible)
-                ShowCursor(false);
-            break;
-        }
 
         case WM_ACTIVATEAPP: {
             #ifdef _DEBUG
@@ -1017,6 +1043,19 @@ void wdxGraphicsWindowGroup::CreateWindows(void) {
     static bool wc_registered = false;
     _hParentWindow = NULL;        
 
+    // these fns arent defined on win95, so get dynamic ptrs to them to avoid
+    // ugly DLL loader failures on w95
+    HINSTANCE hUser32 = (HINSTANCE) LoadLibrary("user32.dll");
+    assert(hUser32);
+
+    _pfnGetMonitorInfo = (PFN_GETMONITORINFO) GetProcAddress(hUser32, "GetMonitorInfoA");
+
+    // Note: could use _TrackMouseEvent in comctrl32.dll (part of IE 3.0+) which emulates
+    // TrackMouseEvent on w95, but that requires another 500K of memory to hold that DLL,
+    // which is lame just to support w95, which probably has other issues anyway
+    _pfnTrackMouseEvent = (PFN_TRACKMOUSEEVENT) GetProcAddress(hUser32, "TrackMouseEvent");
+    FreeLibrary(hUser32);
+
     // Clear before filling in window structure!
     ZeroMemory(&wc, sizeof(WNDCLASS));
     wc.style      = CS_HREDRAW | CS_VREDRAW; //CS_OWNDC;
@@ -1132,22 +1171,15 @@ void wdxGraphicsWindowGroup::CreateWindows(void) {
 
     // rect now contains the coords for the entire window, not the client
     if(dx_full_screen) {
-        // get upper-left corner coords using GetMonitorInfo
-
-        // GetMonInfo doesnt exist on w95, so dont statically link to it
-        HINSTANCE hUser32 = (HINSTANCE) LoadLibrary("user32.dll");
-        assert(hUser32);
-        typedef BOOL (WINAPI* LPGETMONITORINFO)(HMONITOR, LPMONITORINFO);   
-        LPGETMONITORINFO pfnGetMonitorInfo = (LPGETMONITORINFO) GetProcAddress(hUser32, "GetMonitorInfoA");
 
         // extra windows must be parented to the first so app doesnt minimize when user selects them
-
         for(DWORD devnum=0;devnum<_windows.size();devnum++) {
             MONITORINFO minfo;
             ZeroMemory(&minfo, sizeof(MONITORINFO));
             minfo.cbSize = sizeof(MONITORINFO);
-            if(pfnGetMonitorInfo)
-                (*pfnGetMonitorInfo)(_windows[devnum]->_dxgsg->scrn.hMon, &minfo);
+            if(_pfnGetMonitorInfo!=NULL)
+                // get upper-left corner coords using GetMonitorInfo
+                (*_pfnGetMonitorInfo)(_windows[devnum]->_dxgsg->scrn.hMon, &minfo);
              else {
                  minfo.rcMonitor.left = minfo.rcMonitor.top = 0;
              }
@@ -1172,7 +1204,6 @@ void wdxGraphicsWindowGroup::CreateWindows(void) {
                 _hParentWindow=hWin;
             }
         }
-        FreeLibrary(hUser32);
     } else {
         assert(_windows.size()==1);
 
@@ -1277,18 +1308,6 @@ void wdxGraphicsWindow::config_window(wdxGraphicsWindowGroup *pParentGroup) {
 }
 
 void wdxGraphicsWindow::finish_window_setup(void) {
-    // init panda input handling
-    _mouse_input_enabled = false;
-    _mouse_motion_enabled = false;
-    _mouse_passive_motion_enabled = false;
-    _mouse_entry_enabled = false;
-
-    // Enable detection of mouse input
-    enable_mouse_input(true);
-    enable_mouse_motion(true);
-    enable_mouse_passive_motion(true);
-    //  enable_mouse_entry(true);   re-enable this??
-
     // Now indicate that we have our keyboard/mouse device ready.
     GraphicsWindowInputDevice device = GraphicsWindowInputDevice::pointer_and_keyboard("keyboard/mouse");
     _input_devices.push_back(device);
@@ -2447,8 +2466,6 @@ void wdxGraphicsWindow::show_frame(void) {
     _dxgsg->show_frame();
 }
 
-
-
 ////////////////////////////////////////////////////////////////////
 //     Function: end_frame
 //       Access:
@@ -2484,15 +2501,13 @@ void wdxGraphicsWindow::handle_mouse_motion(int x, int y) {
 //  Description:
 ////////////////////////////////////////////////////////////////////
 
-// BUGBUG: this needs to be called when mouse enters.  right now it's just called when keybd focus changes
-void wdxGraphicsWindow::handle_mouse_entry(int state, int x, int y) {
-//  ShowCursor(_props._bCursorIsVisible);
-
-    if(state == MOUSE_EXITED) {
-        _input_devices[0].set_pointer_out_of_window();
-    } else {
+void wdxGraphicsWindow::handle_mouse_entry(bool bEntering, int x, int y) {
+    // usually 'motion' event is equivalent to entering, so
+    // this will never be called w/bEntering true
+    if(bEntering) {
         _input_devices[0].set_pointer_in_window(x, y);
-//        SetCursor(hCursor);  believe this is not necessary, handled by windows
+    } else {
+        _input_devices[0].set_pointer_out_of_window();
     }
 }
 
@@ -2614,34 +2629,6 @@ void wdxGraphicsWindow::update(void) {
 #endif
 }
 
-////////////////////////////////////////////////////////////////////
-//     Function: enable_mouse_input
-//       Access:
-//  Description:
-////////////////////////////////////////////////////////////////////
-void wdxGraphicsWindow::enable_mouse_input(bool val) {
-    _mouse_input_enabled = val;
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function: enable_mouse_motion
-//       Access:
-//  Description:
-////////////////////////////////////////////////////////////////////
-void wdxGraphicsWindow::enable_mouse_motion(bool val) {
-    _mouse_motion_enabled = val;
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function: enable_mouse_passive_motion
-//       Access:
-//  Description:
-////////////////////////////////////////////////////////////////////
-void wdxGraphicsWindow::enable_mouse_passive_motion(bool val) {
-    _mouse_passive_motion_enabled = val;
-}
-
-
 ////////////////////////////////////////////////////////////////////
 //     Function: wdxGraphicsWindow::get_gsg_type
 //       Access: Public, Virtual

+ 14 - 26
panda/src/wdxdisplay/wdxGraphicsWindow.h

@@ -22,14 +22,6 @@
 ////////////////////////////////////////////////////////////////////
 // Includes
 ////////////////////////////////////////////////////////////////////
-#include <pandabase.h>
-
-#include <graphicsWindow.h>
-#define WINDOWS_LEAN_AND_MEAN
-#include <windows.h>
-#undef WINDOWS_LEAN_AND_MEAN
-#include <d3d.h>
-
 #include "dxGraphicsStateGuardian.h"
 
 ////////////////////////////////////////////////////////////////////
@@ -80,14 +72,11 @@ public:
   LONG window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam);
   void process_events(void);
 
-  INLINE bool mouse_entry_enabled(void) { return _mouse_entry_enabled; }
-  INLINE bool mouse_motion_enabled(void) { return _mouse_motion_enabled; }
-  INLINE bool mouse_passive_motion_enabled(void) { return _mouse_passive_motion_enabled; }
-  void handle_window_move( int x, int y );
-  void handle_mouse_motion( int x, int y );
-  void handle_mouse_entry( int state, int x, int y);
-  void handle_keypress( ButtonHandle key, int x, int y );
-  void handle_keyrelease( ButtonHandle key);
+  INLINE void handle_mouse_motion(int x, int y);
+  INLINE void handle_mouse_entry(bool bEntering, int x, int y);
+  INLINE void handle_keypress(ButtonHandle key, int x, int y );
+  INLINE void handle_keyrelease(ButtonHandle key);
+  void handle_window_move(int x, int y);
   void dx_setup();
   virtual void begin_frame( void );
   void show_frame();
@@ -105,27 +94,21 @@ protected:
   bool search_for_device(int devnum,DXDeviceInfo *pDevinfo);
   void setup_colormap(void);
 
-  void enable_mouse_input(bool val);
-  void enable_mouse_motion(bool val);
-  void enable_mouse_passive_motion(bool val);
-  void enable_mouse_entry(bool val);
-
 public:
   UINT_PTR _PandaPausedTimer;
   DXGraphicsStateGuardian *_dxgsg;
   void CreateScreenBuffersAndDevice(DXScreenData &Display);
   
 private:
+  INLINE void track_mouse_leaving(HWND hwnd);
   wdxGraphicsWindowGroup *_pParentWindowGroup;
   HDC               _hdc;
   HPALETTE          _colormap;
   typedef enum { NotAdjusting,MovingOrResizing,Resizing } WindowAdjustType;
   WindowAdjustType  _WindowAdjustingType;
   bool              _bSizeIsMaximized;
-  bool              _mouse_input_enabled;
-  bool              _mouse_motion_enabled;
-  bool              _mouse_passive_motion_enabled;
-  bool              _mouse_entry_enabled;
+  bool              _cursor_in_windowclientarea;
+  bool              _tracking_mouse_leaving;
   bool              _ime_open;
   bool              _ime_active;
   bool              _ime_composition_w;
@@ -183,10 +166,15 @@ public:
     int       _numMonitors;
     LPDIRECTDRAWCREATEEX    _pDDCreateEx;
     DXDeviceInfoVec _DeviceInfoVec;
+
+    // win32 fns that dont exist on w95
+    typedef BOOL (WINAPI* PFN_GETMONITORINFO)(HMONITOR, LPMONITORINFO);
+    PFN_GETMONITORINFO  _pfnGetMonitorInfo;
+    typedef BOOL (WINAPI* PFN_TRACKMOUSEEVENT)(LPTRACKMOUSEEVENT);
+    PFN_TRACKMOUSEEVENT _pfnTrackMouseEvent;
 };
 
 extern void set_global_parameters(void);
 extern void restore_global_parameters(void);
 
-
 #endif