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

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

Issue 2225683008: [ash-md] Cancels app-list (launcher) before entering overview (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: [ash-md] - Prevents accelerators from reaching an active window in overview Created 4 years, 4 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 | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
tdanderson 2016/08/09 14:21:03 Suggested shorter wording for CL description: "Thi
varkha 2016/08/09 16:50:13 Done.
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_selector.h" 5 #include "ash/common/wm/overview/window_selector.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>
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 0.5 * root_window->GetBounds().width() * 188 0.5 * root_window->GetBounds().width() *
189 (1 - kTextFilterScreenProportion), 189 (1 - kTextFilterScreenProportion),
190 kTextFilterDistanceFromTop, 190 kTextFilterDistanceFromTop,
191 root_window->GetBounds().width() * kTextFilterScreenProportion, 191 root_window->GetBounds().width() * kTextFilterScreenProportion,
192 kTextFilterHeight); 192 kTextFilterHeight);
193 } 193 }
194 194
195 // Initializes the text filter on the top of the main root window and requests 195 // Initializes the text filter on the top of the main root window and requests
196 // focus on its textfield. With Material Design uses |image| to place an icon 196 // focus on its textfield. With Material Design uses |image| to place an icon
197 // to the left of the text field. 197 // to the left of the text field.
198 views::Widget* CreateTextFilter(views::TextfieldController* controller, 198 views::Widget* CreateAndActivateTextFilter(
199 WmWindow* root_window, 199 views::TextfieldController* controller,
200 const gfx::ImageSkia& image, 200 WmWindow* root_window,
201 int* text_filter_bottom) { 201 const gfx::ImageSkia& image,
202 int* text_filter_bottom) {
202 views::Widget* widget = new views::Widget; 203 views::Widget* widget = new views::Widget;
203 views::Widget::InitParams params; 204 views::Widget::InitParams params;
204 params.type = views::Widget::InitParams::TYPE_WINDOW_FRAMELESS; 205 params.type = views::Widget::InitParams::TYPE_WINDOW_FRAMELESS;
205 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; 206 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
206 params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW; 207 params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW;
207 params.accept_events = true; 208 params.accept_events = true;
208 params.bounds = GetTextFilterPosition(root_window); 209 params.bounds = GetTextFilterPosition(root_window);
209 *text_filter_bottom = params.bounds.bottom(); 210 *text_filter_bottom = params.bounds.bottom();
210 root_window->GetRootWindowController()->ConfigureWidgetInitParamsForContainer( 211 root_window->GetRootWindowController()->ConfigureWidgetInitParamsForContainer(
211 widget, kShellWindowId_StatusContainer, &params); 212 widget, kShellWindowId_StatusContainer, &params);
(...skipping 30 matching lines...) Expand all
242 container->AddChildView(image_view); 243 container->AddChildView(image_view);
243 } else { 244 } else {
244 textfield->SetBackgroundColor(SK_ColorTRANSPARENT); 245 textfield->SetBackgroundColor(SK_ColorTRANSPARENT);
245 textfield->SetTextColor(kTextFilterTextColor); 246 textfield->SetTextColor(kTextFilterTextColor);
246 } 247 }
247 textfield->SetFontList(bundle.GetFontList(font_style)); 248 textfield->SetFontList(bundle.GetFontList(font_style));
248 container->AddChildView(textfield); 249 container->AddChildView(textfield);
249 layout->SetFlexForView(textfield, 1); 250 layout->SetFlexForView(textfield, 1);
250 widget->SetContentsView(container); 251 widget->SetContentsView(container);
251 252
253 // Deactivate the previously active window to prevent accelerators targeting
tdanderson 2016/08/09 14:21:03 nit: "Deactivate the previously-active window to p
varkha 2016/08/09 16:50:14 Done.
254 // an active window from triggering actions during overview.
255 WmWindow* active_window = WmShell::Get()->GetActiveWindow();
256 if (active_window)
257 active_window->Deactivate();
tdanderson 2016/08/09 14:21:03 If possible it would be good to have a test for th
varkha 2016/08/09 16:50:13 Done.
252 // The textfield initially contains no text, so shift its position to be 258 // The textfield initially contains no text, so shift its position to be
253 // outside the visible bounds of the screen. 259 // outside the visible bounds of the screen.
254 gfx::Transform transform; 260 gfx::Transform transform;
255 transform.Translate(0, -params.bounds.bottom()); 261 transform.Translate(0, -params.bounds.bottom());
256 WmLookup::Get()->GetWindowForWidget(widget)->SetTransform(transform); 262 WmLookup::Get()->GetWindowForWidget(widget)->SetTransform(transform);
257 widget->Show(); 263 widget->Show();
258 textfield->RequestFocus(); 264 textfield->RequestFocus();
259 265
260 return widget; 266 return widget;
261 } 267 }
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 PanelLayoutManager::Get(root)->SetShowCalloutWidgets(false); 334 PanelLayoutManager::Get(root)->SetShowCalloutWidgets(false);
329 335
330 std::unique_ptr<WindowGrid> grid(new WindowGrid(root, windows, this)); 336 std::unique_ptr<WindowGrid> grid(new WindowGrid(root, windows, this));
331 if (grid->empty()) 337 if (grid->empty())
332 continue; 338 continue;
333 num_items_ += grid->size(); 339 num_items_ += grid->size();
334 grid_list_.push_back(std::move(grid)); 340 grid_list_.push_back(std::move(grid));
335 } 341 }
336 342
337 { 343 {
338 // The calls to WindowGrid::PrepareForOverview() and CreateTextFilter(...) 344 // The calls to WindowGrid::PrepareForOverview() and
339 // requires some LayoutManagers (ie PanelLayoutManager) to perform layouts 345 // CreateAndActivateTextFilter(...) require some LayoutManagers (i.e.
340 // so that windows are correctly visible and properly animated in overview 346 // PanelLayoutManager) to perform layouts so that windows are correctly
341 // mode. Otherwise these layouts should be suppressed during overview mode 347 // visible and properly animated in overview mode. Otherwise these layouts
342 // so they don't conflict with overview mode animations. The 348 // should be suppressed during overview mode so they don't conflict with
343 // |restoring_minimized_windows_| flag enables the PanelLayoutManager to 349 // overview mode animations. The |restoring_minimized_windows_| flag enables
344 // make this decision. 350 // the PanelLayoutManager to make this decision.
345 base::AutoReset<bool> auto_restoring_minimized_windows( 351 base::AutoReset<bool> auto_restoring_minimized_windows(
346 &restoring_minimized_windows_, true); 352 &restoring_minimized_windows_, true);
347 353
348 // Do not call PrepareForOverview until all items are added to window_list_ 354 // Do not call PrepareForOverview until all items are added to window_list_
349 // as we don't want to cause any window updates until all windows in 355 // as we don't want to cause any window updates until all windows in
350 // overview are observed. See http://crbug.com/384495. 356 // overview are observed. See http://crbug.com/384495.
351 for (std::unique_ptr<WindowGrid>& window_grid : grid_list_) { 357 for (std::unique_ptr<WindowGrid>& window_grid : grid_list_) {
352 window_grid->PrepareForOverview(); 358 window_grid->PrepareForOverview();
353 window_grid->PositionWindows(true); 359 window_grid->PositionWindows(true);
354 } 360 }
355 361
356 if (ash::MaterialDesignController::IsOverviewMaterial()) { 362 if (ash::MaterialDesignController::IsOverviewMaterial()) {
357 search_image_ = 363 search_image_ =
358 gfx::CreateVectorIcon(gfx::VectorIconId::OMNIBOX_SEARCH, 364 gfx::CreateVectorIcon(gfx::VectorIconId::OMNIBOX_SEARCH,
359 kTextFilterIconSize, kTextFilterIconColorMD); 365 kTextFilterIconSize, kTextFilterIconColorMD);
360 } 366 }
361 WmWindow* root_window = shell->GetPrimaryRootWindow(); 367 WmWindow* root_window = shell->GetPrimaryRootWindow();
362 text_filter_widget_.reset(CreateTextFilter(this, root_window, search_image_, 368 text_filter_widget_.reset(CreateAndActivateTextFilter(
363 &text_filter_bottom_)); 369 this, root_window, search_image_, &text_filter_bottom_));
364 } 370 }
365 371
366 DCHECK(!grid_list_.empty()); 372 DCHECK(!grid_list_.empty());
367 UMA_HISTOGRAM_COUNTS_100("Ash.WindowSelector.Items", num_items_); 373 UMA_HISTOGRAM_COUNTS_100("Ash.WindowSelector.Items", num_items_);
368 374
369 shell->AddActivationObserver(this); 375 shell->AddActivationObserver(this);
370 376
371 display::Screen::GetScreen()->AddObserver(this); 377 display::Screen::GetScreen()->AddObserver(this);
372 shell->RecordUserMetricsAction(UMA_WINDOW_OVERVIEW); 378 shell->RecordUserMetricsAction(UMA_WINDOW_OVERVIEW);
373 // Send an a11y alert. 379 // Send an a11y alert.
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
713 for (size_t i = 0; i <= grid_list_.size() && 719 for (size_t i = 0; i <= grid_list_.size() &&
714 grid_list_[selected_grid_index_]->Move(direction, animate); 720 grid_list_[selected_grid_index_]->Move(direction, animate);
715 i++) { 721 i++) {
716 selected_grid_index_ = 722 selected_grid_index_ =
717 (selected_grid_index_ + display_direction + grid_list_.size()) % 723 (selected_grid_index_ + display_direction + grid_list_.size()) %
718 grid_list_.size(); 724 grid_list_.size();
719 } 725 }
720 } 726 }
721 727
722 } // namespace ash 728 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698