Skip to content

Commit

Permalink
Fixed hit-testing on Windows.
Browse files Browse the repository at this point in the history
Needed to convert from screen to client coords.
  • Loading branch information
icculus committed May 30, 2014
1 parent bf03bec commit bcc2cc8
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/video/windows/SDL_windowsevents.c
Expand Up @@ -870,10 +870,13 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
SDL_Window *window = data->window;
if (window->hit_test) {
const SDL_Point point = { (int) LOWORD(lParam), (int) HIWORD(lParam) };
const SDL_HitTestResult rc = window->hit_test(window, &point, window->hit_test_data);
if (rc == SDL_HITTEST_DRAGGABLE) {
return HTCAPTION;
POINT winpoint = { (int) LOWORD(lParam), (int) HIWORD(lParam) };
if (ScreenToClient(data->hwnd, &winpoint)) {
const SDL_Point point = { (int) winpoint.x, (int) winpoint.y };
const SDL_HitTestResult rc = window->hit_test(window, &point, window->hit_test_data);
if (rc == SDL_HITTEST_DRAGGABLE) {
return HTCAPTION;
}
}
// if we didn't return, this will call DefWindowProc below.
}
Expand Down

0 comments on commit bcc2cc8

Please sign in to comment.