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

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

Issue 2204063002: Add configuration_changed event and set_background_opacity request. (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
« no previous file with comments | « components/exo/shell_surface.h ('k') | components/exo/shell_surface_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "ash/aura/wm_window_aura.h" 7 #include "ash/aura/wm_window_aura.h"
8 #include "ash/common/shell_window_ids.h" 8 #include "ash/common/shell_window_ids.h"
9 #include "ash/common/wm/window_resizer.h" 9 #include "ash/common/wm/window_resizer.h"
10 #include "ash/common/wm/window_state.h" 10 #include "ash/common/wm/window_state.h"
(...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after
479 pending_geometry_ = geometry; 479 pending_geometry_ = geometry;
480 } 480 }
481 481
482 void ShellSurface::SetRectangularShadow(const gfx::Rect& content_bounds) { 482 void ShellSurface::SetRectangularShadow(const gfx::Rect& content_bounds) {
483 TRACE_EVENT1("exo", "ShellSurface::SetRectangularShadow", "content_bounds", 483 TRACE_EVENT1("exo", "ShellSurface::SetRectangularShadow", "content_bounds",
484 content_bounds.ToString()); 484 content_bounds.ToString());
485 485
486 shadow_content_bounds_ = content_bounds; 486 shadow_content_bounds_ = content_bounds;
487 } 487 }
488 488
489 void ShellSurface::SetRectangularShadowBackgroundOpacity(float opacity) {
490 TRACE_EVENT1("exo", "ShellSurface::SetRectangularShadowBackgroundOpacity",
491 "opacity", opacity);
492
493 rectangular_shadow_background_opacity_ = opacity;
494 }
495
489 void ShellSurface::SetScale(double scale) { 496 void ShellSurface::SetScale(double scale) {
490 TRACE_EVENT1("exo", "ShellSurface::SetScale", "scale", scale); 497 TRACE_EVENT1("exo", "ShellSurface::SetScale", "scale", scale);
491 498
492 if (scale <= 0.0) { 499 if (scale <= 0.0) {
493 DLOG(WARNING) << "Surface scale must be greater than 0"; 500 DLOG(WARNING) << "Surface scale must be greater than 0";
494 return; 501 return;
495 } 502 }
496 503
497 pending_scale_ = scale; 504 pending_scale_ = scale;
498 } 505 }
(...skipping 681 matching lines...) Expand 10 before | Expand all | Expand 10 after
1180 void ShellSurface::UpdateShadow() { 1187 void ShellSurface::UpdateShadow() {
1181 if (!widget_) 1188 if (!widget_)
1182 return; 1189 return;
1183 aura::Window* window = widget_->GetNativeWindow(); 1190 aura::Window* window = widget_->GetNativeWindow();
1184 if (shadow_content_bounds_.IsEmpty()) { 1191 if (shadow_content_bounds_.IsEmpty()) {
1185 wm::SetShadowType(window, wm::SHADOW_TYPE_NONE); 1192 wm::SetShadowType(window, wm::SHADOW_TYPE_NONE);
1186 if (shadow_underlay_) 1193 if (shadow_underlay_)
1187 shadow_underlay_->Hide(); 1194 shadow_underlay_->Hide();
1188 } else { 1195 } else {
1189 wm::SetShadowType(window, wm::SHADOW_TYPE_RECTANGULAR); 1196 wm::SetShadowType(window, wm::SHADOW_TYPE_RECTANGULAR);
1190 wm::Shadow* shadow = wm::ShadowController::GetShadowForWindow(window);
1191 // Maximized/Fullscreen window does not create a shadow.
1192 if (!shadow)
1193 return;
1194 1197
1195 if (!shadow_overlay_) { 1198 // TODO(oshima): Adjust the coordinates from client screen to
1196 shadow_overlay_ = new aura::Window(nullptr); 1199 // chromeos screen when multi displays are supported.
1197 DCHECK(shadow_overlay_->owned_by_parent()); 1200 gfx::Point origin = window->bounds().origin();
1198 shadow_overlay_->set_ignore_events(true); 1201 gfx::Point shadow_origin = shadow_content_bounds_.origin();
1199 shadow_overlay_->Init(ui::LAYER_NOT_DRAWN); 1202 shadow_origin -= origin.OffsetFromOrigin();
1200 shadow_overlay_->layer()->Add(shadow->layer()); 1203 gfx::Rect shadow_bounds(shadow_origin, shadow_content_bounds_.size());
1201 window->AddChild(shadow_overlay_); 1204
1202 shadow_overlay_->Show(); 1205 // Always create and show the underlay, even in maximized/fullscreen.
1203 }
1204 if (!shadow_underlay_) { 1206 if (!shadow_underlay_) {
1205 shadow_underlay_ = new aura::Window(nullptr); 1207 shadow_underlay_ = new aura::Window(nullptr);
1206 DCHECK(shadow_underlay_->owned_by_parent()); 1208 DCHECK(shadow_underlay_->owned_by_parent());
1207 shadow_underlay_->set_ignore_events(true); 1209 shadow_underlay_->set_ignore_events(true);
1208 // Ensure the background area inside the shadow is solid black. 1210 // Ensure the background area inside the shadow is solid black.
1209 // Clients that provide translucent contents should not be using 1211 // Clients that provide translucent contents should not be using
1210 // rectangular shadows as this method requires opaque contents to 1212 // rectangular shadows as this method requires opaque contents to
1211 // cast a shadow that represent it correctly. 1213 // cast a shadow that represent it correctly.
1212 shadow_underlay_->Init(ui::LAYER_SOLID_COLOR); 1214 shadow_underlay_->Init(ui::LAYER_SOLID_COLOR);
1213 shadow_underlay_->layer()->SetColor(SK_ColorBLACK); 1215 shadow_underlay_->layer()->SetColor(SK_ColorBLACK);
1214 DCHECK(shadow_underlay_->layer()->fills_bounds_opaquely()); 1216 DCHECK(shadow_underlay_->layer()->fills_bounds_opaquely());
1215 window->AddChild(shadow_underlay_); 1217 window->AddChild(shadow_underlay_);
1216 window->StackChildAtBottom(shadow_underlay_); 1218 window->StackChildAtBottom(shadow_underlay_);
1217 } 1219 }
1220 shadow_underlay_->layer()->SetOpacity(
1221 rectangular_shadow_background_opacity_);
1222 shadow_underlay_->SetBounds(shadow_bounds);
1218 shadow_underlay_->Show(); 1223 shadow_underlay_->Show();
1219 1224
1220 // TODO(oshima): Adjust the coordinates from client screen to 1225 wm::Shadow* shadow = wm::ShadowController::GetShadowForWindow(window);
1221 // chromeos screen when multi displays are support. 1226 // Maximized/Fullscreen window does not create a shadow.
1222 gfx::Point origin = window->bounds().origin(); 1227 if (!shadow)
1223 gfx::Point shadow_origin = shadow_content_bounds_.origin(); 1228 return;
1224 shadow_origin -= origin.OffsetFromOrigin();
1225 gfx::Rect shadow_bounds(shadow_origin, shadow_content_bounds_.size());
1226 1229
1230 if (!shadow_overlay_) {
1231 shadow_overlay_ = new aura::Window(nullptr);
1232 DCHECK(shadow_overlay_->owned_by_parent());
1233 shadow_overlay_->set_ignore_events(true);
1234 shadow_overlay_->Init(ui::LAYER_NOT_DRAWN);
1235 shadow_overlay_->layer()->Add(shadow->layer());
1236 window->AddChild(shadow_overlay_);
1237 shadow_overlay_->Show();
1238 }
1227 shadow_overlay_->SetBounds(shadow_bounds); 1239 shadow_overlay_->SetBounds(shadow_bounds);
1228 shadow_underlay_->SetBounds(shadow_bounds);
1229 shadow->SetContentBounds(gfx::Rect(shadow_bounds.size())); 1240 shadow->SetContentBounds(gfx::Rect(shadow_bounds.size()));
1230 } 1241 }
1231 } 1242 }
1232 1243
1233 } // namespace exo 1244 } // namespace exo
OLDNEW
« no previous file with comments | « components/exo/shell_surface.h ('k') | components/exo/shell_surface_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698