From 4fa80a0aec7ae2c445668ddf58820fff9d890d99 Mon Sep 17 00:00:00 2001 From: nimetu Date: Fri, 18 Mar 2022 14:45:38 +0200 Subject: [PATCH] Fix getCurrentScreenMode() when no window has been created yet --- .../3d/driver/opengl/driver_opengl_window.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/nel/src/3d/driver/opengl/driver_opengl_window.cpp b/nel/src/3d/driver/opengl/driver_opengl_window.cpp index 33b9807ed..4fe1f6507 100644 --- a/nel/src/3d/driver/opengl/driver_opengl_window.cpp +++ b/nel/src/3d/driver/opengl/driver_opengl_window.cpp @@ -2485,13 +2485,19 @@ bool CDriverGL::getCurrentScreenMode(GfxMode &mode) Window child; // get window position so we can compare monitors (or mouse position if window not visible yet) - XWindowAttributes xwa; - XGetWindowAttributes(_dpy, _win, &xwa); - if (xwa.map_state != IsUnmapped) + bool useMouseForPosition = true; + if (_win != EmptyWindow) { - XTranslateCoordinates(_dpy, _win, xwa.root, xwa.x, xwa.y, &x, &y, &child); + XWindowAttributes xwa; + XGetWindowAttributes(_dpy, _win, &xwa); + if (xwa.map_state != IsUnmapped) + { + XTranslateCoordinates(_dpy, _win, xwa.root, xwa.x, xwa.y, &x, &y, &child); + useMouseForPosition = false; + } } - else + + if (useMouseForPosition) { sint rx, ry, wx, wy; uint mask;