Browse Source

resize returns success-val

cxgeorge 24 years ago
parent
commit
1f67a86263

+ 13 - 2
panda/src/display/graphicsWindow.cxx

@@ -674,12 +674,21 @@ swap() {
   display_cat.warning() << "swap() unimplemented by " << get_type() << endl;
   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) {
 resize(unsigned int xsize,unsigned int ysize) {
   display_cat.warning() << "resize() unimplemented by " << get_type() << endl;  
   display_cat.warning() << "resize() unimplemented by " << get_type() << endl;  
+  return false;
 }
 }
 
 
-
 unsigned int GraphicsWindow::
 unsigned int GraphicsWindow::
 verify_window_sizes(unsigned int numsizes,unsigned int *dimen) {
 verify_window_sizes(unsigned int numsizes,unsigned int *dimen) {
   // see if window sizes are supported (i.e. in fullscrn mode)
   // 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
   //       on most cards, assuming they handle the std sizes the app
   //       knows about.
   //       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; 
   display_cat.warning() << "verify_window_sizes() unimplemented by " << get_type() << endl; 
   return numsizes;
   return numsizes;
 }
 }

+ 1 - 1
panda/src/display/graphicsWindow.h

@@ -141,7 +141,7 @@ PUBLISHED:
   // virtual void set_cursor_visible(bool bIsVisible);  // should be overridden by gsg to implement
   // virtual void set_cursor_visible(bool bIsVisible);  // should be overridden by gsg to implement
 
 
   // resize the window to the given size
   // 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();
   virtual void swap();
 
 

+ 6 - 5
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);
     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 (!_props._fullscreen) {
        if(wdxdisplay_cat.is_debug())
        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
          // 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);  
          //window_proc(_mwindow, WM_ERASEBKGND,(WPARAM)_hdc,0x0);  
         handle_reshape(true);
         handle_reshape(true);
-        return;
+        return true;
    }
    }
 
 
    if(wdxdisplay_cat.is_info())
    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))) {
    if(FAILED(hr = _dxgsg->scrn.pDD->EnumDisplayModes(DDEDM_REFRESHRATES,&ddsd_search,&DMI,EnumDisplayModesCallBack))) {
        wdxdisplay_cat.fatal() << "resize() - EnumDisplayModes failed, result = " << ConvD3DErrorToString(hr) << endl;
        wdxdisplay_cat.fatal() << "resize() - EnumDisplayModes failed, result = " << ConvD3DErrorToString(hr) << endl;
-       return;
+       return false;
    }
    }
 
 
    DMI.supportedBitDepths &= _dxgsg->scrn.D3DDevDesc.dwDeviceRenderBitDepth;
    DMI.supportedBitDepths &= _dxgsg->scrn.D3DDevDesc.dwDeviceRenderBitDepth;
@@ -1489,13 +1489,13 @@ void wdxGraphicsWindow::resize(unsigned int xsize,unsigned int ysize) {
    } else {
    } else {
        wdxdisplay_cat.error()
        wdxdisplay_cat.error()
           << "resize failed, no fullScreen resolutions at " << xsize << "x" << ysize << endl;
           << "resize failed, no fullScreen resolutions at " << xsize << "x" << ysize << endl;
-       return;
+       return false;
    }
    }
 
 
    if(FAILED(hr = _dxgsg->scrn.pDD->TestCooperativeLevel())) {
    if(FAILED(hr = _dxgsg->scrn.pDD->TestCooperativeLevel())) {
         wdxdisplay_cat.error() << "TestCooperativeLevel failed : result = " << ConvD3DErrorToString(hr) << endl;
         wdxdisplay_cat.error() << "TestCooperativeLevel failed : result = " << ConvD3DErrorToString(hr) << endl;
         wdxdisplay_cat.error() << "Full screen app failed to get exclusive mode on resize, exiting..\n";
         wdxdisplay_cat.error() << "Full screen app failed to get exclusive mode on resize, exiting..\n";
-        return;
+        return false;
    }
    }
 
 
    _dxgsg->free_dxgsg_objects();
    _dxgsg->free_dxgsg_objects();
@@ -1517,6 +1517,7 @@ void wdxGraphicsWindow::resize(unsigned int xsize,unsigned int ysize) {
    CreateScreenBuffersAndDevice(_dxgsg->scrn);
    CreateScreenBuffersAndDevice(_dxgsg->scrn);
    _dxgsg->RecreateAllVideoSurfaces();
    _dxgsg->RecreateAllVideoSurfaces();
    _dxgsg->SetDXReady(true);
    _dxgsg->SetDXReady(true);
+   return true;
 }
 }
 
 
 unsigned int wdxGraphicsWindow::
 unsigned int wdxGraphicsWindow::

+ 1 - 1
panda/src/wdxdisplay/wdxGraphicsWindow.h

