Added glfwGetWindowPos.

This commit is contained in:
Camilla Berglund 2010-09-14 03:53:22 +02:00
parent f0033aa47f
commit 318f731e3e
6 changed files with 34 additions and 0 deletions

View File

@ -418,6 +418,7 @@ GLFWAPI void glfwCloseWindow(GLFWwindow window);
GLFWAPI void glfwSetWindowTitle(GLFWwindow, const char* title);
GLFWAPI void glfwGetWindowSize(GLFWwindow, int* width, int* height);
GLFWAPI void glfwSetWindowSize(GLFWwindow, int width, int height);
GLFWAPI void glfwGetWindowPos(GLFWwindow, int* x, int* y);
GLFWAPI void glfwSetWindowPos(GLFWwindow, int x, int y);
GLFWAPI void glfwIconifyWindow(GLFWwindow window);
GLFWAPI void glfwRestoreWindow(GLFWwindow window);

View File

@ -267,6 +267,7 @@ version of GLFW.</p>
<li>Added <code>glfwGetError</code> and <code>glfwErrorString</code> error reporting functions and a number of error tokens</li>
<li>Added <code>glfwSetWindowUserPointer</code> and <code>glfwGetWindowUserPointer</code> functions for per-window user pointers</li>
<li>Added <code>glfwGetVersionString</code> function for determining which code paths were enabled at compile time</li>
<li>Added <code>glfwGetWindowPos</code> function for querying the position of the specified window</li>
<li>Added <code>windows</code> simple multi-window test program</li>
<li>Added initial window title parameter to <code>glfwOpenWindow</code></li>
<li>Changed buffer bit depth parameters of <code>glfwOpenWindow</code> to window hints</li>

View File

@ -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

View File

@ -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)
{

View File

@ -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
//========================================================================

View File

@ -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;
}