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

Unified Diff: mojo/converters/input_events/input_events_type_converters.cc

Issue 1344223002: Revert of Overhaul Mandoline event transport code (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 3 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 | « components/pdf_viewer/pdf_viewer.cc ('k') | ui/mojo/events/input_event_constants.mojom » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/converters/input_events/input_events_type_converters.cc
diff --git a/mojo/converters/input_events/input_events_type_converters.cc b/mojo/converters/input_events/input_events_type_converters.cc
index 7e5783b94ad713a2d6e3033d7dbe5bd3e118e4a0..f1db97c009d425e639c812d3da0f2df2ee244af6 100644
--- a/mojo/converters/input_events/input_events_type_converters.cc
+++ b/mojo/converters/input_events/input_events_type_converters.cc
@@ -30,6 +30,10 @@
case EVENT_TYPE_POINTER_MOVE:
DCHECK(event->pointer_data);
+ if (event->pointer_data->horizontal_wheel != 0 ||
+ event->pointer_data->vertical_wheel != 0) {
+ return ui::ET_MOUSEWHEEL;
+ }
if (event->flags &
(EVENT_FLAGS_LEFT_MOUSE_BUTTON | EVENT_FLAGS_MIDDLE_MOUSE_BUTTON |
EVENT_FLAGS_RIGHT_MOUSE_BUTTON)) {
@@ -67,17 +71,12 @@
return ui::ET_TOUCH_CANCELLED;
}
-ui::EventType MojoWheelEventTypeToUIEvent(const EventPtr& event) {
- DCHECK(!event->wheel_data.is_null());
- return ui::ET_MOUSEWHEEL;
-}
-
void SetPointerDataLocationFromEvent(const ui::LocatedEvent& located_event,
- mojo::LocationData* location_data) {
- location_data->x = located_event.location_f().x();
- location_data->y = located_event.location_f().y();
- location_data->screen_x = located_event.root_location_f().x();
- location_data->screen_y = located_event.root_location_f().y();
+ PointerData* pointer_data) {
+ pointer_data->x = located_event.location_f().x();
+ pointer_data->y = located_event.location_f().y();
+ pointer_data->screen_x = located_event.root_location_f().x();
+ pointer_data->screen_y = located_event.root_location_f().y();
}
} // namespace
@@ -135,10 +134,8 @@
case ui::ET_MOUSE_ENTERED:
case ui::ET_MOUSE_EXITED:
case ui::ET_TOUCH_MOVED:
+ case ui::ET_MOUSEWHEEL:
return EVENT_TYPE_POINTER_MOVE;
-
- case ui::ET_MOUSEWHEEL:
- return EVENT_TYPE_WHEEL;
case ui::ET_MOUSE_RELEASED:
case ui::ET_TOUCH_RELEASED:
@@ -169,72 +166,38 @@
event->flags = EventFlags(input.flags());
event->time_stamp = input.time_stamp().ToInternalValue();
- if (input.IsMouseWheelEvent()) {
- const ui::MouseWheelEvent* wheel_event =
- static_cast<const ui::MouseWheelEvent*>(&input);
-
- WheelDataPtr wheel_data(WheelData::New());
- LocationDataPtr location_data(LocationData::New());
- const ui::LocatedEvent* located_event =
- static_cast<const ui::LocatedEvent*>(&input);
- SetPointerDataLocationFromEvent(*located_event, location_data.get());
- wheel_data->location = location_data.Pass();
-
- // TODO(rjkroege): Support page scrolling on windows by directly
- // cracking into a mojo event when the native event is available.
- wheel_data->mode = WHEEL_MODE_LINE;
- // TODO(rjkroege): Support precise scrolling deltas.
-
- if ((input.flags() & ui::EF_SHIFT_DOWN) != 0 &&
- wheel_event->x_offset() == 0) {
- wheel_data->delta_x = wheel_event->y_offset();
- wheel_data->delta_y = 0;
- wheel_data->delta_z = 0;
- } else {
- // TODO(rjkroege): support z in ui::Events.
- wheel_data->delta_x = wheel_event->x_offset();
- wheel_data->delta_y = wheel_event->y_offset();
- wheel_data->delta_z = 0;
- }
- event->wheel_data = wheel_data.Pass();
- } else if (input.IsMouseEvent()) {
+ PointerData pointer_data;
+ if (input.IsMouseEvent()) {
const ui::LocatedEvent* located_event =
static_cast<const ui::LocatedEvent*>(&input);
PointerDataPtr pointer_data(PointerData::New());
// TODO(sky): come up with a better way to handle this.
pointer_data->pointer_id = std::numeric_limits<int32>::max();
pointer_data->kind = POINTER_KIND_MOUSE;
- LocationDataPtr location_data(LocationData::New());
- SetPointerDataLocationFromEvent(*located_event, location_data.get());
- pointer_data->location = location_data.Pass();
-
+ SetPointerDataLocationFromEvent(*located_event, pointer_data.get());
+ if (input.IsMouseWheelEvent()) {
+ const ui::MouseWheelEvent* wheel_event =
+ static_cast<const ui::MouseWheelEvent*>(&input);
+ // This conversion assumes we're using the mojo meaning of these values:
+ // [-1 1].
+ pointer_data->horizontal_wheel =
+ static_cast<float>(wheel_event->x_offset()) / 100.0f;
+ pointer_data->vertical_wheel =
+ static_cast<float>(wheel_event->y_offset()) / 100.0f;
+ }
event->pointer_data = pointer_data.Pass();
} else if (input.IsTouchEvent()) {
const ui::TouchEvent* touch_event =
static_cast<const ui::TouchEvent*>(&input);
-
PointerDataPtr pointer_data(PointerData::New());
pointer_data->pointer_id = touch_event->touch_id();
pointer_data->kind = POINTER_KIND_TOUCH;
- LocationDataPtr location_data(LocationData::New());
- SetPointerDataLocationFromEvent(*touch_event, location_data.get());
- pointer_data->location = location_data.Pass();
-
- BrushDataPtr brush_data(BrushData::New());
-
- // TODO(rjk): this is in the wrong coordinate system
- brush_data->width = touch_event->pointer_details().radius_x();
- brush_data->height = touch_event->pointer_details().radius_y();
- // TODO(rjk): update for touch_event->rotation_angle();
- brush_data->pressure = touch_event->pointer_details().force();
- brush_data->tiltY = 0;
- brush_data->tiltZ = 0;
- pointer_data->brush_data = brush_data.Pass();
+ SetPointerDataLocationFromEvent(*touch_event, pointer_data.get());
+ pointer_data->radius_major = touch_event->pointer_details().radius_x();
+ pointer_data->radius_minor = touch_event->pointer_details().radius_y();
+ pointer_data->pressure = touch_event->pointer_details().force();
+ pointer_data->orientation = touch_event->rotation_angle();
event->pointer_data = pointer_data.Pass();
-
- // TODO(rjkroege): Plumb raw pointer events on windows.
- // TODO(rjkroege): Handle force-touch on MacOS
- // TODO(rjkroege): Adjust brush data appropriately for Android.
} else if (input.IsKeyEvent()) {
const ui::KeyEvent* key_event = static_cast<const ui::KeyEvent*>(&input);
KeyDataPtr key_data(KeyData::New());
@@ -274,10 +237,9 @@
gfx::PointF location;
gfx::PointF screen_location;
if (!input->pointer_data.is_null()) {
- location.SetPoint(input->pointer_data->location->x,
- input->pointer_data->location->y);
- screen_location.SetPoint(input->pointer_data->location->screen_x,
- input->pointer_data->location->screen_y);
+ location.SetPoint(input->pointer_data->x, input->pointer_data->y);
+ screen_location.SetPoint(input->pointer_data->screen_x,
+ input->pointer_data->screen_y);
}
switch (input->action) {
@@ -310,42 +272,32 @@
case EVENT_TYPE_POINTER_UP:
case EVENT_TYPE_POINTER_MOVE:
case EVENT_TYPE_POINTER_CANCEL: {
- switch (input->pointer_data->kind) {
- case POINTER_KIND_MOUSE: {
- // TODO: last flags isn't right. Need to send changed_flags.
- scoped_ptr<ui::MouseEvent> event(new ui::MouseEvent(
- MojoMouseEventTypeToUIEvent(input), location, screen_location,
- ui::EventTimeForNow(), ui::EventFlags(input->flags),
- ui::EventFlags(input->flags)));
- return event.Pass();
- } break;
- case POINTER_KIND_TOUCH: {
- scoped_ptr<ui::TouchEvent> touch_event(new ui::TouchEvent(
- MojoTouchEventTypeToUIEvent(input), location,
- ui::EventFlags(input->flags), input->pointer_data->pointer_id,
- base::TimeDelta::FromInternalValue(input->time_stamp),
- input->pointer_data->brush_data->width,
- input->pointer_data->brush_data->height, 0,
- input->pointer_data->brush_data->pressure));
- touch_event->set_root_location(screen_location);
- return touch_event.Pass();
- } break;
- case POINTER_KIND_PEN:
- NOTIMPLEMENTED();
- break;
+ if (input->pointer_data->kind == POINTER_KIND_MOUSE) {
+ // TODO: last flags isn't right. Need to send changed_flags.
+ scoped_ptr<ui::MouseEvent> event(new ui::MouseEvent(
+ MojoMouseEventTypeToUIEvent(input), location, screen_location,
+ ui::EventTimeForNow(), ui::EventFlags(input->flags),
+ ui::EventFlags(input->flags)));
+ if (event->IsMouseWheelEvent()) {
+ // This conversion assumes we're using the mojo meaning of these
+ // values: [-1 1].
+ scoped_ptr<ui::MouseEvent> wheel_event(new ui::MouseWheelEvent(
+ *event,
+ static_cast<int>(input->pointer_data->horizontal_wheel * 100),
+ static_cast<int>(input->pointer_data->vertical_wheel * 100)));
+ event = wheel_event.Pass();
+ }
+ return event.Pass();
}
- } break;
- case EVENT_TYPE_WHEEL: {
- scoped_ptr<ui::MouseEvent> pre_wheel_event(new ui::MouseEvent(
- MojoWheelEventTypeToUIEvent(input), location, screen_location,
- ui::EventTimeForNow(), ui::EventFlags(input->flags),
- ui::EventFlags(input->flags)));
- scoped_ptr<ui::MouseEvent> wheel_event(new ui::MouseWheelEvent(
- *pre_wheel_event, static_cast<int>(input->wheel_data->delta_x),
- static_cast<int>(input->wheel_data->delta_y)));
- return wheel_event.Pass();
- } break;
-
+ scoped_ptr<ui::TouchEvent> touch_event(new ui::TouchEvent(
+ MojoTouchEventTypeToUIEvent(input), location,
+ ui::EventFlags(input->flags), input->pointer_data->pointer_id,
+ base::TimeDelta::FromInternalValue(input->time_stamp),
+ input->pointer_data->radius_major, input->pointer_data->radius_minor,
+ input->pointer_data->orientation, input->pointer_data->pressure));
+ touch_event->set_root_location(screen_location);
+ return touch_event.Pass();
+ }
default:
NOTIMPLEMENTED();
}
« no previous file with comments | « components/pdf_viewer/pdf_viewer.cc ('k') | ui/mojo/events/input_event_constants.mojom » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698