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

Side by Side 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, 8 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 | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "ash/accelerators/accelerator_dispatcher.h"
6
7 #include "base/memory/scoped_ptr.h"
8 #include "base/message_loop/message_pump_dispatcher.h"
9 #include "base/run_loop.h"
10 #include "ui/events/event.h"
11
12 using base::MessagePumpDispatcher;
13
14 namespace ash {
15
16 namespace {
17
18 bool IsKeyEvent(const MSG& msg) {
19 return msg.message == WM_KEYDOWN || msg.message == WM_SYSKEYDOWN ||
20 msg.message == WM_KEYUP || msg.message == WM_SYSKEYUP;
21 }
22
23 } // namespace
24
25 class AcceleratorDispatcherWin : public AcceleratorDispatcher,
26 public MessagePumpDispatcher {
27 public:
28 explicit AcceleratorDispatcherWin(MessagePumpDispatcher* nested)
29 : nested_dispatcher_(nested) {}
30 virtual ~AcceleratorDispatcherWin() {}
31
32 private:
33 // AcceleratorDispatcher:
34 virtual scoped_ptr<base::RunLoop> CreateRunLoop() OVERRIDE {
35 return scoped_ptr<base::RunLoop>(new base::RunLoop(this));
36 }
37
38 // MessagePumpDispatcher:
39 virtual uint32_t Dispatch(const MSG& event) OVERRIDE {
40 if (IsKeyEvent(event)) {
41 ui::KeyEvent key_event(event, false);
42 if (MenuClosedForPossibleAccelerator(key_event))
43 return POST_DISPATCH_QUIT_LOOP;
44
45 if (AcceleratorProcessedForKeyEvent(key_event))
46 return POST_DISPATCH_NONE;
47 }
48
49 return nested_dispatcher_ ? nested_dispatcher_->Dispatch(event)
50 : POST_DISPATCH_PERFORM_DEFAULT;
51 }
52
53 MessagePumpDispatcher* nested_dispatcher_;
54
55 DISALLOW_COPY_AND_ASSIGN(AcceleratorDispatcherWin);
56 };
57
58 scoped_ptr<AcceleratorDispatcher> AcceleratorDispatcher::Create(
59 MessagePumpDispatcher* nested_dispatcher) {
60 return scoped_ptr<AcceleratorDispatcher>(
61 new AcceleratorDispatcherWin(nested_dispatcher));
62 }
63
64 } // namespace ash
OLDNEW
« 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