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 1235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1246 // Clients that provide translucent contents should not be using | 1246 // Clients that provide translucent contents should not be using |
1247 // rectangular shadows as this method requires opaque contents to | 1247 // rectangular shadows as this method requires opaque contents to |
1248 // cast a shadow that represent it correctly. | 1248 // cast a shadow that represent it correctly. |
1249 shadow_underlay_->Init(ui::LAYER_SOLID_COLOR); | 1249 shadow_underlay_->Init(ui::LAYER_SOLID_COLOR); |
1250 shadow_underlay_->layer()->SetColor(SK_ColorBLACK); | 1250 shadow_underlay_->layer()->SetColor(SK_ColorBLACK); |
1251 DCHECK(shadow_underlay_->layer()->fills_bounds_opaquely()); | 1251 DCHECK(shadow_underlay_->layer()->fills_bounds_opaquely()); |
1252 window->AddChild(shadow_underlay_); | 1252 window->AddChild(shadow_underlay_); |
1253 window->StackChildAtBottom(shadow_underlay_); | 1253 window->StackChildAtBottom(shadow_underlay_); |
1254 } | 1254 } |
1255 | 1255 |
| 1256 float shadow_underlay_opacity = rectangular_shadow_background_opacity_; |
1256 // Put the black background layer behind the window if | 1257 // Put the black background layer behind the window if |
1257 // 1) the window is in immersive fullscreen. | 1258 // 1) the window is in immersive fullscreen. |
1258 // 2) the window can control the bounds of the window in fullscreen ( | 1259 // 2) the window can control the bounds of the window in fullscreen ( |
1259 // thus the background can be visible). | 1260 // thus the background can be visible). |
1260 // 3) the window has no transform (the transformed background may | 1261 // 3) the window has no transform (the transformed background may |
1261 // not cover the entire background, e.g. overview mode). | 1262 // not cover the entire background, e.g. overview mode). |
1262 if (widget_->IsFullscreen() && | 1263 if (widget_->IsFullscreen() && |
1263 ash::wm::GetWindowState(window)->allow_set_bounds_in_maximized() && | 1264 ash::wm::GetWindowState(window)->allow_set_bounds_in_maximized() && |
1264 window->layer()->transform().IsIdentity()) { | 1265 window->layer()->transform().IsIdentity()) { |
1265 gfx::Point origin; | 1266 gfx::Point origin; |
1266 origin -= window->bounds().origin().OffsetFromOrigin(); | 1267 origin -= window->bounds().origin().OffsetFromOrigin(); |
1267 gfx::Rect background_bounds(origin, window->parent()->bounds().size()); | 1268 shadow_bounds.set_origin(origin); |
1268 shadow_underlay_->SetBounds(background_bounds); | 1269 shadow_bounds.set_size(window->parent()->bounds().size()); |
1269 shadow_underlay_->layer()->SetOpacity(1.f); | 1270 shadow_underlay_opacity = 1.0f; |
1270 } else { | |
1271 shadow_underlay_->SetBounds(shadow_bounds); | |
1272 shadow_underlay_->layer()->SetOpacity( | |
1273 rectangular_shadow_background_opacity_); | |
1274 } | 1271 } |
| 1272 |
| 1273 shadow_underlay_->SetBounds(shadow_bounds); |
| 1274 |
| 1275 // TODO(oshima): Setting to the same value should be no-op. |
| 1276 // crbug.com/642223. |
| 1277 if (shadow_underlay_opacity != |
| 1278 shadow_underlay_->layer()->GetTargetOpacity()) { |
| 1279 shadow_underlay_->layer()->SetOpacity(shadow_underlay_opacity); |
| 1280 } |
| 1281 |
1275 shadow_underlay_->Show(); | 1282 shadow_underlay_->Show(); |
1276 | 1283 |
1277 wm::Shadow* shadow = wm::ShadowController::GetShadowForWindow(window); | 1284 wm::Shadow* shadow = wm::ShadowController::GetShadowForWindow(window); |
1278 // Maximized/Fullscreen window does not create a shadow. | 1285 // Maximized/Fullscreen window does not create a shadow. |
1279 if (!shadow) | 1286 if (!shadow) |
1280 return; | 1287 return; |
1281 | 1288 |
1282 if (!shadow_overlay_) { | 1289 if (!shadow_overlay_) { |
1283 shadow_overlay_ = new aura::Window(nullptr); | 1290 shadow_overlay_ = new aura::Window(nullptr); |
1284 DCHECK(shadow_overlay_->owned_by_parent()); | 1291 DCHECK(shadow_overlay_->owned_by_parent()); |
1285 shadow_overlay_->set_ignore_events(true); | 1292 shadow_overlay_->set_ignore_events(true); |
1286 shadow_overlay_->Init(ui::LAYER_NOT_DRAWN); | 1293 shadow_overlay_->Init(ui::LAYER_NOT_DRAWN); |
1287 shadow_overlay_->layer()->Add(shadow->layer()); | 1294 shadow_overlay_->layer()->Add(shadow->layer()); |
1288 window->AddChild(shadow_overlay_); | 1295 window->AddChild(shadow_overlay_); |
1289 shadow_overlay_->Show(); | 1296 shadow_overlay_->Show(); |
1290 } | 1297 } |
1291 shadow_overlay_->SetBounds(shadow_bounds); | 1298 shadow_overlay_->SetBounds(shadow_bounds); |
1292 shadow->SetContentBounds(gfx::Rect(shadow_bounds.size())); | 1299 shadow->SetContentBounds(gfx::Rect(shadow_bounds.size())); |
1293 } | 1300 } |
1294 } | 1301 } |
1295 | 1302 |
1296 } // namespace exo | 1303 } // namespace exo |
OLD | NEW |