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

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

Issue 851853002: It is time. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Trying to reup because the last upload failed. Created 5 years, 11 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/nested_accelerator_dispatcher_linux.cc ('k') | ui/wm/core/shadow.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "ui/wm/core/nested_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/base/accelerators/accelerator.h"
11 #include "ui/events/event.h"
12 #include "ui/wm/core/accelerator_filter.h"
13 #include "ui/wm/core/nested_accelerator_delegate.h"
14
15 using base::MessagePumpDispatcher;
16
17 namespace wm {
18
19 namespace {
20
21 bool IsKeyEvent(const MSG& msg) {
22 return msg.message == WM_KEYDOWN || msg.message == WM_SYSKEYDOWN ||
23 msg.message == WM_KEYUP || msg.message == WM_SYSKEYUP;
24 }
25
26 } // namespace
27
28 class NestedAcceleratorDispatcherWin : public NestedAcceleratorDispatcher,
29 public MessagePumpDispatcher {
30 public:
31 NestedAcceleratorDispatcherWin(NestedAcceleratorDelegate* delegate,
32 MessagePumpDispatcher* nested)
33 : NestedAcceleratorDispatcher(delegate), nested_dispatcher_(nested) {}
34 virtual ~NestedAcceleratorDispatcherWin() {}
35
36 private:
37 // NestedAcceleratorDispatcher:
38 virtual scoped_ptr<base::RunLoop> CreateRunLoop() override {
39 return scoped_ptr<base::RunLoop>(new base::RunLoop(this));
40 }
41
42 // MessagePumpDispatcher:
43 virtual uint32_t Dispatch(const MSG& event) override {
44 if (IsKeyEvent(event)) {
45 ui::KeyEvent key_event(event);
46 ui::Accelerator accelerator = CreateAcceleratorFromKeyEvent(key_event);
47
48 switch (delegate_->ProcessAccelerator(accelerator)) {
49 case NestedAcceleratorDelegate::RESULT_PROCESS_LATER:
50 return POST_DISPATCH_QUIT_LOOP;
51 case NestedAcceleratorDelegate::RESULT_PROCESSED:
52 return POST_DISPATCH_NONE;
53 case NestedAcceleratorDelegate::RESULT_NOT_PROCESSED:
54 break;
55 }
56 }
57
58 return nested_dispatcher_ ? nested_dispatcher_->Dispatch(event)
59 : POST_DISPATCH_PERFORM_DEFAULT;
60 }
61
62 MessagePumpDispatcher* nested_dispatcher_;
63
64 DISALLOW_COPY_AND_ASSIGN(NestedAcceleratorDispatcherWin);
65 };
66
67 scoped_ptr<NestedAcceleratorDispatcher> NestedAcceleratorDispatcher::Create(
68 NestedAcceleratorDelegate* delegate,
69 MessagePumpDispatcher* nested_dispatcher) {
70 return scoped_ptr<NestedAcceleratorDispatcher>(
71 new NestedAcceleratorDispatcherWin(delegate, nested_dispatcher));
72 }
73
74 } // namespace wm
OLDNEW
« no previous file with comments | « ui/wm/core/nested_accelerator_dispatcher_linux.cc ('k') | ui/wm/core/shadow.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698