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