parent
b51584525a
commit
419b078104
@ -76,15 +76,6 @@ static NSUInteger getStyleMask(_GLFWwindow* window)
|
||||
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
|
||||
//
|
||||
static GLFWbool cursorInClientArea(_GLFWwindow* window)
|
||||
@ -142,7 +133,7 @@ static void updateCursorMode(_GLFWwindow* window)
|
||||
_glfwPlatformGetCursorPos(window,
|
||||
&_glfw.ns.restoreCursorPosX,
|
||||
&_glfw.ns.restoreCursorPosY);
|
||||
centerCursor(window);
|
||||
_glfwCenterCursor(window);
|
||||
CGAssociateMouseAndMouseCursorPosition(false);
|
||||
}
|
||||
else if (_glfw.ns.disabledCursorWindow == window)
|
||||
@ -392,7 +383,7 @@ static const NSRange kEmptyRange = { NSNotFound, 0 };
|
||||
[window->context.nsgl.object update];
|
||||
|
||||
if (_glfw.ns.disabledCursorWindow == window)
|
||||
centerCursor(window);
|
||||
_glfwCenterCursor(window);
|
||||
|
||||
const int maximized = [window->ns.object isZoomed];
|
||||
if (window->ns.maximized != maximized)
|
||||
@ -427,7 +418,7 @@ static const NSRange kEmptyRange = { NSNotFound, 0 };
|
||||
[window->context.nsgl.object update];
|
||||
|
||||
if (_glfw.ns.disabledCursorWindow == window)
|
||||
centerCursor(window);
|
||||
_glfwCenterCursor(window);
|
||||
|
||||
int x, y;
|
||||
_glfwPlatformGetWindowPos(window, &x, &y);
|
||||
@ -453,7 +444,7 @@ static const NSRange kEmptyRange = { NSNotFound, 0 };
|
||||
- (void)windowDidBecomeKey:(NSNotification *)notification
|
||||
{
|
||||
if (_glfw.ns.disabledCursorWindow == window)
|
||||
centerCursor(window);
|
||||
_glfwCenterCursor(window);
|
||||
|
||||
_glfwInputWindowFocus(window, GLFW_TRUE);
|
||||
updateCursorMode(window);
|
||||
|
||||
9
glfw/input.c
vendored
9
glfw/input.c
vendored
@ -565,6 +565,15 @@ const char* _glfwGetKeyName(int key)
|
||||
}
|
||||
}
|
||||
|
||||
// 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 //////
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
1
glfw/internal.h
vendored
1
glfw/internal.h
vendored
@ -773,6 +773,7 @@ _GLFWjoystick* _glfwAllocJoystick(const char* name,
|
||||
int hatCount);
|
||||
void _glfwFreeJoystick(_GLFWjoystick* js);
|
||||
const char* _glfwGetKeyName(int key);
|
||||
void _glfwCenterCursor(_GLFWwindow* window);
|
||||
|
||||
GLFWbool _glfwInitVulkan(int mode);
|
||||
void _glfwTerminateVulkan(void);
|
||||
|
||||
6
glfw/window.c
vendored
6
glfw/window.c
vendored
@ -254,11 +254,7 @@ GLFWAPI GLFWwindow* glfwCreateWindow(int width, int height,
|
||||
if (window->monitor)
|
||||
{
|
||||
if (wndconfig.centerCursor)
|
||||
{
|
||||
int width, height;
|
||||
_glfwPlatformGetWindowSize(window, &width, &height);
|
||||
_glfwPlatformSetCursorPos(window, width / 2.0, height / 2.0);
|
||||
}
|
||||
_glfwCenterCursor(window);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
11
glfw/x11_window.c
vendored
11
glfw/x11_window.c
vendored
@ -403,15 +403,6 @@ static char* convertLatin1toUTF8(const char* source)
|
||||
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
|
||||
//
|
||||
static void updateCursorImage(_GLFWwindow* window)
|
||||
@ -455,7 +446,7 @@ static void disableCursor(_GLFWwindow* window)
|
||||
&_glfw.x11.restoreCursorPosX,
|
||||
&_glfw.x11.restoreCursorPosY);
|
||||
updateCursorImage(window);
|
||||
centerCursor(window);
|
||||
_glfwCenterCursor(window);
|
||||
XGrabPointer(_glfw.x11.display, window->x11.handle, True,
|
||||
ButtonPressMask | ButtonReleaseMask | PointerMotionMask,
|
||||
GrabModeAsync, GrabModeAsync,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user