From 9ce9507a7f66634eeb06fc34aebdfb6c4f1a1d11 Mon Sep 17 00:00:00 2001 From: Chris Dalton Date: Wed, 21 Feb 2018 12:06:06 -0700 Subject: Fix touch coordinate mapping in Windows Coordinates were not previously being mapped correctly from screen coordinates to window coordinates. Bug: skia: Change-Id: Ie56ac3b42273aede6f97ee6f83ac9766020510ea Reviewed-on: https://skia-review.googlesource.com/109109 Reviewed-by: Brian Osman Commit-Queue: Chris Dalton --- tools/sk_app/win/Window_win.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'tools/sk_app') diff --git a/tools/sk_app/win/Window_win.cpp b/tools/sk_app/win/Window_win.cpp index 10db0ec675..c442493b21 100644 --- a/tools/sk_app/win/Window_win.cpp +++ b/tools/sk_app/win/Window_win.cpp @@ -303,8 +303,8 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) std::unique_ptr inputs(new TOUCHINPUT[numInputs]); if (GetTouchInputInfo((HTOUCHINPUT)lParam, numInputs, inputs.get(), sizeof(TOUCHINPUT))) { - RECT rect; - GetClientRect(hWnd, &rect); + POINT topLeft = {0, 0}; + ClientToScreen(hWnd, &topLeft); for (uint16_t i = 0; i < numInputs; ++i) { TOUCHINPUT ti = inputs[i]; Window::InputState state; @@ -319,8 +319,8 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) } // TOUCHINPUT coordinates are in 100ths of pixels // Adjust for that, and make them window relative - LONG tx = (ti.x / 100) - rect.left; - LONG ty = (ti.y / 100) - rect.top; + LONG tx = (ti.x / 100) - topLeft.x; + LONG ty = (ti.y / 100) - topLeft.y; eventHandled = window->onTouch(ti.dwID, state, tx, ty) || eventHandled; } } -- cgit v1.2.3