summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsheckylin@chromium.org <sheckylin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-14 06:47:18 +0000
committersheckylin@chromium.org <sheckylin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-14 06:47:18 +0000
commit02301d5a6896fc2ff22103624e0ed06fb1ab17ca (patch)
treed0210a6a71b6acbd906c06b36fb81fcacadb333c
parentc754875e2ea7ac0e40e9db77375899d7683b21c2 (diff)
downloadchromium_src-02301d5a6896fc2ff22103624e0ed06fb1ab17ca.zip
chromium_src-02301d5a6896fc2ff22103624e0ed06fb1ab17ca.tar.gz
chromium_src-02301d5a6896fc2ff22103624e0ed06fb1ab17ca.tar.bz2
Fix mouse horizontal scrolling in app drawer
The old logic consider only horizontal scroll for ScrollEvent and only vertical scroll for MouseWheelEvent. Vertical scroll on touchpad seems to work only because unhandled ScrollEvent would be casted to MouseWheelEvent in root_view.cc (and then be picked up by the app drawer ). The patch now lets both event handlers select the largest scrolling direction and proceed on scrolling no matter it is horizontal or vertical. Contributed by sheckylin@chromium.org BUG=248259 TEST=Tested on device. Change-Id: I5ee647d886c47cec37c4f7d130c6d7b268051064 Review URL: https://chromiumcodereview.appspot.com/16757009 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@206337 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--ui/app_list/views/contents_view.cc32
1 files changed, 23 insertions, 9 deletions
diff --git a/ui/app_list/views/contents_view.cc b/ui/app_list/views/contents_view.cc
index 77c8fb0..5167b89 100644
--- a/ui/app_list/views/contents_view.cc
+++ b/ui/app_list/views/contents_view.cc
@@ -6,6 +6,7 @@
#include <algorithm>
+#include "base/logging.h"
#include "ui/app_list/app_list_constants.h"
#include "ui/app_list/pagination_model.h"
#include "ui/app_list/views/app_list_main_view.h"
@@ -182,10 +183,16 @@ bool ContentsView::OnMouseWheel(const ui::MouseWheelEvent& event) {
if (show_state_ != SHOW_APPS)
return false;
- if (abs(event.y_offset()) > kMinMouseWheelToSwitchPage) {
+ int offset;
+ if (abs(event.x_offset()) > abs(event.y_offset()))
+ offset = event.x_offset();
+ else
+ offset = event.y_offset();
+
+ if (abs(offset) > kMinMouseWheelToSwitchPage) {
if (!pagination_model_->has_transition()) {
pagination_model_->SelectPageRelative(
- event.y_offset() > 0 ? -1 : 1, true);
+ offset > 0 ? -1 : 1, true);
}
return true;
}
@@ -231,17 +238,24 @@ void ContentsView::OnGestureEvent(ui::GestureEvent* event) {
void ContentsView::OnScrollEvent(ui::ScrollEvent* event) {
if (show_state_ != SHOW_APPS ||
- event->type() == ui::ET_SCROLL_FLING_CANCEL ||
- abs(event->x_offset()) < kMinScrollToSwitchPage) {
+ event->type() == ui::ET_SCROLL_FLING_CANCEL) {
return;
}
- if (!pagination_model_->has_transition()) {
- pagination_model_->SelectPageRelative(event->x_offset() > 0 ? -1 : 1,
- true);
+ float offset;
+ if (abs(event->x_offset()) > abs(event->y_offset()))
+ offset = event->x_offset();
+ else
+ offset = event->y_offset();
+
+ if (abs(offset) > kMinScrollToSwitchPage) {
+ if (!pagination_model_->has_transition()) {
+ pagination_model_->SelectPageRelative(offset > 0 ? -1 : 1,
+ true);
+ }
+ event->SetHandled();
+ event->StopPropagation();
}
- event->SetHandled();
- event->StopPropagation();
}
} // namespace app_list