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

Unified Diff: ash/accelerators/accelerator_dispatcher_win.cc

Issue 219743002: x11: Move X event handling out of the message-pump. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: tot-merge-r261267 Created 6 years, 9 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 | « ash/accelerators/accelerator_dispatcher_linux.cc ('k') | ash/accelerators/nested_dispatcher_controller.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/accelerators/accelerator_dispatcher_win.cc
diff --git a/ash/accelerators/accelerator_dispatcher_win.cc b/ash/accelerators/accelerator_dispatcher_win.cc
new file mode 100644
index 0000000000000000000000000000000000000000..35005f34ad23998b3c12ff44d298bb0641a914b6
--- /dev/null
+++ b/ash/accelerators/accelerator_dispatcher_win.cc
@@ -0,0 +1,64 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ash/accelerators/accelerator_dispatcher.h"
+
+#include "base/memory/scoped_ptr.h"
+#include "base/message_loop/message_pump_dispatcher.h"
+#include "base/run_loop.h"
+#include "ui/events/event.h"
+
+using base::MessagePumpDispatcher;
+
+namespace ash {
+
+namespace {
+
+bool IsKeyEvent(const MSG& msg) {
+ return msg.message == WM_KEYDOWN || msg.message == WM_SYSKEYDOWN ||
+ msg.message == WM_KEYUP || msg.message == WM_SYSKEYUP;
+}
+
+} // namespace
+
+class AcceleratorDispatcherWin : public AcceleratorDispatcher,
+ public MessagePumpDispatcher {
+ public:
+ explicit AcceleratorDispatcherWin(MessagePumpDispatcher* nested)
+ : nested_dispatcher_(nested) {}
+ virtual ~AcceleratorDispatcherWin() {}
+
+ private:
+ // AcceleratorDispatcher:
+ virtual scoped_ptr<base::RunLoop> CreateRunLoop() OVERRIDE {
+ return scoped_ptr<base::RunLoop>(new base::RunLoop(this));
+ }
+
+ // MessagePumpDispatcher:
+ virtual uint32_t Dispatch(const MSG& event) OVERRIDE {
+ if (IsKeyEvent(event)) {
+ ui::KeyEvent key_event(event, false);
+ if (MenuClosedForPossibleAccelerator(key_event))
+ return POST_DISPATCH_QUIT_LOOP;
+
+ if (AcceleratorProcessedForKeyEvent(key_event))
+ return POST_DISPATCH_NONE;
+ }
+
+ return nested_dispatcher_ ? nested_dispatcher_->Dispatch(event)
+ : POST_DISPATCH_PERFORM_DEFAULT;
+ }
+
+ MessagePumpDispatcher* nested_dispatcher_;
+
+ DISALLOW_COPY_AND_ASSIGN(AcceleratorDispatcherWin);
+};
+
+scoped_ptr<AcceleratorDispatcher> AcceleratorDispatcher::Create(
+ MessagePumpDispatcher* nested_dispatcher) {
+ return scoped_ptr<AcceleratorDispatcher>(
+ new AcceleratorDispatcherWin(nested_dispatcher));
+}
+
+} // namespace ash
« no previous file with comments | « ash/accelerators/accelerator_dispatcher_linux.cc ('k') | ash/accelerators/nested_dispatcher_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698