diff --git a/panda/src/display/graphicsWindow.cxx b/panda/src/display/graphicsWindow.cxx index 5a41793d2b..d9132c358d 100644 --- a/panda/src/display/graphicsWindow.cxx +++ b/panda/src/display/graphicsWindow.cxx @@ -674,12 +674,21 @@ swap() { display_cat.warning() << "swap() unimplemented by " << get_type() << endl; } -void GraphicsWindow:: +//////////////////////////////////////////////////////////////////// +// Function: GraphicsWindow::resize +// Access: Public +// Description: Resizes the window to the given size. +// Should try to preserve current window bitdepths, +// if possible. If it is not possible to resize window to +// the given size, return false and maintain current +// window size. +//////////////////////////////////////////////////////////////////// +bool GraphicsWindow:: resize(unsigned int xsize,unsigned int ysize) { display_cat.warning() << "resize() unimplemented by " << get_type() << endl; + return false; } - unsigned int GraphicsWindow:: verify_window_sizes(unsigned int numsizes,unsigned int *dimen) { // see if window sizes are supported (i.e. in fullscrn mode) @@ -694,6 +703,8 @@ verify_window_sizes(unsigned int numsizes,unsigned int *dimen) { // on most cards, assuming they handle the std sizes the app // knows about. + // Also note this doesnt guarantee resize() will work, you still need to check its return value. + display_cat.warning() << "verify_window_sizes() unimplemented by " << get_type() << endl; return numsizes; } diff --git a/panda/src/display/graphicsWindow.h b/panda/src/display/graphicsWindow.h index 139465e49e..911b808214 100644 --- a/panda/src/display/graphicsWindow.h +++ b/panda/src/display/graphicsWindow.h @@ -141,7 +141,7 @@ PUBLISHED: // virtual void set_cursor_visible(bool bIsVisible); // should be overridden by gsg to implement // resize the window to the given size - virtual void resize(unsigned int xsize,unsigned int ysize); + virtual bool resize(unsigned int xsize,unsigned int ysize); virtual void swap(); diff --git a/panda/src/wdxdisplay/wdxGraphicsWindow.cxx b/panda/src/wdxdisplay/wdxGraphicsWindow.cxx index c5464fea9f..7890e225b6 100644 --- a/panda/src/wdxdisplay/wdxGraphicsWindow.cxx +++ b/panda/src/wdxdisplay/wdxGraphicsWindow.cxx @@ -1420,7 +1420,7 @@ BOOL WINAPI DriverEnumCallback_MultiMon( GUID* pGUID, TCHAR* strDesc,TCHAR* strN return save_devinfo(pGUID,strDesc,strName,argptr,hm); } -void wdxGraphicsWindow::resize(unsigned int xsize,unsigned int ysize) { +bool wdxGraphicsWindow::resize(unsigned int xsize,unsigned int ysize) { if (!_props._fullscreen) { if(wdxdisplay_cat.is_debug()) @@ -1436,7 +1436,7 @@ void wdxGraphicsWindow::resize(unsigned int xsize,unsigned int ysize) { // this doesnt seem to be working in toontown resize, so I put ddraw blackblt in handle_reshape instead //window_proc(_mwindow, WM_ERASEBKGND,(WPARAM)_hdc,0x0); handle_reshape(true); - return; + return true; } if(wdxdisplay_cat.is_info()) @@ -1469,7 +1469,7 @@ void wdxGraphicsWindow::resize(unsigned int xsize,unsigned int ysize) { if(FAILED(hr = _dxgsg->scrn.pDD->EnumDisplayModes(DDEDM_REFRESHRATES,&ddsd_search,&DMI,EnumDisplayModesCallBack))) { wdxdisplay_cat.fatal() << "resize() - EnumDisplayModes failed, result = " << ConvD3DErrorToString(hr) << endl; - return; + return false; } DMI.supportedBitDepths &= _dxgsg->scrn.D3DDevDesc.dwDeviceRenderBitDepth; @@ -1489,13 +1489,13 @@ void wdxGraphicsWindow::resize(unsigned int xsize,unsigned int ysize) { } else { wdxdisplay_cat.error() << "resize failed, no fullScreen resolutions at " << xsize << "x" << ysize << endl; - return; + return false; } if(FAILED(hr = _dxgsg->scrn.pDD->TestCooperativeLevel())) { wdxdisplay_cat.error() << "TestCooperativeLevel failed : result = " << ConvD3DErrorToString(hr) << endl; wdxdisplay_cat.error() << "Full screen app failed to get exclusive mode on resize, exiting..\n"; - return; + return false; } _dxgsg->free_dxgsg_objects(); @@ -1517,6 +1517,7 @@ void wdxGraphicsWindow::resize(unsigned int xsize,unsigned int ysize) { CreateScreenBuffersAndDevice(_dxgsg->scrn); _dxgsg->RecreateAllVideoSurfaces(); _dxgsg->SetDXReady(true); + return true; } unsigned int wdxGraphicsWindow:: diff --git a/panda/src/wdxdisplay/wdxGraphicsWindow.h b/panda/src/wdxdisplay/wdxGraphicsWindow.h index 4f79321ba4..143d7e9687 100644 --- a/panda/src/wdxdisplay/wdxGraphicsWindow.h +++ b/panda/src/wdxdisplay/wdxGraphicsWindow.h @@ -80,7 +80,7 @@ public: void dx_setup(); virtual void begin_frame( void ); void show_frame(); - virtual void resize(unsigned int xsize,unsigned int ysize); + virtual bool resize(unsigned int xsize,unsigned int ysize); virtual unsigned int verify_window_sizes(unsigned int numsizes,unsigned int *dimen); virtual int get_depth_bitwidth(void); diff --git a/panda/src/wgldisplay/wglGraphicsWindow.cxx b/panda/src/wgldisplay/wglGraphicsWindow.cxx index 9965d52cd9..42eb52724f 100644 --- a/panda/src/wgldisplay/wglGraphicsWindow.cxx +++ b/panda/src/wgldisplay/wglGraphicsWindow.cxx @@ -397,7 +397,8 @@ void wglGraphicsWindow::config() { if (!wc_registered) { // We only need to register the window class once per session. - wc.hCursor = _hMouseCursor; + + wc.hCursor = _hMouseCursor; // even if cursor isnt visible, we need to load it so its visible in client-area window border wc.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH); wc.lpszMenuName = NULL; wc.lpszClassName = WGL_WINDOWCLASSNAME; @@ -1107,7 +1108,7 @@ void wglGraphicsWindow::swap() { SwapBuffers(_hdc); } -void wglGraphicsWindow::resize(unsigned int xsize,unsigned int ysize) { +bool wglGraphicsWindow::resize(unsigned int xsize,unsigned int ysize) { if (!_props._fullscreen) { // resizing windowed mode is easy SetWindowPos(_mwindow, NULL, 0,0, xsize,ysize, SWP_NOZORDER | SWP_NOMOVE | SWP_NOSENDCHANGING); @@ -1128,7 +1129,7 @@ void wglGraphicsWindow::resize(unsigned int xsize,unsigned int ysize) { DEVMODE dm; if (!find_acceptable_display_mode(dwWidth,dwHeight,dwFullScreenBitDepth,dm)) { wgldisplay_cat.fatal() << "window resize(" << xsize << "," << ysize << ") failed, no compatible fullscreen display mode found!\n"; - return; + return false; } // this causes WM_SIZE msg to be produced @@ -1145,6 +1146,7 @@ void wglGraphicsWindow::resize(unsigned int xsize,unsigned int ysize) { assert(_pCurrent_display_settings!=NULL); memcpy(_pCurrent_display_settings,&dm,sizeof(DEVMODE)); } + return true; } unsigned int wglGraphicsWindow:: @@ -1588,7 +1590,7 @@ window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { switch (msg) { - case WM_MOUSEMOVE: + case WM_MOUSEMOVE: { // Win32 doesn't return the same numbers as X does when the mouse // goes beyond the upper or left side of the window #define SET_MOUSE_COORD(iVal,VAL) { \ @@ -1606,27 +1608,31 @@ window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { SET_MOUSE_COORD(y,HIWORD(lparam)); handle_mouse_motion(x, y); - break; - - // 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; } + // if cursor is invisible, make it visible when moving in the window bars,etc + case WM_NCMOUSEMOVE: { + if(!_props._bCursorIsVisible) { + if(!_cursor_in_windowclientarea) { + // wgldisplay_cat.error() << "NCMOUSEMOVE show=true\n"; + ShowCursor(true); + _cursor_in_windowclientarea=true; + } + } + break; + } + case WM_NCMOUSELEAVE: { if(!_props._bCursorIsVisible) { + // wgldisplay_cat.error() << "NCMOUSELEAVE show=false\n"; ShowCursor(false); _cursor_in_windowclientarea=false; } break; } - + case WM_MOUSELEAVE: { _tracking_mouse_leaving=false; handle_mouse_exit(); diff --git a/panda/src/wgldisplay/wglGraphicsWindow.h b/panda/src/wgldisplay/wglGraphicsWindow.h index e711051f07..35008b59e8 100644 --- a/panda/src/wgldisplay/wglGraphicsWindow.h +++ b/panda/src/wgldisplay/wglGraphicsWindow.h @@ -144,7 +144,7 @@ public: virtual void deactivate_window(); virtual void reactivate_window(); - virtual void resize(unsigned int xsize,unsigned int ysize); + virtual bool resize(unsigned int xsize,unsigned int ysize); virtual unsigned int verify_window_sizes(unsigned int numsizes,unsigned int *dimen); protected: