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

Side by Side Diff: ui/aura/env.h

Issue 10960015: aura: Start converting event-filters into event-handlers. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 3 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
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 UI_AURA_ENV_H_ 5 #ifndef UI_AURA_ENV_H_
6 #define UI_AURA_ENV_H_ 6 #define UI_AURA_ENV_H_
7 7
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/observer_list.h" 10 #include "base/observer_list.h"
11 #include "ui/aura/aura_export.h" 11 #include "ui/aura/aura_export.h"
12 #include "ui/aura/client/stacking_client.h" 12 #include "ui/aura/client/stacking_client.h"
13 #include "ui/base/events/event_handler.h"
14 #include "ui/base/events/event_target.h"
13 #include "ui/gfx/point.h" 15 #include "ui/gfx/point.h"
14 16
15 #if defined(USE_X11) 17 #if defined(USE_X11)
16 #include "ui/aura/device_list_updater_aurax11.h" 18 #include "ui/aura/device_list_updater_aurax11.h"
17 #endif 19 #endif
18 20
19 namespace aura { 21 namespace aura {
20 class EnvObserver; 22 class EnvObserver;
21 class EventFilter; 23 class EventFilter;
22 class DisplayManager; 24 class DisplayManager;
23 class Window; 25 class Window;
24 26
25 namespace internal { 27 namespace internal {
26 class DisplayChangeObserverX11; 28 class DisplayChangeObserverX11;
27 } 29 }
28 30
29 #if !defined(USE_X11) 31 #if !defined(USE_X11)
30 // Creates a platform-specific native event dispatcher. 32 // Creates a platform-specific native event dispatcher.
31 MessageLoop::Dispatcher* CreateDispatcher(); 33 MessageLoop::Dispatcher* CreateDispatcher();
32 #endif 34 #endif
33 35
34 // A singleton object that tracks general state within Aura. 36 // A singleton object that tracks general state within Aura.
35 // TODO(beng): manage RootWindows. 37 // TODO(beng): manage RootWindows.
36 class AURA_EXPORT Env { 38 class AURA_EXPORT Env : public ui::EventTarget {
37 public: 39 public:
38 Env(); 40 Env();
39 ~Env(); 41 virtual ~Env();
40 42
41 static Env* GetInstance(); 43 static Env* GetInstance();
42 static void DeleteInstance(); 44 static void DeleteInstance();
43 45
44 void AddObserver(EnvObserver* observer); 46 void AddObserver(EnvObserver* observer);
45 void RemoveObserver(EnvObserver* observer); 47 void RemoveObserver(EnvObserver* observer);
46 48
47 bool is_mouse_button_down() const { return mouse_button_flags_ != 0; } 49 bool is_mouse_button_down() const { return mouse_button_flags_ != 0; }
48 void set_mouse_button_flags(int mouse_button_flags) { 50 void set_mouse_button_flags(int mouse_button_flags) {
49 mouse_button_flags_ = mouse_button_flags; 51 mouse_button_flags_ = mouse_button_flags;
(...skipping 23 matching lines...) Expand all
73 client::StackingClient* stacking_client() { return stacking_client_; } 75 client::StackingClient* stacking_client() { return stacking_client_; }
74 void set_stacking_client(client::StackingClient* stacking_client) { 76 void set_stacking_client(client::StackingClient* stacking_client) {
75 stacking_client_ = stacking_client; 77 stacking_client_ = stacking_client;
76 } 78 }
77 79
78 // Gets/sets DisplayManager. The DisplayManager's ownership is 80 // Gets/sets DisplayManager. The DisplayManager's ownership is
79 // transfered. 81 // transfered.
80 DisplayManager* display_manager() { return display_manager_.get(); } 82 DisplayManager* display_manager() { return display_manager_.get(); }
81 void SetDisplayManager(DisplayManager* display_manager); 83 void SetDisplayManager(DisplayManager* display_manager);
82 84
83 // Env takes ownership of the EventFilter.
84 EventFilter* event_filter() { return event_filter_.get(); }
85 void SetEventFilter(EventFilter* event_filter);
86
87 // Returns the native event dispatcher. The result should only be passed to 85 // Returns the native event dispatcher. The result should only be passed to
88 // base::RunLoop(dispatcher), or used to dispatch an event by 86 // base::RunLoop(dispatcher), or used to dispatch an event by
89 // |Dispatch(const NativeEvent&)| on it. It must never be stored. 87 // |Dispatch(const NativeEvent&)| on it. It must never be stored.
90 #if !defined(OS_MACOSX) 88 #if !defined(OS_MACOSX)
91 MessageLoop::Dispatcher* GetDispatcher(); 89 MessageLoop::Dispatcher* GetDispatcher();
92 #endif 90 #endif
93 91
94 private: 92 private:
95 friend class Window; 93 friend class Window;
96 94
97 void Init(); 95 void Init();
98 96
99 // Called by the Window when it is initialized. Notifies observers. 97 // Called by the Window when it is initialized. Notifies observers.
100 void NotifyWindowInitialized(Window* window); 98 void NotifyWindowInitialized(Window* window);
101 99
100 // Overridden from ui::EventTarget:
101 virtual bool CanAcceptEvents() OVERRIDE;
102 virtual ui::EventTarget* GetParentTarget() OVERRIDE;
103
102 ObserverList<EnvObserver> observers_; 104 ObserverList<EnvObserver> observers_;
103 #if !defined(USE_X11) 105 #if !defined(USE_X11)
104 scoped_ptr<MessageLoop::Dispatcher> dispatcher_; 106 scoped_ptr<MessageLoop::Dispatcher> dispatcher_;
105 #endif 107 #endif
106 108
107 static Env* instance_; 109 static Env* instance_;
108 int mouse_button_flags_; 110 int mouse_button_flags_;
109 // Location of last mouse event, in screen coordinates. 111 // Location of last mouse event, in screen coordinates.
110 gfx::Point last_mouse_location_; 112 gfx::Point last_mouse_location_;
111 // If the cursor is hidden, saves the previous last_mouse_position. 113 // If the cursor is hidden, saves the previous last_mouse_position.
112 gfx::Point hidden_cursor_location_; 114 gfx::Point hidden_cursor_location_;
113 bool is_cursor_hidden_; 115 bool is_cursor_hidden_;
114 bool is_touch_down_; 116 bool is_touch_down_;
115 bool render_white_bg_; 117 bool render_white_bg_;
116 client::StackingClient* stacking_client_; 118 client::StackingClient* stacking_client_;
117 scoped_ptr<DisplayManager> display_manager_; 119 scoped_ptr<DisplayManager> display_manager_;
118 scoped_ptr<EventFilter> event_filter_;
119 120
120 #if defined(USE_X11) 121 #if defined(USE_X11)
121 scoped_ptr<internal::DisplayChangeObserverX11> display_change_observer_; 122 scoped_ptr<internal::DisplayChangeObserverX11> display_change_observer_;
122 DeviceListUpdaterAuraX11 device_list_updater_aurax11_; 123 DeviceListUpdaterAuraX11 device_list_updater_aurax11_;
123 #endif 124 #endif
124 125
125 DISALLOW_COPY_AND_ASSIGN(Env); 126 DISALLOW_COPY_AND_ASSIGN(Env);
126 }; 127 };
127 128
128 } // namespace aura 129 } // namespace aura
129 130
130 #endif // UI_AURA_ENV_H_ 131 #endif // UI_AURA_ENV_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698