From e89202ea0221efbae55a0ed8ee8b620c31b44552 Mon Sep 17 00:00:00 2001 From: kgv Date: Mon, 9 Nov 2020 10:55:34 +0300 Subject: [PATCH] 0031815: Visualization, TKOpenGl - avoid XResizeWindow() within OpenGl_Window::Resize() 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 | 34 +++++++--------------------------- src/Xw/Xw_Window.cxx | 28 +++++++++++++++++----------- 2 files changed, 24 insertions(+), 38 deletions(-) diff --git a/src/OpenGl/OpenGl_Window.cxx b/src/OpenGl/OpenGl_Window.cxx index e94a0ce6ad..157fe789fa 100644 --- a/src/OpenGl/OpenGl_Window.cxx +++ b/src/OpenGl/OpenGl_Window.cxx @@ -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); diff --git a/src/Xw/Xw_Window.cxx b/src/Xw/Xw_Window.cxx index f6489b67e1..709af9e92c 100644 --- a/src/Xw/Xw_Window.cxx +++ b/src/Xw/Xw_Window.cxx @@ -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; }