| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_DESKTOP_H_ | 5 #ifndef UI_AURA_DESKTOP_H_ |
| 6 #define UI_AURA_DESKTOP_H_ | 6 #define UI_AURA_DESKTOP_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| 11 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
| 12 #include "base/message_loop.h" | 12 #include "base/message_loop.h" |
| 13 #include "base/task.h" | 13 #include "base/task.h" |
| 14 #include "ui/aura/aura_export.h" | 14 #include "ui/aura/aura_export.h" |
| 15 #include "ui/aura/cursor.h" | 15 #include "ui/aura/cursor.h" |
| 16 #include "ui/aura/root_window.h" | 16 #include "ui/aura/root_window.h" |
| 17 #include "ui/base/events.h" | 17 #include "ui/base/events.h" |
| 18 #include "ui/gfx/compositor/compositor.h" | 18 #include "ui/gfx/compositor/compositor.h" |
| 19 #include "ui/gfx/native_widget_types.h" | 19 #include "ui/gfx/native_widget_types.h" |
| 20 | 20 |
| 21 namespace gfx { | 21 namespace gfx { |
| 22 class Size; | 22 class Size; |
| 23 } | 23 } |
| 24 | 24 |
| 25 namespace aura { | 25 namespace aura { |
| 26 | 26 |
| 27 class DesktopDelegate; | 27 class DesktopDelegate; |
| 28 class DesktopHost; | 28 class DesktopHost; |
| 29 class DesktopObserver; |
| 29 class MouseEvent; | 30 class MouseEvent; |
| 30 | 31 |
| 31 // Desktop is responsible for hosting a set of windows. | 32 // Desktop is responsible for hosting a set of windows. |
| 32 class AURA_EXPORT Desktop : public ui::CompositorDelegate { | 33 class AURA_EXPORT Desktop : public ui::CompositorDelegate { |
| 33 public: | 34 public: |
| 34 Desktop(); | 35 Desktop(); |
| 35 virtual ~Desktop(); | 36 virtual ~Desktop(); |
| 36 | 37 |
| 37 DesktopDelegate* delegate() { return delegate_.get(); } | 38 DesktopDelegate* delegate() { return delegate_.get(); } |
| 38 void SetDelegate(DesktopDelegate* delegate); | 39 void SetDelegate(DesktopDelegate* delegate); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 | 94 |
| 94 // Invoked from RootWindow when |window| is being destroyed. | 95 // Invoked from RootWindow when |window| is being destroyed. |
| 95 void WindowDestroying(Window* window); | 96 void WindowDestroying(Window* window); |
| 96 | 97 |
| 97 // Returns the desktop's dispatcher. The result should only be passed to | 98 // Returns the desktop's dispatcher. The result should only be passed to |
| 98 // MessageLoopForUI::Run() or MessageLoopForUI::RunAllPendingWithDispatcher(), | 99 // MessageLoopForUI::Run() or MessageLoopForUI::RunAllPendingWithDispatcher(), |
| 99 // or used to dispatch an event by |Dispatch(const NativeEvent&)| on it. | 100 // or used to dispatch an event by |Dispatch(const NativeEvent&)| on it. |
| 100 // It must never be stored. | 101 // It must never be stored. |
| 101 MessageLoop::Dispatcher* GetDispatcher(); | 102 MessageLoop::Dispatcher* GetDispatcher(); |
| 102 | 103 |
| 104 // Add/remove observer. |
| 105 void AddObserver(DesktopObserver* observer); |
| 106 void RemoveObserver(DesktopObserver* observer); |
| 107 |
| 103 static Desktop* GetInstance(); | 108 static Desktop* GetInstance(); |
| 104 | 109 |
| 105 private: | 110 private: |
| 106 // Overridden from ui::CompositorDelegate | 111 // Overridden from ui::CompositorDelegate |
| 107 virtual void ScheduleDraw(); | 112 virtual void ScheduleDraw(); |
| 108 | 113 |
| 109 scoped_ptr<DesktopDelegate> delegate_; | 114 scoped_ptr<DesktopDelegate> delegate_; |
| 110 | 115 |
| 111 scoped_refptr<ui::Compositor> compositor_; | 116 scoped_refptr<ui::Compositor> compositor_; |
| 112 | 117 |
| 113 scoped_ptr<internal::RootWindow> window_; | 118 scoped_ptr<internal::RootWindow> window_; |
| 114 | 119 |
| 115 scoped_ptr<DesktopHost> host_; | 120 scoped_ptr<DesktopHost> host_; |
| 116 | 121 |
| 117 static Desktop* instance_; | 122 static Desktop* instance_; |
| 118 | 123 |
| 119 // Used to schedule painting. | 124 // Used to schedule painting. |
| 120 base::WeakPtrFactory<Desktop> schedule_paint_factory_; | 125 base::WeakPtrFactory<Desktop> schedule_paint_factory_; |
| 121 | 126 |
| 122 // Factory used to create Compositors. Settable by tests. | 127 // Factory used to create Compositors. Settable by tests. |
| 123 static ui::Compositor*(*compositor_factory_)(); | 128 static ui::Compositor*(*compositor_factory_)(); |
| 124 | 129 |
| 125 Window* active_window_; | 130 Window* active_window_; |
| 126 | 131 |
| 127 // Are we in the process of being destroyed? Used to avoid processing during | 132 // Are we in the process of being destroyed? Used to avoid processing during |
| 128 // destruction. | 133 // destruction. |
| 129 bool in_destructor_; | 134 bool in_destructor_; |
| 130 | 135 |
| 136 ObserverList<DesktopObserver> observers_; |
| 137 |
| 131 DISALLOW_COPY_AND_ASSIGN(Desktop); | 138 DISALLOW_COPY_AND_ASSIGN(Desktop); |
| 132 }; | 139 }; |
| 133 | 140 |
| 134 } // namespace aura | 141 } // namespace aura |
| 135 | 142 |
| 136 #endif // UI_AURA_DESKTOP_H_ | 143 #endif // UI_AURA_DESKTOP_H_ |
| OLD | NEW |