Unified nomenclature for cursor positions.

This commit is contained in:
Camilla Berglund
2012-06-22 13:53:02 +02:00
parent e6896a499c
commit cef9dea1d2
14 changed files with 102 additions and 101 deletions
+3 -3
View File
@@ -1152,12 +1152,12 @@ void _glfwPlatformWaitEvents( void )
//========================================================================
// Set physical mouse cursor position
// Set physical cursor position
//========================================================================
void _glfwPlatformSetMouseCursorPos(_GLFWwindow* window, int x, int y)
void _glfwPlatformSetCursorPos(_GLFWwindow* window, int x, int y)
{
// The library seems to assume that after calling this the mouse won't move,
// The library seems to assume that after calling this the cursor won't move,
// but obviously it will, and escape the app's window, and activate other apps,
// and other badness in pain. I think the API's just silly, but maybe I'm
// misunderstanding it...
+13 -13
View File
@@ -55,7 +55,7 @@ static void setCursorMode(_GLFWwindow* window, int newMode)
centerPosY = window->height / 2;
if (oldMode == GLFW_CURSOR_CAPTURED || newMode == GLFW_CURSOR_CAPTURED)
_glfwPlatformSetMouseCursorPos(window, centerPosX, centerPosY);
_glfwPlatformSetCursorPos(window, centerPosX, centerPosY);
_glfwPlatformSetCursorMode(window, newMode);
window->cursorMode = newMode;
@@ -249,11 +249,11 @@ void _glfwInputCursorMotion(_GLFWwindow* window, int x, int y)
window->cursorPosY = y;
}
if (_glfwLibrary.mousePosCallback)
if (_glfwLibrary.cursorPosCallback)
{
_glfwLibrary.mousePosCallback(window,
window->cursorPosX,
window->cursorPosY);
_glfwLibrary.cursorPosCallback(window,
window->cursorPosX,
window->cursorPosY);
}
}
@@ -412,7 +412,7 @@ GLFWAPI int glfwGetMouseButton(GLFWwindow handle, int button)
// Returns the last reported cursor position for the specified window
//========================================================================
GLFWAPI void glfwGetMousePos(GLFWwindow handle, int* xpos, int* ypos)
GLFWAPI void glfwGetCursorPos(GLFWwindow handle, int* xpos, int* ypos)
{
_GLFWwindow* window = (_GLFWwindow*) handle;
@@ -435,7 +435,7 @@ GLFWAPI void glfwGetMousePos(GLFWwindow handle, int* xpos, int* ypos)
// the specified window
//========================================================================
GLFWAPI void glfwSetMousePos(GLFWwindow handle, int xpos, int ypos)
GLFWAPI void glfwSetCursorPos(GLFWwindow handle, int xpos, int ypos)
{
_GLFWwindow* window = (_GLFWwindow*) handle;
@@ -451,11 +451,11 @@ GLFWAPI void glfwSetMousePos(GLFWwindow handle, int xpos, int ypos)
return;
}
// Don't do anything if the mouse position did not change
// Don't do anything if the cursor position did not change
if (xpos == window->cursorPosX && ypos == window->cursorPosY)
return;
// Set GLFW mouse position
// Set GLFW cursor position
window->cursorPosX = xpos;
window->cursorPosY = ypos;
@@ -464,7 +464,7 @@ GLFWAPI void glfwSetMousePos(GLFWwindow handle, int xpos, int ypos)
return;
// Update physical cursor position
_glfwPlatformSetMouseCursorPos(window, xpos, ypos);
_glfwPlatformSetCursorPos(window, xpos, ypos);
}
@@ -542,7 +542,7 @@ GLFWAPI void glfwSetMouseButtonCallback(GLFWmousebuttonfun cbfun)
// Set callback function for mouse moves
//========================================================================
GLFWAPI void glfwSetMousePosCallback(GLFWmouseposfun cbfun)
GLFWAPI void glfwSetCursorPosCallback(GLFWcursorposfun cbfun)
{
if (!_glfwInitialized)
{
@@ -550,10 +550,10 @@ GLFWAPI void glfwSetMousePosCallback(GLFWmouseposfun cbfun)
return;
}
_glfwLibrary.mousePosCallback = cbfun;
_glfwLibrary.cursorPosCallback = cbfun;
// Call the callback function to let the application know the current
// mouse position
// cursor position
if (cbfun)
{
_GLFWwindow* window;
+2 -2
View File
@@ -241,7 +241,7 @@ struct _GLFWlibrary
GLFWwindowfocusfun windowFocusCallback;
GLFWwindowiconifyfun windowIconifyCallback;
GLFWmousebuttonfun mouseButtonCallback;
GLFWmouseposfun mousePosCallback;
GLFWcursorposfun cursorPosCallback;
GLFWcursorenterfun cursorEnterCallback;
GLFWscrollfun scrollCallback;
GLFWkeyfun keyCallback;
@@ -284,7 +284,7 @@ const char* _glfwPlatformGetVersionString(void);
// Input
void _glfwPlatformEnableSystemKeys(_GLFWwindow* window);
void _glfwPlatformDisableSystemKeys(_GLFWwindow* window);
void _glfwPlatformSetMouseCursorPos(_GLFWwindow* window, int x, int y);
void _glfwPlatformSetCursorPos(_GLFWwindow* window, int x, int y);
void _glfwPlatformSetCursorMode(_GLFWwindow* window, int mode);
// Fullscreen
+1 -1
View File
@@ -165,7 +165,7 @@ typedef struct _GLFWwindowWin32
int desiredRefreshRate; // Desired vertical monitor refresh rate
GLboolean cursorCentered;
GLboolean cursorInside;
int oldMouseX, oldMouseY;
int oldCursorX, oldCursorY;
} _GLFWwindowWin32;
+32 -32
View File
@@ -449,7 +449,7 @@ static GLboolean createContext(_GLFWwindow* window,
// Hide mouse cursor
//========================================================================
static void hideMouseCursor(_GLFWwindow* window)
static void hideCursor(_GLFWwindow* window)
{
}
@@ -458,7 +458,7 @@ static void hideMouseCursor(_GLFWwindow* window)
// Capture mouse cursor
//========================================================================
static void captureMouseCursor(_GLFWwindow* window)
static void captureCursor(_GLFWwindow* window)
{
RECT ClipWindowRect;
@@ -477,7 +477,7 @@ static void captureMouseCursor(_GLFWwindow* window)
// Show mouse cursor
//========================================================================
static void showMouseCursor(_GLFWwindow* window)
static void showCursor(_GLFWwindow* window)
{
// Un-capture cursor
ReleaseCapture();
@@ -784,7 +784,7 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
// The window was deactivated (or iconified, see above)
if (window->cursorMode == GLFW_CURSOR_CAPTURED)
showMouseCursor(window);
showCursor(window);
if (window->mode == GLFW_FULLSCREEN)
{
@@ -807,7 +807,7 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
// The window was activated
if (window->cursorMode == GLFW_CURSOR_CAPTURED)
captureMouseCursor(window);
captureCursor(window);
if (window->mode == GLFW_FULLSCREEN)
{
@@ -962,14 +962,14 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
case WM_MOUSEMOVE:
{
int newMouseX, newMouseY;
int newCursorX, newCursorY;
// Get signed (!) mouse position
newMouseX = (int)((short)LOWORD(lParam));
newMouseY = (int)((short)HIWORD(lParam));
// Get signed (!) cursor position
newCursorX = (int)((short)LOWORD(lParam));
newCursorY = (int)((short)HIWORD(lParam));
if (newMouseX != window->Win32.oldMouseX ||
newMouseY != window->Win32.oldMouseY)
if (newCursorX != window->Win32.oldCursorX ||
newCursorY != window->Win32.oldCursorY)
{
int x, y;
@@ -978,17 +978,17 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
if (_glfwLibrary.activeWindow != window)
return 0;
x = newMouseX - window->Win32.oldMouseX;
y = newMouseY - window->Win32.oldMouseY;
x = newCursorX - window->Win32.oldCursorX;
y = newCursorY - window->Win32.oldCursorY;
}
else
{
x = newMouseX;
y = newMouseY;
x = newCursorX;
y = newCursorY;
}
window->Win32.oldMouseX = newMouseX;
window->Win32.oldMouseY = newMouseY;
window->Win32.oldCursorX = newCursorX;
window->Win32.oldCursorY = newCursorY;
window->Win32.cursorCentered = GL_FALSE;
_glfwInputCursorMotion(window, x, y);
@@ -1372,11 +1372,11 @@ static int createWindow(_GLFWwindow* window,
initWGLExtensions(window);
// Initialize mouse position data
// Initialize cursor position data
GetCursorPos(&pos);
ScreenToClient(window->Win32.handle, &pos);
window->Win32.oldMouseX = window->cursorPosX = pos.x;
window->Win32.oldMouseY = window->cursorPosY = pos.y;
window->Win32.oldCursorX = window->cursorPosX = pos.x;
window->Win32.oldCursorY = window->cursorPosY = pos.y;
return GL_TRUE;
}
@@ -1782,13 +1782,13 @@ void _glfwPlatformPollEvents(void)
if (window)
{
window->Win32.cursorCentered = GL_FALSE;
window->Win32.oldMouseX = window->width / 2;
window->Win32.oldMouseY = window->height / 2;
window->Win32.oldCursorX = window->width / 2;
window->Win32.oldCursorY = window->height / 2;
}
else
{
//window->Win32.oldMouseX = window->cursorPosX;
//window->Win32.oldMouseY = window->cursorPosY;
//window->Win32.oldCursorX = window->cursorPosX;
//window->Win32.oldCursorY = window->cursorPosY;
}
while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
@@ -1845,9 +1845,9 @@ void _glfwPlatformPollEvents(void)
if (window->cursorMode == GLFW_CURSOR_CAPTURED &&
!window->Win32.cursorCentered)
{
_glfwPlatformSetMouseCursorPos(window,
window->width / 2,
window->height / 2);
_glfwPlatformSetCursorPos(window,
window->width / 2,
window->height / 2);
window->Win32.cursorCentered = GL_TRUE;
}
}
@@ -1867,10 +1867,10 @@ void _glfwPlatformWaitEvents(void)
//========================================================================
// Set physical mouse cursor position
// Set physical cursor position
//========================================================================
void _glfwPlatformSetMouseCursorPos(_GLFWwindow* window, int x, int y)
void _glfwPlatformSetCursorPos(_GLFWwindow* window, int x, int y)
{
POINT pos;
@@ -1892,13 +1892,13 @@ void _glfwPlatformSetCursorMode(_GLFWwindow* window, int mode)
switch (mode)
{
case GLFW_CURSOR_NORMAL:
showMouseCursor(window);
showCursor(window);
break;
case GLFW_CURSOR_HIDDEN:
hideMouseCursor(window);
hideCursor(window);
break;
case GLFW_CURSOR_CAPTURED:
captureMouseCursor(window);
captureCursor(window);
break;
}
}
+26 -26
View File
@@ -251,10 +251,10 @@ static GLboolean createWindow(_GLFWwindow* window,
//========================================================================
// Hide mouse cursor
// Hide cursor
//========================================================================
static void hideMouseCursor(_GLFWwindow* window)
static void hideCursor(_GLFWwindow* window)
{
if (!window->X11.cursorHidden)
{
@@ -267,12 +267,12 @@ static void hideMouseCursor(_GLFWwindow* window)
//========================================================================
// Capture mouse cursor
// Capture cursor
//========================================================================
static void captureMouseCursor(_GLFWwindow* window)
static void captureCursor(_GLFWwindow* window)
{
hideMouseCursor(window);
hideCursor(window);
if (!window->X11.cursorGrabbed)
{
@@ -290,13 +290,13 @@ static void captureMouseCursor(_GLFWwindow* window)
//========================================================================
// Show mouse cursor
// Show cursor
//========================================================================
static void showMouseCursor(_GLFWwindow* window)
static void showCursor(_GLFWwindow* window)
{
// Un-grab cursor (only in windowed mode: in fullscreen mode we still
// want the mouse grabbed in order to confine the cursor to the window
// want the cursor grabbed in order to confine the cursor to the window
// area)
if (window->X11.cursorGrabbed)
{
@@ -401,7 +401,7 @@ static void enterFullscreenMode(_GLFWwindow* window)
}
// HACK: Try to get window inside viewport (for virtual displays) by moving
// the mouse cursor to the upper left corner (and then to the center)
// the cursor to the upper left corner (and then to the center)
// This hack should be harmless on saner systems as well
XWarpPointer(_glfwLibrary.X11.display, None, window->X11.handle, 0,0,0,0, 0,0);
XWarpPointer(_glfwLibrary.X11.display, None, window->X11.handle, 0,0,0,0,
@@ -615,7 +615,7 @@ static void processSingleEvent(void)
case EnterNotify:
{
// The mouse cursor enters the Window
// The cursor entered the window
window = findWindow(event.xcrossing.window);
if (window == NULL)
{
@@ -624,7 +624,7 @@ static void processSingleEvent(void)
}
if (window->cursorMode == GLFW_CURSOR_HIDDEN)
hideMouseCursor(window);
hideCursor(window);
_glfwInputCursorEnter(window, GL_TRUE);
break;
@@ -632,7 +632,7 @@ static void processSingleEvent(void)
case LeaveNotify:
{
// The mouse cursor leave the Window
// The cursor left the window
window = findWindow(event.xcrossing.window);
if (window == NULL)
{
@@ -641,7 +641,7 @@ static void processSingleEvent(void)
}
if (window->cursorMode == GLFW_CURSOR_HIDDEN)
showMouseCursor(window);
showCursor(window);
_glfwInputCursorEnter(window, GL_FALSE);
break;
@@ -649,7 +649,7 @@ static void processSingleEvent(void)
case MotionNotify:
{
// The mouse cursor was moved
// The cursor was moved
window = findWindow(event.xmotion.window);
if (window == NULL)
{
@@ -660,7 +660,7 @@ static void processSingleEvent(void)
if (event.xmotion.x != window->X11.cursorPosX ||
event.xmotion.y != window->X11.cursorPosY)
{
// The mouse cursor was moved and we didn't do it
// The cursor was moved and we didn't do it
int x, y;
if (window->cursorMode == GLFW_CURSOR_CAPTURED)
@@ -783,7 +783,7 @@ static void processSingleEvent(void)
_glfwInputWindowFocus(window, GL_TRUE);
if (window->cursorMode == GLFW_CURSOR_CAPTURED)
captureMouseCursor(window);
captureCursor(window);
break;
}
@@ -801,7 +801,7 @@ static void processSingleEvent(void)
_glfwInputWindowFocus(window, GL_FALSE);
if (window->cursorMode == GLFW_CURSOR_CAPTURED)
showMouseCursor(window);
showCursor(window);
break;
}
@@ -1197,9 +1197,9 @@ void _glfwPlatformPollEvents(void)
if (window->cursorMode == GLFW_CURSOR_CAPTURED &&
!window->X11.cursorCentered)
{
_glfwPlatformSetMouseCursorPos(window,
window->width / 2,
window->height / 2);
_glfwPlatformSetCursorPos(window,
window->width / 2,
window->height / 2);
window->X11.cursorCentered = GL_TRUE;
// NOTE: This is a temporary fix. It works as long as you use
@@ -1228,10 +1228,10 @@ void _glfwPlatformWaitEvents(void)
//========================================================================
// Set physical mouse cursor position
// Set physical cursor position
//========================================================================
void _glfwPlatformSetMouseCursorPos(_GLFWwindow* window, int x, int y)
void _glfwPlatformSetCursorPos(_GLFWwindow* window, int x, int y)
{
// Store the new position so we can recognise it later
window->X11.cursorPosX = x;
@@ -1242,7 +1242,7 @@ void _glfwPlatformSetMouseCursorPos(_GLFWwindow* window, int x, int y)
//========================================================================
// Set physical mouse cursor mode
// Set physical cursor mode
//========================================================================
void _glfwPlatformSetCursorMode(_GLFWwindow* window, int mode)
@@ -1250,13 +1250,13 @@ void _glfwPlatformSetCursorMode(_GLFWwindow* window, int mode)
switch (mode)
{
case GLFW_CURSOR_NORMAL:
showMouseCursor(window);
showCursor(window);
break;
case GLFW_CURSOR_HIDDEN:
hideMouseCursor(window);
hideCursor(window);
break;
case GLFW_CURSOR_CAPTURED:
captureMouseCursor(window);
captureCursor(window);
break;
}
}