]> OCCT Git - occt.git/commitdiff
0031815: Visualization, TKOpenGl - avoid XResizeWindow() within OpenGl_Window::Resize()
authorkgv <kgv@opencascade.com>
Mon, 9 Nov 2020 07:55:34 +0000 (10:55 +0300)
committerbugmaster <bugmaster@opencascade.com>
Sat, 21 Nov 2020 09:19:45 +0000 (12:19 +0300)
OpenGl_Window::Resize() no more calls XResizeWindow() and relies only on dimensions returned by Aspect_Window.
Xw_Window::Size() now ignores Window in case of virtual window in similar way as WNT_Window does.

src/OpenGl/OpenGl_Window.cxx
src/Xw/Xw_Window.cxx

index e94a0ce6adca006280cc47e74e13e83558cd3464..157fe789fa7b8547cefc170fa2c3b8d7f3cafe99 100644 (file)
@@ -715,28 +715,18 @@ Standard_Boolean OpenGl_Window::Activate()
 // =======================================================================
 void OpenGl_Window::Resize()
 {
-#if !defined(_WIN32) && !defined(HAVE_EGL)
-  Display* aDisp = (Display* )myGlContext->myDisplay;
-  if (aDisp == NULL)
-    return;
-#endif
-
-  Standard_Integer aWidth  = 0;
-  Standard_Integer aHeight = 0;
+  Standard_Integer aWidth = 0, aHeight = 0;
   myPlatformWindow->Size (aWidth, aHeight);
-
-  // If the size is not changed - do nothing
-  if ((myWidth == aWidth) && (myHeight == aHeight))
+  if (myWidth  == aWidth
+   && myHeight == aHeight)
+  {
+    // if the size is not changed - do nothing
     return;
+  }
 
   myWidth  = aWidth;
   myHeight = aHeight;
 
-#if !defined(_WIN32) && !defined(HAVE_EGL)
-  XResizeWindow (aDisp, myGlContext->myWindow, (unsigned int )myWidth, (unsigned int )myHeight);
-  XSync (aDisp, False);
-#endif
-
   Init();
 }
 
@@ -778,18 +768,8 @@ void OpenGl_Window::Init()
     eglQuerySurface ((EGLDisplay )myGlContext->myDisplay, (EGLSurface )myGlContext->myWindow, EGL_WIDTH,  &myWidth);
     eglQuerySurface ((EGLDisplay )myGlContext->myDisplay, (EGLSurface )myGlContext->myWindow, EGL_HEIGHT, &myHeight);
   }
-#elif defined(_WIN32)
-  //
 #else
-  Window aRootWin;
-  int aDummy;
-  unsigned int aDummyU;
-  unsigned int aNewWidth  = 0;
-  unsigned int aNewHeight = 0;
-  Display* aDisp = (Display* )myGlContext->myDisplay;
-  XGetGeometry (aDisp, myGlContext->myWindow, &aRootWin, &aDummy, &aDummy, &aNewWidth, &aNewHeight, &aDummyU, &aDummyU);
-  myWidth  = aNewWidth;
-  myHeight = aNewHeight;
+  //
 #endif
 
   glDisable (GL_DITHER);
index f6489b67e18e1cc15fcb1802ed5b3fa37d8a6faf..709af9e92ce2b097386d083a2bca10e345b59461 100644 (file)
@@ -391,7 +391,7 @@ void Xw_Window::Unmap() const
 // =======================================================================
 Aspect_TypeOfResize Xw_Window::DoResize()
 {
-  if (myXWindow == 0)
+  if (IsVirtual() || myXWindow == 0)
   {
     return Aspect_TOR_UNKNOWN;
   }
@@ -447,9 +447,9 @@ Standard_Boolean Xw_Window::DoMapping() const
 // =======================================================================
 Standard_Real Xw_Window::Ratio() const
 {
-  if (myXWindow == 0)
+  if (IsVirtual() || myXWindow == 0)
   {
-    return 1.0;
+    return Standard_Real(myXRight - myXLeft) / Standard_Real(myYBottom - myYTop);
   }
 
   XFlush (myDisplay->GetDisplay());
@@ -462,11 +462,15 @@ Standard_Real Xw_Window::Ratio() const
 // function : Position
 // purpose  :
 // =======================================================================
-void Xw_Window::Position (Standard_Integer& X1, Standard_Integer& Y1,
-                          Standard_Integer& X2, Standard_Integer& Y2) const
+void Xw_Window::Position (Standard_Integer& theX1, Standard_Integer& theY1,
+                          Standard_Integer& theX2, Standard_Integer& theY2) const
 {
-  if (myXWindow == 0)
+  if (IsVirtual() || myXWindow == 0)
   {
+    theX1  = myXLeft;
+    theX2  = myXRight;
+    theY1  = myYTop;
+    theY2  = myYBottom;
     return;
   }
 
@@ -477,10 +481,10 @@ void Xw_Window::Position (Standard_Integer& X1, Standard_Integer& Y1,
   XTranslateCoordinates (myDisplay->GetDisplay(), anAttributes.root, myXWindow,
                          0, 0, &anAttributes.x, &anAttributes.y, &aChild);
 
-  X1 = -anAttributes.x;
-  X2 = X1 + anAttributes.width;
-  Y1 = -anAttributes.y;
-  Y2 = Y1 + anAttributes.height;
+  theX1 = -anAttributes.x;
+  theX2 = theX1 + anAttributes.width;
+  theY1 = -anAttributes.y;
+  theY2 = theY1 + anAttributes.height;
 }
 
 // =======================================================================
@@ -490,8 +494,10 @@ void Xw_Window::Position (Standard_Integer& X1, Standard_Integer& Y1,
 void Xw_Window::Size (Standard_Integer& theWidth,
                       Standard_Integer& theHeight) const
 {
-  if (myXWindow == 0)
+  if (IsVirtual() || myXWindow == 0)
   {
+    theWidth  = myXRight - myXLeft;
+    theHeight = myYBottom - myYTop;
     return;
   }