diff options
author | cpu@chromium.org <cpu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-05 21:22:12 +0000 |
---|---|---|
committer | cpu@chromium.org <cpu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-05 21:22:12 +0000 |
commit | 884cef8f1a6f00d95f686e5cdba9b147ab4aa8a9 (patch) | |
tree | d875a3c455224c8569cd642926792cb4504d40d7 /ui | |
parent | e99cd4dca809897000378a6a4c567ab7aa8dce2b (diff) | |
download | chromium_src-884cef8f1a6f00d95f686e5cdba9b147ab4aa8a9.zip chromium_src-884cef8f1a6f00d95f686e5cdba9b147ab4aa8a9.tar.gz chromium_src-884cef8f1a6f00d95f686e5cdba9b147ab4aa8a9.tar.bz2 |
Better mouse support for metro aura
-Wheel, r-click and l-click now discriminated
-More efficient, clean mouse event handling
Note; wheel event not properly handled. That is a bigger CL
that will come later.
BUG=151718
TEST= right click and left click
Review URL: https://codereview.chromium.org/11312025
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@166034 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r-- | ui/aura/remote_root_window_host_win.cc | 23 | ||||
-rw-r--r-- | ui/aura/remote_root_window_host_win.h | 4 | ||||
-rw-r--r-- | ui/base/events/event.cc | 5 | ||||
-rw-r--r-- | ui/base/events/event.h | 1 | ||||
-rw-r--r-- | ui/metro_viewer/metro_viewer_messages.h | 14 |
5 files changed, 34 insertions, 13 deletions
diff --git a/ui/aura/remote_root_window_host_win.cc b/ui/aura/remote_root_window_host_win.cc index 63b55433..918ac4d 100644 --- a/ui/aura/remote_root_window_host_win.cc +++ b/ui/aura/remote_root_window_host_win.cc @@ -17,6 +17,9 @@ #include "ui/base/keycodes/keyboard_code_conversion_win.h" #include "ui/base/view_prop.h" +// From metro_viewer_messages.h we only care for the enums. +#include "ui/metro_viewer/metro_viewer_messages.h" + using std::max; using std::min; @@ -141,7 +144,6 @@ void RemoteRootWindowHostWin::OnDeviceScaleFactorChanged( } void RemoteRootWindowHostWin::PrepareForShutdown() { - NOTIMPLEMENTED(); } void RemoteRootWindowHostWin::OnMouseMoved(int32 x, int32 y, int32 extra) { @@ -150,14 +152,19 @@ void RemoteRootWindowHostWin::OnMouseMoved(int32 x, int32 y, int32 extra) { delegate_->OnHostMouseEvent(&event); } -void RemoteRootWindowHostWin::OnMouseClick(int32 x, int32 y, int32 extra) { +void RemoteRootWindowHostWin::OnMouseButton( + int32 x, int32 y, int32 extra, ui::EventType type, ui::EventFlags flags) { gfx::Point location(x, y); - ui::EventType type = (extra == 1) ? - ui::ET_MOUSE_PRESSED : ui::ET_MOUSE_RELEASED; - ui::MouseEvent event(type, location, location, 0); - event.SetClickCount(1); - event.set_flags(ui::EF_LEFT_MOUSE_BUTTON); - delegate_->OnHostMouseEvent(&event); + ui::MouseEvent mouse_event(type, location, location, 0); + mouse_event.set_flags(flags); + + if (type == ui::ET_MOUSEWHEEL) { + ui::MouseWheelEvent wheel_event(mouse_event, extra); + delegate_->OnHostMouseEvent(&wheel_event); + } else { + mouse_event.SetClickCount(1); + delegate_->OnHostMouseEvent(&mouse_event); + } } void RemoteRootWindowHostWin::OnKeyDown(uint32 vkey, diff --git a/ui/aura/remote_root_window_host_win.h b/ui/aura/remote_root_window_host_win.h index 8e4e47d..79b6c4c 100644 --- a/ui/aura/remote_root_window_host_win.h +++ b/ui/aura/remote_root_window_host_win.h @@ -9,6 +9,7 @@ #include "base/compiler_specific.h" #include "ui/aura/root_window_host.h" +#include "ui/base/events/event_constants.h" #include "ui/base/win/window_impl.h" namespace ui { @@ -23,7 +24,8 @@ class AURA_EXPORT RemoteRootWindowHostWin : public RootWindowHost { static RemoteRootWindowHostWin* Create(const gfx::Rect& bounds); void OnMouseMoved(int32 x, int32 y, int32 extra); - void OnMouseClick(int32 x, int32 y, int32 extra); + void OnMouseButton( + int32 x, int32 y, int32 extra, ui::EventType type, ui::EventFlags flags); void OnKeyDown(uint32 vkey, uint32 repeat_count, uint32 scan_code, diff --git a/ui/base/events/event.cc b/ui/base/events/event.cc index 6a44c33..5086822 100644 --- a/ui/base/events/event.cc +++ b/ui/base/events/event.cc @@ -275,6 +275,11 @@ MouseWheelEvent::MouseWheelEvent(const ScrollEvent& scroll_event) set_type(ET_MOUSEWHEEL); } +MouseWheelEvent::MouseWheelEvent(const MouseEvent& mouse_event, int offset) + : MouseEvent(mouse_event), offset_(offset) { + DCHECK(type() == ET_MOUSEWHEEL); +} + #if defined(OS_WIN) // This value matches windows WHEEL_DELTA. // static diff --git a/ui/base/events/event.h b/ui/base/events/event.h index 4f2da00..61cf81b 100644 --- a/ui/base/events/event.h +++ b/ui/base/events/event.h @@ -369,6 +369,7 @@ class UI_EXPORT MouseWheelEvent : public MouseEvent { explicit MouseWheelEvent(const base::NativeEvent& native_event); explicit MouseWheelEvent(const ScrollEvent& scroll_event); + MouseWheelEvent(const MouseEvent& mouse_event, int offset); template <class T> MouseWheelEvent(const MouseWheelEvent& model, diff --git a/ui/metro_viewer/metro_viewer_messages.h b/ui/metro_viewer/metro_viewer_messages.h index ef72ec9..1a43e4c 100644 --- a/ui/metro_viewer/metro_viewer_messages.h +++ b/ui/metro_viewer/metro_viewer_messages.h @@ -6,10 +6,14 @@ #include "base/basictypes.h" #include "ipc/ipc_message_macros.h" +#include "ui/base/events/event_constants.h" #include "ui/gfx/native_widget_types.h" #define IPC_MESSAGE_START MetroViewerMsgStart +IPC_ENUM_TRAITS(ui::EventType) +IPC_ENUM_TRAITS(ui::EventFlags) + // Messages sent from the viewer to the browser. // Inform the browser of the surface to target for compositing. @@ -21,10 +25,12 @@ IPC_MESSAGE_CONTROL3(MetroViewerHostMsg_MouseMoved, int32, /* y-coordinate */ int32 /* modifiers */) // Inforoms the brower that a mouse button was pressed. -IPC_MESSAGE_CONTROL3(MetroViewerHostMsg_MouseButton, - int32, /* x-coordinate */ - int32, /* y-coordinate */ - int32 /* modifiers */) +IPC_MESSAGE_CONTROL5(MetroViewerHostMsg_MouseButton, + int32, /* x-coordinate */ + int32, /* y-coordinate */ + int32, /* extra */ + ui::EventType, /* event type */ + ui::EventFlags /* event flags */) // Informs the browser that a key was pressed. IPC_MESSAGE_CONTROL4(MetroViewerHostMsg_KeyDown, uint32, /* virtual key */ |