Commit 970c05c9 authored by girard@chromium.org's avatar girard@chromium.org

Correct behaviour of touch wrt mouse capture.

We short circuit emulated mouse events (they are emulated on a touch) so
that these events don't get passed to javascript. The short circuit logic
also short-circuited the mouse capture/release logic, which caused failure
when touch happened during a mouse-capture.  

This commit ensures that only the call to ForwardMouseEvent is short-
circuited for emulated events.

BUG=132068
TEST=


Review URL: https://chromiumcodereview.appspot.com/10802085

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@148547 0039d316-1c4b-4281-b951-d872f2087c98
parent 6623b64b
...@@ -66,9 +66,6 @@ ...@@ -66,9 +66,6 @@
#include "webkit/plugins/npapi/webplugin.h" #include "webkit/plugins/npapi/webplugin.h"
#include "webkit/plugins/npapi/webplugin_delegate_impl.h" #include "webkit/plugins/npapi/webplugin_delegate_impl.h"
// From MSDN.
#define MOUSEEVENTF_FROMTOUCH 0xFF515700
using base::TimeDelta; using base::TimeDelta;
using base::TimeTicks; using base::TimeTicks;
using ui::ViewProp; using ui::ViewProp;
...@@ -1872,15 +1869,6 @@ LRESULT RenderWidgetHostViewWin::OnMouseEvent(UINT message, WPARAM wparam, ...@@ -1872,15 +1869,6 @@ LRESULT RenderWidgetHostViewWin::OnMouseEvent(UINT message, WPARAM wparam,
TRACE_EVENT0("browser", "RenderWidgetHostViewWin::OnMouseEvent"); TRACE_EVENT0("browser", "RenderWidgetHostViewWin::OnMouseEvent");
handled = TRUE; handled = TRUE;
// Windows sends (fake) mouse messages for touch events. Ignore these since
// we're processing WM_TOUCH elsewhere.
if (touch_events_enabled_ && (message == WM_MOUSEMOVE ||
message == WM_LBUTTONDOWN || message == WM_LBUTTONUP ||
message == WM_RBUTTONDOWN || message == WM_RBUTTONUP) &&
(GetMessageExtraInfo() & MOUSEEVENTF_FROMTOUCH) ==
MOUSEEVENTF_FROMTOUCH)
return 0;
if (message == WM_MOUSELEAVE) if (message == WM_MOUSELEAVE)
ignore_mouse_movement_ = true; ignore_mouse_movement_ = true;
...@@ -2934,9 +2922,13 @@ void RenderWidgetHostViewWin::ForwardMouseEventToRenderer(UINT message, ...@@ -2934,9 +2922,13 @@ void RenderWidgetHostViewWin::ForwardMouseEventToRenderer(UINT message,
last_mouse_position_.unlocked_global.SetPoint(event.globalX, event.globalY); last_mouse_position_.unlocked_global.SetPoint(event.globalX, event.globalY);
} }
// Send the event to the renderer before changing mouse capture, so that the // Windows sends (fake) mouse messages for touch events. Don't send these to
// capturelost event arrives after mouseup. // the render widget.
render_widget_host_->ForwardMouseEvent(event); if (!touch_events_enabled_ || !ui::IsMouseEventFromTouch(message)) {
// Send the event to the renderer before changing mouse capture, so that
// the capturelost event arrives after mouseup.
render_widget_host_->ForwardMouseEvent(event);
}
switch (event.type) { switch (event.type) {
case WebInputEvent::MouseMove: case WebInputEvent::MouseMove:
......
...@@ -208,6 +208,10 @@ UI_EXPORT base::NativeEvent CreateNoopEvent(); ...@@ -208,6 +208,10 @@ UI_EXPORT base::NativeEvent CreateNoopEvent();
#if defined(OS_WIN) #if defined(OS_WIN)
UI_EXPORT int GetModifiersFromACCEL(const ACCEL& accel); UI_EXPORT int GetModifiersFromACCEL(const ACCEL& accel);
// Returns true if |message| identifies a mouse event that was generated as the
// result of a touch event.
UI_EXPORT bool IsMouseEventFromTouch(UINT message);
#endif #endif
} // namespace ui } // namespace ui
......
...@@ -14,6 +14,9 @@ ...@@ -14,6 +14,9 @@
namespace { namespace {
// From MSDN.
#define MOUSEEVENTF_FROMTOUCH 0xFF515700
// Get the native mouse key state from the native event message type. // Get the native mouse key state from the native event message type.
int GetNativeMouseKey(const base::NativeEvent& native_event) { int GetNativeMouseKey(const base::NativeEvent& native_event) {
switch (native_event.message) { switch (native_event.message) {
...@@ -312,4 +315,13 @@ int GetModifiersFromACCEL(const ACCEL& accel) { ...@@ -312,4 +315,13 @@ int GetModifiersFromACCEL(const ACCEL& accel) {
return modifiers; return modifiers;
} }
// Windows emulates mouse messages for touch events.
bool IsMouseEventFromTouch(UINT message) {
return (message == WM_MOUSEMOVE ||
message == WM_LBUTTONDOWN || message == WM_LBUTTONUP ||
message == WM_RBUTTONDOWN || message == WM_RBUTTONUP) &&
(GetMessageExtraInfo() & MOUSEEVENTF_FROMTOUCH) ==
MOUSEEVENTF_FROMTOUCH;
}
} // namespace ui } // namespace ui
...@@ -58,9 +58,6 @@ ...@@ -58,9 +58,6 @@
#pragma comment(lib, "dwmapi.lib") #pragma comment(lib, "dwmapi.lib")
// From msdn:
#define MOUSEEVENTF_FROMTOUCH 0xFF515700
using ui::ViewProp; using ui::ViewProp;
namespace views { namespace views {
...@@ -1631,14 +1628,8 @@ LRESULT NativeWidgetWin::OnMouseRange(UINT message, ...@@ -1631,14 +1628,8 @@ LRESULT NativeWidgetWin::OnMouseRange(UINT message,
MSG msg = { hwnd(), message, w_param, l_param, 0, MSG msg = { hwnd(), message, w_param, l_param, 0,
{ GET_X_LPARAM(l_param), GET_Y_LPARAM(l_param) } }; { GET_X_LPARAM(l_param), GET_Y_LPARAM(l_param) } };
MouseEvent event(msg); MouseEvent event(msg);
// Only button up/down have MOUSEEVENTF_FROMTOUCH set. if (!touch_ids_.empty() || ui::IsMouseEventFromTouch(message))
if (!touch_ids_.empty() ||
((message == WM_LBUTTONDOWN || message == WM_LBUTTONUP ||
message == WM_RBUTTONDOWN || message == WM_RBUTTONUP) &&
(GetMessageExtraInfo() & MOUSEEVENTF_FROMTOUCH) ==
MOUSEEVENTF_FROMTOUCH)) {
event.set_flags(event.flags() | ui::EF_FROM_TOUCH); event.set_flags(event.flags() | ui::EF_FROM_TOUCH);
}
if (!(event.flags() & ui::EF_IS_NON_CLIENT)) if (!(event.flags() & ui::EF_IS_NON_CLIENT))
if (tooltip_manager_.get()) if (tooltip_manager_.get())
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment