Changes to GLFW

This commit is contained in:
asdqwe 2025-01-08 19:27:44 -03:00
parent f93f7d17c2
commit 3c7c276019
4 changed files with 36 additions and 8 deletions

View File

@ -625,3 +625,6 @@ GLFWbool _glfwCreateContextWGL(_GLFWwindow* window,
const _GLFWctxconfig* ctxconfig, const _GLFWctxconfig* ctxconfig,
const _GLFWfbconfig* fbconfig); const _GLFWfbconfig* fbconfig);
// Workaround for raylib to call disableCursor() earlier
void raylibFixEarlyDisableCursor(_GLFWwindow* window);

View File

@ -2174,11 +2174,11 @@ void _glfwPollEventsWin32(void)
// NOTE: Re-center the cursor only if it has moved since the last call, // NOTE: Re-center the cursor only if it has moved since the last call,
// to avoid breaking glfwWaitEvents with WM_MOUSEMOVE // to avoid breaking glfwWaitEvents with WM_MOUSEMOVE
// The re-center is required in order to prevent the mouse cursor stopping at the edges of the screen. // The re-center is required in order to prevent the mouse cursor stopping at the edges of the screen.
if (window->win32.lastCursorPosX != width / 2 || // if (window->win32.lastCursorPosX != width / 2 ||
window->win32.lastCursorPosY != height / 2) // window->win32.lastCursorPosY != height / 2)
{ // {
_glfwSetCursorPosWin32(window, width / 2, height / 2); _glfwSetCursorPosWin32(window, width / 2, height / 2);
} // }
} }
} }
@ -2590,5 +2590,16 @@ GLFWAPI HWND glfwGetWin32Window(GLFWwindow* handle)
return window->win32.handle; return window->win32.handle;
} }
// Workaround for raylib to call disableCursor() earlier
void raylibFixEarlyDisableCursor(_GLFWwindow* window)
{
_glfw.win32.disabledCursorWindow = window;
_glfwGetCursorPosWin32(window, &_glfw.win32.restoreCursorPosX, &_glfw.win32.restoreCursorPosY);
updateCursorImage(window);
_glfwCenterCursorInContentArea(window);
captureCursor(window);
if (window->rawMouseMotion) enableRawMouseMotion(window);
}
#endif // _GLFW_WIN32 #endif // _GLFW_WIN32

View File

@ -1002,3 +1002,6 @@ GLFWbool _glfwChooseVisualGLX(const _GLFWwndconfig* wndconfig,
const _GLFWfbconfig* fbconfig, const _GLFWfbconfig* fbconfig,
Visual** visual, int* depth); Visual** visual, int* depth);
// Workaround for raylib to call disableCursor() earlier
void raylibFixEarlyDisableCursor(_GLFWwindow* window);

View File

@ -2805,11 +2805,11 @@ void _glfwPollEventsX11(void)
// NOTE: Re-center the cursor only if it has moved since the last call, // NOTE: Re-center the cursor only if it has moved since the last call,
// to avoid breaking glfwWaitEvents with MotionNotify // to avoid breaking glfwWaitEvents with MotionNotify
if (window->x11.lastCursorPosX != width / 2 || // if (window->x11.lastCursorPosX != width / 2 ||
window->x11.lastCursorPosY != height / 2) // window->x11.lastCursorPosY != height / 2)
{ // {
_glfwSetCursorPosX11(window, width / 2, height / 2); _glfwSetCursorPosX11(window, width / 2, height / 2);
} // }
} }
XFlush(_glfw.x11.display); XFlush(_glfw.x11.display);
@ -3354,5 +3354,16 @@ GLFWAPI const char* glfwGetX11SelectionString(void)
return getSelectionString(_glfw.x11.PRIMARY); return getSelectionString(_glfw.x11.PRIMARY);
} }
// Workaround for raylib to call disableCursor() earlier
void raylibFixEarlyDisableCursor(_GLFWwindow* window)
{
if (window->rawMouseMotion) enableRawMouseMotion(window);
_glfw.x11.disabledCursorWindow = window;
_glfwGetCursorPosX11(window, &_glfw.x11.restoreCursorPosX, &_glfw.x11.restoreCursorPosY);
updateCursorImage(window);
_glfwCenterCursorInContentArea(window);
captureCursor(window);
}
#endif // _GLFW_X11 #endif // _GLFW_X11