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" | 7 #include "ash/shell.h" |
8 #include "ash/shell_window_ids.h" | 8 #include "ash/shell_window_ids.h" |
| 9 #include "ash/wm/coordinate_conversion.h" |
9 #include "third_party/skia/include/core/SkCanvas.h" | 10 #include "third_party/skia/include/core/SkCanvas.h" |
10 #include "ui/aura/window.h" | 11 #include "ui/aura/window.h" |
11 #include "ui/aura/window_observer.h" | 12 #include "ui/aura/window_observer.h" |
12 #include "ui/base/animation/slide_animation.h" | 13 #include "ui/base/animation/slide_animation.h" |
13 #include "ui/compositor/layer.h" | 14 #include "ui/compositor/layer.h" |
14 #include "ui/compositor/scoped_layer_animation_settings.h" | 15 #include "ui/compositor/scoped_layer_animation_settings.h" |
15 #include "ui/gfx/canvas.h" | 16 #include "ui/gfx/canvas.h" |
16 #include "ui/gfx/skia_util.h" | 17 #include "ui/gfx/skia_util.h" |
17 #include "ui/views/painter.h" | 18 #include "ui/views/painter.h" |
18 #include "ui/views/view.h" | 19 #include "ui/views/view.h" |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 } | 121 } |
121 | 122 |
122 void PhantomWindowController::CreatePhantomWidget(const gfx::Rect& bounds) { | 123 void PhantomWindowController::CreatePhantomWidget(const gfx::Rect& bounds) { |
123 DCHECK(!phantom_widget_); | 124 DCHECK(!phantom_widget_); |
124 phantom_widget_ = new views::Widget; | 125 phantom_widget_ = new views::Widget; |
125 views::Widget::InitParams params(views::Widget::InitParams::TYPE_POPUP); | 126 views::Widget::InitParams params(views::Widget::InitParams::TYPE_POPUP); |
126 params.transparent = true; | 127 params.transparent = true; |
127 // PhantomWindowController is used by FrameMaximizeButton to highlight the | 128 // PhantomWindowController is used by FrameMaximizeButton to highlight the |
128 // launcher button. Put the phantom in the same window as the launcher so that | 129 // launcher button. Put the phantom in the same window as the launcher so that |
129 // the phantom is visible. | 130 // the phantom is visible. |
130 params.parent = Shell::GetContainer( | 131 params.parent = Shell::GetContainer(wm::GetRootWindowMatching(bounds), |
131 Shell::GetInstance()->GetRootWindowMatching(bounds), | 132 kShellWindowId_LauncherContainer); |
132 kShellWindowId_LauncherContainer); | |
133 params.can_activate = false; | 133 params.can_activate = false; |
134 params.keep_on_top = true; | 134 params.keep_on_top = true; |
135 phantom_widget_->set_focus_on_creation(false); | 135 phantom_widget_->set_focus_on_creation(false); |
136 phantom_widget_->Init(params); | 136 phantom_widget_->Init(params); |
137 phantom_widget_->SetVisibilityChangedAnimationsEnabled(false); | 137 phantom_widget_->SetVisibilityChangedAnimationsEnabled(false); |
138 phantom_widget_->GetNativeWindow()->SetName("PhantomWindow"); | 138 phantom_widget_->GetNativeWindow()->SetName("PhantomWindow"); |
139 views::View* content_view = new views::View; | 139 views::View* content_view = new views::View; |
140 content_view->set_background( | 140 content_view->set_background( |
141 views::Background::CreateBackgroundPainter(true, new EdgePainter)); | 141 views::Background::CreateBackgroundPainter(true, new EdgePainter)); |
142 phantom_widget_->SetContentsView(content_view); | 142 phantom_widget_->SetContentsView(content_view); |
143 phantom_widget_->SetBounds(bounds); | 143 phantom_widget_->SetBounds(bounds); |
144 if (phantom_below_window_) | 144 if (phantom_below_window_) |
145 phantom_widget_->StackBelow(phantom_below_window_); | 145 phantom_widget_->StackBelow(phantom_below_window_); |
146 else | 146 else |
147 phantom_widget_->StackAbove(window_); | 147 phantom_widget_->StackAbove(window_); |
148 phantom_widget_->Show(); | 148 phantom_widget_->Show(); |
149 // Fade the window in. | 149 // Fade the window in. |
150 ui::Layer* layer = phantom_widget_->GetNativeWindow()->layer(); | 150 ui::Layer* layer = phantom_widget_->GetNativeWindow()->layer(); |
151 layer->SetOpacity(0); | 151 layer->SetOpacity(0); |
152 ui::ScopedLayerAnimationSettings scoped_setter(layer->GetAnimator()); | 152 ui::ScopedLayerAnimationSettings scoped_setter(layer->GetAnimator()); |
153 layer->SetOpacity(1); | 153 layer->SetOpacity(1); |
154 } | 154 } |
155 | 155 |
156 } // namespace internal | 156 } // namespace internal |
157 } // namespace ash | 157 } // namespace ash |
OLD | NEW |