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

Unified Diff: ui/events/x/events_x.cc

Issue 688253002: Implemented smooth scrolling using xinput2 in X11. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased Created 5 years, 7 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
Index: ui/events/x/events_x.cc
diff --git a/ui/events/x/events_x.cc b/ui/events/x/events_x.cc
index 9bf87c0e24c4e4b2a25aeedddf4d00b1340f4d0e..4b6c9dd488062a1c9e9c1ce2b4993296f03e3772 100644
--- a/ui/events/x/events_x.cc
+++ b/ui/events/x/events_x.cc
@@ -438,6 +438,9 @@ EventType EventTypeFromNative(const base::NativeEvent& native_event) {
return devices->IsTouchpadXInputEvent(native_event) ? ET_SCROLL
: ET_MOUSEWHEEL;
}
+ if (devices->GetScrollClassEventDetail(native_event) !=
+ SCROLL_TYPE_NO_SCROLL)
+ return ET_MOUSEWHEEL;
sadrul 2015/08/18 16:57:46 Should IsScrollEvent() return true in this case, s
Will Shackleton 2015/08/26 19:52:48 IsScrollEvent() detects XInput 1 scroll events - t
sadrul 2015/08/26 19:55:57 Is there a reason to have separate API for this? I
if (devices->IsCMTMetricsEvent(native_event))
return ET_UMA_DATA;
if (GetButtonMaskForX2Event(xievent))
@@ -711,15 +714,22 @@ gfx::Vector2d GetMouseWheelOffset(const base::NativeEvent& native_event) {
int button = native_event->type == GenericEvent ?
EventButtonFromNative(native_event) : native_event->xbutton.button;
+ int scroll_class_type =
+ DeviceDataManagerX11::GetInstance()
+ ->GetScrollClassDeviceDetail(native_event);
sadrul 2015/08/18 16:57:46 Indenting here is off (you can use 'git cl format'
+ bool vertical_scroll_class = scroll_class_type & SCROLL_TYPE_VERTICAL;
+ bool horizontal_scroll_class = scroll_class_type & SCROLL_TYPE_HORIZONTAL;
+
switch (button) {
case 4:
- return gfx::Vector2d(0, kWheelScrollAmount);
+ return gfx::Vector2d(0, vertical_scroll_class ? 0 : kWheelScrollAmount);
case 5:
- return gfx::Vector2d(0, -kWheelScrollAmount);
+ return gfx::Vector2d(0, vertical_scroll_class ? 0 : -kWheelScrollAmount);
case 6:
- return gfx::Vector2d(kWheelScrollAmount, 0);
+ return gfx::Vector2d(horizontal_scroll_class ? 0 : kWheelScrollAmount, 0);
case 7:
- return gfx::Vector2d(-kWheelScrollAmount, 0);
+ return gfx::Vector2d(horizontal_scroll_class ? 0 : -kWheelScrollAmount,
+ 0);
default:
return gfx::Vector2d();
}
@@ -803,30 +813,41 @@ bool GetScrollOffsets(const base::NativeEvent& native_event,
float* x_offset_ordinal,
float* y_offset_ordinal,
int* finger_count) {
- if (!DeviceDataManagerX11::GetInstance()->IsScrollEvent(native_event))
- return false;
+ if (DeviceDataManagerX11::GetInstance()->IsScrollEvent(native_event)) {
+ // Temp values to prevent passing NULLs to DeviceDataManager.
+ float x_offset_, y_offset_;
+ float x_offset_ordinal_, y_offset_ordinal_;
+ int finger_count_;
+ if (!x_offset)
+ x_offset = &x_offset_;
+ if (!y_offset)
+ y_offset = &y_offset_;
+ if (!x_offset_ordinal)
+ x_offset_ordinal = &x_offset_ordinal_;
+ if (!y_offset_ordinal)
+ y_offset_ordinal = &y_offset_ordinal_;
+ if (!finger_count)
+ finger_count = &finger_count_;
+
+ DeviceDataManagerX11::GetInstance()->GetScrollOffsets(
+ native_event,
+ x_offset, y_offset,
+ x_offset_ordinal, y_offset_ordinal,
+ finger_count);
+ return true;
+ }
- // Temp values to prevent passing NULLs to DeviceDataManager.
- float x_offset_, y_offset_;
- float x_offset_ordinal_, y_offset_ordinal_;
- int finger_count_;
- if (!x_offset)
- x_offset = &x_offset_;
- if (!y_offset)
- y_offset = &y_offset_;
- if (!x_offset_ordinal)
- x_offset_ordinal = &x_offset_ordinal_;
- if (!y_offset_ordinal)
- y_offset_ordinal = &y_offset_ordinal_;
- if (!finger_count)
- finger_count = &finger_count_;
-
- DeviceDataManagerX11::GetInstance()->GetScrollOffsets(
- native_event,
- x_offset, y_offset,
- x_offset_ordinal, y_offset_ordinal,
- finger_count);
- return true;
+ if (DeviceDataManagerX11::GetInstance()->
+ GetScrollClassEventDetail(native_event) != SCROLL_TYPE_NO_SCROLL) {
+ double x_scroll_offset, y_scroll_offset;
+ DeviceDataManagerX11::GetInstance()->GetScrollClassOffsets(
+ native_event,
+ &x_scroll_offset, &y_scroll_offset);
+ *x_offset = x_scroll_offset * kWheelScrollAmount;
+ *y_offset = y_scroll_offset * kWheelScrollAmount;
+ return true;
+ }
+ return false;
}
bool GetFlingData(const base::NativeEvent& native_event,

Powered by Google App Engine
This is Rietveld 408576698