| 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 2332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2343 int num_points, | 2343 int num_points, |
| 2344 TouchEvents* touch_events) { | 2344 TouchEvents* touch_events) { |
| 2345 for (int i = 0; i < num_points; ++i) { | 2345 for (int i = 0; i < num_points; ++i) { |
| 2346 POINT point; | 2346 POINT point; |
| 2347 point.x = TOUCH_COORD_TO_PIXEL(input[i].x); | 2347 point.x = TOUCH_COORD_TO_PIXEL(input[i].x); |
| 2348 point.y = TOUCH_COORD_TO_PIXEL(input[i].y); | 2348 point.y = TOUCH_COORD_TO_PIXEL(input[i].y); |
| 2349 gfx::Point point_location(point.x, point.y); | 2349 gfx::Point point_location(point.x, point.y); |
| 2350 | 2350 |
| 2351 ScreenToClient(hwnd(), &point); | 2351 ScreenToClient(hwnd(), &point); |
| 2352 | 2352 |
| 2353 // We set a check to assert that we do not receive any touch events from | |
| 2354 // user's palm. | |
| 2355 bool touch_event_from_palm = (input[i].dwFlags & TOUCHEVENTF_PALM) != 0; | |
| 2356 CHECK(!touch_event_from_palm) << "There are touch events from user's palm"; | |
| 2357 | |
| 2358 // TOUCHEVENTF_DOWN cannot be combined with TOUCHEVENTF_MOVE or | 2353 // TOUCHEVENTF_DOWN cannot be combined with TOUCHEVENTF_MOVE or |
| 2359 // TOUCHEVENTF_UP, but TOUCHEVENTF_MOVE and TOUCHEVENTF_UP can be combined | 2354 // TOUCHEVENTF_UP, but TOUCHEVENTF_MOVE and TOUCHEVENTF_UP can be combined |
| 2360 // in one input. | 2355 // in one input. |
| 2361 if (input[i].dwFlags & TOUCHEVENTF_DOWN) { | 2356 if (input[i].dwFlags & TOUCHEVENTF_DOWN) { |
| 2362 touch_down_contexts_++; | 2357 touch_down_contexts_++; |
| 2363 active_touch_point_count_++; | 2358 active_touch_point_count_++; |
| 2364 GenerateTouchEvent(input[i].dwID, point_location, ui::ET_TOUCH_PRESSED, | 2359 GenerateTouchEvent(input[i].dwID, point_location, ui::ET_TOUCH_PRESSED, |
| 2365 touch_events); | 2360 touch_events); |
| 2366 } else { | 2361 } else { |
| 2367 if (input[i].dwFlags & TOUCHEVENTF_MOVE) { | 2362 if (input[i].dwFlags & TOUCHEVENTF_MOVE) { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 2383 void HWNDMessageHandler::GenerateTouchEvent(DWORD input_dwID, | 2378 void HWNDMessageHandler::GenerateTouchEvent(DWORD input_dwID, |
| 2384 const gfx::Point& point_location, | 2379 const gfx::Point& point_location, |
| 2385 ui::EventType touch_event_type, | 2380 ui::EventType touch_event_type, |
| 2386 TouchEvents* touch_events) { | 2381 TouchEvents* touch_events) { |
| 2387 int touch_id = static_cast<int>(id_generator_.GetGeneratedID(input_dwID)); | 2382 int touch_id = static_cast<int>(id_generator_.GetGeneratedID(input_dwID)); |
| 2388 if (touch_id < 0 || touch_id >= static_cast<int>(touch_id_list_.size())) { | 2383 if (touch_id < 0 || touch_id >= static_cast<int>(touch_id_list_.size())) { |
| 2389 return; | 2384 return; |
| 2390 } | 2385 } |
| 2391 | 2386 |
| 2392 TouchPoint& touch_point = touch_id_list_[touch_id]; | 2387 TouchPoint& touch_point = touch_id_list_[touch_id]; |
| 2388 int flags = ui::GetModifiersFromKeyState(); |
| 2389 |
| 2390 // The dwTime of every input in the WM_TOUCH message doesn't necessarily |
| 2391 // relate to the system time at all, so use base::TimeTicks::Now() for |
| 2392 // touchevent time. |
| 2393 base::TimeDelta now = ui::EventTimeForNow(); |
| 2393 | 2394 |
| 2394 // We set a check to assert that we do not have missing touch presses in | 2395 // We set a check to assert that we do not have missing touch presses in |
| 2395 // every message. | 2396 // every message. |
| 2396 bool has_missing_touch_press = touch_event_type != ui::ET_TOUCH_PRESSED && | 2397 bool has_missing_touch_press = touch_event_type != ui::ET_TOUCH_PRESSED && |
| 2397 touch_point.in_touch_list == InTouchList::NotPresent; | 2398 touch_point.in_touch_list == InTouchList::NotPresent; |
| 2398 CHECK(!has_missing_touch_press) << "There are missing touch presses"; | 2399 CHECK(!has_missing_touch_press) << "There are missing touch presses"; |
| 2399 | 2400 |
| 2400 int flags = ui::GetModifiersFromKeyState(); | |
| 2401 | |
| 2402 // The dwTime of every input in the WM_TOUCH message doesn't necessarily | |
| 2403 // relate to the system time at all, so use base::TimeTicks::Now() for | |
| 2404 // touchevent time. | |
| 2405 base::TimeDelta now = ui::EventTimeForNow(); | |
| 2406 | |
| 2407 ui::TouchEvent event(touch_event_type, point_location, touch_id, now); | 2401 ui::TouchEvent event(touch_event_type, point_location, touch_id, now); |
| 2408 event.set_flags(flags); | 2402 event.set_flags(flags); |
| 2409 event.latency()->AddLatencyNumberWithTimestamp( | 2403 event.latency()->AddLatencyNumberWithTimestamp( |
| 2410 ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 0, 0, base::TimeTicks::Now(), | 2404 ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 0, 0, base::TimeTicks::Now(), |
| 2411 1); | 2405 1); |
| 2412 touch_events->push_back(event); | 2406 touch_events->push_back(event); |
| 2413 | 2407 |
| 2414 // Mark the active touch pointers in the touch_id_list_ to be | 2408 // Mark the active touch pointers in the touch_id_list_ to be |
| 2415 // InCurrentMessage, so we can track the ones which are missed in the | 2409 // InCurrentMessage, so we can track the ones which are missed in the |
| 2416 // current message and release them. | 2410 // current message and release them. |
| (...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2803 SetWindowPos(hwnd(), NULL, 0, 0, 0, 0, flags | SWP_HIDEWINDOW); | 2797 SetWindowPos(hwnd(), NULL, 0, 0, 0, 0, flags | SWP_HIDEWINDOW); |
| 2804 SetWindowPos(hwnd(), NULL, 0, 0, 0, 0, flags | SWP_SHOWWINDOW); | 2798 SetWindowPos(hwnd(), NULL, 0, 0, 0, 0, flags | SWP_SHOWWINDOW); |
| 2805 } | 2799 } |
| 2806 // WM_DWMCOMPOSITIONCHANGED is only sent to top level windows, however we want | 2800 // WM_DWMCOMPOSITIONCHANGED is only sent to top level windows, however we want |
| 2807 // to notify our children too, since we can have MDI child windows who need to | 2801 // to notify our children too, since we can have MDI child windows who need to |
| 2808 // update their appearance. | 2802 // update their appearance. |
| 2809 EnumChildWindows(hwnd(), &SendDwmCompositionChanged, NULL); | 2803 EnumChildWindows(hwnd(), &SendDwmCompositionChanged, NULL); |
| 2810 } | 2804 } |
| 2811 | 2805 |
| 2812 } // namespace views | 2806 } // namespace views |
| OLD | NEW |