@@ -80,7 +80,7 @@ public:
   void dx_setup();
   void dx_setup();
   virtual void begin_frame( void );
   virtual void begin_frame( void );
   void show_frame();
   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 unsigned int verify_window_sizes(unsigned int numsizes,unsigned int *dimen);
   virtual int get_depth_bitwidth(void);
   virtual int get_depth_bitwidth(void);
 
 

+ 20 - 14
panda/src/wgldisplay/wglGraphicsWindow.cxx

@@ -397,7 +397,8 @@ void wglGraphicsWindow::config() {
 
 
     if (!wc_registered) {
     if (!wc_registered) {
       // We only need to register the window class once per session.
       // 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.hbrBackground  = (HBRUSH)GetStockObject(BLACK_BRUSH);
       wc.lpszMenuName   = NULL;
       wc.lpszMenuName   = NULL;
       wc.lpszClassName  = WGL_WINDOWCLASSNAME;
       wc.lpszClassName  = WGL_WINDOWCLASSNAME;
@@ -1107,7 +1108,7 @@ void wglGraphicsWindow::swap() {
     SwapBuffers(_hdc);
     SwapBuffers(_hdc);
 }
 }
 
 
-void wglGraphicsWindow::resize(unsigned int xsize,unsigned int ysize) {
+bool wglGraphicsWindow::resize(unsigned int xsize,unsigned int ysize) {
     if (!_props._fullscreen) {
     if (!_props._fullscreen) {
         // resizing windowed mode is easy
         // resizing windowed mode is easy
         SetWindowPos(_mwindow, NULL, 0,0, xsize,ysize, SWP_NOZORDER | SWP_NOMOVE | SWP_NOSENDCHANGING);
         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;
       DEVMODE dm;
       if (!find_acceptable_display_mode(dwWidth,dwHeight,dwFullScreenBitDepth,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";
           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
       // 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);
       assert(_pCurrent_display_settings!=NULL);
       memcpy(_pCurrent_display_settings,&dm,sizeof(DEVMODE));
       memcpy(_pCurrent_display_settings,&dm,sizeof(DEVMODE));
     }
     }
+    return true;
 }
 }
 
 
 unsigned int wglGraphicsWindow::
 unsigned int wglGraphicsWindow::
@@ -1588,7 +1590,7 @@ window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) {
 
 
   switch (msg) {
   switch (msg) {
 
 
-    case WM_MOUSEMOVE:
+    case WM_MOUSEMOVE: {
         // Win32 doesn't return the same numbers as X does when the mouse
         // Win32 doesn't return the same numbers as X does when the mouse
         // goes beyond the upper or left side of the window
         // goes beyond the upper or left side of the window
         #define SET_MOUSE_COORD(iVal,VAL) { \
         #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));
         SET_MOUSE_COORD(y,HIWORD(lparam));
     
     
         handle_mouse_motion(x, y);
         handle_mouse_motion(x, y);
+
         break;
         break;
-    
+    }
+
     // if cursor is invisible, make it visible when moving in the window bars,etc
     // if cursor is invisible, make it visible when moving in the window bars,etc
     case WM_NCMOUSEMOVE: {
     case WM_NCMOUSEMOVE: {
-        if(!_props._bCursorIsVisible) {
-            if(!_cursor_in_windowclientarea) {
-                ShowCursor(true);
-                _cursor_in_windowclientarea=true;
-            }
-        }
-        break;
+      if(!_props._bCursorIsVisible) {
+          if(!_cursor_in_windowclientarea) {
+             // wgldisplay_cat.error() << "NCMOUSEMOVE show=true\n";
+              ShowCursor(true);
+              _cursor_in_windowclientarea=true;
+          }
+      }
+      break;
     }
     }
-
+    
     case WM_NCMOUSELEAVE: {
     case WM_NCMOUSELEAVE: {
         if(!_props._bCursorIsVisible) {
         if(!_props._bCursorIsVisible) {
+            // wgldisplay_cat.error() << "NCMOUSELEAVE show=false\n";
             ShowCursor(false);
             ShowCursor(false);
             _cursor_in_windowclientarea=false;
             _cursor_in_windowclientarea=false;
         }
         }
         break;
         break;
     }
     }
-    
+
     case WM_MOUSELEAVE: {
     case WM_MOUSELEAVE: {
        _tracking_mouse_leaving=false;  
        _tracking_mouse_leaving=false;  
        handle_mouse_exit();
        handle_mouse_exit();

+ 1 - 1
panda/src/wgldisplay/wglGraphicsWindow.h

@@ -144,7 +144,7 @@ public:
   virtual void deactivate_window();
   virtual void deactivate_window();
   virtual void reactivate_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);
   virtual unsigned int verify_window_sizes(unsigned int numsizes,unsigned int *dimen);
 
 
 protected:
 protected: