From 6df4bfa96ce57173467ccd1803ac097848946435 Mon Sep 17 00:00:00 2001 From: kervala Date: Sun, 1 Aug 2010 09:32:12 +0200 Subject: [PATCH] Fixed: #1046 XConfigureNotify window position different from XMoveWindow --- .../src/3d/driver/opengl/driver_opengl.cpp | 3 ++ code/nel/src/3d/driver/opengl/driver_opengl.h | 2 + .../3d/driver/opengl/driver_opengl_window.cpp | 45 ++++++++++++++++--- 3 files changed, 45 insertions(+), 5 deletions(-) diff --git a/code/nel/src/3d/driver/opengl/driver_opengl.cpp b/code/nel/src/3d/driver/opengl/driver_opengl.cpp index 46da2b0ef..ab6552980 100644 --- a/code/nel/src/3d/driver/opengl/driver_opengl.cpp +++ b/code/nel/src/3d/driver/opengl/driver_opengl.cpp @@ -207,6 +207,9 @@ CDriverGL::CDriverGL() _win = EmptyWindow; _DestroyWindow = false; + _DecorationWidth = 0; + _DecorationHeight = 0; + _OffScreen = false; _FullScreen = false; _Resizable = false; diff --git a/code/nel/src/3d/driver/opengl/driver_opengl.h b/code/nel/src/3d/driver/opengl/driver_opengl.h index c4ed12412..5f68116fc 100644 --- a/code/nel/src/3d/driver/opengl/driver_opengl.h +++ b/code/nel/src/3d/driver/opengl/driver_opengl.h @@ -681,6 +681,8 @@ private: nlWindow _win; bool _DestroyWindow; + sint32 _DecorationWidth; + sint32 _DecorationHeight; #ifdef NL_OS_WINDOWS diff --git a/code/nel/src/3d/driver/opengl/driver_opengl_window.cpp b/code/nel/src/3d/driver/opengl/driver_opengl_window.cpp index ff08d7e27..13af0b090 100644 --- a/code/nel/src/3d/driver/opengl/driver_opengl_window.cpp +++ b/code/nel/src/3d/driver/opengl/driver_opengl_window.cpp @@ -175,12 +175,40 @@ bool GlWndProc(CDriverGL *driver, XEvent &e) } break; + case MapNotify: + driver->_WndActive = true; + break; + + case UnmapNotify: + driver->_WndActive = false; + break; + + case Expose: + nlwarning("Expose event"); + break; + case ConfigureNotify: - driver->_WindowWidth = e.xconfigure.width; - driver->_WindowHeight = e.xconfigure.height; - driver->_WindowX = e.xconfigure.x; - driver->_WindowY = e.xconfigure.y; + if (!driver->_FullScreen && driver->_WndActive) + { + // first time setting decoration sizes + if ((driver->_DecorationWidth == -1) || (driver->_DecorationWidth == 0)) + { + driver->_DecorationWidth = e.xconfigure.x - driver->_WindowX; + driver->_DecorationHeight = e.xconfigure.y - driver->_WindowY; + + nlwarning("Decoration size x = %d, y = %d", driver->_DecorationWidth, driver->_DecorationHeight); + } + + driver->_WindowWidth = e.xconfigure.width; + driver->_WindowHeight = e.xconfigure.height; + driver->_WindowX = e.xconfigure.x - driver->_DecorationWidth; + driver->_WindowY = e.xconfigure.y - driver->_DecorationHeight; + + XConfigureEvent event = e.xconfigure; + + nlwarning("Configure x = %d, y = %d, width = %d, height = %d, send event = %d", event.x, event.y, event.width, event.height, event.send_event); + } break; @@ -1802,7 +1830,7 @@ void CDriverGL::setWindowPos(sint32 x, sint32 y) _WindowX = x; _WindowY = y; - if (_win == EmptyWindow) + if (_win == EmptyWindow || _FullScreen) return; #ifdef NL_OS_WINDOWS @@ -1815,6 +1843,13 @@ void CDriverGL::setWindowPos(sint32 x, sint32 y) #elif defined (NL_OS_UNIX) + // first time requesting decoration sizes + if (_WindowX && _WindowY && !_DecorationWidth && !_DecorationHeight && _WndActive) + { + _DecorationWidth = -1; + _DecorationHeight = -1; + } + XMoveWindow(_dpy, _win, x, y); #endif // NL_OS_WINDOWS