summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/metro_viewer/metro_viewer_process_host_win.cc6
-rw-r--r--chrome/browser/metro_viewer/metro_viewer_process_host_win.h4
-rw-r--r--content/browser/renderer_host/web_input_event_aura.cc26
-rw-r--r--content/browser/renderer_host/web_input_event_aura.h3
-rw-r--r--content/browser/renderer_host/web_input_event_aurax11.cc17
-rw-r--r--ui/aura/remote_root_window_host_win.cc23
-rw-r--r--ui/aura/remote_root_window_host_win.h4
-rw-r--r--ui/base/events/event.cc5
-rw-r--r--ui/base/events/event.h1
-rw-r--r--ui/metro_viewer/metro_viewer_messages.h14
-rw-r--r--win8/metro_driver/chrome_app_view_ash.cc107
-rw-r--r--win8/metro_driver/chrome_app_view_ash.h4
12 files changed, 149 insertions, 65 deletions
diff --git a/chrome/browser/metro_viewer/metro_viewer_process_host_win.cc b/chrome/browser/metro_viewer/metro_viewer_process_host_win.cc
index f7cbaea..1fd77f3 100644
--- a/chrome/browser/metro_viewer/metro_viewer_process_host_win.cc
+++ b/chrome/browser/metro_viewer/metro_viewer_process_host_win.cc
@@ -71,8 +71,10 @@ void MetroViewerProcessHost::OnMouseMoved(int32 x, int32 y, int32 modifiers) {
aura::RemoteRootWindowHostWin::Instance()->OnMouseMoved(x, y, modifiers);
}
-void MetroViewerProcessHost::OnMouseButton(int32 x, int32 y, int32 modifiers) {
- aura::RemoteRootWindowHostWin::Instance()->OnMouseClick(x, y, modifiers);
+void MetroViewerProcessHost::OnMouseButton(
+ int32 x, int32 y, int32 extra, ui::EventType type, ui::EventFlags flags) {
+ aura::RemoteRootWindowHostWin::Instance()->OnMouseButton(
+ x, y, extra, type, flags);
}
void MetroViewerProcessHost::OnKeyDown(uint32 vkey,
diff --git a/chrome/browser/metro_viewer/metro_viewer_process_host_win.h b/chrome/browser/metro_viewer/metro_viewer_process_host_win.h
index 2782933..f825826 100644
--- a/chrome/browser/metro_viewer/metro_viewer_process_host_win.h
+++ b/chrome/browser/metro_viewer/metro_viewer_process_host_win.h
@@ -10,6 +10,7 @@
#include "base/threading/non_thread_safe.h"
#include "ipc/ipc_listener.h"
#include "ipc/ipc_sender.h"
+#include "ui/base/events/event_constants.h"
#include "ui/gfx/native_widget_types.h"
namespace IPC {
@@ -34,7 +35,8 @@ class MetroViewerProcessHost : public IPC::Listener,
void OnSetTargetSurface(gfx::NativeViewId target_surface);
void OnMouseEvent(int32 msg, WPARAM w_param, LPARAM l_param);
void OnMouseMoved(int32 x, int32 y, int32 modifiers);
- void OnMouseButton(int32 x, int32 y, int32 modifiers);
+ 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/content/browser/renderer_host/web_input_event_aura.cc b/content/browser/renderer_host/web_input_event_aura.cc
index f1b424a..fa2cb65 100644
--- a/content/browser/renderer_host/web_input_event_aura.cc
+++ b/content/browser/renderer_host/web_input_event_aura.cc
@@ -22,8 +22,6 @@ WebKit::WebGestureEvent MakeWebGestureEventFromNativeEvent(
base::NativeEvent native_event);
#else
WebKit::WebMouseWheelEvent MakeWebMouseWheelEventFromAuraEvent(
- ui::MouseWheelEvent* event);
-WebKit::WebMouseWheelEvent MakeWebMouseWheelEventFromAuraEvent(
ui::ScrollEvent* event);
WebKit::WebKeyboardEvent MakeWebKeyboardEventFromAuraEvent(
ui::KeyEvent* event);
@@ -31,7 +29,10 @@ WebKit::WebGestureEvent MakeWebGestureEventFromAuraEvent(
ui::ScrollEvent* event);
#endif
-WebKit::WebMouseEvent MakeWebMouseEventFromAuraEvent(ui::MouseEvent* event);
+WebKit::WebMouseEvent MakeWebMouseEventFromAuraEvent(
+ ui::MouseEvent* event);
+WebKit::WebMouseWheelEvent MakeWebMouseWheelEventFromAuraEvent(
+ ui::MouseWheelEvent* event);
// General approach:
//
@@ -83,8 +84,9 @@ WebKit::WebMouseEvent MakeWebMouseEvent(ui::MouseEvent* event) {
WebKit::WebMouseWheelEvent MakeWebMouseWheelEvent(ui::MouseWheelEvent* event) {
#if defined(OS_WIN)
// Construct an untranslated event from the platform event data.
- WebKit::WebMouseWheelEvent webkit_event =
- MakeUntranslatedWebMouseWheelEventFromNativeEvent(event->native_event());
+ WebKit::WebMouseWheelEvent webkit_event = event->native_event().message ?
+ MakeUntranslatedWebMouseWheelEventFromNativeEvent(event->native_event()) :
+ MakeWebMouseWheelEventFromAuraEvent(event);
#else
WebKit::WebMouseWheelEvent webkit_event =
MakeWebMouseWheelEventFromAuraEvent(event);
@@ -220,4 +222,18 @@ WebKit::WebMouseEvent MakeWebMouseEventFromAuraEvent(ui::MouseEvent* event) {
return webkit_event;
}
+WebKit::WebMouseWheelEvent MakeWebMouseWheelEventFromAuraEvent(
+ ui::MouseWheelEvent* event) {
+ WebKit::WebMouseWheelEvent webkit_event;
+
+ webkit_event.type = WebKit::WebInputEvent::MouseWheel;
+ webkit_event.button = WebKit::WebMouseEvent::ButtonNone;
+ webkit_event.modifiers = EventFlagsToWebEventModifiers(event->flags());
+ webkit_event.timeStampSeconds = event->time_stamp().InSecondsF();
+ webkit_event.deltaY = event->offset();
+ webkit_event.wheelTicksY = webkit_event.deltaY / kPixelsPerTick;
+
+ return webkit_event;
+}
+
} // namespace content
diff --git a/content/browser/renderer_host/web_input_event_aura.h b/content/browser/renderer_host/web_input_event_aura.h
index 7085db1..e32a722 100644
--- a/content/browser/renderer_host/web_input_event_aura.h
+++ b/content/browser/renderer_host/web_input_event_aura.h
@@ -19,6 +19,9 @@ class TouchEvent;
namespace content {
+// Used for scrolling. This matches Firefox behavior.
+const int kPixelsPerTick = 53;
+
CONTENT_EXPORT WebKit::WebMouseEvent MakeWebMouseEvent(
ui::MouseEvent* event);
CONTENT_EXPORT WebKit::WebMouseWheelEvent MakeWebMouseWheelEvent(
diff --git a/content/browser/renderer_host/web_input_event_aurax11.cc b/content/browser/renderer_host/web_input_event_aurax11.cc
index 98c4d89..2c50307 100644
--- a/content/browser/renderer_host/web_input_event_aurax11.cc
+++ b/content/browser/renderer_host/web_input_event_aurax11.cc
@@ -57,9 +57,6 @@ namespace content {
namespace {
-// This matches Firefox behavior.
-const int kPixelsPerTick = 53;
-
int XKeyEventToWindowsKeyCode(XKeyEvent* event) {
int windows_key_code =
ui::KeyboardCodeFromXKeyEvent(reinterpret_cast<XEvent*>(event));
@@ -139,20 +136,6 @@ WebKit::WebUChar GetControlCharacter(int windows_key_code, bool shift) {
} // namespace
WebKit::WebMouseWheelEvent MakeWebMouseWheelEventFromAuraEvent(
- ui::MouseWheelEvent* event) {
- WebKit::WebMouseWheelEvent webkit_event;
-
- webkit_event.type = WebKit::WebInputEvent::MouseWheel;
- webkit_event.button = WebKit::WebMouseEvent::ButtonNone;
- webkit_event.modifiers = EventFlagsToWebEventModifiers(event->flags());
- webkit_event.timeStampSeconds = event->time_stamp().InSecondsF();
- webkit_event.deltaY = event->offset();
- webkit_event.wheelTicksY = webkit_event.deltaY / kPixelsPerTick;
-
- return webkit_event;
-}
-
-WebKit::WebMouseWheelEvent MakeWebMouseWheelEventFromAuraEvent(
ui::ScrollEvent* event) {
WebKit::WebMouseWheelEvent webkit_event;
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 */
diff --git a/win8/metro_driver/chrome_app_view_ash.cc b/win8/metro_driver/chrome_app_view_ash.cc
index 068fddd..6110197 100644
--- a/win8/metro_driver/chrome_app_view_ash.cc
+++ b/win8/metro_driver/chrome_app_view_ash.cc
@@ -80,27 +80,32 @@ class ChromeChannelListener : public IPC::Listener {
// This class helps decoding the pointer properties of an event.
class PointerInfoHandler {
public:
- PointerInfoHandler() : x_(0), y_(0), is_mouse_(false) {};
+ PointerInfoHandler() :
+ x_(0),
+ y_(0),
+ wheel_delta_(0),
+ update_kind_(winui::Input::PointerUpdateKind_Other) {};
HRESULT Init(winui::Core::IPointerEventArgs* args) {
- mswr::ComPtr<winui::Input::IPointerPoint> pointer_point;
- HRESULT hr = args->get_CurrentPoint(&pointer_point);
+ HRESULT hr = args->get_CurrentPoint(&pointer_point_);
if (FAILED(hr))
return hr;
- mswr::ComPtr<windevs::Input::IPointerDevice> pointer_device;
- hr = pointer_point->get_PointerDevice(&pointer_device);
+ winfoundtn::Point point;
+ hr = pointer_point_->get_Position(&point);
if (FAILED(hr))
return hr;
- windevs::Input::PointerDeviceType device_type;
- hr = pointer_device->get_PointerDeviceType(&device_type);
+ mswr::ComPtr<winui::Input::IPointerPointProperties> properties;
+ hr = pointer_point_->get_Properties(&properties);
if (FAILED(hr))
return hr;
- is_mouse_ = (device_type == windevs::Input::PointerDeviceType_Mouse);
- winfoundtn::Point point;
- hr = pointer_point->get_Position(&point);
+ hr = properties->get_PointerUpdateKind(&update_kind_);
+ if (FAILED(hr))
+ return hr;
+
+ hr = properties->get_MouseWheelDelta(&wheel_delta_);
if (FAILED(hr))
return hr;
@@ -109,14 +114,46 @@ class PointerInfoHandler {
return S_OK;
}
- bool is_mouse() const { return is_mouse_; }
+ bool IsMouse() const {
+ mswr::ComPtr<windevs::Input::IPointerDevice> pointer_device;
+ CheckHR(pointer_point_->get_PointerDevice(&pointer_device));
+ windevs::Input::PointerDeviceType device_type;
+ CheckHR(pointer_device->get_PointerDeviceType(&device_type));
+ return (device_type == windevs::Input::PointerDeviceType_Mouse);
+ }
+
+ int32 wheel_delta() const {
+ return wheel_delta_;
+ }
+
+ ui::EventFlags flags() {
+ switch (update_kind_) {
+ case winui::Input::PointerUpdateKind_LeftButtonPressed:
+ return ui::EF_LEFT_MOUSE_BUTTON;
+ case winui::Input::PointerUpdateKind_LeftButtonReleased:
+ return ui::EF_LEFT_MOUSE_BUTTON;
+ case winui::Input::PointerUpdateKind_RightButtonPressed:
+ return ui::EF_RIGHT_MOUSE_BUTTON;
+ case winui::Input::PointerUpdateKind_RightButtonReleased:
+ return ui::EF_RIGHT_MOUSE_BUTTON;
+ case winui::Input::PointerUpdateKind_MiddleButtonPressed:
+ return ui::EF_MIDDLE_MOUSE_BUTTON;
+ case winui::Input::PointerUpdateKind_MiddleButtonReleased:
+ return ui::EF_MIDDLE_MOUSE_BUTTON;
+ default:
+ return ui::EF_NONE;
+ };
+ }
+
int x() const { return x_; }
int y() const { return y_; }
private:
int x_;
int y_;
- bool is_mouse_;
+ int wheel_delta_;
+ winui::Input::PointerUpdateKind update_kind_;
+ mswr::ComPtr<winui::Input::IPointerPoint> pointer_point_;
};
void RunMessageLoop(winui::Core::ICoreDispatcher* dispatcher) {
@@ -206,6 +243,11 @@ ChromeAppViewAsh::SetWindow(winui::Core::ICoreWindow* window) {
&keyup_token_);
CheckHR(hr);
+ hr = window_->add_PointerWheelChanged(mswr::Callback<PointerEventHandler>(
+ this, &ChromeAppViewAsh::OnWheel).Get(),
+ &wheel_token_);
+ CheckHR(hr);
+
hr = window_->add_CharacterReceived(mswr::Callback<CharEventHandler>(
this, &ChromeAppViewAsh::OnCharacterReceived).Get(),
&character_received_token_);
@@ -308,8 +350,7 @@ HRESULT ChromeAppViewAsh::OnPointerMoved(winui::Core::ICoreWindow* sender,
HRESULT hr = pointer.Init(args);
if (FAILED(hr))
return hr;
- if (!pointer.is_mouse())
- return S_OK;
+ DCHECK(pointer.IsMouse());
ui_channel_->Send(new MetroViewerHostMsg_MouseMoved(pointer.x(),
pointer.y(),
@@ -318,32 +359,44 @@ HRESULT ChromeAppViewAsh::OnPointerMoved(winui::Core::ICoreWindow* sender,
}
HRESULT ChromeAppViewAsh::OnPointerPressed(winui::Core::ICoreWindow* sender,
- winui::Core::IPointerEventArgs* args) {
+ winui::Core::IPointerEventArgs* args) {
PointerInfoHandler pointer;
HRESULT hr = pointer.Init(args);
if (FAILED(hr))
return hr;
- if (!pointer.is_mouse())
- return S_OK;
-
- ui_channel_->Send(new MetroViewerHostMsg_MouseButton(pointer.x(),
- pointer.y(),
- 1));
+ DCHECK(pointer.IsMouse());
+ ui_channel_->Send(new MetroViewerHostMsg_MouseButton(pointer.x(), pointer.y(),
+ 0,
+ ui::ET_MOUSE_PRESSED,
+ pointer.flags()));
return S_OK;
}
HRESULT ChromeAppViewAsh::OnPointerReleased(winui::Core::ICoreWindow* sender,
- winui::Core::IPointerEventArgs* args) {
+ winui::Core::IPointerEventArgs* args) {
PointerInfoHandler pointer;
HRESULT hr = pointer.Init(args);
if (FAILED(hr))
return hr;
- if (!pointer.is_mouse())
- return S_OK;
+ DCHECK(pointer.IsMouse());
+ ui_channel_->Send(new MetroViewerHostMsg_MouseButton(pointer.x(), pointer.y(),
+ 0,
+ ui::ET_MOUSE_RELEASED,
+ pointer.flags()));
+ return S_OK;
+}
- ui_channel_->Send(new MetroViewerHostMsg_MouseButton(pointer.x(),
- pointer.y(),
- 0));
+HRESULT ChromeAppViewAsh::OnWheel(winui::Core::ICoreWindow* sender,
+ winui::Core::IPointerEventArgs* args) {
+ PointerInfoHandler pointer;
+ HRESULT hr = pointer.Init(args);
+ if (FAILED(hr))
+ return hr;
+ DCHECK(pointer.IsMouse());
+ ui_channel_->Send(new MetroViewerHostMsg_MouseButton(pointer.x(), pointer.y(),
+ pointer.wheel_delta(),
+ ui::ET_MOUSEWHEEL,
+ ui::EF_NONE));
return S_OK;
}
diff --git a/win8/metro_driver/chrome_app_view_ash.h b/win8/metro_driver/chrome_app_view_ash.h
index 7730bcb..88e8749 100644
--- a/win8/metro_driver/chrome_app_view_ash.h
+++ b/win8/metro_driver/chrome_app_view_ash.h
@@ -44,6 +44,9 @@ class ChromeAppViewAsh
HRESULT OnPointerReleased(winui::Core::ICoreWindow* sender,
winui::Core::IPointerEventArgs* args);
+ HRESULT OnWheel(winui::Core::ICoreWindow* sender,
+ winui::Core::IPointerEventArgs* args);
+
HRESULT OnKeyDown(winui::Core::ICoreWindow* sender,
winui::Core::IKeyEventArgs* args);
@@ -59,6 +62,7 @@ class ChromeAppViewAsh
EventRegistrationToken pointermoved_token_;
EventRegistrationToken pointerpressed_token_;
EventRegistrationToken pointerreleased_token_;
+ EventRegistrationToken wheel_token_;
EventRegistrationToken keydown_token_;
EventRegistrationToken keyup_token_;
EventRegistrationToken character_received_token_;