Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(474)

Side by Side Diff: ui/views/win/hwnd_message_handler.cc

Issue 1147583002: Fix a crash when views::HWNDMessageHandler::HandleTouchMessage (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove the check for missing touch press Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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";
sadrul 2015/05/19 23:38:12 I don't think we should crash here? Why not just i
ananta 2015/05/19 23:40:18 Wanted to check if the missing touch downs are bec
sadrul 2015/05/19 23:51:13 Should we keep the old CHECKs too then? If the pal
2357
2353 // TOUCHEVENTF_DOWN cannot be combined with TOUCHEVENTF_MOVE or 2358 // TOUCHEVENTF_DOWN cannot be combined with TOUCHEVENTF_MOVE or
2354 // TOUCHEVENTF_UP, but TOUCHEVENTF_MOVE and TOUCHEVENTF_UP can be combined 2359 // TOUCHEVENTF_UP, but TOUCHEVENTF_MOVE and TOUCHEVENTF_UP can be combined
2355 // in one input. 2360 // in one input.
2356 if (input[i].dwFlags & TOUCHEVENTF_DOWN) { 2361 if (input[i].dwFlags & TOUCHEVENTF_DOWN) {
2357 touch_down_contexts_++; 2362 touch_down_contexts_++;
2358 active_touch_point_count_++; 2363 active_touch_point_count_++;
2359 GenerateTouchEvent(input[i].dwID, point_location, ui::ET_TOUCH_PRESSED, 2364 GenerateTouchEvent(input[i].dwID, point_location, ui::ET_TOUCH_PRESSED,
2360 touch_events); 2365 touch_events);
2361 } else { 2366 } else {
2362 if (input[i].dwFlags & TOUCHEVENTF_MOVE) { 2367 if (input[i].dwFlags & TOUCHEVENTF_MOVE) {
(...skipping 22 matching lines...) Expand all
2385 } 2390 }
2386 2391
2387 TouchPoint& touch_point = touch_id_list_[touch_id]; 2392 TouchPoint& touch_point = touch_id_list_[touch_id];
2388 int flags = ui::GetModifiersFromKeyState(); 2393 int flags = ui::GetModifiersFromKeyState();
2389 2394
2390 // The dwTime of every input in the WM_TOUCH message doesn't necessarily 2395 // 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 2396 // relate to the system time at all, so use base::TimeTicks::Now() for
2392 // touchevent time. 2397 // touchevent time.
2393 base::TimeDelta now = ui::EventTimeForNow(); 2398 base::TimeDelta now = ui::EventTimeForNow();
2394 2399
2395 // We set a check to assert that we do not have missing touch presses in
2396 // every message.
2397 bool has_missing_touch_press = touch_event_type != ui::ET_TOUCH_PRESSED &&
2398 touch_point.in_touch_list == InTouchList::NotPresent;
2399 CHECK(!has_missing_touch_press) << "There are missing touch presses";
2400
2401 ui::TouchEvent event(touch_event_type, point_location, touch_id, now); 2400 ui::TouchEvent event(touch_event_type, point_location, touch_id, now);
2402 event.set_flags(flags); 2401 event.set_flags(flags);
2403 event.latency()->AddLatencyNumberWithTimestamp( 2402 event.latency()->AddLatencyNumberWithTimestamp(
2404 ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 0, 0, base::TimeTicks::Now(), 2403 ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 0, 0, base::TimeTicks::Now(),
2405 1); 2404 1);
2406 touch_events->push_back(event); 2405 touch_events->push_back(event);
2407 2406
2408 // Mark the active touch pointers in the touch_id_list_ to be 2407 // Mark the active touch pointers in the touch_id_list_ to be
2409 // InCurrentMessage, so we can track the ones which are missed in the 2408 // InCurrentMessage, so we can track the ones which are missed in the
2410 // current message and release them. 2409 // current message and release them.
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after
2797 SetWindowPos(hwnd(), NULL, 0, 0, 0, 0, flags | SWP_HIDEWINDOW); 2796 SetWindowPos(hwnd(), NULL, 0, 0, 0, 0, flags | SWP_HIDEWINDOW);
2798 SetWindowPos(hwnd(), NULL, 0, 0, 0, 0, flags | SWP_SHOWWINDOW); 2797 SetWindowPos(hwnd(), NULL, 0, 0, 0, 0, flags | SWP_SHOWWINDOW);
2799 } 2798 }
2800 // WM_DWMCOMPOSITIONCHANGED is only sent to top level windows, however we want 2799 // WM_DWMCOMPOSITIONCHANGED is only sent to top level windows, however we want
2801 // to notify our children too, since we can have MDI child windows who need to 2800 // to notify our children too, since we can have MDI child windows who need to
2802 // update their appearance. 2801 // update their appearance.
2803 EnumChildWindows(hwnd(), &SendDwmCompositionChanged, NULL); 2802 EnumChildWindows(hwnd(), &SendDwmCompositionChanged, NULL);
2804 } 2803 }
2805 2804
2806 } // namespace views 2805 } // namespace views
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698