| 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 1194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1205 | 1205 |
| 1206 // A change to the widget size requires surface bounds to be re-adjusted. | 1206 // A change to the widget size requires surface bounds to be re-adjusted. |
| 1207 surface_->window()->SetBounds( | 1207 surface_->window()->SetBounds( |
| 1208 gfx::Rect(GetSurfaceOrigin(), surface_->window()->layer()->size())); | 1208 gfx::Rect(GetSurfaceOrigin(), surface_->window()->layer()->size())); |
| 1209 } | 1209 } |
| 1210 | 1210 |
| 1211 void ShellSurface::UpdateShadow() { | 1211 void ShellSurface::UpdateShadow() { |
| 1212 if (!widget_) | 1212 if (!widget_) |
| 1213 return; | 1213 return; |
| 1214 aura::Window* window = widget_->GetNativeWindow(); | 1214 aura::Window* window = widget_->GetNativeWindow(); |
| 1215 ash::wm::WindowState* window_state = ash::wm::GetWindowState(window); |
| 1216 if (widget_->IsFullscreen() && |
| 1217 window_state->allow_set_bounds_in_maximized()) { |
| 1218 if (window->layer()->transform().IsIdentity()) { |
| 1219 wm::SetShadowType(window, wm::SHADOW_TYPE_NONE); |
| 1220 gfx::Point origin; |
| 1221 origin -= window->bounds().origin().OffsetFromOrigin(); |
| 1222 gfx::Rect bounds(origin, window->parent()->bounds().size()); |
| 1223 ShowShadowUnderlay(bounds, 1.0f); |
| 1224 } else if (shadow_underlay_) { |
| 1225 shadow_underlay_->Hide(); |
| 1226 } |
| 1227 return; |
| 1228 } |
| 1229 |
| 1215 if (shadow_content_bounds_.IsEmpty()) { | 1230 if (shadow_content_bounds_.IsEmpty()) { |
| 1216 wm::SetShadowType(window, wm::SHADOW_TYPE_NONE); | 1231 wm::SetShadowType(window, wm::SHADOW_TYPE_NONE); |
| 1217 if (shadow_underlay_) | 1232 if (shadow_underlay_) |
| 1218 shadow_underlay_->Hide(); | 1233 shadow_underlay_->Hide(); |
| 1234 |
| 1219 } else { | 1235 } else { |
| 1220 wm::SetShadowType(window, wm::SHADOW_TYPE_RECTANGULAR); | 1236 wm::SetShadowType(window, wm::SHADOW_TYPE_RECTANGULAR); |
| 1221 | 1237 |
| 1222 // TODO(oshima): Adjust the coordinates from client screen to | 1238 // TODO(oshima): Adjust the coordinates from client screen to |
| 1223 // chromeos screen when multi displays are supported. | 1239 // chromeos screen when multi displays are supported. |
| 1224 gfx::Point origin = window->bounds().origin(); | 1240 gfx::Point origin = window->bounds().origin(); |
| 1225 gfx::Point shadow_origin = shadow_content_bounds_.origin(); | 1241 gfx::Point shadow_origin = shadow_content_bounds_.origin(); |
| 1226 shadow_origin -= origin.OffsetFromOrigin(); | 1242 shadow_origin -= origin.OffsetFromOrigin(); |
| 1227 gfx::Rect shadow_bounds(shadow_origin, shadow_content_bounds_.size()); | 1243 gfx::Rect shadow_bounds(shadow_origin, shadow_content_bounds_.size()); |
| 1228 | 1244 |
| 1229 // Always create and show the underlay, even in maximized/fullscreen. | 1245 // Always create and show the underlay, even in maximized/fullscreen. |
| 1230 if (!shadow_underlay_) { | 1246 ShowShadowUnderlay(shadow_bounds, rectangular_shadow_background_opacity_); |
| 1231 shadow_underlay_ = new aura::Window(nullptr); | |
| 1232 DCHECK(shadow_underlay_->owned_by_parent()); | |
| 1233 shadow_underlay_->set_ignore_events(true); | |
| 1234 // Ensure the background area inside the shadow is solid black. | |
| 1235 // Clients that provide translucent contents should not be using | |
| 1236 // rectangular shadows as this method requires opaque contents to | |
| 1237 // cast a shadow that represent it correctly. | |
| 1238 shadow_underlay_->Init(ui::LAYER_SOLID_COLOR); | |
| 1239 shadow_underlay_->layer()->SetColor(SK_ColorBLACK); | |
| 1240 DCHECK(shadow_underlay_->layer()->fills_bounds_opaquely()); | |
| 1241 window->AddChild(shadow_underlay_); | |
| 1242 window->StackChildAtBottom(shadow_underlay_); | |
| 1243 } | |
| 1244 shadow_underlay_->layer()->SetOpacity( | |
| 1245 rectangular_shadow_background_opacity_); | |
| 1246 shadow_underlay_->SetBounds(shadow_bounds); | |
| 1247 shadow_underlay_->Show(); | |
| 1248 | 1247 |
| 1249 wm::Shadow* shadow = wm::ShadowController::GetShadowForWindow(window); | 1248 wm::Shadow* shadow = wm::ShadowController::GetShadowForWindow(window); |
| 1250 // Maximized/Fullscreen window does not create a shadow. | 1249 // Maximized/Fullscreen window does not create a shadow. |
| 1251 if (!shadow) | 1250 if (!shadow) |
| 1252 return; | 1251 return; |
| 1253 | |
| 1254 if (!shadow_overlay_) { | 1252 if (!shadow_overlay_) { |
| 1255 shadow_overlay_ = new aura::Window(nullptr); | 1253 shadow_overlay_ = new aura::Window(nullptr); |
| 1256 DCHECK(shadow_overlay_->owned_by_parent()); | 1254 DCHECK(shadow_overlay_->owned_by_parent()); |
| 1257 shadow_overlay_->set_ignore_events(true); | 1255 shadow_overlay_->set_ignore_events(true); |
| 1258 shadow_overlay_->Init(ui::LAYER_NOT_DRAWN); | 1256 shadow_overlay_->Init(ui::LAYER_NOT_DRAWN); |
| 1259 shadow_overlay_->layer()->Add(shadow->layer()); | 1257 shadow_overlay_->layer()->Add(shadow->layer()); |
| 1260 window->AddChild(shadow_overlay_); | 1258 window->AddChild(shadow_overlay_); |
| 1261 shadow_overlay_->Show(); | 1259 shadow_overlay_->Show(); |
| 1262 } | 1260 } |
| 1263 shadow_overlay_->SetBounds(shadow_bounds); | 1261 shadow_overlay_->SetBounds(shadow_bounds); |
| 1264 shadow->SetContentBounds(gfx::Rect(shadow_bounds.size())); | 1262 shadow->SetContentBounds(gfx::Rect(shadow_bounds.size())); |
| 1265 } | 1263 } |
| 1266 } | 1264 } |
| 1267 | 1265 |
| 1266 void ShellSurface::ShowShadowUnderlay(const gfx::Rect& bounds, float opacity) { |
| 1267 if (!shadow_underlay_) { |
| 1268 aura::Window* window = widget_->GetNativeWindow(); |
| 1269 shadow_underlay_ = new aura::Window(nullptr); |
| 1270 DCHECK(shadow_underlay_->owned_by_parent()); |
| 1271 shadow_underlay_->set_ignore_events(true); |
| 1272 // Ensure the background area inside the shadow is solid black. |
| 1273 // Clients that provide translucent contents should not be using |
| 1274 // rectangular shadows as this method requires opaque contents to |
| 1275 // cast a shadow that represent it correctly. |
| 1276 shadow_underlay_->Init(ui::LAYER_SOLID_COLOR); |
| 1277 shadow_underlay_->layer()->SetColor(SK_ColorBLACK); |
| 1278 DCHECK(shadow_underlay_->layer()->fills_bounds_opaquely()); |
| 1279 window->AddChild(shadow_underlay_); |
| 1280 window->StackChildAtBottom(shadow_underlay_); |
| 1281 } |
| 1282 shadow_underlay_->layer()->SetOpacity(opacity); |
| 1283 shadow_underlay_->SetBounds(bounds); |
| 1284 shadow_underlay_->Show(); |
| 1285 } |
| 1286 |
| 1268 } // namespace exo | 1287 } // namespace exo |
| OLD | NEW |