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

Side by Side Diff: ui/wm/core/accelerator_filter.cc

Issue 1117173003: Converting (Alt+LeftClick -> RightClick) to (Search+LeftClick -> RightClick) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added a test case for ignoring synthesized mouse events. 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 unified diff | Download patch
« no previous file with comments | « ui/wm/core/accelerator_filter.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/wm/core/accelerator_filter.h" 5 #include "ui/wm/core/accelerator_filter.h"
6 6
7 #include "ui/base/accelerators/accelerator.h" 7 #include "ui/base/accelerators/accelerator.h"
8 #include "ui/base/accelerators/accelerator_history.h" 8 #include "ui/base/accelerators/accelerator_history.h"
9 #include "ui/events/event.h" 9 #include "ui/events/event.h"
10 #include "ui/wm/core/accelerator_delegate.h" 10 #include "ui/wm/core/accelerator_delegate.h"
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 accelerator_history_->StoreCurrentAccelerator(accelerator); 64 accelerator_history_->StoreCurrentAccelerator(accelerator);
65 65
66 AcceleratorDelegate::KeyType key_type = 66 AcceleratorDelegate::KeyType key_type =
67 IsSystemKey(event->key_code()) ? AcceleratorDelegate::KEY_TYPE_SYSTEM 67 IsSystemKey(event->key_code()) ? AcceleratorDelegate::KEY_TYPE_SYSTEM
68 : AcceleratorDelegate::KEY_TYPE_OTHER; 68 : AcceleratorDelegate::KEY_TYPE_OTHER;
69 69
70 if (delegate_->ProcessAccelerator(*event, accelerator, key_type)) 70 if (delegate_->ProcessAccelerator(*event, accelerator, key_type))
71 event->StopPropagation(); 71 event->StopPropagation();
72 } 72 }
73 73
74 void AcceleratorFilter::OnMouseEvent(ui::MouseEvent* event) {
75 // When a mouse event is interleaved between two key accelerators, we must
76 // store this event as an empty default accelerator in the accelerator
77 // history, so that the |AcceleratorController| can notice that something
78 // actually happened between those two key accelerators.
79 // Non-real synthesized mouse events should be ignored because we don't want
80 // them to interfere with tracking the key accelerator.
81 if (event->flags() & ui::EF_IS_SYNTHESIZED)
82 return;
83
84 accelerator_history_->StoreCurrentAccelerator(ui::Accelerator());
85 }
86
74 ui::Accelerator CreateAcceleratorFromKeyEvent(const ui::KeyEvent& key_event) { 87 ui::Accelerator CreateAcceleratorFromKeyEvent(const ui::KeyEvent& key_event) {
75 const int kModifierFlagMask = 88 const int kModifierFlagMask =
76 (ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN | ui::EF_ALT_DOWN); 89 (ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN | ui::EF_ALT_DOWN);
77 90
78 ui::Accelerator accelerator(key_event.key_code(), 91 ui::Accelerator accelerator(key_event.key_code(),
79 key_event.flags() & kModifierFlagMask); 92 key_event.flags() & kModifierFlagMask);
80 if (key_event.type() == ui::ET_KEY_RELEASED) 93 if (key_event.type() == ui::ET_KEY_RELEASED)
81 accelerator.set_type(ui::ET_KEY_RELEASED); 94 accelerator.set_type(ui::ET_KEY_RELEASED);
82 accelerator.set_is_repeat(key_event.IsRepeat()); 95 accelerator.set_is_repeat(key_event.IsRepeat());
83 return accelerator; 96 return accelerator;
84 } 97 }
85 98
86 } // namespace wm 99 } // namespace wm
OLDNEW
« no previous file with comments | « ui/wm/core/accelerator_filter.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698