| 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 "ui/aura/client/aura_constants.h" | 8 #include "ui/aura/client/aura_constants.h" |
| 9 #include "ui/aura/client/drag_drop_client.h" | 9 #include "ui/aura/client/drag_drop_client.h" |
| 10 #include "ui/aura/client/focus_client.h" | 10 #include "ui/aura/client/focus_client.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 internal::NativeWidgetDelegate* native_widget_delegate, | 26 internal::NativeWidgetDelegate* native_widget_delegate, |
| 27 DesktopNativeWidgetAura* desktop_native_widget_aura, | 27 DesktopNativeWidgetAura* desktop_native_widget_aura, |
| 28 const Widget::InitParams& init_params) | 28 const Widget::InitParams& init_params) |
| 29 : aura::WindowTreeHostMus(MusClient::Get()->window_tree_client(), | 29 : aura::WindowTreeHostMus(MusClient::Get()->window_tree_client(), |
| 30 &init_params.mus_properties), | 30 &init_params.mus_properties), |
| 31 native_widget_delegate_(native_widget_delegate), | 31 native_widget_delegate_(native_widget_delegate), |
| 32 desktop_native_widget_aura_(desktop_native_widget_aura), | 32 desktop_native_widget_aura_(desktop_native_widget_aura), |
| 33 fullscreen_restore_state_(ui::SHOW_STATE_DEFAULT), | 33 fullscreen_restore_state_(ui::SHOW_STATE_DEFAULT), |
| 34 close_widget_factory_(this) { | 34 close_widget_factory_(this) { |
| 35 aura::Env::GetInstance()->AddObserver(this); | 35 aura::Env::GetInstance()->AddObserver(this); |
| 36 MusClient::Get()->AddObserver(this); |
| 36 // TODO: use display id and bounds if available, likely need to pass in | 37 // TODO: use display id and bounds if available, likely need to pass in |
| 37 // InitParams for that. | 38 // InitParams for that. |
| 38 } | 39 } |
| 39 | 40 |
| 40 DesktopWindowTreeHostMus::~DesktopWindowTreeHostMus() { | 41 DesktopWindowTreeHostMus::~DesktopWindowTreeHostMus() { |
| 42 MusClient::Get()->RemoveObserver(this); |
| 41 aura::Env::GetInstance()->RemoveObserver(this); | 43 aura::Env::GetInstance()->RemoveObserver(this); |
| 42 desktop_native_widget_aura_->OnDesktopWindowTreeHostDestroyed(this); | 44 desktop_native_widget_aura_->OnDesktopWindowTreeHostDestroyed(this); |
| 43 } | 45 } |
| 44 | 46 |
| 45 bool DesktopWindowTreeHostMus::IsDocked() const { | 47 bool DesktopWindowTreeHostMus::IsDocked() const { |
| 46 return window()->GetProperty(aura::client::kShowStateKey) == | 48 return window()->GetProperty(aura::client::kShowStateKey) == |
| 47 ui::SHOW_STATE_DOCKED; | 49 ui::SHOW_STATE_DOCKED; |
| 48 } | 50 } |
| 49 | 51 |
| 52 // TODO(erg): This needs to be called after window size changed. |
| 53 void DesktopWindowTreeHostMus::UpdateClientArea() { |
| 54 NonClientView* non_client_view = |
| 55 native_widget_delegate_->AsWidget()->non_client_view(); |
| 56 if (!non_client_view || !non_client_view->client_view()) |
| 57 return; |
| 58 |
| 59 const gfx::Rect client_area_rect(non_client_view->client_view()->bounds()); |
| 60 SetClientArea(gfx::Insets( |
| 61 client_area_rect.y(), client_area_rect.x(), |
| 62 non_client_view->bounds().height() - client_area_rect.bottom(), |
| 63 non_client_view->bounds().width() - client_area_rect.right())); |
| 64 } |
| 65 |
| 66 void DesktopWindowTreeHostMus::UpdateHitTestMask() { |
| 67 if (!native_widget_delegate_->HasHitTestMask()) { |
| 68 ClearHitTestMask(); |
| 69 return; |
| 70 } |
| 71 |
| 72 gfx::Path mask_path; |
| 73 native_widget_delegate_->GetHitTestMask(&mask_path); |
| 74 // TODO(jamescook): Use the full path for the mask. |
| 75 gfx::Rect mask_rect = |
| 76 gfx::ToEnclosingRect(gfx::SkRectToRectF(mask_path.getBounds())); |
| 77 SetHitTestMask(mask_rect); |
| 78 } |
| 79 |
| 50 void DesktopWindowTreeHostMus::Init(aura::Window* content_window, | 80 void DesktopWindowTreeHostMus::Init(aura::Window* content_window, |
| 51 const Widget::InitParams& params) { | 81 const Widget::InitParams& params) { |
| 52 // TODO: handle device scale, http://crbug.com/663524. | 82 // TODO: handle device scale, http://crbug.com/663524. |
| 53 if (!params.bounds.IsEmpty()) | 83 if (!params.bounds.IsEmpty()) |
| 54 SetBounds(params.bounds); | 84 SetBounds(params.bounds); |
| 55 } | 85 } |
| 56 | 86 |
| 57 void DesktopWindowTreeHostMus::OnNativeWidgetCreated( | 87 void DesktopWindowTreeHostMus::OnNativeWidgetCreated( |
| 58 const Widget::InitParams& params) { | 88 const Widget::InitParams& params) { |
| 59 if (params.parent && params.parent->GetHost()) { | 89 if (params.parent && params.parent->GetHost()) { |
| (...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 411 void DesktopWindowTreeHostMus::SizeConstraintsChanged() { | 441 void DesktopWindowTreeHostMus::SizeConstraintsChanged() { |
| 412 Widget* widget = native_widget_delegate_->AsWidget(); | 442 Widget* widget = native_widget_delegate_->AsWidget(); |
| 413 window()->SetProperty(aura::client::kCanMaximizeKey, | 443 window()->SetProperty(aura::client::kCanMaximizeKey, |
| 414 widget->widget_delegate()->CanMaximize()); | 444 widget->widget_delegate()->CanMaximize()); |
| 415 window()->SetProperty(aura::client::kCanMinimizeKey, | 445 window()->SetProperty(aura::client::kCanMinimizeKey, |
| 416 widget->widget_delegate()->CanMinimize()); | 446 widget->widget_delegate()->CanMinimize()); |
| 417 window()->SetProperty(aura::client::kCanResizeKey, | 447 window()->SetProperty(aura::client::kCanResizeKey, |
| 418 widget->widget_delegate()->CanResize()); | 448 widget->widget_delegate()->CanResize()); |
| 419 } | 449 } |
| 420 | 450 |
| 451 void DesktopWindowTreeHostMus::OnWindowManagerFrameValuesChanged() { |
| 452 NonClientView* non_client_view = |
| 453 native_widget_delegate_->AsWidget()->non_client_view(); |
| 454 if (non_client_view) { |
| 455 non_client_view->Layout(); |
| 456 non_client_view->SchedulePaint(); |
| 457 } |
| 458 |
| 459 UpdateClientArea(); |
| 460 UpdateHitTestMask(); |
| 461 } |
| 462 |
| 421 void DesktopWindowTreeHostMus::ShowImpl() { | 463 void DesktopWindowTreeHostMus::ShowImpl() { |
| 422 native_widget_delegate_->OnNativeWidgetVisibilityChanging(true); | 464 native_widget_delegate_->OnNativeWidgetVisibilityChanging(true); |
| 423 // Using ui::SHOW_STATE_NORMAL matches that of DesktopWindowTreeHostX11. | 465 // Using ui::SHOW_STATE_NORMAL matches that of DesktopWindowTreeHostX11. |
| 424 ShowWindowWithState(ui::SHOW_STATE_NORMAL); | 466 ShowWindowWithState(ui::SHOW_STATE_NORMAL); |
| 425 WindowTreeHostMus::ShowImpl(); | 467 WindowTreeHostMus::ShowImpl(); |
| 426 native_widget_delegate_->OnNativeWidgetVisibilityChanged(true); | 468 native_widget_delegate_->OnNativeWidgetVisibilityChanged(true); |
| 427 } | 469 } |
| 428 | 470 |
| 429 void DesktopWindowTreeHostMus::HideImpl() { | 471 void DesktopWindowTreeHostMus::HideImpl() { |
| 430 native_widget_delegate_->OnNativeWidgetVisibilityChanging(false); | 472 native_widget_delegate_->OnNativeWidgetVisibilityChanging(false); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 454 if (window == this->window()) { | 496 if (window == this->window()) { |
| 455 is_active_ = true; | 497 is_active_ = true; |
| 456 desktop_native_widget_aura_->HandleActivationChanged(true); | 498 desktop_native_widget_aura_->HandleActivationChanged(true); |
| 457 } else if (is_active_) { | 499 } else if (is_active_) { |
| 458 is_active_ = false; | 500 is_active_ = false; |
| 459 desktop_native_widget_aura_->HandleActivationChanged(false); | 501 desktop_native_widget_aura_->HandleActivationChanged(false); |
| 460 } | 502 } |
| 461 } | 503 } |
| 462 | 504 |
| 463 } // namespace views | 505 } // namespace views |
| OLD | NEW |