From 57d4e44bbef03d0bd31731b4f2da2eeee1aa5017 Mon Sep 17 00:00:00 2001 From: Henrik Hautakoski Date: Wed, 2 Aug 2023 05:19:15 +0200 Subject: [PATCH] source/Platform/Unix/X11Display.cpp: make getSize() query X11 and dont just return cached value. --- source/Platform/Unix/X11Display.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/source/Platform/Unix/X11Display.cpp b/source/Platform/Unix/X11Display.cpp index e8e5770..1f5144c 100644 --- a/source/Platform/Unix/X11Display.cpp +++ b/source/Platform/Unix/X11Display.cpp @@ -126,7 +126,20 @@ void X11Display::setSize(unsigned int width, unsigned int height) Vector2u X11Display::getSize() const { - return m_size; + int x, y; + unsigned int w, h, bw, d; + ::Display* disp = Xlib::getDisplay(); + ::Window ancestor = m_win; + ::Window root = DefaultRootWindow(disp); + + while (Xlib::getParentWindow(ancestor) != root) { + // Next window up (parent window). + ancestor = Xlib::getParentWindow(ancestor); + } + + ::XGetGeometry(disp, ancestor, &root, &x, &y, &w, &h, &bw, &d); + + return Vector2u(w, h); } void X11Display::setPosition(unsigned int x, unsigned int y)