summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--views/controls/menu/submenu_view.cc6
-rw-r--r--views/events/event.cc7
-rw-r--r--views/events/event.h4
-rw-r--r--views/events/event_gtk.cc14
4 files changed, 13 insertions, 18 deletions
diff --git a/views/controls/menu/submenu_view.cc b/views/controls/menu/submenu_view.cc
index 0aecee2..f3ecaea 100644
--- a/views/controls/menu/submenu_view.cc
+++ b/views/controls/menu/submenu_view.cc
@@ -194,11 +194,7 @@ bool SubmenuView::OnMouseWheel(const MouseWheelEvent& e) {
// If the first item isn't entirely visible, make it visible, otherwise make
// the next/previous one entirely visible.
-#if defined(OS_WIN)
- int delta = abs(e.offset() / WHEEL_DELTA);
-#elif defined(OS_LINUX)
- int delta = abs(e.offset());
-#endif
+ int delta = abs(e.offset() / MouseWheelEvent::kWheelDelta);
for (bool scroll_up = (e.offset() > 0); delta != 0; --delta) {
int scroll_target;
if (scroll_up) {
diff --git a/views/events/event.cc b/views/events/event.cc
index f51ec0a..4b74dbe 100644
--- a/views/events/event.cc
+++ b/views/events/event.cc
@@ -112,4 +112,11 @@ TouchEvent::TouchEvent(const TouchEvent& model, View* from, View* to)
}
#endif
+////////////////////////////////////////////////////////////////////////////////
+// MouseWheelEvent, public:
+
+// This value matches windows WHEEL_DELTA.
+// static
+const int MouseWheelEvent::kWheelDelta = 120;
+
} // namespace views
diff --git a/views/events/event.h b/views/events/event.h
index 426862e..a670234 100644
--- a/views/events/event.h
+++ b/views/events/event.h
@@ -316,9 +316,13 @@ class KeyEvent : public Event {
////////////////////////////////////////////////////////////////////////////////
class MouseWheelEvent : public LocatedEvent {
public:
+ // See |offset| for details.
+ static const int kWheelDelta;
+
explicit MouseWheelEvent(NativeEvent native_event);
MouseWheelEvent(NativeEvent2 native_event_2, FromNativeEvent2 from_native);
+ // The amount to scroll. This is in multiples of kWheelDelta.
int offset() const { return offset_; }
private:
diff --git a/views/events/event_gtk.cc b/views/events/event_gtk.cc
index 9e38cffa..a82abd5 100644
--- a/views/events/event_gtk.cc
+++ b/views/events/event_gtk.cc
@@ -46,19 +46,7 @@ int GetMouseWheelOffset(NativeEvent native_event) {
DCHECK(native_event->type == GDK_SCROLL);
int offset = (native_event->scroll.direction == GDK_SCROLL_UP ||
native_event->scroll.direction == GDK_SCROLL_LEFT) ? 1 : -1;
-
- // Scale the offset magnitude by window size, to preserve legacy behavior.
- // TODO(msw): Investigate the use of offset magnitude throughout the codebase.
- int width = 0, height = 0;
- gdk_window_get_geometry(native_event->scroll.window, NULL, NULL, &width,
- &height, NULL);
- if (native_event->scroll.direction == GDK_SCROLL_UP ||
- native_event->scroll.direction == GDK_SCROLL_DOWN)
- offset = offset * height / 5;
- else
- offset = offset * width / 5;
-
- return offset;
+ return MouseWheelEvent::kWheelDelta * offset;
}
unsigned int GetGdkStateFromNative(NativeEvent native_event) {