Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1734)

Unified Diff: sky/viewer/converters/input_event_types.cc

Issue 1192023002: Add buttons to WebInputEvent (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: comments Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sky/viewer/converters/input_event_types.cc
diff --git a/sky/viewer/converters/input_event_types.cc b/sky/viewer/converters/input_event_types.cc
index e6e1c99a7855b0d54b00953e16286c8a99660a05..92869d2b0dcd10339d7b75dde12f2b6eed2b2c77 100644
--- a/sky/viewer/converters/input_event_types.cc
+++ b/sky/viewer/converters/input_event_types.cc
@@ -22,7 +22,13 @@ int EventFlagsToWebInputEventModifiers(int flags) {
(flags & mojo::EVENT_FLAGS_CAPS_LOCK_DOWN ?
blink::WebInputEvent::CapsLockOn : 0) |
(flags & mojo::EVENT_FLAGS_ALT_DOWN ?
- blink::WebInputEvent::AltKey : 0);
+ blink::WebInputEvent::AltKey : 0) |
+ (flags & mojo::EVENT_FLAGS_LEFT_MOUSE_BUTTON ?
+ blink::WebInputEvent::LeftButtonDown : 0) |
+ (flags & mojo::EVENT_FLAGS_MIDDLE_MOUSE_BUTTON ?
+ blink::WebInputEvent::MiddleButtonDown : 0) |
+ (flags & mojo::EVENT_FLAGS_RIGHT_MOUSE_BUTTON ?
+ blink::WebInputEvent::RightButtonDown : 0);
}
int UIEventFlagsToWebInputEventModifiers(int flags) {
@@ -66,6 +72,13 @@ scoped_ptr<blink::WebInputEvent> BuildWebPointerEvent(
web_event->pointer = event->pointer_data->pointer_id;
} else {
web_event->kind = blink::WebPointerEvent::Mouse;
+ // Set the buttons according to http://www.w3.org/TR/pointerevents/
+ int buttons = 0;
+ int modifiers = web_event->modifiers;
+ buttons |= modifiers & blink::WebInputEvent::LeftButtonDown ? 1 << 0 : 0;
+ buttons |= modifiers & blink::WebInputEvent::RightButtonDown ? 1 << 1 : 0;
+ buttons |= modifiers & blink::WebInputEvent::MiddleButtonDown ? 1 << 2 : 0;
+ web_event->buttons = buttons;
}
web_event->x = event->pointer_data->x / device_pixel_ratio;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698