Fixed initial window position and size for hidden windows on X11.

This commit is contained in:
assassini 2013-11-03 10:08:01 +02:00
parent eabbb20d17
commit 6a7935b65e
2 changed files with 28 additions and 9 deletions

View File

@ -1363,10 +1363,6 @@ GLFWAPI void glfwGetWindowPos(GLFWwindow* window, int* xpos, int* ypos);
*
* @note The window manager may put limits on what positions are allowed.
*
* @bug **X11:** Some window managers ignore the set position of hidden (i.e.
* unmapped) windows, instead placing them where it thinks is appropriate once
* they are shown.
*
* @sa glfwGetWindowPos
*
* @ingroup window

View File

@ -1033,6 +1033,20 @@ void _glfwPlatformGetWindowPos(_GLFWwindow* window, int* xpos, int* ypos)
void _glfwPlatformSetWindowPos(_GLFWwindow* window, int xpos, int ypos)
{
XSizeHints* hints = XAllocSizeHints();
long flags;
XGetWMNormalHints(_glfw.x11.display, window->x11.handle, hints, &flags);
// Tell the window manager that we want to decide the initial position in case the window isn't open yet
hints->flags |= (PPosition | USPosition);
hints->x = xpos;
hints->y = ypos;
XSetWMNormalHints(_glfw.x11.display, window->x11.handle, hints);
XFree(hints);
XMoveWindow(_glfw.x11.display, window->x11.handle, xpos, ypos);
XFlush(_glfw.x11.display);
}
@ -1064,20 +1078,29 @@ void _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height)
}
else
{
XSizeHints* hints = XAllocSizeHints();
long flags;
XGetWMNormalHints(_glfw.x11.display, window->x11.handle, hints, &flags);
// Tell the window manager that we want to decide the initial size in case the window isn't open yet
hints->flags |= (PSize | USSize);
hints->width = width;
hints->height = height;
if (!window->resizable)
{
// Update window size restrictions to match new window size
XSizeHints* hints = XAllocSizeHints();
hints->flags |= (PMinSize | PMaxSize);
hints->min_width = hints->max_width = width;
hints->min_height = hints->max_height = height;
XSetWMNormalHints(_glfw.x11.display, window->x11.handle, hints);
XFree(hints);
}
XSetWMNormalHints(_glfw.x11.display, window->x11.handle, hints);
XFree(hints);
XResizeWindow(_glfw.x11.display, window->x11.handle, width, height);
}