OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ash/wm/workspace/phantom_window_controller.h" | 5 #include "ash/wm/workspace/phantom_window_controller.h" |
6 | 6 |
| 7 #include "ash/shell.h" |
| 8 #include "ash/shell_window_ids.h" |
7 #include "third_party/skia/include/core/SkCanvas.h" | 9 #include "third_party/skia/include/core/SkCanvas.h" |
8 #include "ui/aura/window.h" | 10 #include "ui/aura/window.h" |
9 #include "ui/aura/window_observer.h" | 11 #include "ui/aura/window_observer.h" |
10 #include "ui/gfx/canvas.h" | 12 #include "ui/gfx/canvas.h" |
11 #include "ui/gfx/compositor/layer.h" | 13 #include "ui/gfx/compositor/layer.h" |
12 #include "ui/gfx/compositor/scoped_layer_animation_settings.h" | 14 #include "ui/gfx/compositor/scoped_layer_animation_settings.h" |
13 #include "ui/gfx/skia_util.h" | 15 #include "ui/gfx/skia_util.h" |
14 #include "ui/views/painter.h" | 16 #include "ui/views/painter.h" |
15 #include "ui/views/view.h" | 17 #include "ui/views/view.h" |
16 #include "ui/views/widget/widget.h" | 18 #include "ui/views/widget/widget.h" |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 new DelayedWidgetDeleter(phantom_widget_.release(), window_); | 170 new DelayedWidgetDeleter(phantom_widget_.release(), window_); |
169 deleter->ScheduleDelete(delay_ms); | 171 deleter->ScheduleDelete(delay_ms); |
170 } | 172 } |
171 | 173 |
172 void PhantomWindowController::ShowNow() { | 174 void PhantomWindowController::ShowNow() { |
173 if (!phantom_widget_.get()) { | 175 if (!phantom_widget_.get()) { |
174 phantom_widget_.reset(new views::Widget); | 176 phantom_widget_.reset(new views::Widget); |
175 views::Widget::InitParams params(views::Widget::InitParams::TYPE_POPUP); | 177 views::Widget::InitParams params(views::Widget::InitParams::TYPE_POPUP); |
176 params.transparent = true; | 178 params.transparent = true; |
177 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; | 179 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; |
178 params.parent = window_->parent(); | 180 if (type_ == TYPE_DESTINATION) { |
| 181 params.parent = window_->parent(); |
| 182 } else { |
| 183 // TYPE_EDGE is used by FrameMaximizeButton to highlight the launcher |
| 184 // button, make sure the phantom appears over it. |
| 185 params.parent = |
| 186 Shell::GetInstance()->GetContainer(kShellWindowId_LauncherContainer); |
| 187 } |
179 params.can_activate = false; | 188 params.can_activate = false; |
| 189 params.keep_on_top = true; |
180 phantom_widget_->set_focus_on_creation(false); | 190 phantom_widget_->set_focus_on_creation(false); |
181 phantom_widget_->Init(params); | 191 phantom_widget_->Init(params); |
182 phantom_widget_->SetVisibilityChangedAnimationsEnabled(false); | 192 phantom_widget_->SetVisibilityChangedAnimationsEnabled(false); |
183 phantom_widget_->GetNativeWindow()->SetName("PhantomWindow"); | 193 phantom_widget_->GetNativeWindow()->SetName("PhantomWindow"); |
184 views::View* content_view = new views::View; | 194 views::View* content_view = new views::View; |
185 views::Painter* painter = type_ == TYPE_DESTINATION ? | 195 views::Painter* painter = type_ == TYPE_DESTINATION ? |
186 static_cast<views::Painter*>(new DestinationPainter) : | 196 static_cast<views::Painter*>(new DestinationPainter) : |
187 static_cast<views::Painter*>(new EdgePainter); | 197 static_cast<views::Painter*>(new EdgePainter); |
188 content_view->set_background( | 198 content_view->set_background( |
189 views::Background::CreateBackgroundPainter(true, painter)); | 199 views::Background::CreateBackgroundPainter(true, painter)); |
(...skipping 11 matching lines...) Expand all Loading... |
201 phantom_widget_->Show(); | 211 phantom_widget_->Show(); |
202 // Fade the window in. | 212 // Fade the window in. |
203 ui::Layer* layer = phantom_widget_->GetNativeWindow()->layer(); | 213 ui::Layer* layer = phantom_widget_->GetNativeWindow()->layer(); |
204 layer->SetOpacity(0); | 214 layer->SetOpacity(0); |
205 ui::ScopedLayerAnimationSettings scoped_setter(layer->GetAnimator()); | 215 ui::ScopedLayerAnimationSettings scoped_setter(layer->GetAnimator()); |
206 layer->SetOpacity(1); | 216 layer->SetOpacity(1); |
207 } | 217 } |
208 | 218 |
209 } // namespace internal | 219 } // namespace internal |
210 } // namespace ash | 220 } // namespace ash |
OLD | NEW |