Skip to content

Commit

Permalink
Changes to GLFW
Browse files Browse the repository at this point in the history
  • Loading branch information
asdqwe committed Jan 8, 2025
1 parent f93f7d1 commit 3c7c276
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 8 deletions.
3 changes: 3 additions & 0 deletions src/external/glfw/src/win32_platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

19 changes: 15 additions & 4 deletions src/external/glfw/src/win32_window.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
// }
}
}

Expand Down Expand Up @@ -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

3 changes: 3 additions & 0 deletions src/external/glfw/src/x11_platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

19 changes: 15 additions & 4 deletions src/external/glfw/src/x11_window.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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

0 comments on commit 3c7c276

Please sign in to comment.