mirror of
https://github.com/glfw/glfw.git
synced 2024-11-10 00:51:47 +00:00
Removed glfwSetWindowPos and glfwGetWindowPos
glfwGetWindowPos is superseded by glfwGetWindowParam() with GLFW_POSITION_X and GLFW_POSITION_Y as parameters. glfwSetWindowPos can easily lead to bad practices (moving windows around without the users consent), and has been replaced with the GLFW_POSITION_X/Y window hints that allow setting the window position for a newly created window.
This commit is contained in:
parent
c9f4dedd96
commit
424e7c7b53
@ -538,8 +538,6 @@ GLFWAPI void glfwDestroyWindow(GLFWwindow window);
|
|||||||
GLFWAPI void glfwSetWindowTitle(GLFWwindow window, const char* title);
|
GLFWAPI void glfwSetWindowTitle(GLFWwindow window, const char* title);
|
||||||
GLFWAPI void glfwGetWindowSize(GLFWwindow window, int* width, int* height);
|
GLFWAPI void glfwGetWindowSize(GLFWwindow window, int* width, int* height);
|
||||||
GLFWAPI void glfwSetWindowSize(GLFWwindow window, int width, int height);
|
GLFWAPI void glfwSetWindowSize(GLFWwindow window, int width, int height);
|
||||||
GLFWAPI void glfwGetWindowPos(GLFWwindow window, int* xpos, int* ypos);
|
|
||||||
GLFWAPI void glfwSetWindowPos(GLFWwindow window, int xpos, int ypos);
|
|
||||||
GLFWAPI void glfwIconifyWindow(GLFWwindow window);
|
GLFWAPI void glfwIconifyWindow(GLFWwindow window);
|
||||||
GLFWAPI void glfwRestoreWindow(GLFWwindow window);
|
GLFWAPI void glfwRestoreWindow(GLFWwindow window);
|
||||||
GLFWAPI void glfwShowWindow(GLFWwindow window);
|
GLFWAPI void glfwShowWindow(GLFWwindow window);
|
||||||
|
@ -1006,27 +1006,6 @@ void _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//========================================================================
|
|
||||||
// Set the window position
|
|
||||||
//========================================================================
|
|
||||||
|
|
||||||
void _glfwPlatformSetWindowPos(_GLFWwindow* window, int x, int y)
|
|
||||||
{
|
|
||||||
NSRect contentRect =
|
|
||||||
[window->NS.object contentRectForFrameRect:[window->NS.object frame]];
|
|
||||||
|
|
||||||
// We assume here that the client code wants to position the window within the
|
|
||||||
// screen the window currently occupies
|
|
||||||
NSRect screenRect = [[window->NS.object screen] visibleFrame];
|
|
||||||
contentRect.origin = NSMakePoint(screenRect.origin.x + x,
|
|
||||||
screenRect.origin.y + screenRect.size.height -
|
|
||||||
y - contentRect.size.height);
|
|
||||||
|
|
||||||
[window->NS.object setFrame:[window->NS.object frameRectForContentRect:contentRect]
|
|
||||||
display:YES];
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//========================================================================
|
//========================================================================
|
||||||
// Iconify the window
|
// Iconify the window
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
@ -294,7 +294,6 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window, const _GLFWwndconfig* wndcon
|
|||||||
void _glfwPlatformDestroyWindow(_GLFWwindow* window);
|
void _glfwPlatformDestroyWindow(_GLFWwindow* window);
|
||||||
void _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char* title);
|
void _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char* title);
|
||||||
void _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height);
|
void _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height);
|
||||||
void _glfwPlatformSetWindowPos(_GLFWwindow* window, int x, int y);
|
|
||||||
void _glfwPlatformIconifyWindow(_GLFWwindow* window);
|
void _glfwPlatformIconifyWindow(_GLFWwindow* window);
|
||||||
void _glfwPlatformRestoreWindow(_GLFWwindow* window);
|
void _glfwPlatformRestoreWindow(_GLFWwindow* window);
|
||||||
void _glfwPlatformShowWindow(_GLFWwindow* window);
|
void _glfwPlatformShowWindow(_GLFWwindow* window);
|
||||||
|
@ -1058,23 +1058,6 @@ void _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//========================================================================
|
|
||||||
// Set the window position
|
|
||||||
//========================================================================
|
|
||||||
|
|
||||||
void _glfwPlatformSetWindowPos(_GLFWwindow* window, int x, int y)
|
|
||||||
{
|
|
||||||
RECT rect;
|
|
||||||
|
|
||||||
GetClientRect(window->Win32.handle, &rect);
|
|
||||||
AdjustWindowRectEx(&rect, window->Win32.dwStyle, FALSE, window->Win32.dwExStyle);
|
|
||||||
|
|
||||||
SetWindowPos(window->Win32.handle, HWND_TOP,
|
|
||||||
x + rect.left, y + rect.top, 0, 0,
|
|
||||||
SWP_NOOWNERZORDER | SWP_NOSIZE | SWP_NOZORDER);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//========================================================================
|
//========================================================================
|
||||||
// Window iconification
|
// Window iconification
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
46
src/window.c
46
src/window.c
@ -598,52 +598,6 @@ GLFWAPI void glfwSetWindowSize(GLFWwindow handle, int width, int height)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//========================================================================
|
|
||||||
// Get the window position
|
|
||||||
//========================================================================
|
|
||||||
|
|
||||||
GLFWAPI void glfwGetWindowPos(GLFWwindow handle, int* xpos, int* ypos)
|
|
||||||
{
|
|
||||||
_GLFWwindow* window = (_GLFWwindow*) handle;
|
|
||||||
|
|
||||||
if (!_glfwInitialized)
|
|
||||||
{
|
|
||||||
_glfwSetError(GLFW_NOT_INITIALIZED, NULL);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (xpos != NULL)
|
|
||||||
*xpos = window->positionX;
|
|
||||||
|
|
||||||
if (ypos != NULL)
|
|
||||||
*ypos = window->positionY;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//========================================================================
|
|
||||||
// Set the window position
|
|
||||||
//========================================================================
|
|
||||||
|
|
||||||
GLFWAPI void glfwSetWindowPos(GLFWwindow handle, int xpos, int ypos)
|
|
||||||
{
|
|
||||||
_GLFWwindow* window = (_GLFWwindow*) handle;
|
|
||||||
|
|
||||||
if (!_glfwInitialized)
|
|
||||||
{
|
|
||||||
_glfwSetError(GLFW_NOT_INITIALIZED, NULL);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (window->mode == GLFW_FULLSCREEN || window->iconified)
|
|
||||||
{
|
|
||||||
// TODO: Figure out if this is an error
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
_glfwPlatformSetWindowPos(window, xpos, ypos);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//========================================================================
|
//========================================================================
|
||||||
// Window iconification
|
// Window iconification
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
@ -1012,16 +1012,6 @@ void _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//========================================================================
|
|
||||||
// Set the window position.
|
|
||||||
//========================================================================
|
|
||||||
|
|
||||||
void _glfwPlatformSetWindowPos(_GLFWwindow* window, int x, int y)
|
|
||||||
{
|
|
||||||
XMoveWindow(_glfwLibrary.X11.display, window->X11.handle, x, y);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//========================================================================
|
//========================================================================
|
||||||
// Window iconification
|
// Window iconification
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
Loading…
Reference in New Issue
Block a user