Unified nomenclature for cursor positions.
diff --git a/examples/splitview.c b/examples/splitview.c index 0f27d32..c584f9a 100644 --- a/examples/splitview.c +++ b/examples/splitview.c
@@ -379,7 +379,7 @@ // Mouse position callback function //======================================================================== -static void mousePosFun(GLFWwindow window, int x, int y) +static void cursorPosFun(GLFWwindow window, int x, int y) { // Depending on which view was selected, rotate around different axes switch (active_view) @@ -404,7 +404,7 @@ break; } - // Remember mouse position + // Remember cursor position xpos = x; ypos = y; } @@ -472,7 +472,7 @@ // Set callback functions glfwSetWindowSizeCallback(windowSizeFun); glfwSetWindowRefreshCallback(windowRefreshFun); - glfwSetMousePosCallback(mousePosFun); + glfwSetCursorPosCallback(cursorPosFun); glfwSetMouseButtonCallback(mouseButtonFun); // Main loop
diff --git a/examples/triangle.c b/examples/triangle.c index 0f6631d..ee34049 100644 --- a/examples/triangle.c +++ b/examples/triangle.c
@@ -39,7 +39,7 @@ do { double t = glfwGetTime(); - glfwGetMousePos(window, &x, NULL); + glfwGetCursorPos(window, &x, NULL); // Get window size (may be different than the requested size) glfwGetWindowSize(window, &width, &height);
diff --git a/examples/wave.c b/examples/wave.c index 44bae58..5457483 100644 --- a/examples/wave.c +++ b/examples/wave.c
@@ -323,10 +323,10 @@ //======================================================================== -// Callback function for mouse motion events +// Callback function for cursor motion events //======================================================================== -void mouse_position_callback(GLFWwindow window, int x, int y) +void cursor_position_callback(GLFWwindow window, int x, int y) { if (locked) { @@ -403,7 +403,7 @@ // Window resize handler glfwSetWindowSizeCallback(window_resize_callback); glfwSetMouseButtonCallback(mouse_button_callback); - glfwSetMousePosCallback(mouse_position_callback); + glfwSetCursorPosCallback(cursor_position_callback); glfwSetScrollCallback(scroll_callback); // Initialize OpenGL
diff --git a/include/GL/glfw3.h b/include/GL/glfw3.h index c77561b..28e38bd 100644 --- a/include/GL/glfw3.h +++ b/include/GL/glfw3.h
@@ -480,7 +480,7 @@ typedef void (* GLFWwindowfocusfun)(GLFWwindow,int); typedef void (* GLFWwindowiconifyfun)(GLFWwindow,int); typedef void (* GLFWmousebuttonfun)(GLFWwindow,int,int); -typedef void (* GLFWmouseposfun)(GLFWwindow,int,int); +typedef void (* GLFWcursorposfun)(GLFWwindow,int,int); typedef void (* GLFWcursorenterfun)(GLFWwindow,int); typedef void (* GLFWscrollfun)(GLFWwindow,double,double); typedef void (* GLFWkeyfun)(GLFWwindow,int,int); @@ -559,13 +559,13 @@ GLFWAPI void glfwSetInputMode(GLFWwindow window, int mode, int value); GLFWAPI int glfwGetKey(GLFWwindow window, int key); GLFWAPI int glfwGetMouseButton(GLFWwindow window, int button); -GLFWAPI void glfwGetMousePos(GLFWwindow window, int* xpos, int* ypos); -GLFWAPI void glfwSetMousePos(GLFWwindow window, int xpos, int ypos); +GLFWAPI void glfwGetCursorPos(GLFWwindow window, int* xpos, int* ypos); +GLFWAPI void glfwSetCursorPos(GLFWwindow window, int xpos, int ypos); GLFWAPI void glfwGetScrollOffset(GLFWwindow window, double* xoffset, double* yoffset); GLFWAPI void glfwSetKeyCallback(GLFWkeyfun cbfun); GLFWAPI void glfwSetCharCallback(GLFWcharfun cbfun); GLFWAPI void glfwSetMouseButtonCallback(GLFWmousebuttonfun cbfun); -GLFWAPI void glfwSetMousePosCallback(GLFWmouseposfun cbfun); +GLFWAPI void glfwSetCursorPosCallback(GLFWcursorposfun cbfun); GLFWAPI void glfwSetCursorEnterCallback(GLFWcursorenterfun cbfun); GLFWAPI void glfwSetScrollCallback(GLFWscrollfun cbfun);
diff --git a/readme.html b/readme.html index 086f18f..8982eae 100644 --- a/readme.html +++ b/readme.html
@@ -299,6 +299,7 @@ <li>Renamed <code>GLFW_BUILD_DLL</code> to <code>_GLFW_BUILD_DLL</code></li> <li>Renamed <code>version</code> test to <code>glfwinfo</code></li> <li>Renamed <code>GLFW_NO_GLU</code> to <code>GLFW_INCLUDE_GLU</code> and made it disabled by default</li> + <li>Renamed mouse position functions to cursor position equivalents</li> <li>Replaced ad hoc build system with CMake</li> <li>Replaced layout-dependent key codes with single, platform-independent set based on US layout</li> <li>Replaced mouse wheel interface with two-dimensional, floating point scrolling interface</li>
diff --git a/src/cocoa_window.m b/src/cocoa_window.m index b5231ec..2c7b842 100644 --- a/src/cocoa_window.m +++ b/src/cocoa_window.m
@@ -1152,12 +1152,12 @@ //======================================================================== -// 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...
diff --git a/src/input.c b/src/input.c index 90ada56..37da571 100644 --- a/src/input.c +++ b/src/input.c
@@ -55,7 +55,7 @@ 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 @@ 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 @@ // 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 @@ // 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 @@ 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 @@ return; // Update physical cursor position - _glfwPlatformSetMouseCursorPos(window, xpos, ypos); + _glfwPlatformSetCursorPos(window, xpos, ypos); } @@ -542,7 +542,7 @@ // Set callback function for mouse moves //======================================================================== -GLFWAPI void glfwSetMousePosCallback(GLFWmouseposfun cbfun) +GLFWAPI void glfwSetCursorPosCallback(GLFWcursorposfun cbfun) { if (!_glfwInitialized) { @@ -550,10 +550,10 @@ 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;
diff --git a/src/internal.h b/src/internal.h index ec2bab1..700b6c0 100644 --- a/src/internal.h +++ b/src/internal.h
@@ -241,7 +241,7 @@ GLFWwindowfocusfun windowFocusCallback; GLFWwindowiconifyfun windowIconifyCallback; GLFWmousebuttonfun mouseButtonCallback; - GLFWmouseposfun mousePosCallback; + GLFWcursorposfun cursorPosCallback; GLFWcursorenterfun cursorEnterCallback; GLFWscrollfun scrollCallback; GLFWkeyfun keyCallback; @@ -284,7 +284,7 @@ // 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
diff --git a/src/win32_platform.h b/src/win32_platform.h index e7b7b16..eeadbf2 100644 --- a/src/win32_platform.h +++ b/src/win32_platform.h
@@ -165,7 +165,7 @@ int desiredRefreshRate; // Desired vertical monitor refresh rate GLboolean cursorCentered; GLboolean cursorInside; - int oldMouseX, oldMouseY; + int oldCursorX, oldCursorY; } _GLFWwindowWin32;
diff --git a/src/win32_window.c b/src/win32_window.c index 4990be4..935767c 100755 --- a/src/win32_window.c +++ b/src/win32_window.c
@@ -449,7 +449,7 @@ // Hide mouse cursor //======================================================================== -static void hideMouseCursor(_GLFWwindow* window) +static void hideCursor(_GLFWwindow* window) { } @@ -458,7 +458,7 @@ // Capture mouse cursor //======================================================================== -static void captureMouseCursor(_GLFWwindow* window) +static void captureCursor(_GLFWwindow* window) { RECT ClipWindowRect; @@ -477,7 +477,7 @@ // Show mouse cursor //======================================================================== -static void showMouseCursor(_GLFWwindow* window) +static void showCursor(_GLFWwindow* window) { // Un-capture cursor ReleaseCapture(); @@ -784,7 +784,7 @@ // 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 @@ // The window was activated if (window->cursorMode == GLFW_CURSOR_CAPTURED) - captureMouseCursor(window); + captureCursor(window); if (window->mode == GLFW_FULLSCREEN) { @@ -962,14 +962,14 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ //======================================================================== -// 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 @@ 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; } }
diff --git a/src/x11_window.c b/src/x11_window.c index 9ec5449..84b6f7d 100644 --- a/src/x11_window.c +++ b/src/x11_window.c
@@ -251,10 +251,10 @@ //======================================================================== -// Hide mouse cursor +// Hide cursor //======================================================================== -static void hideMouseCursor(_GLFWwindow* window) +static void hideCursor(_GLFWwindow* window) { if (!window->X11.cursorHidden) { @@ -267,12 +267,12 @@ //======================================================================== -// 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 @@ //======================================================================== -// 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 @@ } // 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 @@ 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 @@ } if (window->cursorMode == GLFW_CURSOR_HIDDEN) - hideMouseCursor(window); + hideCursor(window); _glfwInputCursorEnter(window, GL_TRUE); break; @@ -632,7 +632,7 @@ 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 @@ } if (window->cursorMode == GLFW_CURSOR_HIDDEN) - showMouseCursor(window); + showCursor(window); _glfwInputCursorEnter(window, GL_FALSE); break; @@ -649,7 +649,7 @@ case MotionNotify: { - // The mouse cursor was moved + // The cursor was moved window = findWindow(event.xmotion.window); if (window == NULL) { @@ -660,7 +660,7 @@ 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 @@ _glfwInputWindowFocus(window, GL_TRUE); if (window->cursorMode == GLFW_CURSOR_CAPTURED) - captureMouseCursor(window); + captureCursor(window); break; } @@ -801,7 +801,7 @@ _glfwInputWindowFocus(window, GL_FALSE); if (window->cursorMode == GLFW_CURSOR_CAPTURED) - showMouseCursor(window); + showCursor(window); break; } @@ -1197,9 +1197,9 @@ 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 @@ //======================================================================== -// 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 @@ //======================================================================== -// Set physical mouse cursor mode +// Set physical cursor mode //======================================================================== void _glfwPlatformSetCursorMode(_GLFWwindow* window, int mode) @@ -1250,13 +1250,13 @@ 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; } }
diff --git a/tests/accuracy.c b/tests/accuracy.c index ae57298..cfb7027 100644 --- a/tests/accuracy.c +++ b/tests/accuracy.c
@@ -50,7 +50,7 @@ gluOrtho2D(0.f, window_width, 0.f, window_height); } -static void mouse_position_callback(GLFWwindow window, int x, int y) +static void cursor_position_callback(GLFWwindow window, int x, int y) { cursor_x = x; cursor_y = y; @@ -75,7 +75,7 @@ exit(EXIT_FAILURE); } - glfwSetMousePosCallback(mouse_position_callback); + glfwSetCursorPosCallback(cursor_position_callback); glfwSetWindowSizeCallback(window_size_callback); glfwSwapInterval(1);
diff --git a/tests/events.c b/tests/events.c index cc79da6..8ab5426 100644 --- a/tests/events.c +++ b/tests/events.c
@@ -270,9 +270,9 @@ printf(" was %s\n", get_action_name(action)); } -static void mouse_position_callback(GLFWwindow window, int x, int y) +static void cursor_position_callback(GLFWwindow window, int x, int y) { - printf("%08x at %0.3f: Mouse position: %i %i\n", counter++, glfwGetTime(), x, y); + printf("%08x at %0.3f: Cursor position: %i %i\n", counter++, glfwGetTime(), x, y); } static void cursor_enter_callback(GLFWwindow window, int entered) @@ -361,7 +361,7 @@ glfwSetWindowFocusCallback(window_focus_callback); glfwSetWindowIconifyCallback(window_iconify_callback); glfwSetMouseButtonCallback(mouse_button_callback); - glfwSetMousePosCallback(mouse_position_callback); + glfwSetCursorPosCallback(cursor_position_callback); glfwSetCursorEnterCallback(cursor_enter_callback); glfwSetScrollCallback(scroll_callback); glfwSetKeyCallback(key_callback);
diff --git a/tests/peter.c b/tests/peter.c index 5ae7ba5..b9f21f2 100644 --- a/tests/peter.c +++ b/tests/peter.c
@@ -1,5 +1,5 @@ //======================================================================== -// Mouse cursor bug test +// Cursor input bug test // Copyright (c) Camilla Berglund <elmindreda@elmindreda.org> // // This software is provided 'as-is', without any express or implied @@ -41,7 +41,7 @@ static GLboolean open_window(void); -static void toggle_mouse_cursor(GLFWwindow window) +static void toggle_cursor(GLFWwindow window) { if (glfwGetInputMode(window, GLFW_CURSOR_MODE) == GLFW_CURSOR_CAPTURED) { @@ -55,9 +55,9 @@ } } -static void mouse_position_callback(GLFWwindow window, int x, int y) +static void cursor_position_callback(GLFWwindow window, int x, int y) { - printf("Mouse moved to: %i %i (%i %i)\n", x, y, x - cursor_x, y - cursor_y); + printf("Cursor moved to: %i %i (%i %i)\n", x, y, x - cursor_x, y - cursor_y); cursor_x = x; cursor_y = y; } @@ -69,7 +69,7 @@ case GLFW_KEY_SPACE: { if (action == GLFW_PRESS) - toggle_mouse_cursor(window); + toggle_cursor(window); break; } @@ -98,11 +98,11 @@ if (!window_handle) return GL_FALSE; - glfwGetMousePos(window_handle, &cursor_x, &cursor_y); - printf("Mouse position: %i %i\n", cursor_x, cursor_y); + glfwGetCursorPos(window_handle, &cursor_x, &cursor_y); + printf("Cursor position: %i %i\n", cursor_x, cursor_y); glfwSetWindowSizeCallback(window_size_callback); - glfwSetMousePosCallback(mouse_position_callback); + glfwSetCursorPosCallback(cursor_position_callback); glfwSetKeyCallback(key_callback); glfwSwapInterval(1);