From 6051745d92924822c619a5292648c4ee87b89606 Mon Sep 17 00:00:00 2001 From: cxgeorge <> Date: Fri, 8 Mar 2002 03:09:44 +0000 Subject: [PATCH] fix up mouse stuff --- panda/src/dxgsg/Sources.pp | 2 +- panda/src/dxgsg/dxGeomNodeContext.h | 14 +- panda/src/dxgsg/dxGraphicsStateGuardian.cxx | 13 +- panda/src/dxgsg/dxGraphicsStateGuardian.h | 88 +--------- panda/src/dxgsg/dxTextureContext.h | 24 +-- panda/src/dxgsg/dxgsgbase.h | 136 +++++++++++++++ panda/src/wdxdisplay/wdxGraphicsPipe.h | 16 +- panda/src/wdxdisplay/wdxGraphicsWindow.cxx | 181 +++++++++----------- panda/src/wdxdisplay/wdxGraphicsWindow.h | 40 ++--- 9 files changed, 243 insertions(+), 271 deletions(-) create mode 100644 panda/src/dxgsg/dxgsgbase.h diff --git a/panda/src/dxgsg/Sources.pp b/panda/src/dxgsg/Sources.pp index 0b2655eb09..8b80f1eb3c 100644 --- a/panda/src/dxgsg/Sources.pp +++ b/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 diff --git a/panda/src/dxgsg/dxGeomNodeContext.h b/panda/src/dxgsg/dxGeomNodeContext.h index 345c212259..93e2295b3b 100644 --- a/panda/src/dxgsg/dxGeomNodeContext.h +++ b/panda/src/dxgsg/dxGeomNodeContext.h @@ -19,25 +19,13 @@ #ifndef DXGEOMNODECONTEXT_H #define DXGEOMNODECONTEXT_H -#include - -#ifdef WIN32_VC -// Must include windows.h before dx.h on NT -#define WIN32_LEAN_AND_MEAN -#include -#undef WIN32_LEAN_AND_MEAN -#endif +#include "dxgsgbase.h" #include #include #include "pvector.h" -#define D3D_OVERLOADS // get D3DVECTOR '+' operator, etc from d3dtypes.h -#include -#if DIRECT3D_VERSION != 0x0700 -#error DX7 headers not available, you need to install MS Platform SDK! -#endif typedef struct { DWORD nVerts; diff --git a/panda/src/dxgsg/dxGraphicsStateGuardian.cxx b/panda/src/dxgsg/dxGraphicsStateGuardian.cxx index a886b6765a..fd564aca3c 100644 --- a/panda/src/dxgsg/dxGraphicsStateGuardian.cxx +++ b/panda/src/dxgsg/dxGraphicsStateGuardian.cxx @@ -16,7 +16,9 @@ // //////////////////////////////////////////////////////////////////// -#include +#include "dxGraphicsStateGuardian.h" +#include "config_dxgsg.h" + #include #include #include @@ -54,20 +56,13 @@ #include #include #include +#include #ifdef DO_PSTATS #include #include #endif -#include "config_dxgsg.h" -#include "dxGraphicsStateGuardian.h" - -// disable nameless struct 'warning' -#pragma warning (disable : 4201) - -#include - // print out simple drawprim stats every few secs //#define COUNT_DRAWPRIMS diff --git a/panda/src/dxgsg/dxGraphicsStateGuardian.h b/panda/src/dxgsg/dxGraphicsStateGuardian.h index 9dca9639ce..c9a5f7d903 100644 --- a/panda/src/dxgsg/dxGraphicsStateGuardian.h +++ b/panda/src/dxgsg/dxGraphicsStateGuardian.h @@ -19,9 +19,7 @@ #ifndef DXGRAPHICSSTATEGUARDIAN_H #define DXGRAPHICSSTATEGUARDIAN_H -//#define GSG_VERBOSE - -#include +#include "dxgsgbase.h" #include #include #include @@ -37,95 +35,13 @@ #include #include #include - #include "dxGeomNodeContext.h" #include "dxTextureContext.h" #include -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 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 diff --git a/panda/src/dxgsg/dxTextureContext.h b/panda/src/dxgsg/dxTextureContext.h index f2fc1e8011..0ae1e8bbe4 100644 --- a/panda/src/dxgsg/dxTextureContext.h +++ b/panda/src/dxgsg/dxTextureContext.h @@ -19,33 +19,11 @@ #ifndef DXTEXTURECONTEXT_H #define DXTEXTURECONTEXT_H -#include - -#define WIN32_LEAN_AND_MEAN -#ifndef STRICT -// enable strict type checking in windows.h, see msdn -#define STRICT -#endif - -#include - -#include - -#define D3D_OVERLOADS // get D3DVECTOR '+' operator, etc from d3dtypes.h -#include -#undef WIN32_LEAN_AND_MEAN +#include "dxgsgbase.h" #include #include -//#define USE_TEXFMTVEC // doesnt work now, crashes in destructor - -#ifdef USE_TEXFMTVEC -typedef pvector DDPixelFormatVec; -#else -#define MAX_DX_TEXPIXFMTS 20 // should be enough for any card -#endif - //////////////////////////////////////////////////////////////////// // Class : DXTextureContext // Description : diff --git a/panda/src/dxgsg/dxgsgbase.h b/panda/src/dxgsg/dxgsgbase.h new file mode 100644 index 0000000000..c0d45fea34 --- /dev/null +++ b/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 +// panda3d@yahoogroups.com . +// +//////////////////////////////////////////////////////////////////// + +#ifndef DXGSGBASE_H +#define DXGSGBASE_H + +#include + +// 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 +#include + +#define D3D_OVERLOADS // get D3DVECTOR '+' operator, etc from d3dtypes.h +#include +#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 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 + diff --git a/panda/src/wdxdisplay/wdxGraphicsPipe.h b/panda/src/wdxdisplay/wdxGraphicsPipe.h index 944ab399bd..9302c00b00 100644 --- a/panda/src/wdxdisplay/wdxGraphicsPipe.h +++ b/panda/src/wdxdisplay/wdxGraphicsPipe.h @@ -21,24 +21,10 @@ //////////////////////////////////////////////////////////////////// // Includes //////////////////////////////////////////////////////////////////// -#include #include -#include #include "wdxGraphicsWindow.h" - -#ifndef STRICT -#define STRICT -#endif -#define WINDOWS_LEAN_AND_MEAN -#include -#undef WINDOWS_LEAN_AND_MEAN - -//////////////////////////////////////////////////////////////////// -// Defines -//////////////////////////////////////////////////////////////////// - -extern char * ConvD3DErrorToString(const HRESULT &error); +#include //////////////////////////////////////////////////////////////////// // Class : wdxGraphicsPipe diff --git a/panda/src/wdxdisplay/wdxGraphicsWindow.cxx b/panda/src/wdxdisplay/wdxGraphicsWindow.cxx index fce5ef05dc..c8e8162f7a 100644 --- a/panda/src/wdxdisplay/wdxGraphicsWindow.cxx +++ b/panda/src/wdxdisplay/wdxGraphicsWindow.cxx @@ -26,17 +26,12 @@ #include #include - #include #ifdef DO_PSTATS #include #endif -#define D3D_OVERLOADS -//#define INITGUID dont want this if linking w/dxguid.lib -#include - #include //////////////////////////////////////////////////////////////////// @@ -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)) { + if(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)) { - 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_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 diff --git a/panda/src/wdxdisplay/wdxGraphicsWindow.h b/panda/src/wdxdisplay/wdxGraphicsWindow.h index e09702b270..4f79321ba4 100644 --- a/panda/src/wdxdisplay/wdxGraphicsWindow.h +++ b/panda/src/wdxdisplay/wdxGraphicsWindow.h @@ -22,14 +22,6 @@ //////////////////////////////////////////////////////////////////// // Includes //////////////////////////////////////////////////////////////////// -#include - -#include -#define WINDOWS_LEAN_AND_MEAN -#include -#undef WINDOWS_LEAN_AND_MEAN -#include - #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