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_shell/launcher/launcher.h" | 5 #include "ui/aura_shell/launcher/launcher.h" |
6 | 6 |
7 #include "ui/aura/window.h" | 7 #include "ui/aura/window.h" |
8 #include "ui/aura_shell/launcher/launcher_model.h" | 8 #include "ui/aura_shell/launcher/launcher_model.h" |
9 #include "ui/aura_shell/launcher/launcher_view.h" | 9 #include "ui/aura_shell/launcher/launcher_view.h" |
10 #include "ui/aura_shell/shell.h" | 10 #include "ui/aura_shell/shell.h" |
11 #include "ui/aura_shell/shell_delegate.h" | 11 #include "ui/aura_shell/shell_delegate.h" |
12 #include "ui/aura_shell/shell_window_ids.h" | 12 #include "ui/aura_shell/shell_window_ids.h" |
13 #include "ui/gfx/compositor/layer.h" | 13 #include "ui/gfx/compositor/layer.h" |
14 #include "ui/views/widget/widget.h" | 14 #include "ui/views/widget/widget.h" |
15 | 15 |
16 namespace aura_shell { | 16 namespace aura_shell { |
17 | 17 |
18 Launcher::Launcher(aura::Window* window_container) | 18 Launcher::Launcher(aura::Window* window_container) |
19 : widget_(NULL), | 19 : widget_(NULL), |
20 window_container_(window_container) { | 20 window_container_(window_container) { |
21 window_container->AddObserver(this); | 21 window_container->AddObserver(this); |
22 | 22 |
23 model_.reset(new LauncherModel); | 23 model_.reset(new LauncherModel); |
24 | 24 |
25 widget_ = new views::Widget; | 25 widget_ = new views::Widget; |
26 views::Widget::InitParams params(views::Widget::InitParams::TYPE_CONTROL); | 26 views::Widget::InitParams params(views::Widget::InitParams::TYPE_CONTROL); |
27 params.create_texture_for_layer = true; | 27 // All the content is drawn by the launcher buttons. Turn off the widget's |
28 params.transparent = true; | 28 // layer's texture to avoid unnecessary memory use. |
| 29 params.create_texture_for_layer = false; |
29 params.parent = Shell::GetInstance()->GetContainer( | 30 params.parent = Shell::GetInstance()->GetContainer( |
30 aura_shell::internal::kShellWindowId_LauncherContainer); | 31 aura_shell::internal::kShellWindowId_LauncherContainer); |
31 internal::LauncherView* launcher_view = | 32 internal::LauncherView* launcher_view = |
32 new internal::LauncherView(model_.get()); | 33 new internal::LauncherView(model_.get()); |
33 launcher_view->Init(); | 34 launcher_view->Init(); |
34 params.delegate = launcher_view; | 35 params.delegate = launcher_view; |
35 widget_->Init(params); | 36 widget_->Init(params); |
36 gfx::Size pref = static_cast<views::View*>(launcher_view)->GetPreferredSize(); | 37 gfx::Size pref = static_cast<views::View*>(launcher_view)->GetPreferredSize(); |
37 widget_->SetBounds(gfx::Rect(0, 0, pref.width(), pref.height())); | 38 widget_->SetBounds(gfx::Rect(0, 0, pref.width(), pref.height())); |
38 widget_->SetContentsView(launcher_view); | 39 widget_->SetContentsView(launcher_view); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 model_->RemoveItemAt(i - model_->items().begin()); | 90 model_->RemoveItemAt(i - model_->items().begin()); |
90 } | 91 } |
91 | 92 |
92 void Launcher::OnWindowVisibilityChanged(aura::Window* window, | 93 void Launcher::OnWindowVisibilityChanged(aura::Window* window, |
93 bool visibile) { | 94 bool visibile) { |
94 if (visibile && !known_windows_[window]) | 95 if (visibile && !known_windows_[window]) |
95 MaybeAdd(window); | 96 MaybeAdd(window); |
96 } | 97 } |
97 | 98 |
98 } // namespace aura_shell | 99 } // namespace aura_shell |
OLD | NEW |