From 0d1dd82b890e44d770ea18dba213d5814d13d089 Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Mon, 14 Mar 2016 20:39:27 +0100 Subject: [PATCH] Move X11 PPosition hack to glfwSetWindowPos --- src/x11_window.c | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/src/x11_window.c b/src/x11_window.c index 03cc3749..dfcbd387 100644 --- a/src/x11_window.c +++ b/src/x11_window.c @@ -446,14 +446,6 @@ static GLFWbool createWindow(_GLFWwindow* window, hints->flags |= PPosition; _glfwPlatformGetMonitorPos(wndconfig->monitor, &hints->x, &hints->y); } - else - { - // HACK: Explicitly setting PPosition to any value causes some WMs, - // notably Compiz and Metacity, to honor the position of - // unmapped windows set by XMoveWindow - hints->flags |= PPosition; - hints->x = hints->y = 0; - } if (!wndconfig->resizable) { @@ -1615,6 +1607,24 @@ void _glfwPlatformGetWindowPos(_GLFWwindow* window, int* xpos, int* ypos) void _glfwPlatformSetWindowPos(_GLFWwindow* window, int xpos, int ypos) { + // HACK: Explicitly setting PPosition to any value causes some WMs, notably + // Compiz and Metacity, to honor the position of unmapped windows + if (!_glfwPlatformWindowVisible(window)) + { + long supplied; + XSizeHints* hints = XAllocSizeHints(); + + if (XGetWMNormalHints(_glfw.x11.display, window->x11.handle, hints, &supplied)) + { + hints->flags |= PPosition; + hints->x = hints->y = 0; + + XSetWMNormalHints(_glfw.x11.display, window->x11.handle, hints); + } + + XFree(hints); + } + XMoveWindow(_glfw.x11.display, window->x11.handle, xpos, ypos); XFlush(_glfw.x11.display); }