OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef AURA_DESKTOP_H_ | |
6 #define AURA_DESKTOP_H_ | |
7 #pragma once | |
8 | |
9 #include "aura/root_window.h" | |
10 #include "aura/aura_export.h" | |
11 #include "base/basictypes.h" | |
12 #include "base/memory/ref_counted.h" | |
13 #include "base/task.h" | |
14 #include "ui/gfx/compositor/compositor.h" | |
15 #include "ui/gfx/native_widget_types.h" | |
16 | |
17 namespace gfx { | |
18 class Size; | |
19 } | |
20 | |
21 namespace aura { | |
22 | |
23 class DesktopHost; | |
24 class MouseEvent; | |
25 | |
26 // Desktop is responsible for hosting a set of windows. | |
27 class AURA_EXPORT Desktop : public ui::CompositorDelegate { | |
28 public: | |
29 Desktop(); | |
30 ~Desktop(); | |
31 | |
32 // Shows the desktop host. | |
33 void Show(); | |
34 | |
35 // Sets the size of the desktop. | |
36 void SetSize(const gfx::Size& size); | |
37 | |
38 // Shows the desktop host and runs an event loop for it. | |
39 void Run(); | |
40 | |
41 // Draws the necessary set of windows. | |
42 void Draw(); | |
43 | |
44 // Handles a mouse event. Returns true if handled. | |
45 bool OnMouseEvent(const MouseEvent& event); | |
46 | |
47 // Handles a key event. Returns true if handled. | |
48 bool OnKeyEvent(const KeyEvent& event); | |
49 | |
50 // Called when the host changes size. | |
51 void OnHostResized(const gfx::Size& size); | |
52 | |
53 // Compositor we're drawing to. | |
54 ui::Compositor* compositor() { return compositor_.get(); } | |
55 | |
56 Window* window() { return window_.get(); } | |
57 | |
58 static Desktop* GetInstance(); | |
59 | |
60 private: | |
61 // Overridden from ui::CompositorDelegate | |
62 virtual void ScheduleCompositorPaint(); | |
63 | |
64 scoped_refptr<ui::Compositor> compositor_; | |
65 | |
66 scoped_ptr<internal::RootWindow> window_; | |
67 | |
68 scoped_ptr<DesktopHost> host_; | |
69 | |
70 static Desktop* instance_; | |
71 | |
72 // Used to schedule painting. | |
73 ScopedRunnableMethodFactory<Desktop> schedule_paint_; | |
74 | |
75 DISALLOW_COPY_AND_ASSIGN(Desktop); | |
76 }; | |
77 | |
78 } // namespace aura | |
79 | |
80 #endif // AURA_DESKTOP_H_ | |
OLD | NEW |