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