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

Side by Side Diff: components/exo/shell_surface.cc

Issue 2664403004: Use pixel coordinates for shadow underlay bounds (Closed)
Patch Set: update 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "components/exo/shell_surface.h" 5 #include "components/exo/shell_surface.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "ash/common/frame/custom_frame_view_ash.h" 9 #include "ash/common/frame/custom_frame_view_ash.h"
10 #include "ash/common/shelf/wm_shelf.h" 10 #include "ash/common/shelf/wm_shelf.h"
(...skipping 1396 matching lines...) Expand 10 before | Expand all | Expand 10 after
1407 void ShellSurface::UpdateShadow() { 1407 void ShellSurface::UpdateShadow() {
1408 if (!widget_) 1408 if (!widget_)
1409 return; 1409 return;
1410 aura::Window* window = widget_->GetNativeWindow(); 1410 aura::Window* window = widget_->GetNativeWindow();
1411 if (!shadow_enabled_) { 1411 if (!shadow_enabled_) {
1412 wm::SetShadowElevation(window, wm::ShadowElevation::NONE); 1412 wm::SetShadowElevation(window, wm::ShadowElevation::NONE);
1413 if (shadow_underlay_) 1413 if (shadow_underlay_)
1414 shadow_underlay_->Hide(); 1414 shadow_underlay_->Hide();
1415 } else { 1415 } else {
1416 wm::SetShadowElevation(window, wm::ShadowElevation::MEDIUM); 1416 wm::SetShadowElevation(window, wm::ShadowElevation::MEDIUM);
1417 gfx::Rect shadow_content_bounds =
1418 gfx::ScaleToEnclosedRect(shadow_content_bounds_, 1.f / scale_);
1419 gfx::Rect shadow_underlay_bounds = shadow_content_bounds_;
1420 if (shadow_underlay_bounds.IsEmpty())
1421 shadow_underlay_bounds = gfx::Rect(surface_->window()->bounds().size());
1417 1422
1418 gfx::Rect shadow_content_bounds = shadow_content_bounds_; 1423 if (!shadow_underlay_in_shell_surface_) {
1419 if (shadow_content_bounds.IsEmpty()) 1424 shadow_content_bounds = shadow_content_bounds_;
1420 shadow_content_bounds = window->bounds(); 1425 if (shadow_content_bounds.IsEmpty()) {
1426 shadow_content_bounds = window->bounds();
1427 }
1428 }
1421 1429
1422 // TODO(oshima): Adjust the coordinates from client screen to 1430 // TODO(oshima): Adjust the coordinates from client screen to
1423 // chromeos screen when multi displays are supported. 1431 // chromeos screen when multi displays are supported.
1424 gfx::Point origin = window->bounds().origin(); 1432 gfx::Point origin = window->bounds().origin();
1425 gfx::Point shadow_origin = shadow_content_bounds.origin(); 1433 gfx::Point shadow_origin = shadow_content_bounds.origin();
1426 shadow_origin -= origin.OffsetFromOrigin(); 1434 shadow_origin -= origin.OffsetFromOrigin();
1427 gfx::Rect shadow_bounds(shadow_origin, shadow_content_bounds.size()); 1435 gfx::Rect shadow_bounds(shadow_origin, shadow_content_bounds.size());
1428 1436
1429 // Always create and show the underlay, even in maximized/fullscreen. 1437 // Always create and show the underlay, even in maximized/fullscreen.
1430 if (!shadow_underlay_) { 1438 if (!shadow_underlay_) {
1431 shadow_underlay_ = new aura::Window(nullptr); 1439 shadow_underlay_ = new aura::Window(nullptr);
1432 shadow_underlay_event_handler_ = 1440 shadow_underlay_event_handler_ =
1433 base::MakeUnique<ShadowUnderlayEventHandler>(); 1441 base::MakeUnique<ShadowUnderlayEventHandler>();
1434 shadow_underlay_->SetTargetHandler(shadow_underlay_event_handler_.get()); 1442 shadow_underlay_->SetTargetHandler(shadow_underlay_event_handler_.get());
1435 DCHECK(shadow_underlay_->owned_by_parent()); 1443 DCHECK(shadow_underlay_->owned_by_parent());
1436 // Ensure the background area inside the shadow is solid black. 1444 // Ensure the background area inside the shadow is solid black.
1437 // Clients that provide translucent contents should not be using 1445 // Clients that provide translucent contents should not be using
1438 // rectangular shadows as this method requires opaque contents to 1446 // rectangular shadows as this method requires opaque contents to
1439 // cast a shadow that represent it correctly. 1447 // cast a shadow that represent it correctly.
1440 shadow_underlay_->Init(ui::LAYER_SOLID_COLOR); 1448 shadow_underlay_->Init(ui::LAYER_SOLID_COLOR);
1441 shadow_underlay_->layer()->SetColor(SK_ColorBLACK); 1449 shadow_underlay_->layer()->SetColor(SK_ColorBLACK);
1442 DCHECK(shadow_underlay_->layer()->fills_bounds_opaquely()); 1450 DCHECK(shadow_underlay_->layer()->fills_bounds_opaquely());
1443 window->AddChild(shadow_underlay_); 1451 if (!shadow_underlay_in_shell_surface_) {
1444 window->StackChildAtBottom(shadow_underlay_); 1452 window->AddChild(shadow_underlay_);
1453 window->StackChildAtBottom(shadow_underlay_);
1454 } else {
1455 surface_->window()->AddChild(shadow_underlay_);
1456 }
1457 }
1458
1459 if (shadow_underlay_in_shell_surface_) {
1460 surface_->window()->StackChildAtBottom(shadow_underlay_);
1445 } 1461 }
1446 1462
1447 bool underlay_capture_events = 1463 bool underlay_capture_events =
1448 WMHelper::GetInstance()->IsSpokenFeedbackEnabled() && 1464 WMHelper::GetInstance()->IsSpokenFeedbackEnabled() &&
1449 widget_->IsActive(); 1465 widget_->IsActive();
1450 1466
1451 float shadow_underlay_opacity = shadow_background_opacity_; 1467 float shadow_underlay_opacity = shadow_background_opacity_;
1452 // Put the black background layer behind the window if 1468 // Put the black background layer behind the window if
1453 // 1) the window is in immersive fullscreen or is active with 1469 // 1) the window is in immersive fullscreen or is active with
1454 // spoken feedback enabled. 1470 // spoken feedback enabled.
1455 // 2) the window can control the bounds of the window in fullscreen ( 1471 // 2) the window can control the bounds of the window in fullscreen (
1456 // thus the background can be visible). 1472 // thus the background can be visible).
1457 // 3) the window has no transform (the transformed background may 1473 // 3) the window has no transform (the transformed background may
1458 // not cover the entire background, e.g. overview mode). 1474 // not cover the entire background, e.g. overview mode).
1459 if ((widget_->IsFullscreen() || underlay_capture_events) && 1475 if ((widget_->IsFullscreen() || underlay_capture_events) &&
1460 ash::wm::GetWindowState(window)->allow_set_bounds_in_maximized() && 1476 ash::wm::GetWindowState(window)->allow_set_bounds_in_maximized() &&
1461 window->layer()->GetTargetTransform().IsIdentity()) { 1477 window->layer()->GetTargetTransform().IsIdentity()) {
1462 gfx::Point origin; 1478 if (!shadow_underlay_in_shell_surface_) {
1463 origin -= window->bounds().origin().OffsetFromOrigin(); 1479 gfx::Point origin;
1464 shadow_bounds.set_origin(origin); 1480 origin -= window->bounds().origin().OffsetFromOrigin();
1465 shadow_bounds.set_size(window->parent()->bounds().size()); 1481 shadow_bounds.set_origin(origin);
1482 shadow_bounds.set_size(window->parent()->bounds().size());
1483 } else {
1484 shadow_underlay_bounds = gfx::Rect(surface_->window()->bounds().size());
1485 }
1466 shadow_underlay_opacity = 1.0f; 1486 shadow_underlay_opacity = 1.0f;
1467 } 1487 }
1468 1488
1469 gfx::Rect shadow_underlay_bounds = shadow_bounds; 1489 if (!shadow_underlay_in_shell_surface_)
1490 shadow_underlay_bounds = shadow_bounds;
1470 1491
1471 // Constrain the underlay bounds to the client area in case shell surface 1492 // Constrain the underlay bounds to the client area in case shell surface
1472 // frame is enabled. 1493 // frame is enabled.
1473 if (frame_enabled_) { 1494 if (frame_enabled_) {
1474 shadow_underlay_bounds.Intersect( 1495 shadow_underlay_bounds.Intersect(
1475 widget_->non_client_view()->frame_view()->GetBoundsForClientView()); 1496 widget_->non_client_view()->frame_view()->GetBoundsForClientView());
1476 } 1497 }
1477 1498
1478 shadow_underlay_->SetBounds(shadow_underlay_bounds); 1499 shadow_underlay_->SetBounds(shadow_underlay_bounds);
1479 1500
(...skipping 11 matching lines...) Expand all
1491 if (!shadow) 1512 if (!shadow)
1492 return; 1513 return;
1493 1514
1494 if (!shadow_overlay_) { 1515 if (!shadow_overlay_) {
1495 shadow_overlay_ = new aura::Window(nullptr); 1516 shadow_overlay_ = new aura::Window(nullptr);
1496 DCHECK(shadow_overlay_->owned_by_parent()); 1517 DCHECK(shadow_overlay_->owned_by_parent());
1497 shadow_overlay_->set_ignore_events(true); 1518 shadow_overlay_->set_ignore_events(true);
1498 shadow_overlay_->Init(ui::LAYER_NOT_DRAWN); 1519 shadow_overlay_->Init(ui::LAYER_NOT_DRAWN);
1499 shadow_overlay_->layer()->Add(shadow->layer()); 1520 shadow_overlay_->layer()->Add(shadow->layer());
1500 window->AddChild(shadow_overlay_); 1521 window->AddChild(shadow_overlay_);
1501 window->StackChildAbove(shadow_overlay_, shadow_underlay_); 1522
1523 if (!shadow_underlay_in_shell_surface_) {
1524 window->StackChildAbove(shadow_overlay_, shadow_underlay_);
1525 } else {
1526 window->StackChildBelow(shadow_overlay_, surface_->window());
1527 }
1502 shadow_overlay_->Show(); 1528 shadow_overlay_->Show();
1503 } 1529 }
1504 shadow_overlay_->SetBounds(shadow_bounds); 1530 shadow_overlay_->SetBounds(shadow_bounds);
1505 shadow->SetContentBounds(gfx::Rect(shadow_bounds.size())); 1531 shadow->SetContentBounds(gfx::Rect(shadow_bounds.size()));
1506 // Surfaces that can't be activated are usually menus and tooltips. Use a 1532 // Surfaces that can't be activated are usually menus and tooltips. Use a
1507 // small style shadow for them. 1533 // small style shadow for them.
1508 if (!activatable_) 1534 if (!activatable_)
1509 shadow->SetElevation(wm::ShadowElevation::SMALL); 1535 shadow->SetElevation(wm::ShadowElevation::SMALL);
1510 // We don't have rounded corners unless frame is enabled. 1536 // We don't have rounded corners unless frame is enabled.
1511 if (!frame_enabled_) 1537 if (!frame_enabled_)
1512 shadow->SetRoundedCornerRadius(0); 1538 shadow->SetRoundedCornerRadius(0);
1513 } 1539 }
1514 } 1540 }
1515 1541
1516 } // namespace exo 1542 } // namespace exo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698