OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef ASH_ACCELERATORS_ACCELERATOR_DISPATCHER_H_ | 5 #ifndef ASH_ACCELERATORS_ACCELERATOR_DISPATCHER_H_ |
6 #define ASH_ACCELERATORS_ACCELERATOR_DISPATCHER_H_ | 6 #define ASH_ACCELERATORS_ACCELERATOR_DISPATCHER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "ash/ash_export.h" | 9 #include "ash/ash_export.h" |
10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
11 #include "ui/aura/window.h" | 11 #include "ui/aura/window.h" |
12 #include "ui/aura/window_observer.h" | 12 #include "ui/aura/window_observer.h" |
13 | 13 |
14 namespace ash { | 14 namespace ash { |
15 | 15 |
16 // Dispatcher for handling accelerators in ash. | 16 // Dispatcher for handling accelerators in ash. |
17 // Wraps a nested dispatcher to which control is passed if no accelerator key | 17 // Wraps a nested dispatcher to which control is passed if no accelerator key |
18 // has been pressed. | 18 // has been pressed. |
19 // TODO(pkotwicz): Port AcceleratorDispatcher to mac. | 19 // TODO(pkotwicz): Port AcceleratorDispatcher to mac. |
20 // TODO(pkotwicz): Add support for a |nested_dispatcher| which sends | 20 // TODO(pkotwicz): Add support for a |nested_dispatcher| which sends |
21 // events to a system IME. | 21 // events to a system IME. |
22 class ASH_EXPORT AcceleratorDispatcher : public MessageLoop::Dispatcher, | 22 class ASH_EXPORT AcceleratorDispatcher : public MessageLoop::Dispatcher, |
23 public aura::WindowObserver { | 23 public aura::WindowObserver { |
24 public: | 24 public: |
25 explicit AcceleratorDispatcher(MessageLoop::Dispatcher* nested_dispatcher, | 25 explicit AcceleratorDispatcher(MessageLoop::Dispatcher* nested_dispatcher, |
26 aura::Window* associated_window); | 26 aura::Window* associated_window); |
27 virtual ~AcceleratorDispatcher(); | 27 virtual ~AcceleratorDispatcher(); |
28 | 28 |
29 #if defined(USE_X11) | 29 // MessageLoop::Dispatcher overrides: |
30 virtual base::MessagePumpDispatcher::DispatchStatus Dispatch( | 30 virtual bool Dispatch(const base::NativeEvent& event) OVERRIDE; |
31 XEvent* xev) OVERRIDE; | |
32 #elif defined(OS_WIN) | |
33 bool AcceleratorDispatcher::Dispatch(const MSG& msg) OVERRIDE; | |
34 #endif | |
35 | 31 |
36 // aura::WindowObserver overrides: | 32 // aura::WindowObserver overrides: |
37 virtual void OnWindowDestroying(aura::Window* window) OVERRIDE; | 33 virtual void OnWindowDestroying(aura::Window* window) OVERRIDE; |
38 | 34 |
39 private: | 35 private: |
40 MessageLoop::Dispatcher* nested_dispatcher_; | 36 MessageLoop::Dispatcher* nested_dispatcher_; |
41 | 37 |
42 // Window associated with |nested_dispatcher_| which is used to determine | 38 // Window associated with |nested_dispatcher_| which is used to determine |
43 // whether the |nested_dispatcher_| is allowed to receive events. | 39 // whether the |nested_dispatcher_| is allowed to receive events. |
44 aura::Window* associated_window_; | 40 aura::Window* associated_window_; |
45 | 41 |
46 DISALLOW_COPY_AND_ASSIGN(AcceleratorDispatcher); | 42 DISALLOW_COPY_AND_ASSIGN(AcceleratorDispatcher); |
47 }; | 43 }; |
48 | 44 |
49 } // namespace ash | 45 } // namespace ash |
50 | 46 |
51 #endif // ASH_ACCELERATORS_ACCELERATOR_DISPATCHER_H_ | 47 #endif // ASH_ACCELERATORS_ACCELERATOR_DISPATCHER_H_ |
OLD | NEW |