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

Unified Diff: services/ui/ws/event_dispatcher.h

Issue 2125883003: Adds ability for pre-target accelerators to not consume events (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: merge Created 4 years, 5 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
« no previous file with comments | « services/ui/test_wm/test_wm.cc ('k') | services/ui/ws/event_dispatcher.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: services/ui/ws/event_dispatcher.h
diff --git a/services/ui/ws/event_dispatcher.h b/services/ui/ws/event_dispatcher.h
index 8d0ca2919ccff37d9c9dac6def55fa7819e483a8..aeeffd0a90a6b13ab0730e7c3815ce92c782877c 100644
--- a/services/ui/ws/event_dispatcher.h
+++ b/services/ui/ws/event_dispatcher.h
@@ -22,9 +22,7 @@ namespace ui {
class Event;
class KeyEvent;
class LocatedEvent;
-}
-namespace ui {
namespace ws {
class Accelerator;
@@ -38,6 +36,15 @@ class EventDispatcherTestApi;
// Handles dispatching events to the right location as well as updating focus.
class EventDispatcher : public ServerWindowObserver {
public:
+ enum class AcceleratorMatchPhase {
+ // Both pre and post should be considered.
+ ANY,
+
+ // PRE_TARGETs are not considered, only the actual target and any
+ // accelerators registered with POST_TARGET.
+ POST_ONLY,
+ };
+
explicit EventDispatcher(EventDispatcherDelegate* delegate);
~EventDispatcher() override;
@@ -104,8 +111,11 @@ class EventDispatcher : public ServerWindowObserver {
void RemoveAccelerator(uint32_t id);
// Processes the supplied event, informing the delegate as approriate. This
- // may result in generating any number of events.
- void ProcessEvent(const ui::Event& event);
+ // may result in generating any number of events. If |match_phase| is
+ // ANY and there is a matching accelerator with PRE_TARGET found, than only
+ // OnAccelerator() is called. The expectation is after the PRE_TARGET has been
+ // handled this is again called with an AcceleratorMatchPhase of POST_ONLY.
+ void ProcessEvent(const ui::Event& event, AcceleratorMatchPhase match_phase);
private:
friend class test::EventDispatcherTestApi;
@@ -130,7 +140,8 @@ class EventDispatcher : public ServerWindowObserver {
bool is_pointer_down;
};
- void ProcessKeyEvent(const ui::KeyEvent& event);
+ void ProcessKeyEvent(const ui::KeyEvent& event,
+ AcceleratorMatchPhase match_phase);
bool IsTrackingPointer(int32_t pointer_id) const {
return pointer_targets_.count(pointer_id) > 0;
@@ -227,6 +238,12 @@ class EventDispatcher : public ServerWindowObserver {
// Keeps track of number of observe requests for each observed window.
std::map<const ServerWindow*, uint8_t> observed_windows_;
+#if !defined(NDEBUG)
+ std::unique_ptr<ui::Event> previous_event_;
+ AcceleratorMatchPhase previous_accelerator_match_phase_ =
+ AcceleratorMatchPhase::ANY;
+#endif
+
DISALLOW_COPY_AND_ASSIGN(EventDispatcher);
};
« no previous file with comments | « services/ui/test_wm/test_wm.cc ('k') | services/ui/ws/event_dispatcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698