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

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

Issue 1318653002: Attempt to fix mouse input issues after a sequence of touch presses. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Pass the correct input id to release touch state during touch release Created 5 years, 3 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 | « ui/views/win/hwnd_message_handler.h ('k') | 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 2323 matching lines...) Expand 10 before | Expand all | Expand 10 after
2334 2334
2335 // Handle touch events only on Aura for now. 2335 // Handle touch events only on Aura for now.
2336 int num_points = LOWORD(w_param); 2336 int num_points = LOWORD(w_param);
2337 scoped_ptr<TOUCHINPUT[]> input(new TOUCHINPUT[num_points]); 2337 scoped_ptr<TOUCHINPUT[]> input(new TOUCHINPUT[num_points]);
2338 if (ui::GetTouchInputInfoWrapper(reinterpret_cast<HTOUCHINPUT>(l_param), 2338 if (ui::GetTouchInputInfoWrapper(reinterpret_cast<HTOUCHINPUT>(l_param),
2339 num_points, input.get(), 2339 num_points, input.get(),
2340 sizeof(TOUCHINPUT))) { 2340 sizeof(TOUCHINPUT))) {
2341 // input[i].dwTime doesn't necessarily relate to the system time at all, 2341 // input[i].dwTime doesn't necessarily relate to the system time at all,
2342 // so use base::TimeTicks::Now(). 2342 // so use base::TimeTicks::Now().
2343 const base::TimeTicks event_time = base::TimeTicks::Now(); 2343 const base::TimeTicks event_time = base::TimeTicks::Now();
2344 int flags = ui::GetModifiersFromKeyState();
2345 TouchEvents touch_events; 2344 TouchEvents touch_events;
2346 for (int i = 0; i < num_points; ++i) { 2345 for (int i = 0; i < num_points; ++i) {
2347 POINT point; 2346 POINT point;
2348 point.x = TOUCH_COORD_TO_PIXEL(input[i].x); 2347 point.x = TOUCH_COORD_TO_PIXEL(input[i].x);
2349 point.y = TOUCH_COORD_TO_PIXEL(input[i].y); 2348 point.y = TOUCH_COORD_TO_PIXEL(input[i].y);
2350 2349
2351 if (base::win::GetVersion() == base::win::VERSION_WIN7) { 2350 if (base::win::GetVersion() == base::win::VERSION_WIN7) {
2352 // Windows 7 sends touch events for touches in the non-client area, 2351 // Windows 7 sends touch events for touches in the non-client area,
2353 // whereas Windows 8 does not. In order to unify the behaviour, always 2352 // whereas Windows 8 does not. In order to unify the behaviour, always
2354 // ignore touch events in the non-client area. 2353 // ignore touch events in the non-client area.
2355 LPARAM l_param_ht = MAKELPARAM(point.x, point.y); 2354 LPARAM l_param_ht = MAKELPARAM(point.x, point.y);
2356 LRESULT hittest = SendMessage(hwnd(), WM_NCHITTEST, 0, l_param_ht); 2355 LRESULT hittest = SendMessage(hwnd(), WM_NCHITTEST, 0, l_param_ht);
2357 2356
2358 if (hittest != HTCLIENT) 2357 if (hittest != HTCLIENT)
2359 return 0; 2358 return 0;
2360 } 2359 }
2361 2360
2362 ScreenToClient(hwnd(), &point); 2361 ScreenToClient(hwnd(), &point);
2363 2362
2364 last_touch_message_time_ = ::GetMessageTime(); 2363 last_touch_message_time_ = ::GetMessageTime();
2365 2364
2366 ui::EventType touch_event_type = ui::ET_UNKNOWN; 2365 gfx::Point touch_point(point.x, point.y);
2366 unsigned int touch_id = id_generator_.GetGeneratedID(input[i].dwID);
2367 base::TimeDelta time_delta = event_time - base::TimeTicks();
2367 2368
2368 if (input[i].dwFlags & TOUCHEVENTF_DOWN) { 2369 if (input[i].dwFlags & TOUCHEVENTF_DOWN) {
2369 touch_ids_.insert(input[i].dwID); 2370 touch_ids_.insert(input[i].dwID);
2370 touch_event_type = ui::ET_TOUCH_PRESSED; 2371 GenerateTouchEvent(ui::ET_TOUCH_PRESSED, touch_point, touch_id,
2372 event_time, time_delta, &touch_events);
2371 touch_down_contexts_++; 2373 touch_down_contexts_++;
2372 base::MessageLoop::current()->PostDelayedTask( 2374 base::MessageLoop::current()->PostDelayedTask(
2373 FROM_HERE, 2375 FROM_HERE,
2374 base::Bind(&HWNDMessageHandler::ResetTouchDownContext, 2376 base::Bind(&HWNDMessageHandler::ResetTouchDownContext,
2375 weak_factory_.GetWeakPtr()), 2377 weak_factory_.GetWeakPtr()),
2376 base::TimeDelta::FromMilliseconds(kTouchDownContextResetTimeout)); 2378 base::TimeDelta::FromMilliseconds(kTouchDownContextResetTimeout));
2377 } else if (input[i].dwFlags & TOUCHEVENTF_UP) { 2379 } else {
2378 touch_ids_.erase(input[i].dwID); 2380 if (input[i].dwFlags & TOUCHEVENTF_MOVE) {
2379 touch_event_type = ui::ET_TOUCH_RELEASED; 2381 GenerateTouchEvent(ui::ET_TOUCH_MOVED, touch_point, touch_id,
2380 } else if (input[i].dwFlags & TOUCHEVENTF_MOVE) { 2382 event_time, time_delta, &touch_events);
2381 touch_event_type = ui::ET_TOUCH_MOVED; 2383 }
2382 }
2383 if (touch_event_type != ui::ET_UNKNOWN) {
2384 ui::TouchEvent event(touch_event_type,
2385 gfx::Point(point.x, point.y),
2386 id_generator_.GetGeneratedID(input[i].dwID),
2387 event_time - base::TimeTicks());
2388 event.set_flags(flags);
2389 event.latency()->AddLatencyNumberWithTimestamp(
2390 ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT,
2391 0,
2392 0,
2393 event_time,
2394 1);
2395 2384
2396 touch_events.push_back(event); 2385 if (input[i].dwFlags & TOUCHEVENTF_UP) {
2397 if (touch_event_type == ui::ET_TOUCH_RELEASED) 2386 touch_ids_.erase(input[i].dwID);
2387 GenerateTouchEvent(ui::ET_TOUCH_RELEASED, touch_point, touch_id,
2388 event_time, time_delta, &touch_events);
2398 id_generator_.ReleaseNumber(input[i].dwID); 2389 id_generator_.ReleaseNumber(input[i].dwID);
2390 }
2399 } 2391 }
2400 } 2392 }
2401 // Handle the touch events asynchronously. We need this because touch 2393 // Handle the touch events asynchronously. We need this because touch
2402 // events on windows don't fire if we enter a modal loop in the context of 2394 // events on windows don't fire if we enter a modal loop in the context of
2403 // a touch event. 2395 // a touch event.
2404 base::MessageLoop::current()->PostTask( 2396 base::MessageLoop::current()->PostTask(
2405 FROM_HERE, 2397 FROM_HERE,
2406 base::Bind(&HWNDMessageHandler::HandleTouchEvents, 2398 base::Bind(&HWNDMessageHandler::HandleTouchEvents,
2407 weak_factory_.GetWeakPtr(), touch_events)); 2399 weak_factory_.GetWeakPtr(), touch_events));
2408 } 2400 }
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after
2783 UINT flags = SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER; 2775 UINT flags = SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER;
2784 SetWindowPos(hwnd(), NULL, 0, 0, 0, 0, flags | SWP_HIDEWINDOW); 2776 SetWindowPos(hwnd(), NULL, 0, 0, 0, 0, flags | SWP_HIDEWINDOW);
2785 SetWindowPos(hwnd(), NULL, 0, 0, 0, 0, flags | SWP_SHOWWINDOW); 2777 SetWindowPos(hwnd(), NULL, 0, 0, 0, 0, flags | SWP_SHOWWINDOW);
2786 } 2778 }
2787 // WM_DWMCOMPOSITIONCHANGED is only sent to top level windows, however we want 2779 // WM_DWMCOMPOSITIONCHANGED is only sent to top level windows, however we want
2788 // to notify our children too, since we can have MDI child windows who need to 2780 // to notify our children too, since we can have MDI child windows who need to
2789 // update their appearance. 2781 // update their appearance.
2790 EnumChildWindows(hwnd(), &SendDwmCompositionChanged, NULL); 2782 EnumChildWindows(hwnd(), &SendDwmCompositionChanged, NULL);
2791 } 2783 }
2792 2784
2785 void HWNDMessageHandler::GenerateTouchEvent(ui::EventType event_type,
2786 const gfx::Point& point,
2787 unsigned int id,
2788 base::TimeTicks event_time,
2789 base::TimeDelta time_stamp,
2790 TouchEvents* touch_events) {
2791 ui::TouchEvent event(event_type, point, id, time_stamp);
2792
2793 event.set_flags(ui::GetModifiersFromKeyState());
2794
2795 event.latency()->AddLatencyNumberWithTimestamp(
2796 ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT,
2797 0,
2798 0,
2799 event_time,
2800 1);
2801
2802 touch_events->push_back(event);
2803 }
2804
2793 } // namespace views 2805 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/win/hwnd_message_handler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698