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

Unified Diff: ash/wm/sticky_keys.cc

Issue 81863002: Sticky keys modifies an entire scroll sequence instead of just a single event. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebasing Created 7 years, 1 month 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 | « ash/wm/sticky_keys.h ('k') | ash/wm/sticky_keys_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/wm/sticky_keys.cc
diff --git a/ash/wm/sticky_keys.cc b/ash/wm/sticky_keys.cc
index efdfd160173ab9316b80765344d01778002d0350..86bc2749a3a13b59a286706fdef079c8f06503ff 100644
--- a/ash/wm/sticky_keys.cc
+++ b/ash/wm/sticky_keys.cc
@@ -172,6 +172,7 @@ StickyKeysHandler::StickyKeysHandler(ui::EventFlags target_modifier_flag,
current_state_(DISABLED),
event_from_myself_(false),
preparing_to_enable_(false),
+ scroll_delta_(0),
delegate_(delegate) {
}
@@ -223,11 +224,28 @@ bool StickyKeysHandler::HandleScrollEvent(ui::ScrollEvent* event) {
if (event_from_myself_ || current_state_ == DISABLED)
return false;
DCHECK(current_state_ == ENABLED || current_state_ == LOCKED);
-
preparing_to_enable_ = false;
- AppendModifier(event);
- if (current_state_ == ENABLED) {
+
+ // We detect a direction change if the current |scroll_delta_| is assigned
+ // and the offset of the current scroll event has the opposing sign.
+ bool direction_changed = false;
+ if (current_state_ == ENABLED && event->type() == ui::ET_SCROLL) {
+ int offset = event->y_offset();
+ if (scroll_delta_)
+ direction_changed = offset * scroll_delta_ <= 0;
+ scroll_delta_ = offset;
+ }
+
+ if (!direction_changed)
+ AppendModifier(event);
+
+ // We want to modify all the scroll events in the scroll sequence, which ends
+ // with a fling start event. We also stop when the scroll sequence changes
+ // direction.
+ if (current_state_ == ENABLED &&
+ (event->type() == ui::ET_SCROLL_FLING_START || direction_changed)) {
current_state_ = DISABLED;
+ scroll_delta_ = 0;
DispatchEventAndReleaseModifier(event);
return true;
}
@@ -268,6 +286,7 @@ bool StickyKeysHandler::HandleDisabledState(ui::KeyEvent* event) {
case TARGET_MODIFIER_UP:
if (preparing_to_enable_) {
preparing_to_enable_ = false;
+ scroll_delta_ = 0;
current_state_ = ENABLED;
modifier_up_event_.reset(event->Copy());
return true;
« no previous file with comments | « ash/wm/sticky_keys.h ('k') | ash/wm/sticky_keys_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698