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 "ui/aura/desktop.h" | 5 #include "ui/aura/desktop.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 14 matching lines...) Expand all Loading... |
25 #include "ui/aura/window_delegate.h" | 25 #include "ui/aura/window_delegate.h" |
26 #include "ui/base/hit_test.h" | 26 #include "ui/base/hit_test.h" |
27 #include "ui/gfx/compositor/compositor.h" | 27 #include "ui/gfx/compositor/compositor.h" |
28 #include "ui/gfx/compositor/layer.h" | 28 #include "ui/gfx/compositor/layer.h" |
29 #include "ui/gfx/compositor/layer_animator.h" | 29 #include "ui/gfx/compositor/layer_animator.h" |
30 | 30 |
31 #ifdef USE_WEBKIT_COMPOSITOR | 31 #ifdef USE_WEBKIT_COMPOSITOR |
32 #include "ui/gfx/compositor/compositor_cc.h" | 32 #include "ui/gfx/compositor/compositor_cc.h" |
33 #endif | 33 #endif |
34 | 34 |
| 35 #if defined(USE_X11) |
| 36 #include "base/message_pump_x.h" |
| 37 #endif |
| 38 |
35 using std::string; | 39 using std::string; |
36 using std::vector; | 40 using std::vector; |
37 | 41 |
38 namespace aura { | 42 namespace aura { |
39 | 43 |
40 namespace { | 44 namespace { |
41 | 45 |
42 // Default bounds for the host window. | 46 // Default bounds for the host window. |
43 static const int kDefaultHostWindowX = 200; | 47 static const int kDefaultHostWindowX = 200; |
44 static const int kDefaultHostWindowY = 200; | 48 static const int kDefaultHostWindowY = 200; |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 if (ui::Compositor::compositor_factory()) { | 129 if (ui::Compositor::compositor_factory()) { |
126 compositor_ = (*ui::Compositor::compositor_factory())(this); | 130 compositor_ = (*ui::Compositor::compositor_factory())(this); |
127 } else { | 131 } else { |
128 #ifdef USE_WEBKIT_COMPOSITOR | 132 #ifdef USE_WEBKIT_COMPOSITOR |
129 ui::CompositorCC::Initialize(false); | 133 ui::CompositorCC::Initialize(false); |
130 #endif | 134 #endif |
131 compositor_ = ui::Compositor::Create(this, host_->GetAcceleratedWidget(), | 135 compositor_ = ui::Compositor::Create(this, host_->GetAcceleratedWidget(), |
132 host_->GetSize()); | 136 host_->GetSize()); |
133 } | 137 } |
134 DCHECK(compositor_.get()); | 138 DCHECK(compositor_.get()); |
| 139 #if defined(USE_X11) |
| 140 base::MessagePumpX::SetDefaultDispatcher(host_.get()); |
| 141 #endif |
135 } | 142 } |
136 | 143 |
137 Desktop::~Desktop() { | 144 Desktop::~Desktop() { |
| 145 #if defined(USE_X11) |
| 146 base::MessagePumpX::SetDefaultDispatcher(NULL); |
| 147 #endif |
| 148 |
138 in_destructor_ = true; | 149 in_destructor_ = true; |
139 #ifdef USE_WEBKIT_COMPOSITOR | 150 #ifdef USE_WEBKIT_COMPOSITOR |
140 if (!ui::Compositor::compositor_factory()) | 151 if (!ui::Compositor::compositor_factory()) |
141 ui::CompositorCC::Terminate(); | 152 ui::CompositorCC::Terminate(); |
142 #endif | 153 #endif |
143 if (instance_ == this) | 154 if (instance_ == this) |
144 instance_ = NULL; | 155 instance_ = NULL; |
145 } | 156 } |
146 | 157 |
147 // static | 158 // static |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 | 192 |
182 void Desktop::SetCursor(gfx::NativeCursor cursor) { | 193 void Desktop::SetCursor(gfx::NativeCursor cursor) { |
183 last_cursor_ = cursor; | 194 last_cursor_ = cursor; |
184 // A lot of code seems to depend on NULL cursors actually showing an arrow, | 195 // A lot of code seems to depend on NULL cursors actually showing an arrow, |
185 // so just pass everything along to the host. | 196 // so just pass everything along to the host. |
186 host_->SetCursor(cursor); | 197 host_->SetCursor(cursor); |
187 } | 198 } |
188 | 199 |
189 void Desktop::Run() { | 200 void Desktop::Run() { |
190 ShowDesktop(); | 201 ShowDesktop(); |
191 MessageLoopForUI::current()->RunWithDispatcher(host_.get()); | 202 MessageLoopForUI::current()->Run(); |
192 } | 203 } |
193 | 204 |
194 void Desktop::Draw() { | 205 void Desktop::Draw() { |
195 compositor_->Draw(false); | 206 compositor_->Draw(false); |
196 } | 207 } |
197 | 208 |
198 bool Desktop::DispatchMouseEvent(MouseEvent* event) { | 209 bool Desktop::DispatchMouseEvent(MouseEvent* event) { |
199 static const int kMouseButtonFlagMask = | 210 static const int kMouseButtonFlagMask = |
200 ui::EF_LEFT_BUTTON_DOWN | | 211 ui::EF_LEFT_BUTTON_DOWN | |
201 ui::EF_MIDDLE_BUTTON_DOWN | | 212 ui::EF_MIDDLE_BUTTON_DOWN | |
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
580 base::StringToInt(parts[1], &parsed_height) && parsed_height > 0) { | 591 base::StringToInt(parts[1], &parsed_height) && parsed_height > 0) { |
581 bounds.set_size(gfx::Size(parsed_width, parsed_height)); | 592 bounds.set_size(gfx::Size(parsed_width, parsed_height)); |
582 } else if (use_fullscreen_host_window_) { | 593 } else if (use_fullscreen_host_window_) { |
583 bounds = gfx::Rect(DesktopHost::GetNativeDisplaySize()); | 594 bounds = gfx::Rect(DesktopHost::GetNativeDisplaySize()); |
584 } | 595 } |
585 | 596 |
586 return bounds; | 597 return bounds; |
587 } | 598 } |
588 | 599 |
589 } // namespace aura | 600 } // namespace aura |
OLD | NEW |