Commit 9fc035a5 authored by Leon Linhart's avatar Leon Linhart Committed by Camilla Löwy
Browse files

Win32: Fix cursor enter/position event order

This fixes the cursor enter event being emitted after the first cursor
position event on Windows.

Closes #1490.

(cherry picked from commit 4f0b8b0ddaada126cd257f2e5b06450e932ad5f6)
parent ce7cd3e2
......@@ -122,6 +122,7 @@ information on what to include when reporting a bug.
relocatable (#1470)
- [Win32] Bugfix: `GLFW_INCLUDE_VULKAN` plus `VK_USE_PLATFORM_WIN32_KHR` caused
symbol redefinition (#1524)
- [Win32] Bugfix: Invoke cursor enter callback before cursor position callback
- [X11] Bugfix: The CMake files did not check for the XInput headers (#1480)
- [X11] Bugfix: Key names were not updated when the keyboard layout changed
(#1462,#1528)
......@@ -225,6 +226,7 @@ skills.
- Glenn Lewis
- Shane Liesegang
- Anders Lindqvist
- Leon Linhart
- Eyal Lotem
- Aaron Loucks
- Luflosi
......
......@@ -828,6 +828,19 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
const int x = GET_X_LPARAM(lParam);
const int y = GET_Y_LPARAM(lParam);
if (!window->win32.cursorTracked)
{
TRACKMOUSEEVENT tme;
ZeroMemory(&tme, sizeof(tme));
tme.cbSize = sizeof(tme);
tme.dwFlags = TME_LEAVE;
tme.hwndTrack = window->win32.handle;
TrackMouseEvent(&tme);
window->win32.cursorTracked = GLFW_TRUE;
_glfwInputCursorEnter(window, GLFW_TRUE);
}
if (window->cursorMode == GLFW_CURSOR_DISABLED)
{
const int dx = x - window->win32.lastCursorPosX;
......@@ -848,19 +861,6 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
window->win32.lastCursorPosX = x;
window->win32.lastCursorPosY = y;
if (!window->win32.cursorTracked)
{
TRACKMOUSEEVENT tme;
ZeroMemory(&tme, sizeof(tme));
tme.cbSize = sizeof(tme);
tme.dwFlags = TME_LEAVE;
tme.hwndTrack = window->win32.handle;
TrackMouseEvent(&tme);
window->win32.cursorTracked = GLFW_TRUE;
_glfwInputCursorEnter(window, GLFW_TRUE);
}
return 0;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment