| 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 UI_AURA_ENV_H_ | 5 #ifndef UI_AURA_ENV_H_ |
| 6 #define UI_AURA_ENV_H_ | 6 #define UI_AURA_ENV_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
| 11 #include "base/observer_list.h" | 11 #include "base/observer_list.h" |
| 12 #include "ui/aura/aura_export.h" | 12 #include "ui/aura/aura_export.h" |
| 13 #include "ui/aura/client/stacking_client.h" | 13 #include "ui/aura/client/stacking_client.h" |
| 14 | 14 |
| 15 namespace aura { | 15 namespace aura { |
| 16 | 16 |
| 17 class EnvObserver; | 17 class EnvObserver; |
| 18 class MonitorChangeObserverX11; | 18 class MonitorChangeObserverX11; |
| 19 class MonitorManager; | 19 class MonitorManager; |
| 20 class Window; | 20 class Window; |
| 21 | 21 |
| 22 #if !defined(OS_MACOSX) | 22 #if !defined(OS_MACOSX) |
| 23 class Dispatcher : public MessageLoop::Dispatcher { | |
| 24 public: | |
| 25 virtual ~Dispatcher() {} | |
| 26 }; | |
| 27 | |
| 28 // Creates a platform-specific native event dispatcher. | 23 // Creates a platform-specific native event dispatcher. |
| 29 Dispatcher* CreateDispatcher(); | 24 MessageLoop::Dispatcher* CreateDispatcher(); |
| 30 #endif | 25 #endif |
| 31 | 26 |
| 32 // A singleton object that tracks general state within Aura. | 27 // A singleton object that tracks general state within Aura. |
| 33 // TODO(beng): manage RootWindows. | 28 // TODO(beng): manage RootWindows. |
| 34 class AURA_EXPORT Env { | 29 class AURA_EXPORT Env { |
| 35 public: | 30 public: |
| 36 Env(); | 31 Env(); |
| 37 ~Env(); | 32 ~Env(); |
| 38 | 33 |
| 39 static Env* GetInstance(); | 34 static Env* GetInstance(); |
| 40 static void DeleteInstance(); | 35 static void DeleteInstance(); |
| 41 | 36 |
| 42 void AddObserver(EnvObserver* observer); | 37 void AddObserver(EnvObserver* observer); |
| 43 void RemoveObserver(EnvObserver* observer); | 38 void RemoveObserver(EnvObserver* observer); |
| 44 | 39 |
| 45 bool is_mouse_button_down() const { return mouse_button_flags_ != 0; } | 40 bool is_mouse_button_down() const { return mouse_button_flags_ != 0; } |
| 46 void set_mouse_button_flags(int mouse_button_flags) { | 41 void set_mouse_button_flags(int mouse_button_flags) { |
| 47 mouse_button_flags_ = mouse_button_flags; | 42 mouse_button_flags_ = mouse_button_flags; |
| 48 } | 43 } |
| 49 | 44 |
| 50 client::StackingClient* stacking_client() { return stacking_client_; } | 45 client::StackingClient* stacking_client() { return stacking_client_; } |
| 51 void set_stacking_client(client::StackingClient* stacking_client) { | 46 void set_stacking_client(client::StackingClient* stacking_client) { |
| 52 stacking_client_ = stacking_client; | 47 stacking_client_ = stacking_client; |
| 53 } | 48 } |
| 54 | 49 |
| 55 #if defined(USE_X11) | |
| 56 MonitorChangeObserverX11* monitor_change_observer() { | |
| 57 return monitor_change_observer_.get(); | |
| 58 } | |
| 59 #endif | |
| 60 | |
| 61 // Gets/sets MonitorManager. The MonitorManager's ownership is | 50 // Gets/sets MonitorManager. The MonitorManager's ownership is |
| 62 // transfered. | 51 // transfered. |
| 63 MonitorManager* monitor_manager() { return monitor_manager_.get(); } | 52 MonitorManager* monitor_manager() { return monitor_manager_.get(); } |
| 64 void SetMonitorManager(MonitorManager* monitor_manager); | 53 void SetMonitorManager(MonitorManager* monitor_manager); |
| 65 | 54 |
| 66 // Returns the native event dispatcher. The result should only be passed to | 55 // Returns the native event dispatcher. The result should only be passed to |
| 67 // MessageLoopForUI::RunWithDispatcher() or | 56 // MessageLoopForUI::RunWithDispatcher() or |
| 68 // MessageLoopForUI::RunAllPendingWithDispatcher(), or used to dispatch | 57 // MessageLoopForUI::RunAllPendingWithDispatcher(), or used to dispatch |
| 69 // an event by |Dispatch(const NativeEvent&)| on it. It must never be stored. | 58 // an event by |Dispatch(const NativeEvent&)| on it. It must never be stored. |
| 70 #if !defined(OS_MACOSX) | 59 #if !defined(OS_MACOSX) |
| 71 MessageLoop::Dispatcher* GetDispatcher(); | 60 MessageLoop::Dispatcher* GetDispatcher(); |
| 72 #endif | 61 #endif |
| 73 | 62 |
| 74 private: | 63 private: |
| 75 friend class Window; | 64 friend class Window; |
| 76 | 65 |
| 77 // Called by the Window when it is initialized. Notifies observers. | 66 // Called by the Window when it is initialized. Notifies observers. |
| 78 void NotifyWindowInitialized(Window* window); | 67 void NotifyWindowInitialized(Window* window); |
| 79 | 68 |
| 80 ObserverList<EnvObserver> observers_; | 69 ObserverList<EnvObserver> observers_; |
| 81 #if !defined(OS_MACOSX) | 70 #if !defined(OS_MACOSX) |
| 82 scoped_ptr<Dispatcher> dispatcher_; | 71 scoped_ptr<MessageLoop::Dispatcher> dispatcher_; |
| 83 #endif | 72 #endif |
| 84 | 73 |
| 85 static Env* instance_; | 74 static Env* instance_; |
| 86 int mouse_button_flags_; | 75 int mouse_button_flags_; |
| 87 client::StackingClient* stacking_client_; | 76 client::StackingClient* stacking_client_; |
| 88 scoped_ptr<MonitorManager> monitor_manager_; | 77 scoped_ptr<MonitorManager> monitor_manager_; |
| 89 | 78 |
| 90 #if defined(USE_X11) | |
| 91 scoped_ptr<MonitorChangeObserverX11> monitor_change_observer_; | |
| 92 #endif | |
| 93 | |
| 94 DISALLOW_COPY_AND_ASSIGN(Env); | 79 DISALLOW_COPY_AND_ASSIGN(Env); |
| 95 }; | 80 }; |
| 96 | 81 |
| 97 } // namespace aura | 82 } // namespace aura |
| 98 | 83 |
| 99 #endif // UI_AURA_ENV_H_ | 84 #endif // UI_AURA_ENV_H_ |
| OLD | NEW |