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

Side by Side Diff: ash/wm/overview/window_overview.cc

Issue 260883005: Separated alt-tab window cycle from overview mode (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed access issue Created 6 years, 7 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_overview.h" 5 #include "ash/wm/overview/window_overview.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "ash/accessibility_delegate.h" 9 #include "ash/accessibility_delegate.h"
10 #include "ash/metrics/user_metrics_recorder.h" 10 #include "ash/metrics/user_metrics_recorder.h"
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 delete this; 113 delete this;
114 } 114 }
115 115
116 void CleanupWidgetAfterAnimationObserver::OnLayerAnimationScheduled( 116 void CleanupWidgetAfterAnimationObserver::OnLayerAnimationScheduled(
117 ui::LayerAnimationSequence* sequence) { 117 ui::LayerAnimationSequence* sequence) {
118 } 118 }
119 119
120 } // namespace 120 } // namespace
121 121
122 WindowOverview::WindowOverview(WindowSelector* window_selector, 122 WindowOverview::WindowOverview(WindowSelector* window_selector,
123 WindowSelectorItemList* windows, 123 WindowSelectorItemList* windows)
124 aura::Window* single_root_window)
125 : window_selector_(window_selector), 124 : window_selector_(window_selector),
126 windows_(windows), 125 windows_(windows),
127 selection_index_(0), 126 selection_index_(0),
128 single_root_window_(single_root_window),
129 overview_start_time_(base::Time::Now()), 127 overview_start_time_(base::Time::Now()),
130 cursor_client_(NULL) { 128 cursor_client_(NULL) {
131 Shell* shell = Shell::GetInstance(); 129 Shell* shell = Shell::GetInstance();
132 shell->OnOverviewModeStarting(); 130 shell->OnOverviewModeStarting();
133 for (WindowSelectorItemList::iterator iter = windows_->begin(); 131 for (WindowSelectorItemList::iterator iter = windows_->begin();
134 iter != windows_->end(); ++iter) { 132 iter != windows_->end(); ++iter) {
135 (*iter)->PrepareForOverview(); 133 (*iter)->PrepareForOverview();
136 } 134 }
137 PositionWindows(/* animate */ true); 135 PositionWindows(/* animate */ true);
138 DCHECK(!windows_->empty()); 136 DCHECK(!windows_->empty());
139 cursor_client_ = aura::client::GetCursorClient( 137 cursor_client_ = aura::client::GetCursorClient(
140 windows_->front()->GetRootWindow()); 138 windows_->front()->GetRootWindow());
141 if (cursor_client_) { 139 if (cursor_client_) {
142 cursor_client_->SetCursor(ui::kCursorPointer); 140 cursor_client_->SetCursor(ui::kCursorPointer);
143 cursor_client_->ShowCursor(); 141 cursor_client_->ShowCursor();
144 // TODO(flackr): Only prevent cursor changes for windows in the overview. 142 // TODO(flackr): Only prevent cursor changes for windows in the overview.
145 // This will be easier to do without exposing the overview mode code if the 143 // This will be easier to do without exposing the overview mode code if the
146 // cursor changes are moved to ToplevelWindowEventHandler::HandleMouseMoved 144 // cursor changes are moved to ToplevelWindowEventHandler::HandleMouseMoved
147 // as suggested there. 145 // as suggested there.
148 cursor_client_->LockCursor(); 146 cursor_client_->LockCursor();
149 } 147 }
150 shell->PrependPreTargetHandler(this); 148 shell->PrependPreTargetHandler(this);
151 shell->GetScreen()->AddObserver(this); 149 shell->GetScreen()->AddObserver(this);
152 shell->metrics()->RecordUserMetricsAction(UMA_WINDOW_OVERVIEW); 150 shell->metrics()->RecordUserMetricsAction(UMA_WINDOW_OVERVIEW);
153 HideAndTrackNonOverviewWindows(); 151 HideAndTrackNonOverviewWindows();
154 // Send an a11y alert only if the overview was activated by the user. 152 // Send an a11y alert
155 if (window_selector_->mode() == WindowSelector::OVERVIEW) { 153 shell->accessibility_delegate()->TriggerAccessibilityAlert(
156 shell->accessibility_delegate()->TriggerAccessibilityAlert( 154 A11Y_ALERT_WINDOW_OVERVIEW_MODE_ENTERED);
157 A11Y_ALERT_WINDOW_OVERVIEW_MODE_ENTERED);
158 }
159 } 155 }
160 156
161 WindowOverview::~WindowOverview() { 157 WindowOverview::~WindowOverview() {
162 const aura::WindowTracker::Windows hidden_windows = hidden_windows_.windows(); 158 const aura::WindowTracker::Windows hidden_windows = hidden_windows_.windows();
163 for (aura::WindowTracker::Windows::const_iterator iter = 159 for (aura::WindowTracker::Windows::const_iterator iter =
164 hidden_windows.begin(); iter != hidden_windows.end(); ++iter) { 160 hidden_windows.begin(); iter != hidden_windows.end(); ++iter) {
165 ui::ScopedLayerAnimationSettings settings( 161 ui::ScopedLayerAnimationSettings settings(
166 (*iter)->layer()->GetAnimator()); 162 (*iter)->layer()->GetAnimator());
167 settings.SetTransitionDuration(base::TimeDelta::FromMilliseconds( 163 settings.SetTransitionDuration(base::TimeDelta::FromMilliseconds(
168 ScopedTransformOverviewWindow::kTransitionMilliseconds)); 164 ScopedTransformOverviewWindow::kTransitionMilliseconds));
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 InitializeSelectionWidget(); 243 InitializeSelectionWidget();
248 selection_widget_->SetBounds(target_bounds); 244 selection_widget_->SetBounds(target_bounds);
249 } 245 }
250 selection_index_ = index; 246 selection_index_ = index;
251 } 247 }
252 248
253 void WindowOverview::OnWindowsChanged() { 249 void WindowOverview::OnWindowsChanged() {
254 PositionWindows(/* animate */ true); 250 PositionWindows(/* animate */ true);
255 } 251 }
256 252
257 void WindowOverview::MoveToSingleRootWindow(aura::Window* root_window) {
258 single_root_window_ = root_window;
259 PositionWindows(/* animate */ true);
260 }
261
262 void WindowOverview::OnKeyEvent(ui::KeyEvent* event) { 253 void WindowOverview::OnKeyEvent(ui::KeyEvent* event) {
263 if (GetTargetedWindow(static_cast<aura::Window*>(event->target()))) 254 if (GetTargetedWindow(static_cast<aura::Window*>(event->target())))
264 event->StopPropagation(); 255 event->StopPropagation();
265 if (event->type() != ui::ET_KEY_PRESSED) 256 if (event->type() != ui::ET_KEY_PRESSED)
266 return; 257 return;
267 258
268 if (event->key_code() == ui::VKEY_ESCAPE) 259 if (event->key_code() == ui::VKEY_ESCAPE)
269 window_selector_->CancelSelection(); 260 window_selector_->CancelSelection();
270 } 261 }
271 262
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); 362 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET);
372 (*iter)->Hide(); 363 (*iter)->Hide();
373 // Hiding the window can result in it being destroyed. 364 // Hiding the window can result in it being destroyed.
374 if (!hidden_windows_.Contains(*iter)) 365 if (!hidden_windows_.Contains(*iter))
375 continue; 366 continue;
376 (*iter)->layer()->SetOpacity(0); 367 (*iter)->layer()->SetOpacity(0);
377 } 368 }
378 } 369 }
379 370
380 void WindowOverview::PositionWindows(bool animate) { 371 void WindowOverview::PositionWindows(bool animate) {
381 if (single_root_window_) { 372 aura::Window::Windows root_window_list = Shell::GetAllRootWindows();
382 std::vector<WindowSelectorItem*> windows; 373 for (size_t i = 0; i < root_window_list.size(); ++i)
383 for (WindowSelectorItemList::iterator iter = windows_->begin(); 374 PositionWindowsFromRoot(root_window_list[i], animate);
384 iter != windows_->end(); ++iter) {
385 windows.push_back(*iter);
386 }
387 PositionWindowsOnRoot(single_root_window_, windows, animate);
388 } else {
389 aura::Window::Windows root_window_list = Shell::GetAllRootWindows();
390 for (size_t i = 0; i < root_window_list.size(); ++i)
391 PositionWindowsFromRoot(root_window_list[i], animate);
392 }
393 } 375 }
394 376
395 void WindowOverview::PositionWindowsFromRoot(aura::Window* root_window, 377 void WindowOverview::PositionWindowsFromRoot(aura::Window* root_window,
396 bool animate) { 378 bool animate) {
397 std::vector<WindowSelectorItem*> windows; 379 std::vector<WindowSelectorItem*> windows;
398 for (WindowSelectorItemList::iterator iter = windows_->begin(); 380 for (WindowSelectorItemList::iterator iter = windows_->begin();
399 iter != windows_->end(); ++iter) { 381 iter != windows_->end(); ++iter) {
400 if ((*iter)->GetRootWindow() == root_window) 382 if ((*iter)->GetRootWindow() == root_window)
401 windows.push_back(*iter); 383 windows.push_back(*iter);
402 } 384 }
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
448 } 430 }
449 431
450 void WindowOverview::InitializeSelectionWidget() { 432 void WindowOverview::InitializeSelectionWidget() {
451 selection_widget_.reset(new views::Widget); 433 selection_widget_.reset(new views::Widget);
452 views::Widget::InitParams params; 434 views::Widget::InitParams params;
453 params.type = views::Widget::InitParams::TYPE_POPUP; 435 params.type = views::Widget::InitParams::TYPE_POPUP;
454 params.can_activate = false; 436 params.can_activate = false;
455 params.keep_on_top = false; 437 params.keep_on_top = false;
456 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; 438 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
457 params.opacity = views::Widget::InitParams::OPAQUE_WINDOW; 439 params.opacity = views::Widget::InitParams::OPAQUE_WINDOW;
458 params.parent = Shell::GetContainer(single_root_window_ 440 params.parent = Shell::GetContainer(windows_->front()->GetRootWindow(),
459 ? single_root_window_
460 : windows_->front()->GetRootWindow(),
461 kShellWindowId_DefaultContainer); 441 kShellWindowId_DefaultContainer);
462 params.accept_events = false; 442 params.accept_events = false;
463 selection_widget_->set_focus_on_creation(false); 443 selection_widget_->set_focus_on_creation(false);
464 selection_widget_->Init(params); 444 selection_widget_->Init(params);
465 views::View* content_view = new views::View; 445 views::View* content_view = new views::View;
466 content_view->set_background( 446 content_view->set_background(
467 views::Background::CreateSolidBackground(kWindowOverviewSelectionColor)); 447 views::Background::CreateSolidBackground(kWindowOverviewSelectionColor));
468 selection_widget_->SetContentsView(content_view); 448 selection_widget_->SetContentsView(content_view);
469 selection_widget_->Show(); 449 selection_widget_->Show();
470 selection_widget_->GetNativeWindow()->parent()->StackChildAtBottom( 450 selection_widget_->GetNativeWindow()->parent()->StackChildAtBottom(
471 selection_widget_->GetNativeWindow()); 451 selection_widget_->GetNativeWindow());
472 selection_widget_->GetNativeWindow()->layer()->SetOpacity( 452 selection_widget_->GetNativeWindow()->layer()->SetOpacity(
473 kWindowOverviewSelectionOpacity); 453 kWindowOverviewSelectionOpacity);
474 } 454 }
475 455
476 gfx::Rect WindowOverview::GetSelectionBounds(size_t index) { 456 gfx::Rect WindowOverview::GetSelectionBounds(size_t index) {
477 gfx::Rect bounds((*windows_)[index]->bounds()); 457 gfx::Rect bounds((*windows_)[index]->bounds());
478 bounds.Inset(-kWindowOverviewSelectionPadding, 458 bounds.Inset(-kWindowOverviewSelectionPadding,
479 -kWindowOverviewSelectionPadding); 459 -kWindowOverviewSelectionPadding);
480 return bounds; 460 return bounds;
481 } 461 }
482 462
483 } // namespace ash 463 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698