Index: ui/views/win/hwnd_message_handler.cc |
=================================================================== |
--- ui/views/win/hwnd_message_handler.cc (revision 218568) |
+++ ui/views/win/hwnd_message_handler.cc (working copy) |
@@ -2041,11 +2041,17 @@ |
LRESULT HWNDMessageHandler::OnTouchEvent(UINT message, |
WPARAM w_param, |
LPARAM l_param) { |
+ // Handle touch events only on Aura for now. |
sky
2013/08/22 22:07:16
How does this effect non-aura?
ananta
2013/08/22 22:48:15
In non AURA the RenderWidgetHostViewWin class hand
|
+#if !defined(USE_AURA) |
+ SetMsgHandled(FALSE); |
+ return 0; |
+#endif |
int num_points = LOWORD(w_param); |
scoped_ptr<TOUCHINPUT[]> input(new TOUCHINPUT[num_points]); |
if (ui::GetTouchInputInfoWrapper(reinterpret_cast<HTOUCHINPUT>(l_param), |
num_points, input.get(), |
sizeof(TOUCHINPUT))) { |
+ TouchEvents touch_events; |
for (int i = 0; i < num_points; ++i) { |
ui::EventType touch_event_type = ui::ET_UNKNOWN; |
@@ -2058,8 +2064,6 @@ |
} else if (input[i].dwFlags & TOUCHEVENTF_MOVE) { |
touch_event_type = ui::ET_TOUCH_MOVED; |
} |
- // Handle touch events only on Aura for now. |
-#if defined(USE_AURA) |
if (touch_event_type != ui::ET_UNKNOWN) { |
POINT point; |
point.x = TOUCH_COORD_TO_PIXEL(input[i].x) / |
@@ -2074,10 +2078,16 @@ |
gfx::Point(point.x, point.y), |
input[i].dwID % ui::GestureSequence::kMaxGesturePoints, |
base::TimeDelta::FromMilliseconds(input[i].dwTime)); |
- delegate_->HandleTouchEvent(event); |
+ touch_events.push_back(event); |
} |
-#endif |
} |
+ // Handle the touch events asynchronously. We need this because touch |
+ // events on windows don't fire if we enter a modal loop in the context of |
+ // a touch event. |
+ base::MessageLoop::current()->PostTask( |
+ FROM_HERE, |
+ base::Bind(&HWNDMessageHandler::HandleTouchEvents, |
+ base::Unretained(this), touch_events)); |
sky
2013/08/22 22:07:16
Don't use Unretained here. There is no guarantee t
ananta
2013/08/22 22:48:15
Done.
|
} |
CloseTouchInputHandle(reinterpret_cast<HTOUCHINPUT>(l_param)); |
SetMsgHandled(FALSE); |
@@ -2181,4 +2191,12 @@ |
SetMsgHandled(FALSE); |
} |
+void HWNDMessageHandler::HandleTouchEvents(const TouchEvents& touch_events) { |
+ if (!delegate_) |
+ return; |
+ for (size_t i = 0; i < touch_events.size(); ++i) { |
sky
2013/08/22 22:07:16
nit: no {}
ananta
2013/08/22 22:48:15
Done.
|
+ delegate_->HandleTouchEvent(touch_events[i]); |
+ } |
+} |
+ |
} // namespace views |