| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ui/views/win/hwnd_message_handler.h" | 5 #include "ui/views/win/hwnd_message_handler.h" |
| 6 | 6 |
| 7 #include <dwmapi.h> | 7 #include <dwmapi.h> |
| 8 #include <oleacc.h> | 8 #include <oleacc.h> |
| 9 #include <shellapi.h> | 9 #include <shellapi.h> |
| 10 | 10 |
| (...skipping 2290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2301 tracked_objects::ScopedTracker tracking_profile( | 2301 tracked_objects::ScopedTracker tracking_profile( |
| 2302 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 2302 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 2303 "440919 HWNDMessageHandler::OnTouchEvent")); | 2303 "440919 HWNDMessageHandler::OnTouchEvent")); |
| 2304 | 2304 |
| 2305 // Handle touch events only on Aura for now. | 2305 // Handle touch events only on Aura for now. |
| 2306 int num_points = LOWORD(w_param); | 2306 int num_points = LOWORD(w_param); |
| 2307 scoped_ptr<TOUCHINPUT[]> input(new TOUCHINPUT[num_points]); | 2307 scoped_ptr<TOUCHINPUT[]> input(new TOUCHINPUT[num_points]); |
| 2308 if (ui::GetTouchInputInfoWrapper(reinterpret_cast<HTOUCHINPUT>(l_param), | 2308 if (ui::GetTouchInputInfoWrapper(reinterpret_cast<HTOUCHINPUT>(l_param), |
| 2309 num_points, input.get(), | 2309 num_points, input.get(), |
| 2310 sizeof(TOUCHINPUT))) { | 2310 sizeof(TOUCHINPUT))) { |
| 2311 // input[i].dwTime doesn't necessarily relate to the system time at all, |
| 2312 // so use base::TimeTicks::Now(). |
| 2313 const base::TimeTicks event_time = base::TimeTicks::Now(); |
| 2311 int flags = ui::GetModifiersFromKeyState(); | 2314 int flags = ui::GetModifiersFromKeyState(); |
| 2312 TouchEvents touch_events; | 2315 TouchEvents touch_events; |
| 2313 for (int i = 0; i < num_points; ++i) { | 2316 for (int i = 0; i < num_points; ++i) { |
| 2314 POINT point; | 2317 POINT point; |
| 2315 point.x = TOUCH_COORD_TO_PIXEL(input[i].x); | 2318 point.x = TOUCH_COORD_TO_PIXEL(input[i].x); |
| 2316 point.y = TOUCH_COORD_TO_PIXEL(input[i].y); | 2319 point.y = TOUCH_COORD_TO_PIXEL(input[i].y); |
| 2317 | 2320 |
| 2318 if (base::win::GetVersion() == base::win::VERSION_WIN7) { | 2321 if (base::win::GetVersion() == base::win::VERSION_WIN7) { |
| 2319 // Windows 7 sends touch events for touches in the non-client area, | 2322 // Windows 7 sends touch events for touches in the non-client area, |
| 2320 // whereas Windows 8 does not. In order to unify the behaviour, always | 2323 // whereas Windows 8 does not. In order to unify the behaviour, always |
| (...skipping 20 matching lines...) Expand all Loading... |
| 2341 base::Bind(&HWNDMessageHandler::ResetTouchDownContext, | 2344 base::Bind(&HWNDMessageHandler::ResetTouchDownContext, |
| 2342 weak_factory_.GetWeakPtr()), | 2345 weak_factory_.GetWeakPtr()), |
| 2343 base::TimeDelta::FromMilliseconds(kTouchDownContextResetTimeout)); | 2346 base::TimeDelta::FromMilliseconds(kTouchDownContextResetTimeout)); |
| 2344 } else if (input[i].dwFlags & TOUCHEVENTF_UP) { | 2347 } else if (input[i].dwFlags & TOUCHEVENTF_UP) { |
| 2345 touch_ids_.erase(input[i].dwID); | 2348 touch_ids_.erase(input[i].dwID); |
| 2346 touch_event_type = ui::ET_TOUCH_RELEASED; | 2349 touch_event_type = ui::ET_TOUCH_RELEASED; |
| 2347 } else if (input[i].dwFlags & TOUCHEVENTF_MOVE) { | 2350 } else if (input[i].dwFlags & TOUCHEVENTF_MOVE) { |
| 2348 touch_event_type = ui::ET_TOUCH_MOVED; | 2351 touch_event_type = ui::ET_TOUCH_MOVED; |
| 2349 } | 2352 } |
| 2350 if (touch_event_type != ui::ET_UNKNOWN) { | 2353 if (touch_event_type != ui::ET_UNKNOWN) { |
| 2351 // input[i].dwTime doesn't necessarily relate to the system time at all, | |
| 2352 // so use base::TimeTicks::Now() | |
| 2353 const base::TimeTicks now = base::TimeTicks::Now(); | |
| 2354 ui::TouchEvent event(touch_event_type, | 2354 ui::TouchEvent event(touch_event_type, |
| 2355 gfx::Point(point.x, point.y), | 2355 gfx::Point(point.x, point.y), |
| 2356 id_generator_.GetGeneratedID(input[i].dwID), | 2356 id_generator_.GetGeneratedID(input[i].dwID), |
| 2357 now - base::TimeTicks()); | 2357 event_time - base::TimeTicks()); |
| 2358 event.set_flags(flags); | 2358 event.set_flags(flags); |
| 2359 event.latency()->AddLatencyNumberWithTimestamp( | 2359 event.latency()->AddLatencyNumberWithTimestamp( |
| 2360 ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, | 2360 ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, |
| 2361 0, | 2361 0, |
| 2362 0, | 2362 0, |
| 2363 base::TimeTicks::FromInternalValue( | 2363 event_time, |
| 2364 event.time_stamp().ToInternalValue()), | |
| 2365 1); | 2364 1); |
| 2366 | 2365 |
| 2367 touch_events.push_back(event); | 2366 touch_events.push_back(event); |
| 2368 if (touch_event_type == ui::ET_TOUCH_RELEASED) | 2367 if (touch_event_type == ui::ET_TOUCH_RELEASED) |
| 2369 id_generator_.ReleaseNumber(input[i].dwID); | 2368 id_generator_.ReleaseNumber(input[i].dwID); |
| 2370 } | 2369 } |
| 2371 } | 2370 } |
| 2372 // Handle the touch events asynchronously. We need this because touch | 2371 // Handle the touch events asynchronously. We need this because touch |
| 2373 // events on windows don't fire if we enter a modal loop in the context of | 2372 // events on windows don't fire if we enter a modal loop in the context of |
| 2374 // a touch event. | 2373 // a touch event. |
| (...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2743 SetWindowPos(hwnd(), NULL, 0, 0, 0, 0, flags | SWP_HIDEWINDOW); | 2742 SetWindowPos(hwnd(), NULL, 0, 0, 0, 0, flags | SWP_HIDEWINDOW); |
| 2744 SetWindowPos(hwnd(), NULL, 0, 0, 0, 0, flags | SWP_SHOWWINDOW); | 2743 SetWindowPos(hwnd(), NULL, 0, 0, 0, 0, flags | SWP_SHOWWINDOW); |
| 2745 } | 2744 } |
| 2746 // WM_DWMCOMPOSITIONCHANGED is only sent to top level windows, however we want | 2745 // WM_DWMCOMPOSITIONCHANGED is only sent to top level windows, however we want |
| 2747 // to notify our children too, since we can have MDI child windows who need to | 2746 // to notify our children too, since we can have MDI child windows who need to |
| 2748 // update their appearance. | 2747 // update their appearance. |
| 2749 EnumChildWindows(hwnd(), &SendDwmCompositionChanged, NULL); | 2748 EnumChildWindows(hwnd(), &SendDwmCompositionChanged, NULL); |
| 2750 } | 2749 } |
| 2751 | 2750 |
| 2752 } // namespace views | 2751 } // namespace views |
| OLD | NEW |