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 #include "aura/desktop.h" | 5 #include "aura/desktop.h" |
6 | 6 |
7 #include "aura/desktop_host.h" | 7 #include "aura/desktop_host.h" |
| 8 #include "aura/root_window.h" |
8 #include "aura/window.h" | 9 #include "aura/window.h" |
9 #include "base/logging.h" | 10 #include "base/logging.h" |
10 #include "base/message_loop.h" | 11 #include "base/message_loop.h" |
11 #include "ui/gfx/compositor/compositor.h" | 12 #include "ui/gfx/compositor/compositor.h" |
12 | 13 |
13 namespace aura { | 14 namespace aura { |
14 | 15 |
15 // static | 16 // static |
16 Desktop* Desktop::instance_ = NULL; | 17 Desktop* Desktop::instance_ = NULL; |
17 | 18 |
18 Desktop::Desktop() | 19 Desktop::Desktop() |
19 : host_(aura::DesktopHost::Create(gfx::Rect(200, 200, 1024, 768))) { | 20 : host_(aura::DesktopHost::Create(gfx::Rect(200, 200, 1024, 768))) { |
20 compositor_ = ui::Compositor::Create(host_->GetAcceleratedWidget(), | 21 compositor_ = ui::Compositor::Create(host_->GetAcceleratedWidget(), |
21 host_->GetSize()); | 22 host_->GetSize()); |
22 host_->SetDesktop(this); | 23 host_->SetDesktop(this); |
23 DCHECK(compositor_.get()); | 24 DCHECK(compositor_.get()); |
24 window_.reset(new Window(NULL)); | 25 window_.reset(new internal::RootWindow); |
25 } | 26 } |
26 | 27 |
27 Desktop::~Desktop() { | 28 Desktop::~Desktop() { |
28 } | 29 } |
29 | 30 |
| 31 void Desktop::Show() { |
| 32 host_->Show(); |
| 33 } |
| 34 |
| 35 void Desktop::SetSize(const gfx::Size& size) { |
| 36 host_->SetSize(size); |
| 37 } |
| 38 |
30 void Desktop::Run() { | 39 void Desktop::Run() { |
31 host_->Show(); | 40 Show(); |
32 MessageLoop main_message_loop(MessageLoop::TYPE_UI); | 41 MessageLoop main_message_loop(MessageLoop::TYPE_UI); |
33 MessageLoopForUI::current()->Run(host_); | 42 MessageLoopForUI::current()->Run(host_); |
34 } | 43 } |
35 | 44 |
36 void Desktop::Draw() { | 45 void Desktop::Draw() { |
37 // Second pass renders the layers. | |
38 compositor_->NotifyStart(); | 46 compositor_->NotifyStart(); |
39 window_->DrawTree(); | 47 window_->DrawTree(); |
40 compositor_->NotifyEnd(); | 48 compositor_->NotifyEnd(); |
41 } | 49 } |
42 | 50 |
43 bool Desktop::OnMouseEvent(const MouseEvent& event) { | 51 bool Desktop::OnMouseEvent(const MouseEvent& event) { |
44 return window_->OnMouseEvent(event); | 52 return window_->HandleMouseEvent(event); |
45 } | 53 } |
46 | 54 |
47 // static | 55 // static |
48 Desktop* Desktop::GetInstance() { | 56 Desktop* Desktop::GetInstance() { |
49 if (!instance_) { | 57 if (!instance_) { |
50 instance_ = new Desktop; | 58 instance_ = new Desktop; |
51 instance_->window_->Init(); | 59 instance_->window_->Init(); |
52 } | 60 } |
53 return instance_; | 61 return instance_; |
54 } | 62 } |
55 | 63 |
56 } // namespace aura | 64 } // namespace aura |
OLD | NEW |