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

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

Issue 2203793003: [ash-md] Properly scales windows with transient parents in overview (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2785
Patch Set: 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 315 matching lines...) Expand 10 before | Expand all | Expand 10 after
326 if (window != window_ && window->GetType() != ui::wm::WINDOW_TYPE_NORMAL && 326 if (window != window_ && window->GetType() != ui::wm::WINDOW_TYPE_NORMAL &&
327 window->GetType() != ui::wm::WINDOW_TYPE_PANEL) { 327 window->GetType() != ui::wm::WINDOW_TYPE_PANEL) {
328 continue; 328 continue;
329 } 329 }
330 bounds.Union( 330 bounds.Union(
331 window->GetParent()->ConvertRectToScreen(window->GetTargetBounds())); 331 window->GetParent()->ConvertRectToScreen(window->GetTargetBounds()));
332 } 332 }
333 return bounds; 333 return bounds;
334 } 334 }
335 335
336 gfx::Rect ScopedTransformOverviewWindow::GetTransformedBounds(
337 bool hide_header) const {
338 const bool material = ash::MaterialDesignController::IsOverviewMaterial();
339 const int top_inset = hide_header ? GetTopInset() : 0;
340 gfx::Rect bounds;
341 for (auto* window : GetTransientTreeIterator(window_)) {
342 // Ignore other window types when computing bounding box of window
343 // selector target item.
344 if (window != window_ &&
345 (!material || (window->GetType() != ui::wm::WINDOW_TYPE_NORMAL &&
346 window->GetType() != ui::wm::WINDOW_TYPE_PANEL))) {
347 continue;
348 }
349 gfx::RectF window_bounds(window->GetTargetBounds());
350 gfx::Transform new_transform =
351 TransformAboutPivot(gfx::Point(window_bounds.x(), window_bounds.y()),
352 window->GetTargetTransform());
353 new_transform.TransformRect(&window_bounds);
354
355 // With Material Design the preview title is shown above the preview window.
356 // Hide the window header for apps or browser windows with no tabs (web
357 // apps) to avoid showing both the window header and the preview title.
358 if (material && top_inset > 0) {
359 gfx::RectF header_bounds(window_bounds);
360 header_bounds.set_height(top_inset);
361 new_transform.TransformRect(&header_bounds);
362 window_bounds.Inset(0, gfx::ToCeiledInt(header_bounds.height()), 0, 0);
363 }
364 bounds.Union(window->GetParent()->ConvertRectToScreen(
365 ToEnclosingRect(window_bounds)));
366 }
367 return bounds;
368 }
369
370 int ScopedTransformOverviewWindow::GetTopInset() const {
371 for (auto* window : GetTransientTreeIterator(window_)) {
372 // If there are regular windows in the transient ancestor tree, all those
373 // windows are shown in the same overview item and the header is not masked.
374 if (window != window_ && (window->GetType() == ui::wm::WINDOW_TYPE_NORMAL ||
375 window->GetType() == ui::wm::WINDOW_TYPE_PANEL)) {
376 return 0;
377 }
378 }
379 return window_->GetIntProperty(WmWindowProperty::TOP_VIEW_INSET);
380 }
381
336 void ScopedTransformOverviewWindow::ShowWindowIfMinimized() { 382 void ScopedTransformOverviewWindow::ShowWindowIfMinimized() {
337 if (minimized_ && window_->GetShowState() == ui::SHOW_STATE_MINIMIZED) 383 if (minimized_ && window_->GetShowState() == ui::SHOW_STATE_MINIMIZED)
338 window_->Show(); 384 window_->Show();
339 } 385 }
340 386
341 void ScopedTransformOverviewWindow::ShowWindowOnExit() { 387 void ScopedTransformOverviewWindow::ShowWindowOnExit() {
342 if (minimized_) { 388 if (minimized_) {
343 minimized_ = false; 389 minimized_ = false;
344 original_transform_ = gfx::Transform(); 390 original_transform_ = gfx::Transform();
345 original_opacity_ = kRestoreWindowOpacity; 391 original_opacity_ = kRestoreWindowOpacity;
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
417 mask_->layer()->SetFillsBoundsOpaquely(false); 463 mask_->layer()->SetFillsBoundsOpaquely(false);
418 window()->GetLayer()->SetMaskLayer(mask_->layer()); 464 window()->GetLayer()->SetMaskLayer(mask_->layer());
419 } 465 }
420 if (!determined_original_window_shape_) { 466 if (!determined_original_window_shape_) {
421 determined_original_window_shape_ = true; 467 determined_original_window_shape_ = true;
422 SkRegion* window_shape = window()->GetLayer()->alpha_shape(); 468 SkRegion* window_shape = window()->GetLayer()->alpha_shape();
423 if (!original_window_shape_ && window_shape) 469 if (!original_window_shape_ && window_shape)
424 original_window_shape_.reset(new SkRegion(*window_shape)); 470 original_window_shape_.reset(new SkRegion(*window_shape));
425 } 471 }
426 gfx::Rect bounds(GetTargetBoundsInScreen().size()); 472 gfx::Rect bounds(GetTargetBoundsInScreen().size());
427 const int inset = 473 const int inset = (use_mask || use_shape) ? GetTopInset() : 0;
428 (use_mask || use_shape)
429 ? window()->GetIntProperty(WmWindowProperty::TOP_VIEW_INSET)
430 : 0;
431 if (mask_) { 474 if (mask_) {
432 // Mask layer is used both to hide the window header and to use rounded 475 // Mask layer is used both to hide the window header and to use rounded
433 // corners. Its layout needs to be update when setting a transform. 476 // corners. Its layout needs to be update when setting a transform.
434 mask_->layer()->SetBounds(bounds); 477 mask_->layer()->SetBounds(bounds);
435 mask_->set_inset(inset); 478 mask_->set_inset(inset);
436 mask_->set_radius(radius); 479 mask_->set_radius(radius);
437 window()->GetLayer()->SchedulePaint(bounds); 480 window()->GetLayer()->SchedulePaint(bounds);
438 } else if (inset > 0) { 481 } else if (inset > 0) {
439 // Alpha shape is only used to to hide the window header and only when 482 // Alpha shape is only used to to hide the window header and only when
440 // not using a mask layer. 483 // not using a mask layer.
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
492 if (parent_window) 535 if (parent_window)
493 parent_window->CloseWidget(); 536 parent_window->CloseWidget();
494 } 537 }
495 538
496 // static 539 // static
497 void ScopedTransformOverviewWindow::SetImmediateCloseForTests() { 540 void ScopedTransformOverviewWindow::SetImmediateCloseForTests() {
498 immediate_close_for_tests = true; 541 immediate_close_for_tests = true;
499 } 542 }
500 543
501 } // namespace ash 544 } // 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