OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/overview/window_grid.h" | 5 #include "ash/wm/overview/window_grid.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <functional> | 8 #include <functional> |
9 #include <set> | 9 #include <set> |
10 #include <utility> | 10 #include <utility> |
(...skipping 24 matching lines...) Expand all Loading... |
35 #include "ui/gfx/animation/tween.h" | 35 #include "ui/gfx/animation/tween.h" |
36 #include "ui/gfx/canvas.h" | 36 #include "ui/gfx/canvas.h" |
37 #include "ui/gfx/geometry/safe_integer_conversions.h" | 37 #include "ui/gfx/geometry/safe_integer_conversions.h" |
38 #include "ui/gfx/geometry/vector2d.h" | 38 #include "ui/gfx/geometry/vector2d.h" |
39 #include "ui/gfx/scoped_canvas.h" | 39 #include "ui/gfx/scoped_canvas.h" |
40 #include "ui/views/background.h" | 40 #include "ui/views/background.h" |
41 #include "ui/views/border.h" | 41 #include "ui/views/border.h" |
42 #include "ui/views/painter.h" | 42 #include "ui/views/painter.h" |
43 #include "ui/views/view.h" | 43 #include "ui/views/view.h" |
44 #include "ui/views/widget/widget.h" | 44 #include "ui/views/widget/widget.h" |
| 45 #include "ui/wm/core/coordinate_conversion.h" |
45 #include "ui/wm/core/shadow.h" | 46 #include "ui/wm/core/shadow.h" |
46 #include "ui/wm/core/shadow_types.h" | 47 #include "ui/wm/core/shadow_types.h" |
47 #include "ui/wm/core/window_animations.h" | 48 #include "ui/wm/core/window_animations.h" |
48 | 49 |
49 namespace ash { | 50 namespace ash { |
50 namespace { | 51 namespace { |
51 | 52 |
52 using Windows = std::vector<WmWindow*>; | 53 using Windows = aura::Window::Windows; |
53 | 54 |
54 // A comparator for locating a given target window. | 55 // A comparator for locating a given target window. |
55 struct WindowSelectorItemComparator { | 56 struct WindowSelectorItemComparator { |
56 explicit WindowSelectorItemComparator(const WmWindow* target_window) | 57 explicit WindowSelectorItemComparator(const aura::Window* target_window) |
57 : target(target_window) {} | 58 : target(target_window) {} |
58 | 59 |
59 bool operator()(std::unique_ptr<WindowSelectorItem>& window) const { | 60 bool operator()(std::unique_ptr<WindowSelectorItem>& window) const { |
60 return window->GetWindow() == target; | 61 return window->GetWindow() == target; |
61 } | 62 } |
62 | 63 |
63 const WmWindow* target; | 64 const aura::Window* target; |
64 }; | 65 }; |
65 | 66 |
66 // Time it takes for the selector widget to move to the next target. The same | 67 // Time it takes for the selector widget to move to the next target. The same |
67 // time is used for fading out shield widget when the overview mode is opened | 68 // time is used for fading out shield widget when the overview mode is opened |
68 // or closed. | 69 // or closed. |
69 const int kOverviewSelectorTransitionMilliseconds = 250; | 70 const int kOverviewSelectorTransitionMilliseconds = 250; |
70 | 71 |
71 // The color and opacity of the screen shield in overview. | 72 // The color and opacity of the screen shield in overview. |
72 const SkColor kShieldColor = SkColorSetARGB(255, 0, 0, 0); | 73 const SkColor kShieldColor = SkColorSetARGB(255, 0, 0, 0); |
73 const float kShieldOpacity = 0.7f; | 74 const float kShieldOpacity = 0.7f; |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 break; | 216 break; |
216 } | 217 } |
217 return vector; | 218 return vector; |
218 } | 219 } |
219 | 220 |
220 // Creates and returns a background translucent widget parented in | 221 // Creates and returns a background translucent widget parented in |
221 // |root_window|'s default container and having |background_color|. | 222 // |root_window|'s default container and having |background_color|. |
222 // When |border_thickness| is non-zero, a border is created having | 223 // When |border_thickness| is non-zero, a border is created having |
223 // |border_color|, otherwise |border_color| parameter is ignored. | 224 // |border_color|, otherwise |border_color| parameter is ignored. |
224 // The new background widget starts with |initial_opacity| and then fades in. | 225 // The new background widget starts with |initial_opacity| and then fades in. |
225 views::Widget* CreateBackgroundWidget(WmWindow* root_window, | 226 views::Widget* CreateBackgroundWidget(aura::Window* root_window, |
226 ui::LayerType layer_type, | 227 ui::LayerType layer_type, |
227 SkColor background_color, | 228 SkColor background_color, |
228 int border_thickness, | 229 int border_thickness, |
229 int border_radius, | 230 int border_radius, |
230 SkColor border_color, | 231 SkColor border_color, |
231 float initial_opacity) { | 232 float initial_opacity) { |
232 views::Widget* widget = new views::Widget; | 233 views::Widget* widget = new views::Widget; |
233 views::Widget::InitParams params; | 234 views::Widget::InitParams params; |
234 params.type = views::Widget::InitParams::TYPE_POPUP; | 235 params.type = views::Widget::InitParams::TYPE_POPUP; |
235 params.keep_on_top = false; | 236 params.keep_on_top = false; |
236 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; | 237 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; |
237 params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW; | 238 params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW; |
238 params.layer_type = layer_type; | 239 params.layer_type = layer_type; |
239 params.accept_events = false; | 240 params.accept_events = false; |
240 widget->set_focus_on_creation(false); | 241 widget->set_focus_on_creation(false); |
241 // Parenting in kShellWindowId_WallpaperContainer allows proper layering of | 242 // Parenting in kShellWindowId_WallpaperContainer allows proper layering of |
242 // the shield and selection widgets. Since that container is created with | 243 // the shield and selection widgets. Since that container is created with |
243 // USE_LOCAL_COORDINATES BoundsInScreenBehavior local bounds in |root_window_| | 244 // USE_LOCAL_COORDINATES BoundsInScreenBehavior local bounds in |root_window_| |
244 // need to be provided. | 245 // need to be provided. |
245 root_window->GetRootWindowController()->ConfigureWidgetInitParamsForContainer( | 246 RootWindowController::ForWindow(root_window) |
246 widget, kShellWindowId_WallpaperContainer, ¶ms); | 247 ->ConfigureWidgetInitParamsForContainer( |
| 248 widget, kShellWindowId_WallpaperContainer, ¶ms); |
247 widget->Init(params); | 249 widget->Init(params); |
248 WmWindow* widget_window = WmWindow::Get(widget->GetNativeWindow()); | 250 aura::Window* widget_window = widget->GetNativeWindow(); |
249 // Disable the "bounce in" animation when showing the window. | 251 // Disable the "bounce in" animation when showing the window. |
250 widget_window->SetVisibilityAnimationTransition(::wm::ANIMATE_NONE); | 252 ::wm::SetWindowVisibilityAnimationTransition(widget_window, |
| 253 ::wm::ANIMATE_NONE); |
251 // The background widget should not activate the shelf when passing under it. | 254 // The background widget should not activate the shelf when passing under it. |
252 widget_window->GetWindowState()->set_ignored_by_shelf(true); | 255 wm::GetWindowState(widget_window)->set_ignored_by_shelf(true); |
253 if (params.layer_type == ui::LAYER_SOLID_COLOR) { | 256 if (params.layer_type == ui::LAYER_SOLID_COLOR) { |
254 widget_window->GetLayer()->SetColor(background_color); | 257 widget_window->layer()->SetColor(background_color); |
255 } else { | 258 } else { |
256 views::View* content_view = | 259 views::View* content_view = |
257 new RoundedRectView(border_radius, SK_ColorTRANSPARENT); | 260 new RoundedRectView(border_radius, SK_ColorTRANSPARENT); |
258 content_view->set_background(new BackgroundWith1PxBorder( | 261 content_view->set_background(new BackgroundWith1PxBorder( |
259 background_color, border_color, border_thickness, border_radius)); | 262 background_color, border_color, border_thickness, border_radius)); |
260 widget->SetContentsView(content_view); | 263 widget->SetContentsView(content_view); |
261 } | 264 } |
262 widget_window->GetParent()->StackChildAtTop(widget_window); | 265 widget_window->parent()->StackChildAtTop(widget_window); |
263 widget->Show(); | 266 widget->Show(); |
264 widget_window->SetOpacity(initial_opacity); | 267 widget_window->layer()->SetOpacity(initial_opacity); |
265 return widget; | 268 return widget; |
266 } | 269 } |
267 | 270 |
268 bool IsMinimizedStateType(wm::WindowStateType type) { | 271 bool IsMinimizedStateType(wm::WindowStateType type) { |
269 return type == wm::WINDOW_STATE_TYPE_MINIMIZED; | 272 return type == wm::WINDOW_STATE_TYPE_MINIMIZED; |
270 } | 273 } |
271 | 274 |
272 } // namespace | 275 } // namespace |
273 | 276 |
274 WindowGrid::WindowGrid(WmWindow* root_window, | 277 WindowGrid::WindowGrid(aura::Window* root_window, |
275 const std::vector<WmWindow*>& windows, | 278 const std::vector<aura::Window*>& windows, |
276 WindowSelector* window_selector) | 279 WindowSelector* window_selector) |
277 : root_window_(root_window), | 280 : root_window_(root_window), |
278 window_selector_(window_selector), | 281 window_selector_(window_selector), |
279 window_observer_(this), | 282 window_observer_(this), |
280 window_state_observer_(this), | 283 window_state_observer_(this), |
281 selected_index_(0), | 284 selected_index_(0), |
282 num_columns_(0), | 285 num_columns_(0), |
283 prepared_for_overview_(false) { | 286 prepared_for_overview_(false) { |
284 std::vector<WmWindow*> windows_in_root; | 287 aura::Window::Windows windows_in_root; |
285 for (auto* window : windows) { | 288 for (auto* window : windows) { |
286 if (window->GetRootWindow() == root_window) | 289 if (window->GetRootWindow() == root_window) |
287 windows_in_root.push_back(window); | 290 windows_in_root.push_back(window); |
288 } | 291 } |
289 | 292 |
290 for (auto* window : windows_in_root) { | 293 for (auto* window : windows_in_root) { |
291 window_observer_.Add(window->aura_window()); | 294 window_observer_.Add(window); |
292 window_state_observer_.Add(window->GetWindowState()); | 295 window_state_observer_.Add(wm::GetWindowState(window)); |
293 window_list_.push_back( | 296 window_list_.push_back( |
294 base::MakeUnique<WindowSelectorItem>(window, window_selector_)); | 297 base::MakeUnique<WindowSelectorItem>(window, window_selector_)); |
295 } | 298 } |
296 } | 299 } |
297 | 300 |
298 WindowGrid::~WindowGrid() {} | 301 WindowGrid::~WindowGrid() {} |
299 | 302 |
300 void WindowGrid::Shutdown() { | 303 void WindowGrid::Shutdown() { |
301 for (const auto& window : window_list_) | 304 for (const auto& window : window_list_) |
302 window->Shutdown(); | 305 window->Shutdown(); |
303 | 306 |
304 if (shield_widget_) { | 307 if (shield_widget_) { |
305 // Fade out the shield widget. This animation continues past the lifetime | 308 // Fade out the shield widget. This animation continues past the lifetime |
306 // of |this|. | 309 // of |this|. |
307 WmWindow* widget_window = WmWindow::Get(shield_widget_->GetNativeWindow()); | 310 aura::Window* widget_window = shield_widget_->GetNativeWindow(); |
308 ui::ScopedLayerAnimationSettings animation_settings( | 311 ui::ScopedLayerAnimationSettings animation_settings( |
309 widget_window->GetLayer()->GetAnimator()); | 312 widget_window->layer()->GetAnimator()); |
310 animation_settings.SetTransitionDuration(base::TimeDelta::FromMilliseconds( | 313 animation_settings.SetTransitionDuration(base::TimeDelta::FromMilliseconds( |
311 kOverviewSelectorTransitionMilliseconds)); | 314 kOverviewSelectorTransitionMilliseconds)); |
312 animation_settings.SetTweenType(gfx::Tween::EASE_OUT); | 315 animation_settings.SetTweenType(gfx::Tween::EASE_OUT); |
313 animation_settings.SetPreemptionStrategy( | 316 animation_settings.SetPreemptionStrategy( |
314 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); | 317 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); |
315 // CleanupAnimationObserver will delete itself (and the shield widget) when | 318 // CleanupAnimationObserver will delete itself (and the shield widget) when |
316 // the opacity animation is complete. | 319 // the opacity animation is complete. |
317 // Ownership over the observer is passed to the window_selector_->delegate() | 320 // Ownership over the observer is passed to the window_selector_->delegate() |
318 // which has longer lifetime so that animations can continue even after the | 321 // which has longer lifetime so that animations can continue even after the |
319 // overview mode is shut down. | 322 // overview mode is shut down. |
(...skipping 12 matching lines...) Expand all Loading... |
332 for (const auto& window : window_list_) | 335 for (const auto& window : window_list_) |
333 window->PrepareForOverview(); | 336 window->PrepareForOverview(); |
334 prepared_for_overview_ = true; | 337 prepared_for_overview_ = true; |
335 } | 338 } |
336 | 339 |
337 void WindowGrid::PositionWindows(bool animate) { | 340 void WindowGrid::PositionWindows(bool animate) { |
338 if (window_selector_->is_shut_down() || window_list_.empty()) | 341 if (window_selector_->is_shut_down() || window_list_.empty()) |
339 return; | 342 return; |
340 DCHECK(shield_widget_.get()); | 343 DCHECK(shield_widget_.get()); |
341 // Keep the background shield widget covering the whole screen. | 344 // Keep the background shield widget covering the whole screen. |
342 WmWindow* widget_window = WmWindow::Get(shield_widget_->GetNativeWindow()); | 345 aura::Window* widget_window = shield_widget_->GetNativeWindow(); |
343 const gfx::Rect bounds = widget_window->GetParent()->GetBounds(); | 346 const gfx::Rect bounds = widget_window->parent()->bounds(); |
344 widget_window->SetBounds(bounds); | 347 widget_window->SetBounds(bounds); |
345 gfx::Rect total_bounds = root_window_->ConvertRectToScreen( | 348 gfx::Rect total_bounds = ScreenUtil::GetDisplayWorkAreaBoundsInParent( |
346 ScreenUtil::GetDisplayWorkAreaBoundsInParent( | 349 root_window_->GetChildById(kShellWindowId_DefaultContainer)); |
347 root_window_->GetChildByShellWindowId(kShellWindowId_DefaultContainer) | 350 ::wm::ConvertRectToScreen(root_window_, &total_bounds); |
348 ->aura_window())); | |
349 // Windows occupy vertically centered area with additional vertical insets. | 351 // Windows occupy vertically centered area with additional vertical insets. |
350 int horizontal_inset = | 352 int horizontal_inset = |
351 gfx::ToFlooredInt(std::min(kOverviewInsetRatio * total_bounds.width(), | 353 gfx::ToFlooredInt(std::min(kOverviewInsetRatio * total_bounds.width(), |
352 kOverviewInsetRatio * total_bounds.height())); | 354 kOverviewInsetRatio * total_bounds.height())); |
353 int vertical_inset = | 355 int vertical_inset = |
354 horizontal_inset + | 356 horizontal_inset + |
355 kOverviewVerticalInset * (total_bounds.height() - 2 * horizontal_inset); | 357 kOverviewVerticalInset * (total_bounds.height() - 2 * horizontal_inset); |
356 total_bounds.Inset(std::max(0, horizontal_inset - kWindowMargin), | 358 total_bounds.Inset(std::max(0, horizontal_inset - kWindowMargin), |
357 std::max(0, vertical_inset - kWindowMargin)); | 359 std::max(0, vertical_inset - kWindowMargin)); |
358 std::vector<gfx::Rect> rects; | 360 std::vector<gfx::Rect> rects; |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
520 return out_of_bounds; | 522 return out_of_bounds; |
521 } | 523 } |
522 | 524 |
523 WindowSelectorItem* WindowGrid::SelectedWindow() const { | 525 WindowSelectorItem* WindowGrid::SelectedWindow() const { |
524 if (!selection_widget_) | 526 if (!selection_widget_) |
525 return nullptr; | 527 return nullptr; |
526 CHECK(selected_index_ < window_list_.size()); | 528 CHECK(selected_index_ < window_list_.size()); |
527 return window_list_[selected_index_].get(); | 529 return window_list_[selected_index_].get(); |
528 } | 530 } |
529 | 531 |
530 bool WindowGrid::Contains(const WmWindow* window) const { | 532 bool WindowGrid::Contains(const aura::Window* window) const { |
531 for (const auto& window_item : window_list_) { | 533 for (const auto& window_item : window_list_) { |
532 if (window_item->Contains(window)) | 534 if (window_item->Contains(window)) |
533 return true; | 535 return true; |
534 } | 536 } |
535 return false; | 537 return false; |
536 } | 538 } |
537 | 539 |
538 void WindowGrid::FilterItems(const base::string16& pattern) { | 540 void WindowGrid::FilterItems(const base::string16& pattern) { |
539 base::i18n::FixedPatternStringSearchIgnoringCaseAndAccents finder(pattern); | 541 base::i18n::FixedPatternStringSearchIgnoringCaseAndAccents finder(pattern); |
540 for (const auto& window : window_list_) { | 542 for (const auto& window : window_list_) { |
541 if (finder.Search(window->GetWindow()->aura_window()->GetTitle(), nullptr, | 543 if (finder.Search(window->GetWindow()->GetTitle(), nullptr, nullptr)) { |
542 nullptr)) { | |
543 window->SetDimmed(false); | 544 window->SetDimmed(false); |
544 } else { | 545 } else { |
545 window->SetDimmed(true); | 546 window->SetDimmed(true); |
546 if (selection_widget_ && SelectedWindow() == window.get()) { | 547 if (selection_widget_ && SelectedWindow() == window.get()) { |
547 SelectedWindow()->SetSelected(false); | 548 SelectedWindow()->SetSelected(false); |
548 selection_widget_.reset(); | 549 selection_widget_.reset(); |
549 selector_shadow_.reset(); | 550 selector_shadow_.reset(); |
550 } | 551 } |
551 } | 552 } |
552 } | 553 } |
553 } | 554 } |
554 | 555 |
555 void WindowGrid::WindowClosing(WindowSelectorItem* window) { | 556 void WindowGrid::WindowClosing(WindowSelectorItem* window) { |
556 if (!selection_widget_ || SelectedWindow() != window) | 557 if (!selection_widget_ || SelectedWindow() != window) |
557 return; | 558 return; |
558 WmWindow* selection_widget_window = | 559 aura::Window* selection_widget_window = selection_widget_->GetNativeWindow(); |
559 WmWindow::Get(selection_widget_->GetNativeWindow()); | |
560 std::unique_ptr<ScopedOverviewAnimationSettings> animation_settings_label = | 560 std::unique_ptr<ScopedOverviewAnimationSettings> animation_settings_label = |
561 ScopedOverviewAnimationSettingsFactory::Get() | 561 ScopedOverviewAnimationSettingsFactory::Get() |
562 ->CreateOverviewAnimationSettings( | 562 ->CreateOverviewAnimationSettings( |
563 OverviewAnimationType::OVERVIEW_ANIMATION_CLOSING_SELECTOR_ITEM, | 563 OverviewAnimationType::OVERVIEW_ANIMATION_CLOSING_SELECTOR_ITEM, |
564 selection_widget_window); | 564 selection_widget_window); |
565 selection_widget_->SetOpacity(0.f); | 565 selection_widget_->SetOpacity(0.f); |
566 } | 566 } |
567 | 567 |
568 void WindowGrid::OnWindowDestroying(aura::Window* window) { | 568 void WindowGrid::OnWindowDestroying(aura::Window* window) { |
569 window_observer_.Remove(window); | 569 window_observer_.Remove(window); |
570 window_state_observer_.Remove(wm::GetWindowState(window)); | 570 window_state_observer_.Remove(wm::GetWindowState(window)); |
571 auto iter = std::find_if(window_list_.begin(), window_list_.end(), | 571 auto iter = std::find_if(window_list_.begin(), window_list_.end(), |
572 WindowSelectorItemComparator(WmWindow::Get(window))); | 572 WindowSelectorItemComparator(window)); |
573 | 573 |
574 DCHECK(iter != window_list_.end()); | 574 DCHECK(iter != window_list_.end()); |
575 | 575 |
576 size_t removed_index = iter - window_list_.begin(); | 576 size_t removed_index = iter - window_list_.begin(); |
577 window_list_.erase(iter); | 577 window_list_.erase(iter); |
578 | 578 |
579 if (empty()) { | 579 if (empty()) { |
580 // If the grid is now empty, notify the window selector so that it erases us | 580 // If the grid is now empty, notify the window selector so that it erases us |
581 // from its grid list. | 581 // from its grid list. |
582 window_selector_->OnGridEmpty(this); | 582 window_selector_->OnGridEmpty(this); |
(...skipping 15 matching lines...) Expand all Loading... |
598 | 598 |
599 void WindowGrid::OnWindowBoundsChanged(aura::Window* window, | 599 void WindowGrid::OnWindowBoundsChanged(aura::Window* window, |
600 const gfx::Rect& old_bounds, | 600 const gfx::Rect& old_bounds, |
601 const gfx::Rect& new_bounds) { | 601 const gfx::Rect& new_bounds) { |
602 // During preparation, window bounds can change. Ignore bounds | 602 // During preparation, window bounds can change. Ignore bounds |
603 // change notifications in this case; we'll reposition soon. | 603 // change notifications in this case; we'll reposition soon. |
604 if (!prepared_for_overview_) | 604 if (!prepared_for_overview_) |
605 return; | 605 return; |
606 | 606 |
607 auto iter = std::find_if(window_list_.begin(), window_list_.end(), | 607 auto iter = std::find_if(window_list_.begin(), window_list_.end(), |
608 WindowSelectorItemComparator(WmWindow::Get(window))); | 608 WindowSelectorItemComparator(window)); |
609 DCHECK(iter != window_list_.end()); | 609 DCHECK(iter != window_list_.end()); |
610 | 610 |
611 // Immediately finish any active bounds animation. | 611 // Immediately finish any active bounds animation. |
612 window->layer()->GetAnimator()->StopAnimatingProperty( | 612 window->layer()->GetAnimator()->StopAnimatingProperty( |
613 ui::LayerAnimationElement::BOUNDS); | 613 ui::LayerAnimationElement::BOUNDS); |
614 PositionWindows(false); | 614 PositionWindows(false); |
615 } | 615 } |
616 | 616 |
617 void WindowGrid::OnPostWindowStateTypeChange(wm::WindowState* window_state, | 617 void WindowGrid::OnPostWindowStateTypeChange(wm::WindowState* window_state, |
618 wm::WindowStateType old_type) { | 618 wm::WindowStateType old_type) { |
619 // During preparation, window state can change, e.g. updating shelf | 619 // During preparation, window state can change, e.g. updating shelf |
620 // visibility may show the temporarily hidden (minimized) panels. | 620 // visibility may show the temporarily hidden (minimized) panels. |
621 if (!prepared_for_overview_) | 621 if (!prepared_for_overview_) |
622 return; | 622 return; |
623 | 623 |
624 wm::WindowStateType new_type = window_state->GetStateType(); | 624 wm::WindowStateType new_type = window_state->GetStateType(); |
625 if (IsMinimizedStateType(old_type) == IsMinimizedStateType(new_type)) | 625 if (IsMinimizedStateType(old_type) == IsMinimizedStateType(new_type)) |
626 return; | 626 return; |
627 | 627 |
628 auto iter = std::find_if( | 628 auto iter = |
629 window_list_.begin(), window_list_.end(), | 629 std::find_if(window_list_.begin(), window_list_.end(), |
630 [window_state](std::unique_ptr<WindowSelectorItem>& item) { | 630 [window_state](std::unique_ptr<WindowSelectorItem>& item) { |
631 return item->Contains(WmWindow::Get(window_state->window())); | 631 return item->Contains(window_state->window()); |
632 }); | 632 }); |
633 if (iter != window_list_.end()) { | 633 if (iter != window_list_.end()) { |
634 (*iter)->OnMinimizedStateChanged(); | 634 (*iter)->OnMinimizedStateChanged(); |
635 PositionWindows(false); | 635 PositionWindows(false); |
636 } | 636 } |
637 } | 637 } |
638 | 638 |
639 void WindowGrid::InitShieldWidget() { | 639 void WindowGrid::InitShieldWidget() { |
640 // TODO(varkha): The code assumes that SHELF_BACKGROUND_MAXIMIZED is | 640 // TODO(varkha): The code assumes that SHELF_BACKGROUND_MAXIMIZED is |
641 // synonymous with a black shelf background. Update this code if that | 641 // synonymous with a black shelf background. Update this code if that |
642 // assumption is no longer valid. | 642 // assumption is no longer valid. |
643 const float initial_opacity = | 643 const float initial_opacity = |
644 (WmShelf::ForWindow(root_window_->aura_window())->GetBackgroundType() == | 644 (WmShelf::ForWindow(root_window_)->GetBackgroundType() == |
645 SHELF_BACKGROUND_MAXIMIZED) | 645 SHELF_BACKGROUND_MAXIMIZED) |
646 ? 1.f | 646 ? 1.f |
647 : 0.f; | 647 : 0.f; |
648 shield_widget_.reset( | 648 shield_widget_.reset( |
649 CreateBackgroundWidget(root_window_, ui::LAYER_SOLID_COLOR, kShieldColor, | 649 CreateBackgroundWidget(root_window_, ui::LAYER_SOLID_COLOR, kShieldColor, |
650 0, 0, SK_ColorTRANSPARENT, initial_opacity)); | 650 0, 0, SK_ColorTRANSPARENT, initial_opacity)); |
651 WmWindow* widget_window = WmWindow::Get(shield_widget_->GetNativeWindow()); | 651 aura::Window* widget_window = shield_widget_->GetNativeWindow(); |
652 const gfx::Rect bounds = widget_window->GetParent()->GetBounds(); | 652 const gfx::Rect bounds = widget_window->parent()->bounds(); |
653 widget_window->SetBounds(bounds); | 653 widget_window->SetBounds(bounds); |
654 widget_window->aura_window()->SetName("OverviewModeShield"); | 654 widget_window->SetName("OverviewModeShield"); |
655 | 655 |
656 ui::ScopedLayerAnimationSettings animation_settings( | 656 ui::ScopedLayerAnimationSettings animation_settings( |
657 widget_window->GetLayer()->GetAnimator()); | 657 widget_window->layer()->GetAnimator()); |
658 animation_settings.SetTransitionDuration(base::TimeDelta::FromMilliseconds( | 658 animation_settings.SetTransitionDuration(base::TimeDelta::FromMilliseconds( |
659 kOverviewSelectorTransitionMilliseconds)); | 659 kOverviewSelectorTransitionMilliseconds)); |
660 animation_settings.SetTweenType(gfx::Tween::EASE_OUT); | 660 animation_settings.SetTweenType(gfx::Tween::EASE_OUT); |
661 animation_settings.SetPreemptionStrategy( | 661 animation_settings.SetPreemptionStrategy( |
662 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); | 662 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); |
663 shield_widget_->SetOpacity(kShieldOpacity); | 663 shield_widget_->SetOpacity(kShieldOpacity); |
664 } | 664 } |
665 | 665 |
666 void WindowGrid::InitSelectionWidget(WindowSelector::Direction direction) { | 666 void WindowGrid::InitSelectionWidget(WindowSelector::Direction direction) { |
667 selection_widget_.reset(CreateBackgroundWidget( | 667 selection_widget_.reset(CreateBackgroundWidget( |
668 root_window_, ui::LAYER_TEXTURED, kWindowSelectionColor, | 668 root_window_, ui::LAYER_TEXTURED, kWindowSelectionColor, |
669 kWindowSelectionBorderThickness, kWindowSelectionRadius, | 669 kWindowSelectionBorderThickness, kWindowSelectionRadius, |
670 kWindowSelectionBorderColor, 0.f)); | 670 kWindowSelectionBorderColor, 0.f)); |
671 WmWindow* widget_window = WmWindow::Get(selection_widget_->GetNativeWindow()); | 671 aura::Window* widget_window = selection_widget_->GetNativeWindow(); |
672 const gfx::Rect target_bounds = | 672 gfx::Rect target_bounds = SelectedWindow()->target_bounds(); |
673 root_window_->ConvertRectFromScreen(SelectedWindow()->target_bounds()); | 673 ::wm::ConvertRectFromScreen(root_window_, &target_bounds); |
674 gfx::Vector2d fade_out_direction = | 674 gfx::Vector2d fade_out_direction = |
675 GetSlideVectorForFadeIn(direction, target_bounds); | 675 GetSlideVectorForFadeIn(direction, target_bounds); |
676 widget_window->SetBounds(target_bounds - fade_out_direction); | 676 widget_window->SetBounds(target_bounds - fade_out_direction); |
677 widget_window->aura_window()->SetName("OverviewModeSelector"); | 677 widget_window->SetName("OverviewModeSelector"); |
678 | 678 |
679 selector_shadow_.reset(new ::wm::Shadow()); | 679 selector_shadow_.reset(new ::wm::Shadow()); |
680 selector_shadow_->Init(::wm::ShadowElevation::LARGE); | 680 selector_shadow_->Init(::wm::ShadowElevation::LARGE); |
681 selector_shadow_->layer()->SetVisible(true); | 681 selector_shadow_->layer()->SetVisible(true); |
682 selection_widget_->GetLayer()->SetMasksToBounds(false); | 682 selection_widget_->GetLayer()->SetMasksToBounds(false); |
683 selection_widget_->GetLayer()->Add(selector_shadow_->layer()); | 683 selection_widget_->GetLayer()->Add(selector_shadow_->layer()); |
684 selector_shadow_->SetContentBounds(gfx::Rect(target_bounds.size())); | 684 selector_shadow_->SetContentBounds(gfx::Rect(target_bounds.size())); |
685 } | 685 } |
686 | 686 |
687 void WindowGrid::MoveSelectionWidget(WindowSelector::Direction direction, | 687 void WindowGrid::MoveSelectionWidget(WindowSelector::Direction direction, |
688 bool recreate_selection_widget, | 688 bool recreate_selection_widget, |
689 bool out_of_bounds, | 689 bool out_of_bounds, |
690 bool animate) { | 690 bool animate) { |
691 // If the selection widget is already active, fade it out in the selection | 691 // If the selection widget is already active, fade it out in the selection |
692 // direction. | 692 // direction. |
693 if (selection_widget_ && (recreate_selection_widget || out_of_bounds)) { | 693 if (selection_widget_ && (recreate_selection_widget || out_of_bounds)) { |
694 // Animate the old selection widget and then destroy it. | 694 // Animate the old selection widget and then destroy it. |
695 views::Widget* old_selection = selection_widget_.get(); | 695 views::Widget* old_selection = selection_widget_.get(); |
696 WmWindow* old_selection_window = | 696 aura::Window* old_selection_window = old_selection->GetNativeWindow(); |
697 WmWindow::Get(old_selection->GetNativeWindow()); | |
698 gfx::Vector2d fade_out_direction = | 697 gfx::Vector2d fade_out_direction = |
699 GetSlideVectorForFadeIn(direction, old_selection_window->GetBounds()); | 698 GetSlideVectorForFadeIn(direction, old_selection_window->bounds()); |
700 | 699 |
701 ui::ScopedLayerAnimationSettings animation_settings( | 700 ui::ScopedLayerAnimationSettings animation_settings( |
702 old_selection_window->GetLayer()->GetAnimator()); | 701 old_selection_window->layer()->GetAnimator()); |
703 animation_settings.SetTransitionDuration(base::TimeDelta::FromMilliseconds( | 702 animation_settings.SetTransitionDuration(base::TimeDelta::FromMilliseconds( |
704 kOverviewSelectorTransitionMilliseconds)); | 703 kOverviewSelectorTransitionMilliseconds)); |
705 animation_settings.SetPreemptionStrategy( | 704 animation_settings.SetPreemptionStrategy( |
706 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); | 705 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); |
707 animation_settings.SetTweenType(gfx::Tween::FAST_OUT_LINEAR_IN); | 706 animation_settings.SetTweenType(gfx::Tween::FAST_OUT_LINEAR_IN); |
708 // CleanupAnimationObserver will delete itself (and the widget) when the | 707 // CleanupAnimationObserver will delete itself (and the widget) when the |
709 // motion animation is complete. | 708 // motion animation is complete. |
710 // Ownership over the observer is passed to the window_selector_->delegate() | 709 // Ownership over the observer is passed to the window_selector_->delegate() |
711 // which has longer lifetime so that animations can continue even after the | 710 // which has longer lifetime so that animations can continue even after the |
712 // overview mode is shut down. | 711 // overview mode is shut down. |
713 std::unique_ptr<CleanupAnimationObserver> observer( | 712 std::unique_ptr<CleanupAnimationObserver> observer( |
714 new CleanupAnimationObserver(std::move(selection_widget_))); | 713 new CleanupAnimationObserver(std::move(selection_widget_))); |
715 animation_settings.AddObserver(observer.get()); | 714 animation_settings.AddObserver(observer.get()); |
716 window_selector_->delegate()->AddDelayedAnimationObserver( | 715 window_selector_->delegate()->AddDelayedAnimationObserver( |
717 std::move(observer)); | 716 std::move(observer)); |
718 old_selection->SetOpacity(0.f); | 717 old_selection->SetOpacity(0.f); |
719 old_selection_window->SetBounds(old_selection_window->GetBounds() + | 718 old_selection_window->SetBounds(old_selection_window->bounds() + |
720 fade_out_direction); | 719 fade_out_direction); |
721 old_selection->Hide(); | 720 old_selection->Hide(); |
722 } | 721 } |
723 if (out_of_bounds) | 722 if (out_of_bounds) |
724 return; | 723 return; |
725 | 724 |
726 if (!selection_widget_) | 725 if (!selection_widget_) |
727 InitSelectionWidget(direction); | 726 InitSelectionWidget(direction); |
728 // Send an a11y alert so that if ChromeVox is enabled, the item label is | 727 // Send an a11y alert so that if ChromeVox is enabled, the item label is |
729 // read. | 728 // read. |
730 SelectedWindow()->SendAccessibleSelectionEvent(); | 729 SelectedWindow()->SendAccessibleSelectionEvent(); |
731 // The selection widget is moved to the newly selected item in the same | 730 // The selection widget is moved to the newly selected item in the same |
732 // grid. | 731 // grid. |
733 MoveSelectionWidgetToTarget(animate); | 732 MoveSelectionWidgetToTarget(animate); |
734 } | 733 } |
735 | 734 |
736 void WindowGrid::MoveSelectionWidgetToTarget(bool animate) { | 735 void WindowGrid::MoveSelectionWidgetToTarget(bool animate) { |
737 gfx::Rect bounds = | 736 gfx::Rect bounds = SelectedWindow()->target_bounds(); |
738 root_window_->ConvertRectFromScreen(SelectedWindow()->target_bounds()); | 737 ::wm::ConvertRectFromScreen(root_window_, &bounds); |
739 if (animate) { | 738 if (animate) { |
740 WmWindow* selection_widget_window = | 739 aura::Window* selection_widget_window = |
741 WmWindow::Get(selection_widget_->GetNativeWindow()); | 740 selection_widget_->GetNativeWindow(); |
742 ui::ScopedLayerAnimationSettings animation_settings( | 741 ui::ScopedLayerAnimationSettings animation_settings( |
743 selection_widget_window->GetLayer()->GetAnimator()); | 742 selection_widget_window->layer()->GetAnimator()); |
744 animation_settings.SetTransitionDuration(base::TimeDelta::FromMilliseconds( | 743 animation_settings.SetTransitionDuration(base::TimeDelta::FromMilliseconds( |
745 kOverviewSelectorTransitionMilliseconds)); | 744 kOverviewSelectorTransitionMilliseconds)); |
746 animation_settings.SetTweenType(gfx::Tween::EASE_IN_OUT); | 745 animation_settings.SetTweenType(gfx::Tween::EASE_IN_OUT); |
747 animation_settings.SetPreemptionStrategy( | 746 animation_settings.SetPreemptionStrategy( |
748 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); | 747 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); |
749 selection_widget_->SetBounds(bounds); | 748 selection_widget_->SetBounds(bounds); |
750 selection_widget_->SetOpacity(1.f); | 749 selection_widget_->SetOpacity(1.f); |
751 | 750 |
752 if (selector_shadow_) { | 751 if (selector_shadow_) { |
753 ui::ScopedLayerAnimationSettings animation_settings_shadow( | 752 ui::ScopedLayerAnimationSettings animation_settings_shadow( |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
834 *min_right = left; | 833 *min_right = left; |
835 if (*max_right < left) | 834 if (*max_right < left) |
836 *max_right = left; | 835 *max_right = left; |
837 } | 836 } |
838 *max_bottom = top + height; | 837 *max_bottom = top + height; |
839 } | 838 } |
840 return windows_fit; | 839 return windows_fit; |
841 } | 840 } |
842 | 841 |
843 } // namespace ash | 842 } // namespace ash |
OLD | NEW |