| 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/threading/thread_task_runner_handle.h" | 8 #include "base/threading/thread_task_runner_handle.h" |
| 9 #include "ui/aura/client/aura_constants.h" | 9 #include "ui/aura/client/aura_constants.h" |
| 10 #include "ui/aura/client/cursor_client.h" | 10 #include "ui/aura/client/cursor_client.h" |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 DesktopNativeWidgetAura* desktop_native_widget_aura, | 174 DesktopNativeWidgetAura* desktop_native_widget_aura, |
| 175 const std::map<std::string, std::vector<uint8_t>>* mus_properties) | 175 const std::map<std::string, std::vector<uint8_t>>* mus_properties) |
| 176 : aura::WindowTreeHostMus(MusClient::Get()->window_tree_client(), | 176 : aura::WindowTreeHostMus(MusClient::Get()->window_tree_client(), |
| 177 mus_properties), | 177 mus_properties), |
| 178 native_widget_delegate_(native_widget_delegate), | 178 native_widget_delegate_(native_widget_delegate), |
| 179 desktop_native_widget_aura_(desktop_native_widget_aura), | 179 desktop_native_widget_aura_(desktop_native_widget_aura), |
| 180 fullscreen_restore_state_(ui::SHOW_STATE_DEFAULT), | 180 fullscreen_restore_state_(ui::SHOW_STATE_DEFAULT), |
| 181 close_widget_factory_(this) { | 181 close_widget_factory_(this) { |
| 182 aura::Env::GetInstance()->AddObserver(this); | 182 aura::Env::GetInstance()->AddObserver(this); |
| 183 MusClient::Get()->AddObserver(this); | 183 MusClient::Get()->AddObserver(this); |
| 184 native_widget_delegate_->AsWidget()->AddObserver(this); |
| 184 // DesktopNativeWidgetAura registers the association between |content_window_| | 185 // DesktopNativeWidgetAura registers the association between |content_window_| |
| 185 // and Widget, but code may also want to go from the root (window()) to the | 186 // and Widget, but code may also want to go from the root (window()) to the |
| 186 // Widget. This call enables that. | 187 // Widget. This call enables that. |
| 187 NativeWidgetAura::RegisterNativeWidgetForWindow(desktop_native_widget_aura, | 188 NativeWidgetAura::RegisterNativeWidgetForWindow(desktop_native_widget_aura, |
| 188 window()); | 189 window()); |
| 189 // TODO: use display id and bounds if available, likely need to pass in | 190 // TODO: use display id and bounds if available, likely need to pass in |
| 190 // InitParams for that. | 191 // InitParams for that. |
| 191 } | 192 } |
| 192 | 193 |
| 193 DesktopWindowTreeHostMus::~DesktopWindowTreeHostMus() { | 194 DesktopWindowTreeHostMus::~DesktopWindowTreeHostMus() { |
| 194 // The cursor-client can be accessed during WindowTreeHostMus tear-down. So | 195 // The cursor-client can be accessed during WindowTreeHostMus tear-down. So |
| 195 // the cursor-client needs to be unset on the root-window before | 196 // the cursor-client needs to be unset on the root-window before |
| 196 // |cursor_manager_| is destroyed. | 197 // |cursor_manager_| is destroyed. |
| 197 aura::client::SetCursorClient(window(), nullptr); | 198 aura::client::SetCursorClient(window(), nullptr); |
| 199 native_widget_delegate_->AsWidget()->RemoveObserver(this); |
| 198 MusClient::Get()->RemoveObserver(this); | 200 MusClient::Get()->RemoveObserver(this); |
| 199 aura::Env::GetInstance()->RemoveObserver(this); | 201 aura::Env::GetInstance()->RemoveObserver(this); |
| 200 desktop_native_widget_aura_->OnDesktopWindowTreeHostDestroyed(this); | 202 desktop_native_widget_aura_->OnDesktopWindowTreeHostDestroyed(this); |
| 201 } | 203 } |
| 202 | 204 |
| 203 bool DesktopWindowTreeHostMus::IsDocked() const { | 205 bool DesktopWindowTreeHostMus::IsDocked() const { |
| 204 return window()->GetProperty(aura::client::kShowStateKey) == | 206 return window()->GetProperty(aura::client::kShowStateKey) == |
| 205 ui::SHOW_STATE_DOCKED; | 207 ui::SHOW_STATE_DOCKED; |
| 206 } | 208 } |
| 207 | 209 |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 273 | 275 |
| 274 void DesktopWindowTreeHostMus::OnNativeWidgetCreated( | 276 void DesktopWindowTreeHostMus::OnNativeWidgetCreated( |
| 275 const Widget::InitParams& params) { | 277 const Widget::InitParams& params) { |
| 276 if (params.parent && params.parent->GetHost()) { | 278 if (params.parent && params.parent->GetHost()) { |
| 277 parent_ = static_cast<DesktopWindowTreeHostMus*>(params.parent->GetHost()); | 279 parent_ = static_cast<DesktopWindowTreeHostMus*>(params.parent->GetHost()); |
| 278 parent_->children_.insert(this); | 280 parent_->children_.insert(this); |
| 279 } | 281 } |
| 280 native_widget_delegate_->OnNativeWidgetCreated(true); | 282 native_widget_delegate_->OnNativeWidgetCreated(true); |
| 281 } | 283 } |
| 282 | 284 |
| 285 void DesktopWindowTreeHostMus::OnNativeWidgetActivationChanged(bool active) { |
| 286 // In Mus, when our aura Window receives an activation signal, it can be |
| 287 // because of remote messages. We need to forward that to Widget so that |
| 288 // Widget can notify everyone listening for that signal. |
| 289 native_widget_delegate_->OnNativeWidgetActivationChanged(active); |
| 290 } |
| 291 |
| 283 void DesktopWindowTreeHostMus::OnWidgetInitDone() { | 292 void DesktopWindowTreeHostMus::OnWidgetInitDone() { |
| 284 // Because of construction order it's possible the bounds have changed before | 293 // Because of construction order it's possible the bounds have changed before |
| 285 // the NonClientView was created, which means we may not have sent the | 294 // the NonClientView was created, which means we may not have sent the |
| 286 // client-area and hit-test-mask. | 295 // client-area and hit-test-mask. |
| 287 SendClientAreaToServer(); | 296 SendClientAreaToServer(); |
| 288 SendHitTestMaskToServer(); | 297 SendHitTestMaskToServer(); |
| 289 } | 298 } |
| 290 | 299 |
| 291 std::unique_ptr<corewm::Tooltip> DesktopWindowTreeHostMus::CreateTooltip() { | 300 std::unique_ptr<corewm::Tooltip> DesktopWindowTreeHostMus::CreateTooltip() { |
| 292 return base::MakeUnique<corewm::TooltipAura>(); | 301 return base::MakeUnique<corewm::TooltipAura>(); |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 485 aura::Env::GetInstance()->SetActiveFocusClient( | 494 aura::Env::GetInstance()->SetActiveFocusClient( |
| 486 aura::client::GetFocusClient(window()), window()); | 495 aura::client::GetFocusClient(window()), window()); |
| 487 if (is_active_) { | 496 if (is_active_) { |
| 488 window()->Focus(); | 497 window()->Focus(); |
| 489 if (window()->GetProperty(aura::client::kDrawAttentionKey)) | 498 if (window()->GetProperty(aura::client::kDrawAttentionKey)) |
| 490 window()->SetProperty(aura::client::kDrawAttentionKey, false); | 499 window()->SetProperty(aura::client::kDrawAttentionKey, false); |
| 491 } | 500 } |
| 492 } | 501 } |
| 493 | 502 |
| 494 void DesktopWindowTreeHostMus::Deactivate() { | 503 void DesktopWindowTreeHostMus::Deactivate() { |
| 495 // TODO: Deactivate() means focus next window, that needs to go to mus. | 504 if (is_active_) |
| 496 // http://crbug.com/663618. | 505 DeactivateWindow(); |
| 497 NOTIMPLEMENTED(); | |
| 498 } | 506 } |
| 499 | 507 |
| 500 bool DesktopWindowTreeHostMus::IsActive() const { | 508 bool DesktopWindowTreeHostMus::IsActive() const { |
| 501 return is_active_; | 509 return is_active_; |
| 502 } | 510 } |
| 503 | 511 |
| 504 void DesktopWindowTreeHostMus::Maximize() { | 512 void DesktopWindowTreeHostMus::Maximize() { |
| 505 window()->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); | 513 window()->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); |
| 506 } | 514 } |
| 507 void DesktopWindowTreeHostMus::Minimize() { | 515 void DesktopWindowTreeHostMus::Minimize() { |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 662 native_widget_delegate_->AsWidget()->non_client_view(); | 670 native_widget_delegate_->AsWidget()->non_client_view(); |
| 663 if (non_client_view) { | 671 if (non_client_view) { |
| 664 non_client_view->Layout(); | 672 non_client_view->Layout(); |
| 665 non_client_view->SchedulePaint(); | 673 non_client_view->SchedulePaint(); |
| 666 } | 674 } |
| 667 | 675 |
| 668 SendClientAreaToServer(); | 676 SendClientAreaToServer(); |
| 669 SendHitTestMaskToServer(); | 677 SendHitTestMaskToServer(); |
| 670 } | 678 } |
| 671 | 679 |
| 680 void DesktopWindowTreeHostMus::OnWidgetActivationChanged(Widget* widget, |
| 681 bool active) { |
| 682 // TODO(erg): Theoretically, this shouldn't be necessary. We should be able |
| 683 // to just set |is_active_| in OnNativeWidgetActivationChanged() above, |
| 684 // instead of asking the Widget to change the activation and have the widget |
| 685 // then tell us the activation has changed. But if we do that, focus breaks. |
| 686 is_active_ = active; |
| 687 } |
| 688 |
| 672 void DesktopWindowTreeHostMus::ShowImpl() { | 689 void DesktopWindowTreeHostMus::ShowImpl() { |
| 673 native_widget_delegate_->OnNativeWidgetVisibilityChanging(true); | 690 native_widget_delegate_->OnNativeWidgetVisibilityChanging(true); |
| 674 // Using ui::SHOW_STATE_NORMAL matches that of DesktopWindowTreeHostX11. | 691 // Using ui::SHOW_STATE_NORMAL matches that of DesktopWindowTreeHostX11. |
| 675 ShowWindowWithState(ui::SHOW_STATE_NORMAL); | 692 ShowWindowWithState(ui::SHOW_STATE_NORMAL); |
| 676 WindowTreeHostMus::ShowImpl(); | 693 WindowTreeHostMus::ShowImpl(); |
| 677 native_widget_delegate_->OnNativeWidgetVisibilityChanged(true); | 694 native_widget_delegate_->OnNativeWidgetVisibilityChanged(true); |
| 678 } | 695 } |
| 679 | 696 |
| 680 void DesktopWindowTreeHostMus::HideImpl() { | 697 void DesktopWindowTreeHostMus::HideImpl() { |
| 681 native_widget_delegate_->OnNativeWidgetVisibilityChanging(false); | 698 native_widget_delegate_->OnNativeWidgetVisibilityChanging(false); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 704 SendHitTestMaskToServer(); | 721 SendHitTestMaskToServer(); |
| 705 } | 722 } |
| 706 } | 723 } |
| 707 | 724 |
| 708 void DesktopWindowTreeHostMus::OnWindowInitialized(aura::Window* window) {} | 725 void DesktopWindowTreeHostMus::OnWindowInitialized(aura::Window* window) {} |
| 709 | 726 |
| 710 void DesktopWindowTreeHostMus::OnActiveFocusClientChanged( | 727 void DesktopWindowTreeHostMus::OnActiveFocusClientChanged( |
| 711 aura::client::FocusClient* focus_client, | 728 aura::client::FocusClient* focus_client, |
| 712 aura::Window* window) { | 729 aura::Window* window) { |
| 713 if (window == this->window()) { | 730 if (window == this->window()) { |
| 714 is_active_ = true; | |
| 715 desktop_native_widget_aura_->HandleActivationChanged(true); | 731 desktop_native_widget_aura_->HandleActivationChanged(true); |
| 716 } else if (is_active_) { | 732 } else if (is_active_) { |
| 717 is_active_ = false; | |
| 718 desktop_native_widget_aura_->HandleActivationChanged(false); | 733 desktop_native_widget_aura_->HandleActivationChanged(false); |
| 719 } | 734 } |
| 720 } | 735 } |
| 721 | 736 |
| 722 } // namespace views | 737 } // namespace views |
| OLD | NEW |