mirror of
https://github.com/glfw/glfw.git
synced 2026-09-22 08:50:15 +00:00
Added glfwGetWindowPos.
This commit is contained in:
@@ -157,6 +157,7 @@ typedef struct _GLFWwindow
|
||||
GLboolean iconified; // GL_TRUE if this window is iconified
|
||||
GLboolean closed; // GL_TRUE if this window should be closed
|
||||
int width, height;
|
||||
int positionX, positionY;
|
||||
int mode; // GLFW_WINDOW or GLFW_FULLSCREEN
|
||||
GLboolean sysKeysDisabled; // system keys disabled flag
|
||||
GLboolean windowNoResize; // resize- and maximize gadgets disabled flag
|
||||
|
||||
@@ -906,6 +906,9 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
|
||||
|
||||
case WM_MOVE:
|
||||
{
|
||||
window->positionX = LOWORD(lParam);
|
||||
window->positionY = HIWORD(lParam);
|
||||
|
||||
// If the mouse is locked, update the clipping rect
|
||||
if (window == _glfwLibrary.cursorLockWindow)
|
||||
{
|
||||
|
||||
@@ -807,6 +807,26 @@ GLFWAPI void glfwSetWindowSize(GLFWwindow window, int width, int height)
|
||||
}
|
||||
|
||||
|
||||
//========================================================================
|
||||
// Get the window position
|
||||
//========================================================================
|
||||
|
||||
GLFWAPI void glfwGetWindowPos(GLFWwindow window, int* x, int* y)
|
||||
{
|
||||
if (!_glfwInitialized)
|
||||
{
|
||||
_glfwSetError(GLFW_NOT_INITIALIZED);
|
||||
return;
|
||||
}
|
||||
|
||||
if (x != NULL)
|
||||
*x = window->positionX;
|
||||
|
||||
if (y != NULL)
|
||||
*y = window->positionY;
|
||||
}
|
||||
|
||||
|
||||
//========================================================================
|
||||
// Set the window position
|
||||
//========================================================================
|
||||
|
||||
@@ -1215,6 +1215,14 @@ static void processSingleEvent(void)
|
||||
window->height);
|
||||
}
|
||||
}
|
||||
|
||||
if (event.xconfigure.x != window->positionX ||
|
||||
event.xconfigure.y != window->positionY)
|
||||
{
|
||||
window->positionX = event.xconfigure.x;
|
||||
window->positionY = event.xconfigure.y;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user