Browse Source

fix ime for dx7, put in hooks for dx8, dx9

David Rose 22 years ago
parent
commit
e46e47b442

+ 4 - 4
panda/src/dxgsg7/dxGraphicsStateGuardian7.cxx

@@ -5134,19 +5134,19 @@ void DXGraphicsStateGuardian7::show_frame(void) {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 void DXGraphicsStateGuardian7::
 void DXGraphicsStateGuardian7::
 support_overlay_window(bool flag) {
 support_overlay_window(bool flag) {
-  if (_overlay_windows_supported && !flag) {
+  if (!flag) {
     // Disable support for overlay windows.
     // Disable support for overlay windows.
     _overlay_windows_supported = false;
     _overlay_windows_supported = false;
 
 
-    if (_pScrn->bIsFullScreen) {
+    if (_pScrn != (DXScreenData *)NULL && _pScrn->bIsFullScreen) {
       _pScrn->pddsPrimary->SetClipper(NULL);
       _pScrn->pddsPrimary->SetClipper(NULL);
     }
     }
 
 
-  } else if (!_overlay_windows_supported && flag) {
+  } else {
     // Enable support for overlay windows.
     // Enable support for overlay windows.
     _overlay_windows_supported = true;
     _overlay_windows_supported = true;
 
 
-    if (_pScrn->bIsFullScreen) {
+    if (_pScrn != (DXScreenData *)NULL && _pScrn->bIsFullScreen) {
       // Create a Clipper object to blt the whole screen.
       // Create a Clipper object to blt the whole screen.
       LPDIRECTDRAWCLIPPER Clipper;
       LPDIRECTDRAWCLIPPER Clipper;
 
 

+ 17 - 0
panda/src/dxgsg7/wdxGraphicsWindow7.cxx

@@ -404,6 +404,23 @@ do_fullscreen_resize(int x_size, int y_size) {
   return true;
   return true;
 }
 }
 
 
+////////////////////////////////////////////////////////////////////
+//     Function: wdxGraphicsWindow7::support_overlay_window
+//       Access: Protected, Virtual
+//  Description: Some windows graphics contexts (e.g. DirectX)
+//               require special support to enable the displaying of
+//               an overlay window (particularly the IME window) over
+//               the fullscreen graphics window.  This is a hook for
+//               the window to enable or disable that mode when
+//               necessary.
+////////////////////////////////////////////////////////////////////
+void wdxGraphicsWindow7::
+support_overlay_window(bool flag) {
+  if (_dxgsg != (DXGraphicsStateGuardian7 *)NULL) {
+    _dxgsg->support_overlay_window(flag);
+  }
+}
+
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: wdxGraphicsWindow7::set_to_temp_rendertarget
 //     Function: wdxGraphicsWindow7::set_to_temp_rendertarget
 //       Access: Private
 //       Access: Private

+ 1 - 0
panda/src/dxgsg7/wdxGraphicsWindow7.h

@@ -53,6 +53,7 @@ protected:
   virtual void fullscreen_restored(WindowProperties &properties);
   virtual void fullscreen_restored(WindowProperties &properties);
   virtual void handle_reshape();
   virtual void handle_reshape();
   virtual bool do_fullscreen_resize(int x_size, int y_size);
   virtual bool do_fullscreen_resize(int x_size, int y_size);
+  virtual void support_overlay_window(bool flag);
 
 
 private:
 private:
   bool set_to_temp_rendertarget();
   bool set_to_temp_rendertarget();

+ 2 - 5
panda/src/dxgsg8/wdxGraphicsPipe8.cxx

@@ -754,14 +754,11 @@ search_for_valid_displaymode(DXScreenData &scrn,
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: wdxGraphicsPipew8::make_device
 //     Function: wdxGraphicsPipew8::make_device
 //       Access: Public, Virtual
 //       Access: Public, Virtual
-//  Description: Creates a new device.  ??????
+//  Description: Creates a new reference to a particular hardware
+//               device and associates it with the pipe.
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-
 PT(GraphicsDevice) wdxGraphicsPipe8::
 PT(GraphicsDevice) wdxGraphicsPipe8::
 make_device(void *scrn) {
 make_device(void *scrn) {
-
-  // FrameBufferProperties really belongs as part of the window/renderbuffer specification
-  // put here because of GLX multithreading requirement
   PT(DXGraphicsDevice8) device = new DXGraphicsDevice8(this);
   PT(DXGraphicsDevice8) device = new DXGraphicsDevice8(this);
   device->_pScrn = (DXScreenData*) scrn;
   device->_pScrn = (DXScreenData*) scrn;
   device->_pD3DDevice = device->_pScrn->pD3DDevice;
   device->_pD3DDevice = device->_pScrn->pD3DDevice;

+ 30 - 22
panda/src/dxgsg8/wdxGraphicsWindow8.cxx

@@ -397,6 +397,23 @@ do_fullscreen_resize(int x_size, int y_size) {
   return bResizeSucceeded;
   return bResizeSucceeded;
 }
 }
 
 
+////////////////////////////////////////////////////////////////////
+//     Function: wdxGraphicsWindow8::support_overlay_window
+//       Access: Protected, Virtual
+//  Description: Some windows graphics contexts (e.g. DirectX)
+//               require special support to enable the displaying of
+//               an overlay window (particularly the IME window) over
+//               the fullscreen graphics window.  This is a hook for
+//               the window to enable or disable that mode when
+//               necessary.
+////////////////////////////////////////////////////////////////////
+void wdxGraphicsWindow8::
+support_overlay_window(bool flag) {
+  if (_dxgsg != (DXGraphicsStateGuardian8 *)NULL) {
+    _dxgsg->support_overlay_window(flag);
+  }
+}
+
 #if 1
 #if 1
 //////////////////////////////////////////////////////////////////
 //////////////////////////////////////////////////////////////////
 //     Function: WinGraphicsWindow::window_proc
 //     Function: WinGraphicsWindow::window_proc
@@ -455,19 +472,6 @@ window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) {
            return 0;
            return 0;
         }
         }
 
 
-        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
-          // to see the IME window.
-          _dxgsg->support_overlay_window(true);
-          break;
-
-        case WM_IME_ENDCOMPOSITION:
-          // Turn off the support for overlay windows, since we're done
-          // with the IME window for now and it just slows things down.
-          _dxgsg->support_overlay_window(false);
-          break;
-
         case WM_ENTERSIZEMOVE:
         case WM_ENTERSIZEMOVE:
              if(_dxgsg!=NULL) 
              if(_dxgsg!=NULL) 
                 _dxgsg->SetDXReady(false);   // dont see pic during resize
                 _dxgsg->SetDXReady(false);   // dont see pic during resize
@@ -1718,16 +1722,20 @@ reset_window(bool swapchain) {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 bool wdxGraphicsWindow8::
 bool wdxGraphicsWindow8::
 open_window(void) {
 open_window(void) {
+  cerr << "open_window()\n";
   PT(DXGraphicsDevice8) dxdev;
   PT(DXGraphicsDevice8) dxdev;
   DXGraphicsStateGuardian8 *dxgsg;
   DXGraphicsStateGuardian8 *dxgsg;
   DCAST_INTO_R(dxgsg,_gsg,false);
   DCAST_INTO_R(dxgsg,_gsg,false);
   WindowProperties props;
   WindowProperties props;
 
 
   if(!choose_device()) {
   if(!choose_device()) {
-      return false;
+    return false;
   }
   }
-  if (dxgsg->get_pipe()->get_device() && !multiple_windows)
+  if (dxgsg->get_pipe()->get_device() && !multiple_windows) {
+    wdxdisplay8_cat.error() 
+      << "Could not create window; multiple window support not enabled.\n";
     return false;
     return false;
+  }
 
 
   wdxdisplay8_cat.debug() << "_wcontext.hWnd is " << _wcontext.hWnd << "\n";
   wdxdisplay8_cat.debug() << "_wcontext.hWnd is " << _wcontext.hWnd << "\n";
   if (!WinGraphicsWindow::open_window()) {
   if (!WinGraphicsWindow::open_window()) {
@@ -1745,12 +1753,14 @@ open_window(void) {
     create_screen_buffers_and_device(_wcontext, dx_force_16bpp_zbuffer);
     create_screen_buffers_and_device(_wcontext, dx_force_16bpp_zbuffer);
     dxgsg->get_pipe()->make_device((void*)(&_wcontext));
     dxgsg->get_pipe()->make_device((void*)(&_wcontext));
     dxgsg->copy_pres_reset(&_wcontext);
     dxgsg->copy_pres_reset(&_wcontext);
-    if (multiple_windows) // then we have no choice but to waist a framebuffer
+    if (multiple_windows) {
+      // then we have no choice but to waste a framebuffer
       dxgsg->create_swap_chain(&_wcontext);
       dxgsg->create_swap_chain(&_wcontext);
-  }
-  else {
+    }
 
 
-    // fill in the DXScreenData from dxdevice here and change the reference to hWnd.
+  } else {
+    // fill in the DXScreenData from dxdevice here and change the
+    // reference to hWnd.
     dxdev = (DXGraphicsDevice8*)dxgsg->get_pipe()->get_device();
     dxdev = (DXGraphicsDevice8*)dxgsg->get_pipe()->get_device();
     props = get_properties();
     props = get_properties();
 
 
@@ -1764,12 +1774,10 @@ open_window(void) {
 
 
     init_resized_window();
     init_resized_window();
 
 
-
     if (wdxdisplay8_cat.is_debug()) {
     if (wdxdisplay8_cat.is_debug()) {
       wdxdisplay8_cat.debug() << "Current device is " << dxdev << "\n";
       wdxdisplay8_cat.debug() << "Current device is " << dxdev << "\n";
-      
-      dxgsg->create_swap_chain(&_wcontext);
     }
     }
+    dxgsg->create_swap_chain(&_wcontext);
   }
   }
   wdxdisplay8_cat.debug() << "swapchain is " << _wcontext.pSwapChain << "\n";
   wdxdisplay8_cat.debug() << "swapchain is " << _wcontext.pSwapChain << "\n";
   return true;
   return true;

+ 1 - 0
panda/src/dxgsg8/wdxGraphicsWindow8.h

@@ -55,6 +55,7 @@ protected:
   virtual void fullscreen_restored(WindowProperties &properties);
   virtual void fullscreen_restored(WindowProperties &properties);
   virtual void handle_reshape();
   virtual void handle_reshape();
   virtual bool do_fullscreen_resize(int x_size, int y_size);
   virtual bool do_fullscreen_resize(int x_size, int y_size);
+  virtual void support_overlay_window(bool flag);
 
 
 private:
 private:
   //  bool set_to_temp_rendertarget();
   //  bool set_to_temp_rendertarget();

+ 1 - 1
panda/src/dxgsg9/dxGraphicsStateGuardian9.cxx

@@ -927,7 +927,7 @@ support_overlay_window(bool flag) {
     _overlay_windows_supported = false;
     _overlay_windows_supported = false;
 
 
     if (dx_full_screen) {
     if (dx_full_screen) {
-      _pScrn->pddsPrimary->SetClipper(NULL);
+      _pD3DDevicesPrimary->SetClipper(NULL);
     }
     }
 
 
   } else if (!_overlay_windows_supported && flag) {
   } else if (!_overlay_windows_supported && flag) {

+ 28 - 21
panda/src/dxgsg9/wdxGraphicsWindow9.cxx

@@ -397,6 +397,23 @@ do_fullscreen_resize(int x_size, int y_size) {
   return bResizeSucceeded;
   return bResizeSucceeded;
 }
 }
 
 
+////////////////////////////////////////////////////////////////////
+//     Function: wdxGraphicsWindow9::support_overlay_window
+//       Access: Protected, Virtual
+//  Description: Some windows graphics contexts (e.g. DirectX)
+//               require special support to enable the displaying of
+//               an overlay window (particularly the IME window) over
+//               the fullscreen graphics window.  This is a hook for
+//               the window to enable or disable that mode when
+//               necessary.
+////////////////////////////////////////////////////////////////////
+void wdxGraphicsWindow9::
+support_overlay_window(bool flag) {
+  if (_dxgsg != (DXGraphicsStateGuardian9 *)NULL) {
+    _dxgsg->support_overlay_window(flag);
+  }
+}
+
 #if 1
 #if 1
 //////////////////////////////////////////////////////////////////
 //////////////////////////////////////////////////////////////////
 //     Function: WinGraphicsWindow::window_proc
 //     Function: WinGraphicsWindow::window_proc
@@ -455,19 +472,6 @@ window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) {
            return 0;
            return 0;
         }
         }
 
 
-        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
-          // to see the IME window.
-          _dxgsg->support_overlay_window(true);
-          break;
-
-        case WM_IME_ENDCOMPOSITION:
-          // Turn off the support for overlay windows, since we're done
-          // with the IME window for now and it just slows things down.
-          _dxgsg->support_overlay_window(false);
-          break;
-
         case WM_ENTERSIZEMOVE:
         case WM_ENTERSIZEMOVE:
              if(_dxgsg!=NULL) 
              if(_dxgsg!=NULL) 
                 _dxgsg->SetDXReady(false);   // dont see pic during resize
                 _dxgsg->SetDXReady(false);   // dont see pic during resize
@@ -1728,8 +1732,11 @@ open_window(void) {
   if(!choose_device()) {
   if(!choose_device()) {
       return false;
       return false;
   }
   }
-  if (dxgsg->get_pipe()->get_device() && !multiple_windows)
+  if (dxgsg->get_pipe()->get_device() && !multiple_windows) {
+    wdxdisplay9_cat.error() 
+      << "Could not create window; multiple window support not enabled.\n";
     return false;
     return false;
+  }
 
 
   wdxdisplay9_cat.debug() << "_wcontext.hWnd is " << _wcontext.hWnd << "\n";
   wdxdisplay9_cat.debug() << "_wcontext.hWnd is " << _wcontext.hWnd << "\n";
   if (!WinGraphicsWindow::open_window()) {
   if (!WinGraphicsWindow::open_window()) {
@@ -1747,12 +1754,14 @@ open_window(void) {
     create_screen_buffers_and_device(_wcontext, dx_force_16bpp_zbuffer);
     create_screen_buffers_and_device(_wcontext, dx_force_16bpp_zbuffer);
     dxgsg->get_pipe()->make_device((void*)(&_wcontext));
     dxgsg->get_pipe()->make_device((void*)(&_wcontext));
     dxgsg->copy_pres_reset(&_wcontext);
     dxgsg->copy_pres_reset(&_wcontext);
-    if (multiple_windows) // then we have no choice but to waist a framebuffer
+    if (multiple_windows) {
+      // then we have no choice but to waste a framebuffer
       dxgsg->create_swap_chain(&_wcontext);
       dxgsg->create_swap_chain(&_wcontext);
-  }
-  else {
+    }
 
 
-    // fill in the DXScreenData from dxdevice here and change the reference to hWnd.
+  } else {
+    // fill in the DXScreenData from dxdevice here and change the
+    // reference to hWnd.
     dxdev = (DXGraphicsDevice9*)dxgsg->get_pipe()->get_device();
     dxdev = (DXGraphicsDevice9*)dxgsg->get_pipe()->get_device();
     props = get_properties();
     props = get_properties();
 
 
@@ -1766,12 +1775,10 @@ open_window(void) {
 
 
     init_resized_window();
     init_resized_window();
 
 
-
     if (wdxdisplay9_cat.is_debug()) {
     if (wdxdisplay9_cat.is_debug()) {
       wdxdisplay9_cat.debug() << "Current device is " << dxdev << "\n";
       wdxdisplay9_cat.debug() << "Current device is " << dxdev << "\n";
-      
-      dxgsg->create_swap_chain(&_wcontext);
     }
     }
+    dxgsg->create_swap_chain(&_wcontext);
   }
   }
   wdxdisplay9_cat.debug() << "swapchain is " << _wcontext.pSwapChain << "\n";
   wdxdisplay9_cat.debug() << "swapchain is " << _wcontext.pSwapChain << "\n";
   return true;
   return true;

+ 1 - 0
panda/src/dxgsg9/wdxGraphicsWindow9.h

@@ -55,6 +55,7 @@ protected:
   virtual void fullscreen_restored(WindowProperties &properties);
   virtual void fullscreen_restored(WindowProperties &properties);
   virtual void handle_reshape();
   virtual void handle_reshape();
   virtual bool do_fullscreen_resize(int x_size, int y_size);
   virtual bool do_fullscreen_resize(int x_size, int y_size);
+  virtual void support_overlay_window(bool flag);
 
 
 private:
 private:
   //  bool set_to_temp_rendertarget();
   //  bool set_to_temp_rendertarget();

+ 16 - 0
panda/src/windisplay/winGraphicsWindow.cxx

@@ -440,6 +440,20 @@ void WinGraphicsWindow::
 reconsider_fullscreen_size(DWORD &, DWORD &, DWORD &) {
 reconsider_fullscreen_size(DWORD &, DWORD &, DWORD &) {
 }
 }
 
 
+////////////////////////////////////////////////////////////////////
+//     Function: WinGraphicsWindow::support_overlay_window
+//       Access: Protected, Virtual
+//  Description: Some windows graphics contexts (e.g. DirectX)
+//               require special support to enable the displaying of
+//               an overlay window (particularly the IME window) over
+//               the fullscreen graphics window.  This is a hook for
+//               the window to enable or disable that mode when
+//               necessary.
+////////////////////////////////////////////////////////////////////
+void WinGraphicsWindow::
+support_overlay_window(bool) {
+}
+
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: WinGraphicsWindow::open_fullscreen_window
 //     Function: WinGraphicsWindow::open_fullscreen_window
 //       Access: Private
 //       Access: Private
@@ -818,10 +832,12 @@ window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) {
         break;
         break;
         
         
       case WM_IME_STARTCOMPOSITION:
       case WM_IME_STARTCOMPOSITION:
+        support_overlay_window(true);
         _ime_active = true;
         _ime_active = true;
         break;
         break;
         
         
       case WM_IME_ENDCOMPOSITION:
       case WM_IME_ENDCOMPOSITION:
+        support_overlay_window(false);
         _ime_active = false;
         _ime_active = false;
         break;
         break;
         
         

+ 2 - 0
panda/src/windisplay/winGraphicsWindow.h

@@ -73,6 +73,8 @@ protected:
   virtual void reconsider_fullscreen_size(DWORD &x_size, DWORD &y_size, 
   virtual void reconsider_fullscreen_size(DWORD &x_size, DWORD &y_size, 
                                           DWORD &bitdepth);
                                           DWORD &bitdepth);
 
 
+  virtual void support_overlay_window(bool flag);
+
 private:
 private:
   bool open_fullscreen_window();
   bool open_fullscreen_window();
   bool open_regular_window();
   bool open_regular_window();