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

Side by Side Diff: content/browser/renderer_host/render_widget_host_view_win.cc

Issue 10802085: Correct behaviour of touch wrt mouse capture. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 4 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 "content/browser/renderer_host/render_widget_host_view_win.h" 5 #include "content/browser/renderer_host/render_widget_host_view_win.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <map> 8 #include <map>
9 #include <peninputpanel_i.c> 9 #include <peninputpanel_i.c>
10 #include <stack> 10 #include <stack>
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 result.windowX = result.x; 285 result.windowX = result.x;
286 result.windowY = result.y; 286 result.windowY = result.y;
287 // Note that we support diagonal scrolling. 287 // Note that we support diagonal scrolling.
288 result.deltaX = static_cast<float>(delta.x); 288 result.deltaX = static_cast<float>(delta.x);
289 result.wheelTicksX = WHEEL_DELTA; 289 result.wheelTicksX = WHEEL_DELTA;
290 result.deltaY = static_cast<float>(delta.y); 290 result.deltaY = static_cast<float>(delta.y);
291 result.wheelTicksY = WHEEL_DELTA; 291 result.wheelTicksY = WHEEL_DELTA;
292 return result; 292 return result;
293 } 293 }
294 294
295 // Windows emulates mouse messages for touch events.
296 bool IsEmulatedMouseEvent(UINT message) {
sky 2012/07/24 16:41:40 Move this to ui/base/win/events_win.h/events_win.c
girard 2012/07/24 19:49:01 Done.
297 return (message == WM_MOUSEMOVE ||
298 message == WM_LBUTTONDOWN || message == WM_LBUTTONUP ||
299 message == WM_RBUTTONDOWN || message == WM_RBUTTONUP) &&
300 (GetMessageExtraInfo() & MOUSEEVENTF_FROMTOUCH) ==
301 MOUSEEVENTF_FROMTOUCH;
302 }
303
295 static const int kTouchMask = 0x7; 304 static const int kTouchMask = 0x7;
296 305
297 inline int GetTouchType(const TOUCHINPUT& point) { 306 inline int GetTouchType(const TOUCHINPUT& point) {
298 return point.dwFlags & kTouchMask; 307 return point.dwFlags & kTouchMask;
299 } 308 }
300 309
301 inline void SetTouchType(TOUCHINPUT* point, int type) { 310 inline void SetTouchType(TOUCHINPUT* point, int type) {
302 point->dwFlags = (point->dwFlags & kTouchMask) | type; 311 point->dwFlags = (point->dwFlags & kTouchMask) | type;
303 } 312 }
304 313
(...skipping 1545 matching lines...) Expand 10 before | Expand all | Expand 10 after
1850 handled = FALSE; 1859 handled = FALSE;
1851 return 0; 1860 return 0;
1852 } 1861 }
1853 } 1862 }
1854 1863
1855 LRESULT RenderWidgetHostViewWin::OnMouseEvent(UINT message, WPARAM wparam, 1864 LRESULT RenderWidgetHostViewWin::OnMouseEvent(UINT message, WPARAM wparam,
1856 LPARAM lparam, BOOL& handled) { 1865 LPARAM lparam, BOOL& handled) {
1857 TRACE_EVENT0("browser", "RenderWidgetHostViewWin::OnMouseEvent"); 1866 TRACE_EVENT0("browser", "RenderWidgetHostViewWin::OnMouseEvent");
1858 handled = TRUE; 1867 handled = TRUE;
1859 1868
1860 // Windows sends (fake) mouse messages for touch events. Ignore these since
1861 // we're processing WM_TOUCH elsewhere.
1862 if (touch_events_enabled_ && (message == WM_MOUSEMOVE ||
1863 message == WM_LBUTTONDOWN || message == WM_LBUTTONUP ||
1864 message == WM_RBUTTONDOWN || message == WM_RBUTTONUP) &&
1865 (GetMessageExtraInfo() & MOUSEEVENTF_FROMTOUCH) ==
1866 MOUSEEVENTF_FROMTOUCH)
1867 return 0;
1868
1869 if (message == WM_MOUSELEAVE) 1869 if (message == WM_MOUSELEAVE)
1870 ignore_mouse_movement_ = true; 1870 ignore_mouse_movement_ = true;
1871 1871
1872 if (mouse_locked_) { 1872 if (mouse_locked_) {
1873 HandleLockedMouseEvent(message, wparam, lparam); 1873 HandleLockedMouseEvent(message, wparam, lparam);
1874 MoveCursorToCenterIfNecessary(); 1874 MoveCursorToCenterIfNecessary();
1875 return 0; 1875 return 0;
1876 } 1876 }
1877 1877
1878 if (::IsWindow(tooltip_hwnd_)) { 1878 if (::IsWindow(tooltip_hwnd_)) {
(...skipping 1033 matching lines...) Expand 10 before | Expand all | Expand 10 after
2912 event.movementX = 2912 event.movementX =
2913 event.globalX - last_mouse_position_.unlocked_global.x(); 2913 event.globalX - last_mouse_position_.unlocked_global.x();
2914 event.movementY = 2914 event.movementY =
2915 event.globalY - last_mouse_position_.unlocked_global.y(); 2915 event.globalY - last_mouse_position_.unlocked_global.y();
2916 } 2916 }
2917 2917
2918 last_mouse_position_.unlocked.SetPoint(event.windowX, event.windowY); 2918 last_mouse_position_.unlocked.SetPoint(event.windowX, event.windowY);
2919 last_mouse_position_.unlocked_global.SetPoint(event.globalX, event.globalY); 2919 last_mouse_position_.unlocked_global.SetPoint(event.globalX, event.globalY);
2920 } 2920 }
2921 2921
2922 // Send the event to the renderer before changing mouse capture, so that the 2922 // Windows sends (fake) mouse messages for touch events. Don't send these to
2923 // capturelost event arrives after mouseup. 2923 // the render widget.
2924 render_widget_host_->ForwardMouseEvent(event); 2924 if (!(touch_events_enabled_ && IsEmulatedMouseEvent(message))) {
2925 // Send the event to the renderer before changing mouse capture, so that the
2926 // capturelost event arrives after mouseup.
2927 render_widget_host_->ForwardMouseEvent(event);
2928 }
2925 2929
2926 switch (event.type) { 2930 switch (event.type) {
2927 case WebInputEvent::MouseMove: 2931 case WebInputEvent::MouseMove:
2928 TrackMouseLeave(true); 2932 TrackMouseLeave(true);
2929 break; 2933 break;
2930 case WebInputEvent::MouseLeave: 2934 case WebInputEvent::MouseLeave:
2931 TrackMouseLeave(false); 2935 TrackMouseLeave(false);
2932 break; 2936 break;
2933 case WebInputEvent::MouseDown: 2937 case WebInputEvent::MouseDown:
2934 SetCapture(); 2938 SetCapture();
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
3155 // receive a focus change in the context of a pointer down message, it means 3159 // receive a focus change in the context of a pointer down message, it means
3156 // that the pointer down message occurred on the edit field and we should 3160 // that the pointer down message occurred on the edit field and we should
3157 // display the on screen keyboard 3161 // display the on screen keyboard
3158 if (!received_focus_change_after_pointer_down_ && virtual_keyboard_) 3162 if (!received_focus_change_after_pointer_down_ && virtual_keyboard_)
3159 DisplayOnScreenKeyboardIfNeeded(); 3163 DisplayOnScreenKeyboardIfNeeded();
3160 received_focus_change_after_pointer_down_ = false; 3164 received_focus_change_after_pointer_down_ = false;
3161 pointer_down_context_ = false; 3165 pointer_down_context_ = false;
3162 } 3166 }
3163 3167
3164 } // namespace content 3168 } // namespace content
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