OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "ui/views/mus/desktop_window_tree_host_mus.h" | 5 #include "ui/views/mus/desktop_window_tree_host_mus.h" |
6 | 6 |
7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
10 #include "base/threading/thread_task_runner_handle.h" | 10 #include "base/threading/thread_task_runner_handle.h" |
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
269 if (!auto_update_client_area_) | 269 if (!auto_update_client_area_) |
270 return false; | 270 return false; |
271 | 271 |
272 using WIP = views::Widget::InitParams; | 272 using WIP = views::Widget::InitParams; |
273 const WIP::Type type = desktop_native_widget_aura_->widget_type(); | 273 const WIP::Type type = desktop_native_widget_aura_->widget_type(); |
274 return type == WIP::TYPE_WINDOW || type == WIP::TYPE_PANEL; | 274 return type == WIP::TYPE_WINDOW || type == WIP::TYPE_PANEL; |
275 } | 275 } |
276 | 276 |
277 void DesktopWindowTreeHostMus::Init(aura::Window* content_window, | 277 void DesktopWindowTreeHostMus::Init(aura::Window* content_window, |
278 const Widget::InitParams& params) { | 278 const Widget::InitParams& params) { |
279 // Needed so we don't render over the non-client area the window manager | 279 // |TYPE_WINDOW| and |TYPE_PANEL| are forced to transparent as otherwise the |
280 // renders to. | 280 // window is opaque and the client decorations drawn by the window manager |
281 content_window->layer()->SetFillsBoundsOpaquely(false); | 281 // would not be seen. |
| 282 const bool transparent = |
| 283 params.opacity == Widget::InitParams::TRANSLUCENT_WINDOW || |
| 284 params.type == Widget::InitParams::TYPE_WINDOW || |
| 285 params.type == Widget::InitParams::TYPE_PANEL; |
| 286 content_window->SetTransparent(transparent); |
| 287 window()->SetTransparent(transparent); |
| 288 |
282 if (!params.bounds.IsEmpty()) | 289 if (!params.bounds.IsEmpty()) |
283 SetBoundsInDIP(params.bounds); | 290 SetBoundsInDIP(params.bounds); |
284 | 291 |
285 cursor_manager_ = base::MakeUnique<wm::CursorManager>( | 292 cursor_manager_ = base::MakeUnique<wm::CursorManager>( |
286 base::MakeUnique<NativeCursorManagerMus>(window())); | 293 base::MakeUnique<NativeCursorManagerMus>(window())); |
287 aura::client::SetCursorClient(window(), cursor_manager_.get()); | 294 aura::client::SetCursorClient(window(), cursor_manager_.get()); |
288 InitHost(); | 295 InitHost(); |
289 | 296 |
290 NativeWidgetAura::SetShadowElevationFromInitParams(window(), params); | 297 NativeWidgetAura::SetShadowElevationFromInitParams(window(), params); |
291 | 298 |
292 // Transient parents are connected using the Window created by WindowTreeHost, | 299 // Transient parents are connected using the Window created by WindowTreeHost, |
293 // which is owned by the window manager. This way the window manager can | 300 // which is owned by the window manager. This way the window manager can |
294 // properly identify and honor transients. | 301 // properly identify and honor transients. |
295 if (params.parent && params.parent->GetHost()) { | 302 if (params.parent && params.parent->GetHost()) { |
296 aura::client::GetTransientWindowClient()->AddTransientChild( | 303 aura::client::GetTransientWindowClient()->AddTransientChild( |
297 params.parent->GetHost()->window(), window()); | 304 params.parent->GetHost()->window(), window()); |
298 } | 305 } |
299 | 306 |
300 if (!params.accept_events) { | 307 if (!params.accept_events) { |
301 aura::WindowPortMus::Get(window())->SetEventTargetingPolicy( | 308 aura::WindowPortMus::Get(window())->SetEventTargetingPolicy( |
302 ui::mojom::EventTargetingPolicy::NONE); | 309 ui::mojom::EventTargetingPolicy::NONE); |
303 } | 310 } |
304 } | 311 } |
305 | 312 |
306 void DesktopWindowTreeHostMus::OnNativeWidgetCreated( | 313 void DesktopWindowTreeHostMus::OnNativeWidgetCreated( |
307 const Widget::InitParams& params) { | 314 const Widget::InitParams& params) { |
| 315 window()->SetName(params.name); |
| 316 desktop_native_widget_aura_->content_window()->SetName( |
| 317 "DesktopNativeWidgetAura - content window"); |
308 if (params.parent && params.parent->GetHost()) { | 318 if (params.parent && params.parent->GetHost()) { |
309 parent_ = static_cast<DesktopWindowTreeHostMus*>(params.parent->GetHost()); | 319 parent_ = static_cast<DesktopWindowTreeHostMus*>(params.parent->GetHost()); |
310 parent_->children_.insert(this); | 320 parent_->children_.insert(this); |
311 } | 321 } |
312 native_widget_delegate_->OnNativeWidgetCreated(true); | 322 native_widget_delegate_->OnNativeWidgetCreated(true); |
313 } | 323 } |
314 | 324 |
315 void DesktopWindowTreeHostMus::OnNativeWidgetActivationChanged(bool active) { | 325 void DesktopWindowTreeHostMus::OnNativeWidgetActivationChanged(bool active) { |
316 // In Mus, when our aura Window receives an activation signal, it can be | 326 // In Mus, when our aura Window receives an activation signal, it can be |
317 // because of remote messages. We need to forward that to Widget so that | 327 // because of remote messages. We need to forward that to Widget so that |
(...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
803 aura::client::FocusClient* focus_client, | 813 aura::client::FocusClient* focus_client, |
804 aura::Window* window) { | 814 aura::Window* window) { |
805 if (window == this->window()) { | 815 if (window == this->window()) { |
806 desktop_native_widget_aura_->HandleActivationChanged(true); | 816 desktop_native_widget_aura_->HandleActivationChanged(true); |
807 } else if (is_active_) { | 817 } else if (is_active_) { |
808 desktop_native_widget_aura_->HandleActivationChanged(false); | 818 desktop_native_widget_aura_->HandleActivationChanged(false); |
809 } | 819 } |
810 } | 820 } |
811 | 821 |
812 } // namespace views | 822 } // namespace views |
OLD | NEW |