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 so that the |
280 // renders to. | 280 // window-manager draws the non-client area. |
James Cook
2017/03/02 21:00:01
Do we have to do it this way? I understand there's
sky
2017/03/02 21:28:42
I updated the comment. Any better?
As to performa
James Cook
2017/03/02 21:44:24
Better!
| |
281 content_window->layer()->SetFillsBoundsOpaquely(false); | 281 const bool transparent = |
282 params.opacity == Widget::InitParams::TRANSLUCENT_WINDOW || | |
283 params.type == Widget::InitParams::TYPE_WINDOW || | |
284 params.type == Widget::InitParams::TYPE_PANEL; | |
285 content_window->SetTransparent(transparent); | |
286 window()->SetTransparent(transparent); | |
287 | |
282 if (!params.bounds.IsEmpty()) | 288 if (!params.bounds.IsEmpty()) |
283 SetBoundsInDIP(params.bounds); | 289 SetBoundsInDIP(params.bounds); |
284 | 290 |
285 cursor_manager_ = base::MakeUnique<wm::CursorManager>( | 291 cursor_manager_ = base::MakeUnique<wm::CursorManager>( |
286 base::MakeUnique<NativeCursorManagerMus>(window())); | 292 base::MakeUnique<NativeCursorManagerMus>(window())); |
287 aura::client::SetCursorClient(window(), cursor_manager_.get()); | 293 aura::client::SetCursorClient(window(), cursor_manager_.get()); |
288 InitHost(); | 294 InitHost(); |
289 | 295 |
290 NativeWidgetAura::SetShadowElevationFromInitParams(window(), params); | 296 NativeWidgetAura::SetShadowElevationFromInitParams(window(), params); |
291 | 297 |
292 // Transient parents are connected using the Window created by WindowTreeHost, | 298 // Transient parents are connected using the Window created by WindowTreeHost, |
293 // which is owned by the window manager. This way the window manager can | 299 // which is owned by the window manager. This way the window manager can |
294 // properly identify and honor transients. | 300 // properly identify and honor transients. |
295 if (params.parent && params.parent->GetHost()) { | 301 if (params.parent && params.parent->GetHost()) { |
296 aura::client::GetTransientWindowClient()->AddTransientChild( | 302 aura::client::GetTransientWindowClient()->AddTransientChild( |
297 params.parent->GetHost()->window(), window()); | 303 params.parent->GetHost()->window(), window()); |
298 } | 304 } |
299 | 305 |
300 if (!params.accept_events) { | 306 if (!params.accept_events) { |
301 aura::WindowPortMus::Get(window())->SetEventTargetingPolicy( | 307 aura::WindowPortMus::Get(window())->SetEventTargetingPolicy( |
302 ui::mojom::EventTargetingPolicy::NONE); | 308 ui::mojom::EventTargetingPolicy::NONE); |
303 } | 309 } |
304 } | 310 } |
305 | 311 |
306 void DesktopWindowTreeHostMus::OnNativeWidgetCreated( | 312 void DesktopWindowTreeHostMus::OnNativeWidgetCreated( |
307 const Widget::InitParams& params) { | 313 const Widget::InitParams& params) { |
314 window()->SetName(params.name); | |
315 desktop_native_widget_aura_->content_window()->SetName( | |
316 "DesktopNativeWidgetAura - content window"); | |
308 if (params.parent && params.parent->GetHost()) { | 317 if (params.parent && params.parent->GetHost()) { |
309 parent_ = static_cast<DesktopWindowTreeHostMus*>(params.parent->GetHost()); | 318 parent_ = static_cast<DesktopWindowTreeHostMus*>(params.parent->GetHost()); |
310 parent_->children_.insert(this); | 319 parent_->children_.insert(this); |
311 } | 320 } |
312 native_widget_delegate_->OnNativeWidgetCreated(true); | 321 native_widget_delegate_->OnNativeWidgetCreated(true); |
313 } | 322 } |
314 | 323 |
315 void DesktopWindowTreeHostMus::OnNativeWidgetActivationChanged(bool active) { | 324 void DesktopWindowTreeHostMus::OnNativeWidgetActivationChanged(bool active) { |
316 // In Mus, when our aura Window receives an activation signal, it can be | 325 // 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 | 326 // 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, | 812 aura::client::FocusClient* focus_client, |
804 aura::Window* window) { | 813 aura::Window* window) { |
805 if (window == this->window()) { | 814 if (window == this->window()) { |
806 desktop_native_widget_aura_->HandleActivationChanged(true); | 815 desktop_native_widget_aura_->HandleActivationChanged(true); |
807 } else if (is_active_) { | 816 } else if (is_active_) { |
808 desktop_native_widget_aura_->HandleActivationChanged(false); | 817 desktop_native_widget_aura_->HandleActivationChanged(false); |
809 } | 818 } |
810 } | 819 } |
811 | 820 |
812 } // namespace views | 821 } // namespace views |
OLD | NEW |