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

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

Issue 2197773002: [ash-md] Properly scales windows with transient parents in overview (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: [ash-md] Disables rounded corners by default in overview mode (nits) 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
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/common/wm/overview/scoped_transform_overview_window.h" 5 #include "ash/common/wm/overview/scoped_transform_overview_window.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <vector> 8 #include <vector>
9 9
10 #include "ash/common/material_design/material_design_controller.h" 10 #include "ash/common/material_design/material_design_controller.h"
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 if (window != window_ && window->GetType() != ui::wm::WINDOW_TYPE_NORMAL && 336 if (window != window_ && window->GetType() != ui::wm::WINDOW_TYPE_NORMAL &&
337 window->GetType() != ui::wm::WINDOW_TYPE_PANEL) { 337 window->GetType() != ui::wm::WINDOW_TYPE_PANEL) {
338 continue; 338 continue;
339 } 339 }
340 bounds.Union( 340 bounds.Union(
341 window->GetParent()->ConvertRectToScreen(window->GetTargetBounds())); 341 window->GetParent()->ConvertRectToScreen(window->GetTargetBounds()));
342 } 342 }
343 return bounds; 343 return bounds;
344 } 344 }
345 345
346 gfx::Rect ScopedTransformOverviewWindow::GetTransformedBounds(
347 bool hide_header) const {
348 const bool material = ash::MaterialDesignController::IsOverviewMaterial();
349 const int top_inset = hide_header ? GetTopInset() : 0;
350 gfx::Rect bounds;
351 for (auto* window : GetTransientTreeIterator(window_)) {
352 // Ignore other window types when computing bounding box of window
353 // selector target item.
354 if (window != window_ &&
355 (!material || (window->GetType() != ui::wm::WINDOW_TYPE_NORMAL &&
356 window->GetType() != ui::wm::WINDOW_TYPE_PANEL))) {
357 continue;
358 }
359 gfx::RectF window_bounds(window->GetTargetBounds());
360 gfx::Transform new_transform =
361 TransformAboutPivot(gfx::Point(window_bounds.x(), window_bounds.y()),
362 window->GetTargetTransform());
363 new_transform.TransformRect(&window_bounds);
364
365 // With Material Design the preview title is shown above the preview window.
366 // Hide the window header for apps or browser windows with no tabs (web
367 // apps) to avoid showing both the window header and the preview title.
368 if (material && top_inset > 0) {
369 gfx::RectF header_bounds(window_bounds);
370 header_bounds.set_height(top_inset);
371 new_transform.TransformRect(&header_bounds);
372 window_bounds.Inset(0, gfx::ToCeiledInt(header_bounds.height()), 0, 0);
373 }
374 bounds.Union(window->GetParent()->ConvertRectToScreen(
375 ToEnclosingRect(window_bounds)));
376 }
377 return bounds;
378 }
379
380 int ScopedTransformOverviewWindow::GetTopInset() const {
381 for (auto* window : GetTransientTreeIterator(window_)) {
382 // If there are regular windows in the transient ancestor tree, all those
383 // windows are shown in the same overview item and the header is not masked.
384 if (window != window_ && (window->GetType() == ui::wm::WINDOW_TYPE_NORMAL ||
385 window->GetType() == ui::wm::WINDOW_TYPE_PANEL)) {
386 return 0;
387 }
388 }
389 return window_->GetIntProperty(WmWindowProperty::TOP_VIEW_INSET);
390 }
391
346 void ScopedTransformOverviewWindow::ShowWindowIfMinimized() { 392 void ScopedTransformOverviewWindow::ShowWindowIfMinimized() {
347 if ((original_visibility_ == ORIGINALLY_MINIMIZED && 393 if ((original_visibility_ == ORIGINALLY_MINIMIZED &&
348 window_->GetShowState() == ui::SHOW_STATE_MINIMIZED) || 394 window_->GetShowState() == ui::SHOW_STATE_MINIMIZED) ||
349 (original_visibility_ == ORIGINALLY_DOCKED_MINIMIZED && 395 (original_visibility_ == ORIGINALLY_DOCKED_MINIMIZED &&
350 window_->GetWindowState()->GetStateType() == 396 window_->GetWindowState()->GetStateType() ==
351 wm::WINDOW_STATE_TYPE_DOCKED_MINIMIZED)) { 397 wm::WINDOW_STATE_TYPE_DOCKED_MINIMIZED)) {
352 window_->Show(); 398 window_->Show();
353 } 399 }
354 } 400 }
355 401
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
432 mask_->layer()->SetFillsBoundsOpaquely(false); 478 mask_->layer()->SetFillsBoundsOpaquely(false);
433 window()->GetLayer()->SetMaskLayer(mask_->layer()); 479 window()->GetLayer()->SetMaskLayer(mask_->layer());
434 } 480 }
435 if (!determined_original_window_shape_) { 481 if (!determined_original_window_shape_) {
436 determined_original_window_shape_ = true; 482 determined_original_window_shape_ = true;
437 SkRegion* window_shape = window()->GetLayer()->alpha_shape(); 483 SkRegion* window_shape = window()->GetLayer()->alpha_shape();
438 if (!original_window_shape_ && window_shape) 484 if (!original_window_shape_ && window_shape)
439 original_window_shape_.reset(new SkRegion(*window_shape)); 485 original_window_shape_.reset(new SkRegion(*window_shape));
440 } 486 }
441 gfx::Rect bounds(GetTargetBoundsInScreen().size()); 487 gfx::Rect bounds(GetTargetBoundsInScreen().size());
442 const int inset = 488 const int inset = (use_mask || use_shape) ? GetTopInset() : 0;
443 (use_mask || use_shape)
444 ? window()->GetIntProperty(WmWindowProperty::TOP_VIEW_INSET)
445 : 0;
446 if (mask_) { 489 if (mask_) {
447 // Mask layer is used both to hide the window header and to use rounded 490 // Mask layer is used both to hide the window header and to use rounded
448 // corners. Its layout needs to be update when setting a transform. 491 // corners. Its layout needs to be update when setting a transform.
449 mask_->layer()->SetBounds(bounds); 492 mask_->layer()->SetBounds(bounds);
450 mask_->set_inset(inset); 493 mask_->set_inset(inset);
451 mask_->set_radius(radius); 494 mask_->set_radius(radius);
452 window()->GetLayer()->SchedulePaint(bounds); 495 window()->GetLayer()->SchedulePaint(bounds);
453 } else if (inset > 0) { 496 } else if (inset > 0) {
454 // Alpha shape is only used to to hide the window header and only when 497 // Alpha shape is only used to to hide the window header and only when
455 // not using a mask layer. 498 // not using a mask layer.
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
507 if (parent_window) 550 if (parent_window)
508 parent_window->CloseWidget(); 551 parent_window->CloseWidget();
509 } 552 }
510 553
511 // static 554 // static
512 void ScopedTransformOverviewWindow::SetImmediateCloseForTests() { 555 void ScopedTransformOverviewWindow::SetImmediateCloseForTests() {
513 immediate_close_for_tests = true; 556 immediate_close_for_tests = true;
514 } 557 }
515 558
516 } // namespace ash 559 } // namespace ash
OLDNEW
« no previous file with comments | « ash/common/wm/overview/scoped_transform_overview_window.h ('k') | ash/common/wm/overview/window_grid.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698