Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(673)

Side by Side Diff: ash/common/wm/overview/window_grid.cc

Issue 2699033002: Replace WmWindowObserver with aura::WindowObserver. (Closed)
Patch Set: Check for null images in ShelfWindowWatcher. Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ash/common/wm/overview/window_grid.h ('k') | ash/common/wm/overview/window_selector.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/common/wm/overview/window_grid.h" 5 #include "ash/common/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>
11 #include <vector> 11 #include <vector>
12 12
13 #include "ash/common/ash_switches.h" 13 #include "ash/common/ash_switches.h"
14 #include "ash/common/shelf/wm_shelf.h" 14 #include "ash/common/shelf/wm_shelf.h"
15 #include "ash/common/wm/overview/cleanup_animation_observer.h" 15 #include "ash/common/wm/overview/cleanup_animation_observer.h"
16 #include "ash/common/wm/overview/scoped_overview_animation_settings.h" 16 #include "ash/common/wm/overview/scoped_overview_animation_settings.h"
17 #include "ash/common/wm/overview/scoped_overview_animation_settings_factory.h" 17 #include "ash/common/wm/overview/scoped_overview_animation_settings_factory.h"
18 #include "ash/common/wm/overview/window_selector.h" 18 #include "ash/common/wm/overview/window_selector.h"
19 #include "ash/common/wm/overview/window_selector_delegate.h" 19 #include "ash/common/wm/overview/window_selector_delegate.h"
20 #include "ash/common/wm/overview/window_selector_item.h" 20 #include "ash/common/wm/overview/window_selector_item.h"
21 #include "ash/common/wm/window_state.h" 21 #include "ash/common/wm/window_state.h"
22 #include "ash/common/wm/wm_screen_util.h" 22 #include "ash/common/wm/wm_screen_util.h"
23 #include "ash/common/wm_lookup.h" 23 #include "ash/common/wm_lookup.h"
24 #include "ash/common/wm_window.h" 24 #include "ash/common/wm_window.h"
25 #include "ash/public/cpp/shelf_types.h" 25 #include "ash/public/cpp/shelf_types.h"
26 #include "ash/public/cpp/shell_window_ids.h" 26 #include "ash/public/cpp/shell_window_ids.h"
27 #include "ash/root_window_controller.h" 27 #include "ash/root_window_controller.h"
28 #include "ash/wm/window_state_aura.h"
28 #include "base/command_line.h" 29 #include "base/command_line.h"
29 #include "base/i18n/string_search.h" 30 #include "base/i18n/string_search.h"
30 #include "base/memory/ptr_util.h" 31 #include "base/memory/ptr_util.h"
31 #include "base/strings/string_number_conversions.h" 32 #include "base/strings/string_number_conversions.h"
32 #include "third_party/skia/include/core/SkColor.h" 33 #include "third_party/skia/include/core/SkColor.h"
33 #include "third_party/skia/include/pathops/SkPathOps.h" 34 #include "third_party/skia/include/pathops/SkPathOps.h"
34 #include "ui/compositor/layer_animation_observer.h" 35 #include "ui/compositor/layer_animation_observer.h"
35 #include "ui/compositor/scoped_layer_animation_settings.h" 36 #include "ui/compositor/scoped_layer_animation_settings.h"
36 #include "ui/gfx/animation/tween.h" 37 #include "ui/gfx/animation/tween.h"
37 #include "ui/gfx/canvas.h" 38 #include "ui/gfx/canvas.h"
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 selected_index_(0), 284 selected_index_(0),
284 num_columns_(0), 285 num_columns_(0),
285 prepared_for_overview_(false) { 286 prepared_for_overview_(false) {
286 std::vector<WmWindow*> windows_in_root; 287 std::vector<WmWindow*> windows_in_root;
287 for (auto* window : windows) { 288 for (auto* window : windows) {
288 if (window->GetRootWindow() == root_window) 289 if (window->GetRootWindow() == root_window)
289 windows_in_root.push_back(window); 290 windows_in_root.push_back(window);
290 } 291 }
291 292
292 for (auto* window : windows_in_root) { 293 for (auto* window : windows_in_root) {
293 window_observer_.Add(window); 294 window_observer_.Add(window->aura_window());
294 window_state_observer_.Add(window->GetWindowState()); 295 window_state_observer_.Add(window->GetWindowState());
295 window_list_.push_back( 296 window_list_.push_back(
296 base::MakeUnique<WindowSelectorItem>(window, window_selector_)); 297 base::MakeUnique<WindowSelectorItem>(window, window_selector_));
297 } 298 }
298 } 299 }
299 300
300 WindowGrid::~WindowGrid() {} 301 WindowGrid::~WindowGrid() {}
301 302
302 void WindowGrid::Shutdown() { 303 void WindowGrid::Shutdown() {
303 for (const auto& window : window_list_) 304 for (const auto& window : window_list_)
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
561 WmWindow* selection_widget_window = 562 WmWindow* selection_widget_window =
562 WmLookup::Get()->GetWindowForWidget(selection_widget_.get()); 563 WmLookup::Get()->GetWindowForWidget(selection_widget_.get());
563 std::unique_ptr<ScopedOverviewAnimationSettings> animation_settings_label = 564 std::unique_ptr<ScopedOverviewAnimationSettings> animation_settings_label =
564 ScopedOverviewAnimationSettingsFactory::Get() 565 ScopedOverviewAnimationSettingsFactory::Get()
565 ->CreateOverviewAnimationSettings( 566 ->CreateOverviewAnimationSettings(
566 OverviewAnimationType::OVERVIEW_ANIMATION_CLOSING_SELECTOR_ITEM, 567 OverviewAnimationType::OVERVIEW_ANIMATION_CLOSING_SELECTOR_ITEM,
567 selection_widget_window); 568 selection_widget_window);
568 selection_widget_->SetOpacity(0.f); 569 selection_widget_->SetOpacity(0.f);
569 } 570 }
570 571
571 void WindowGrid::OnWindowDestroying(WmWindow* window) { 572 void WindowGrid::OnWindowDestroying(aura::Window* window) {
572 window_observer_.Remove(window); 573 window_observer_.Remove(window);
573 window_state_observer_.Remove(window->GetWindowState()); 574 window_state_observer_.Remove(wm::GetWindowState(window));
574 auto iter = std::find_if(window_list_.begin(), window_list_.end(), 575 auto iter = std::find_if(window_list_.begin(), window_list_.end(),
575 WindowSelectorItemComparator(window)); 576 WindowSelectorItemComparator(WmWindow::Get(window)));
576 577
577 DCHECK(iter != window_list_.end()); 578 DCHECK(iter != window_list_.end());
578 579
579 size_t removed_index = iter - window_list_.begin(); 580 size_t removed_index = iter - window_list_.begin();
580 window_list_.erase(iter); 581 window_list_.erase(iter);
581 582
582 if (empty()) { 583 if (empty()) {
583 // If the grid is now empty, notify the window selector so that it erases us 584 // If the grid is now empty, notify the window selector so that it erases us
584 // from its grid list. 585 // from its grid list.
585 window_selector_->OnGridEmpty(this); 586 window_selector_->OnGridEmpty(this);
586 return; 587 return;
587 } 588 }
588 589
589 // If selecting, update the selection index. 590 // If selecting, update the selection index.
590 if (selection_widget_) { 591 if (selection_widget_) {
591 bool send_focus_alert = selected_index_ == removed_index; 592 bool send_focus_alert = selected_index_ == removed_index;
592 if (selected_index_ >= removed_index && selected_index_ != 0) 593 if (selected_index_ >= removed_index && selected_index_ != 0)
593 selected_index_--; 594 selected_index_--;
594 SelectedWindow()->SetSelected(true); 595 SelectedWindow()->SetSelected(true);
595 if (send_focus_alert) 596 if (send_focus_alert)
596 SelectedWindow()->SendAccessibleSelectionEvent(); 597 SelectedWindow()->SendAccessibleSelectionEvent();
597 } 598 }
598 599
599 PositionWindows(true); 600 PositionWindows(true);
600 } 601 }
601 602
602 void WindowGrid::OnWindowBoundsChanged(WmWindow* window, 603 void WindowGrid::OnWindowBoundsChanged(aura::Window* window,
603 const gfx::Rect& old_bounds, 604 const gfx::Rect& old_bounds,
604 const gfx::Rect& new_bounds) { 605 const gfx::Rect& new_bounds) {
605 // During preparation, window bounds can change. Ignore bounds 606 // During preparation, window bounds can change. Ignore bounds
606 // change notifications in this case; we'll reposition soon. 607 // change notifications in this case; we'll reposition soon.
607 if (!prepared_for_overview_) 608 if (!prepared_for_overview_)
608 return; 609 return;
609 610
610 auto iter = std::find_if(window_list_.begin(), window_list_.end(), 611 auto iter = std::find_if(window_list_.begin(), window_list_.end(),
611 WindowSelectorItemComparator(window)); 612 WindowSelectorItemComparator(WmWindow::Get(window)));
612 DCHECK(iter != window_list_.end()); 613 DCHECK(iter != window_list_.end());
613 614
614 // Immediately finish any active bounds animation. 615 // Immediately finish any active bounds animation.
615 window->StopAnimatingProperty(ui::LayerAnimationElement::BOUNDS); 616 window->layer()->GetAnimator()->StopAnimatingProperty(
617 ui::LayerAnimationElement::BOUNDS);
616 PositionWindows(false); 618 PositionWindows(false);
617 } 619 }
618 620
619 void WindowGrid::OnPostWindowStateTypeChange(wm::WindowState* window_state, 621 void WindowGrid::OnPostWindowStateTypeChange(wm::WindowState* window_state,
620 wm::WindowStateType old_type) { 622 wm::WindowStateType old_type) {
621 // During preparation, window state can change, e.g. updating shelf 623 // During preparation, window state can change, e.g. updating shelf
622 // visibility may show the temporarily hidden (minimized) panels. 624 // visibility may show the temporarily hidden (minimized) panels.
623 if (!prepared_for_overview_) 625 if (!prepared_for_overview_)
624 return; 626 return;
625 627
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
838 *min_right = left; 840 *min_right = left;
839 if (*max_right < left) 841 if (*max_right < left)
840 *max_right = left; 842 *max_right = left;
841 } 843 }
842 *max_bottom = top + height; 844 *max_bottom = top + height;
843 } 845 }
844 return windows_fit; 846 return windows_fit;
845 } 847 }
846 848
847 } // namespace ash 849 } // namespace ash
OLDNEW
« no previous file with comments | « ash/common/wm/overview/window_grid.h ('k') | ash/common/wm/overview/window_selector.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698