Removed duplicates of centerCursor function

master
iamCaveLamp ago%!(EXTRA string=6 years) committed by Camilla Löwy
parent 757cd3aea2
commit a46104ee69
  1. 17
      src/cocoa_window.m
  2. 9
      src/input.c
  3. 1
      src/internal.h
  4. 11
      src/win32_window.c
  5. 7
      src/window.c
  6. 11
      src/x11_window.c

@ -67,15 +67,6 @@ static NSUInteger getStyleMask(_GLFWwindow* window)
return styleMask; return styleMask;
} }
// Center the cursor in the view of the window
//
static void centerCursor(_GLFWwindow *window)
{
int width, height;
_glfwPlatformGetWindowSize(window, &width, &height);
_glfwPlatformSetCursorPos(window, width / 2.0, height / 2.0);
}
// Returns whether the cursor is in the client area of the specified window // Returns whether the cursor is in the client area of the specified window
// //
static GLFWbool cursorInClientArea(_GLFWwindow* window) static GLFWbool cursorInClientArea(_GLFWwindow* window)
@ -133,7 +124,7 @@ static void updateCursorMode(_GLFWwindow* window)
_glfwPlatformGetCursorPos(window, _glfwPlatformGetCursorPos(window,
&_glfw.ns.restoreCursorPosX, &_glfw.ns.restoreCursorPosX,
&_glfw.ns.restoreCursorPosY); &_glfw.ns.restoreCursorPosY);
centerCursor(window); _glfwCenterCursor(window);
CGAssociateMouseAndMouseCursorPosition(false); CGAssociateMouseAndMouseCursorPosition(false);
} }
else if (_glfw.ns.disabledCursorWindow == window) else if (_glfw.ns.disabledCursorWindow == window)
@ -280,7 +271,7 @@ static const NSRange kEmptyRange = { NSNotFound, 0 };
[window->context.nsgl.object update]; [window->context.nsgl.object update];
if (_glfw.ns.disabledCursorWindow == window) if (_glfw.ns.disabledCursorWindow == window)
centerCursor(window); _glfwCenterCursor(window);
const int maximized = [window->ns.object isZoomed]; const int maximized = [window->ns.object isZoomed];
if (window->ns.maximized != maximized) if (window->ns.maximized != maximized)
@ -315,7 +306,7 @@ static const NSRange kEmptyRange = { NSNotFound, 0 };
[window->context.nsgl.object update]; [window->context.nsgl.object update];
if (_glfw.ns.disabledCursorWindow == window) if (_glfw.ns.disabledCursorWindow == window)
centerCursor(window); _glfwCenterCursor(window);
int x, y; int x, y;
_glfwPlatformGetWindowPos(window, &x, &y); _glfwPlatformGetWindowPos(window, &x, &y);
@ -341,7 +332,7 @@ static const NSRange kEmptyRange = { NSNotFound, 0 };
- (void)windowDidBecomeKey:(NSNotification *)notification - (void)windowDidBecomeKey:(NSNotification *)notification
{ {
if (_glfw.ns.disabledCursorWindow == window) if (_glfw.ns.disabledCursorWindow == window)
centerCursor(window); _glfwCenterCursor(window);
_glfwInputWindowFocus(window, GLFW_TRUE); _glfwInputWindowFocus(window, GLFW_TRUE);
updateCursorMode(window); updateCursorMode(window);

@ -453,6 +453,15 @@ void _glfwFreeJoystick(_GLFWjoystick* js)
memset(js, 0, sizeof(_GLFWjoystick)); memset(js, 0, sizeof(_GLFWjoystick));
} }
// Center the cursor in the middle of the window
//
void _glfwCenterCursor(_GLFWwindow* window)
{
int width, height;
_glfwPlatformGetWindowSize(window, &width, &height);
_glfwPlatformSetCursorPos(window, width / 2.0, height / 2.0);
}
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
////// GLFW public API ////// ////// GLFW public API //////

