diff options
Diffstat (limited to 'ui')
-rw-r--r-- | ui/views/widget/desktop_aura/desktop_root_window_host_win.cc | 6 | ||||
-rw-r--r-- | ui/views/widget/desktop_aura/desktop_root_window_host_win.h | 1 | ||||
-rw-r--r-- | ui/views/widget/native_widget_win.cc | 5 | ||||
-rw-r--r-- | ui/views/widget/native_widget_win.h | 1 | ||||
-rw-r--r-- | ui/views/win/hwnd_message_handler.cc | 38 | ||||
-rw-r--r-- | ui/views/win/hwnd_message_handler_delegate.h | 5 |
6 files changed, 54 insertions, 2 deletions
diff --git a/ui/views/widget/desktop_aura/desktop_root_window_host_win.cc b/ui/views/widget/desktop_aura/desktop_root_window_host_win.cc index dfcad72..23b2f06 100644 --- a/ui/views/widget/desktop_aura/desktop_root_window_host_win.cc +++ b/ui/views/widget/desktop_aura/desktop_root_window_host_win.cc @@ -680,6 +680,12 @@ bool DesktopRootWindowHostWin::HandleUntranslatedKeyEvent( OnHostKeyEvent(duplicate_event.get()); } +bool DesktopRootWindowHostWin::HandleTouchEvent( + const ui::TouchEvent& event) { + return root_window_host_delegate_->OnHostTouchEvent( + const_cast<ui::TouchEvent*>(&event)); +} + bool DesktopRootWindowHostWin::HandleIMEMessage(UINT message, WPARAM w_param, LPARAM l_param, diff --git a/ui/views/widget/desktop_aura/desktop_root_window_host_win.h b/ui/views/widget/desktop_aura/desktop_root_window_host_win.h index 643cdd6..ea8d417 100644 --- a/ui/views/widget/desktop_aura/desktop_root_window_host_win.h +++ b/ui/views/widget/desktop_aura/desktop_root_window_host_win.h @@ -172,6 +172,7 @@ class VIEWS_EXPORT DesktopRootWindowHostWin virtual bool HandleMouseEvent(const ui::MouseEvent& event) OVERRIDE; virtual bool HandleKeyEvent(const ui::KeyEvent& event) OVERRIDE; virtual bool HandleUntranslatedKeyEvent(const ui::KeyEvent& event) OVERRIDE; + virtual bool HandleTouchEvent(const ui::TouchEvent& event) OVERRIDE; virtual bool HandleIMEMessage(UINT message, WPARAM w_param, LPARAM l_param, diff --git a/ui/views/widget/native_widget_win.cc b/ui/views/widget/native_widget_win.cc index 892c283..db96721 100644 --- a/ui/views/widget/native_widget_win.cc +++ b/ui/views/widget/native_widget_win.cc @@ -781,6 +781,11 @@ bool NativeWidgetWin::HandleUntranslatedKeyEvent(const ui::KeyEvent& event) { return !!input_method; } +bool NativeWidgetWin::HandleTouchEvent(const ui::TouchEvent& event) { + NOTREACHED() << "Touch events are not supported"; + return false; +} + bool NativeWidgetWin::HandleIMEMessage(UINT message, WPARAM w_param, LPARAM l_param, diff --git a/ui/views/widget/native_widget_win.h b/ui/views/widget/native_widget_win.h index 2855fb69..769818d 100644 --- a/ui/views/widget/native_widget_win.h +++ b/ui/views/widget/native_widget_win.h @@ -230,6 +230,7 @@ class VIEWS_EXPORT NativeWidgetWin : public internal::NativeWidgetPrivate, virtual bool HandleMouseEvent(const ui::MouseEvent& event) OVERRIDE; virtual bool HandleKeyEvent(const ui::KeyEvent& event) OVERRIDE; virtual bool HandleUntranslatedKeyEvent(const ui::KeyEvent& event) OVERRIDE; + virtual bool HandleTouchEvent(const ui::TouchEvent& event) OVERRIDE; virtual bool HandleIMEMessage(UINT message, WPARAM w_param, LPARAM l_param, diff --git a/ui/views/win/hwnd_message_handler.cc b/ui/views/win/hwnd_message_handler.cc index 57cbfaf..9061bdf 100644 --- a/ui/views/win/hwnd_message_handler.cc +++ b/ui/views/win/hwnd_message_handler.cc @@ -295,6 +295,10 @@ const int kCustomObjectID = 1; // The thickness of an auto-hide taskbar in pixels. const int kAutoHideTaskbarThicknessPx = 2; +// The touch id to be used for touch events coming in from Windows Aura +// Desktop. +const int kDesktopChromeAuraTouchId = 9; + } // namespace // A scoping class that prevents a window from being able to redraw in response @@ -1463,6 +1467,12 @@ LRESULT HWNDMessageHandler::OnMouseActivate(UINT message, LRESULT HWNDMessageHandler::OnMouseRange(UINT message, WPARAM w_param, LPARAM l_param) { +#if defined(USE_AURA) + // We handle touch events on Windows Aura. Ignore synthesized mouse messages + // from Windows. + if (!touch_ids_.empty() || ui::IsMouseEventFromTouch(message)) + return 0; +#endif if (message == WM_RBUTTONUP && is_right_mouse_pressed_on_caption_) { is_right_mouse_pressed_on_caption_ = false; ReleaseCapture(); @@ -1974,10 +1984,34 @@ LRESULT HWNDMessageHandler::OnTouchEvent(UINT message, if (GetTouchInputInfo(reinterpret_cast<HTOUCHINPUT>(l_param), num_points, input.get(), sizeof(TOUCHINPUT))) { for (int i = 0; i < num_points; ++i) { - if (input[i].dwFlags & TOUCHEVENTF_DOWN) + ui::EventType touch_event_type = ui::ET_UNKNOWN; + + if (input[i].dwFlags & TOUCHEVENTF_DOWN) { touch_ids_.insert(input[i].dwID); - if (input[i].dwFlags & TOUCHEVENTF_UP) + touch_event_type = ui::ET_TOUCH_PRESSED; + } else if (input[i].dwFlags & TOUCHEVENTF_UP) { touch_ids_.erase(input[i].dwID); + touch_event_type = ui::ET_TOUCH_RELEASED; + } 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); + point.y = TOUCH_COORD_TO_PIXEL(input[i].y); + + ScreenToClient(hwnd(), &point); + + ui::TouchEvent event( + touch_event_type, + gfx::Point(point.x, point.y), + kDesktopChromeAuraTouchId, + base::TimeDelta::FromMilliseconds(input[i].dwTime)); + delegate_->HandleTouchEvent(event); + } +#endif } } CloseTouchInputHandle(reinterpret_cast<HTOUCHINPUT>(l_param)); diff --git a/ui/views/win/hwnd_message_handler_delegate.h b/ui/views/win/hwnd_message_handler_delegate.h index 16927f9..53235dc 100644 --- a/ui/views/win/hwnd_message_handler_delegate.h +++ b/ui/views/win/hwnd_message_handler_delegate.h @@ -19,6 +19,7 @@ namespace ui { class Accelerator; class KeyEvent; class MouseEvent; +class TouchEvent; } namespace views { @@ -171,6 +172,10 @@ class VIEWS_EXPORT HWNDMessageHandlerDelegate { // translation). Returns true if the event was sent to the input method. virtual bool HandleUntranslatedKeyEvent(const ui::KeyEvent& event) = 0; + // Called when a touch event is received. Returns true if the event was + // handled by the delegate. + virtual bool HandleTouchEvent(const ui::TouchEvent& event) = 0; + // Called when an IME message needs to be processed by the delegate. Returns // true if the event was handled and no default processing should be // performed. |