Skip to content

Commit

Permalink
Fixed bug 4748 - Calling WIN_UpdateClipCursor() / WIN_UpdateClipCurso…
Browse files Browse the repository at this point in the history
…rForWindows() on WIN_PumpEvents() causes beeping and choppy mouse cursor movement, right-click doesn't work

The problem here was calling ClipCursor() continuously in a tight loop. Fixed by only calling ClipCursor() if the clip area needs to be updated.
  • Loading branch information
slouken committed Feb 11, 2020
1 parent 668276f commit c31727c
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/video/windows/SDL_windowswindow.c
Expand Up @@ -938,11 +938,14 @@ WIN_UpdateClipCursor(SDL_Window *window)
data->cursor_clipped_rect = rect;
}
} else {
RECT clipped_rect;
if (GetClientRect(data->hwnd, &rect) && !IsRectEmpty(&rect)) {
ClientToScreen(data->hwnd, (LPPOINT) & rect);
ClientToScreen(data->hwnd, (LPPOINT) & rect + 1);
if (ClipCursor(&rect)) {
data->cursor_clipped_rect = rect;
if (!GetClipCursor(&clipped_rect) || SDL_memcmp(&rect, &clipped_rect, sizeof(rect)) != 0) {
if (ClipCursor(&rect)) {
data->cursor_clipped_rect = rect;
}
}
}
}
Expand Down

0 comments on commit c31727c

Please sign in to comment.