From 3c7c276019b24b63b95bfd605b30c1e0c778a1a5 Mon Sep 17 00:00:00 2001 From: asdqwe Date: Wed, 8 Jan 2025 19:27:44 -0300 Subject: [PATCH] Changes to GLFW --- src/external/glfw/src/win32_platform.h | 3 +++ src/external/glfw/src/win32_window.c | 19 +++++++++++++++---- src/external/glfw/src/x11_platform.h | 3 +++ src/external/glfw/src/x11_window.c | 19 +++++++++++++++---- 4 files changed, 36 insertions(+), 8 deletions(-) diff --git a/src/external/glfw/src/win32_platform.h b/src/external/glfw/src/win32_platform.h index 7e3d8845..62ec3dec 100644 --- a/src/external/glfw/src/win32_platform.h +++ b/src/external/glfw/src/win32_platform.h @@ -625,3 +625,6 @@ GLFWbool _glfwCreateContextWGL(_GLFWwindow* window, const _GLFWctxconfig* ctxconfig, const _GLFWfbconfig* fbconfig); +// Workaround for raylib to call disableCursor() earlier +void raylibFixEarlyDisableCursor(_GLFWwindow* window); + diff --git a/src/external/glfw/src/win32_window.c b/src/external/glfw/src/win32_window.c index 3762b769..c65492d6 100644 --- a/src/external/glfw/src/win32_window.c +++ b/src/external/glfw/src/win32_window.c @@ -2174,11 +2174,11 @@ void _glfwPollEventsWin32(void) // NOTE: Re-center the cursor only if it has moved since the last call, // 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. - if (window->win32.lastCursorPosX != width / 2 || - window->win32.lastCursorPosY != height / 2) - { +// if (window->win32.lastCursorPosX != width / 2 || +// window->win32.lastCursorPosY != height / 2) +// { _glfwSetCursorPosWin32(window, width / 2, height / 2); - } +// } } } @@ -2590,5 +2590,16 @@ GLFWAPI HWND glfwGetWin32Window(GLFWwindow* 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 diff --git a/src/external/glfw/src/x11_platform.h b/src/external/glfw/src/x11_platform.h index 14e363d1..17ea447e 100644 --- a/src/external/glfw/src/x11_platform.h +++ b/src/external/glfw/src/x11_platform.h @@ -1002,3 +1002,6 @@ GLFWbool _glfwChooseVisualGLX(const _GLFWwndconfig* wndconfig, const _GLFWfbconfig* fbconfig, Visual** visual, int* depth); +// Workaround for raylib to call disableCursor() earlier +void raylibFixEarlyDisableCursor(_GLFWwindow* window); + diff --git a/src/external/glfw/src/x11_window.c b/src/external/glfw/src/x11_window.c index 49e60a50..b408cbd5 100644 --- a/src/external/glfw/src/x11_window.c +++ b/src/external/glfw/src/x11_window.c @@ -2805,11 +2805,11 @@ void _glfwPollEventsX11(void) // NOTE: Re-center the cursor only if it has moved since the last call, // to avoid breaking glfwWaitEvents with MotionNotify - if (window->x11.lastCursorPosX != width / 2 || - window->x11.lastCursorPosY != height / 2) - { +// if (window->x11.lastCursorPosX != width / 2 || +// window->x11.lastCursorPosY != height / 2) +// { _glfwSetCursorPosX11(window, width / 2, height / 2); - } +// } } XFlush(_glfw.x11.display); @@ -3354,5 +3354,16 @@ GLFWAPI const char* glfwGetX11SelectionString(void) 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