@ -760,6 +760,7 @@ _GLFWjoystick* _glfwAllocJoystick(const char* name,
int buttonCount, int buttonCount,
int hatCount); int hatCount);
void _glfwFreeJoystick(_GLFWjoystick* js); void _glfwFreeJoystick(_GLFWjoystick* js);
void _glfwCenterCursor(_GLFWwindow* window);
GLFWbool _glfwInitVulkan(int mode); GLFWbool _glfwInitVulkan(int mode);
void _glfwTerminateVulkan(void); void _glfwTerminateVulkan(void);

@ -236,15 +236,6 @@ static void applyAspectRatio(_GLFWwindow* window, int edge, RECT* area)
} }
} }
// Centers the cursor over the window client area
//
static void centerCursor(_GLFWwindow* window)
{
int width, height;
_glfwPlatformGetWindowSize(window, &width, &height);
_glfwPlatformSetCursorPos(window, width / 2.0, height / 2.0);
}
// Updates the cursor image according to its cursor mode // Updates the cursor image according to its cursor mode
// //
static void updateCursorImage(_GLFWwindow* window) static void updateCursorImage(_GLFWwindow* window)
@ -287,7 +278,7 @@ static void disableCursor(_GLFWwindow* window)
&_glfw.win32.restoreCursorPosX, &_glfw.win32.restoreCursorPosX,
&_glfw.win32.restoreCursorPosY); &_glfw.win32.restoreCursorPosY);
updateCursorImage(window); updateCursorImage(window);
centerCursor(window); _glfwCenterCursor(window);
updateClipRect(window); updateClipRect(window);
if (!RegisterRawInputDevices(&rid, 1, sizeof(rid))) if (!RegisterRawInputDevices(&rid, 1, sizeof(rid)))

@ -143,7 +143,6 @@ void _glfwInputWindowMonitor(_GLFWwindow* window, _GLFWmonitor* monitor)
window->monitor = monitor; window->monitor = monitor;
} }
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
////// GLFW public API ////// ////// GLFW public API //////
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
@ -230,11 +229,7 @@ GLFWAPI GLFWwindow* glfwCreateWindow(int width, int height,
if (window->monitor) if (window->monitor)
{ {
if (wndconfig.centerCursor) if (wndconfig.centerCursor)
{ _glfwCenterCursor(window);
int width, height;
_glfwPlatformGetWindowSize(window, &width, &height);
_glfwPlatformSetCursorPos(window, width / 2.0, height / 2.0);
}
} }
else else
{ {

@ -501,15 +501,6 @@ static char* convertLatin1toUTF8(const char* source)
return target; return target;
} }
// Centers the cursor over the window client area
//
static void centerCursor(_GLFWwindow* window)
{
int width, height;
_glfwPlatformGetWindowSize(window, &width, &height);
_glfwPlatformSetCursorPos(window, width / 2.0, height / 2.0);
}
// Updates the cursor image according to its cursor mode // Updates the cursor image according to its cursor mode
// //
static void updateCursorImage(_GLFWwindow* window) static void updateCursorImage(_GLFWwindow* window)
@ -553,7 +544,7 @@ static void disableCursor(_GLFWwindow* window)
&_glfw.x11.restoreCursorPosX, &_glfw.x11.restoreCursorPosX,
&_glfw.x11.restoreCursorPosY); &_glfw.x11.restoreCursorPosY);
updateCursorImage(window); updateCursorImage(window);
centerCursor(window); _glfwCenterCursor(window);
XGrabPointer(_glfw.x11.display, window->x11.handle, True, XGrabPointer(_glfw.x11.display, window->x11.handle, True,
ButtonPressMask | ButtonReleaseMask | PointerMotionMask, ButtonPressMask | ButtonReleaseMask | PointerMotionMask,
GrabModeAsync, GrabModeAsync, GrabModeAsync, GrabModeAsync,

Loading…
Cancel
Save