summaryrefslogtreecommitdiffstats
path: root/ash/accelerators
diff options
context:
space:
mode:
authorsadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-02-08 00:10:03 +0000
committersadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-02-08 00:10:03 +0000
commit93805f36f94bd5f824cff64e2f61e24a2df16d6d (patch)
tree6405a410b8b20a37581d5617ae045c23274d2829 /ash/accelerators
parent58d8c71c27e4f4e832f76ee6332fdcc16b0ed42b (diff)
downloadchromium_src-93805f36f94bd5f824cff64e2f61e24a2df16d6d.zip
chromium_src-93805f36f94bd5f824cff64e2f61e24a2df16d6d.tar.gz
chromium_src-93805f36f94bd5f824cff64e2f61e24a2df16d6d.tar.bz2
message-pump: Change how MessagePumpDispatchers process events.
This patch allows a MessagePumpDispatcher to invoke the default handling of the message in the message-pump by setting the DISPATCH_DEFAULT flag on the return value from the ::Dispatch() callback. As before, the dispatcher can still request a termination of the current message-loop, but setting the DISPATCH_QUIT flag on the return value (instead of returning false). The callback can set both flags, in which case the message-loop will perform the default action, and also terminate the current loop. As a result of this, we can remove duplicate code, namely aura::DispatcherWin, and aura::Env::GetDispatcher(), that performs the same action as the default message pump. R=darin@chromium.org, sky@chromium.org Review URL: https://codereview.chromium.org/152083004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@249860 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash/accelerators')
-rw-r--r--ash/accelerators/accelerator_dispatcher.cc13
-rw-r--r--ash/accelerators/accelerator_dispatcher.h2
-rw-r--r--ash/accelerators/nested_dispatcher_controller_unittest.cc7
3 files changed, 11 insertions, 11 deletions
diff --git a/ash/accelerators/accelerator_dispatcher.cc b/ash/accelerators/accelerator_dispatcher.cc
index 7d29e68..646ef4f 100644
--- a/ash/accelerators/accelerator_dispatcher.cc
+++ b/ash/accelerators/accelerator_dispatcher.cc
@@ -85,11 +85,12 @@ void AcceleratorDispatcher::OnWindowDestroying(aura::Window* window) {
associated_window_ = NULL;
}
-bool AcceleratorDispatcher::Dispatch(const base::NativeEvent& event) {
+uint32_t AcceleratorDispatcher::Dispatch(const base::NativeEvent& event) {
if (!associated_window_)
- return false;
+ return POST_DISPATCH_QUIT_LOOP;
+
if (!ui::IsNoopEvent(event) && !associated_window_->CanReceiveEvents())
- return aura::Env::GetInstance()->GetDispatcher()->Dispatch(event);
+ return POST_DISPATCH_PERFORM_DEFAULT;
if (IsKeyEvent(event)) {
// Modifiers can be changed by the user preference, so we need to rewrite
@@ -100,7 +101,7 @@ bool AcceleratorDispatcher::Dispatch(const base::NativeEvent& event) {
DCHECK(event_rewriter);
event_rewriter->OnKeyEvent(&key_event);
if (key_event.stopped_propagation())
- return true;
+ return POST_DISPATCH_NONE;
if (IsPossibleAcceleratorNotForMenu(key_event)) {
if (views::MenuController* menu_controller =
@@ -111,7 +112,7 @@ bool AcceleratorDispatcher::Dispatch(const base::NativeEvent& event) {
#else
NOTIMPLEMENTED() << " Repost NativeEvent here.";
#endif
- return false;
+ return POST_DISPATCH_QUIT_LOOP;
}
}
@@ -127,7 +128,7 @@ bool AcceleratorDispatcher::Dispatch(const base::NativeEvent& event) {
Shell::GetInstance()->accelerator_controller()->context()->
UpdateContext(accelerator);
if (accelerator_controller->Process(accelerator))
- return true;
+ return POST_DISPATCH_NONE;
}
return nested_dispatcher_->Dispatch(key_event.native_event());
diff --git a/ash/accelerators/accelerator_dispatcher.h b/ash/accelerators/accelerator_dispatcher.h
index ecc85b0..a7ae40a 100644
--- a/ash/accelerators/accelerator_dispatcher.h
+++ b/ash/accelerators/accelerator_dispatcher.h
@@ -27,7 +27,7 @@ class ASH_EXPORT AcceleratorDispatcher : public base::MessagePumpDispatcher,
virtual ~AcceleratorDispatcher();
// MessagePumpDispatcher overrides:
- virtual bool Dispatch(const base::NativeEvent& event) OVERRIDE;
+ virtual uint32_t Dispatch(const base::NativeEvent& event) OVERRIDE;
// aura::WindowObserver overrides:
virtual void OnWindowDestroying(aura::Window* window) OVERRIDE;
diff --git a/ash/accelerators/nested_dispatcher_controller_unittest.cc b/ash/accelerators/nested_dispatcher_controller_unittest.cc
index f3ae2b7..db5fb7a 100644
--- a/ash/accelerators/nested_dispatcher_controller_unittest.cc
+++ b/ash/accelerators/nested_dispatcher_controller_unittest.cc
@@ -35,13 +35,12 @@ class MockDispatcher : public base::MessagePumpDispatcher {
int num_key_events_dispatched() { return num_key_events_dispatched_; }
-#if defined(OS_WIN) || defined(USE_X11) || defined(USE_OZONE)
- virtual bool Dispatch(const base::NativeEvent& event) OVERRIDE {
+ virtual uint32_t Dispatch(const base::NativeEvent& event) OVERRIDE {
if (ui::EventTypeFromNative(event) == ui::ET_KEY_RELEASED)
num_key_events_dispatched_++;
- return !ui::IsNoopEvent(event);
+ return ui::IsNoopEvent(event) ? POST_DISPATCH_QUIT_LOOP
+ : POST_DISPATCH_NONE;
}
-#endif
private:
int num_key_events_dispatched_;