Chromium Code Reviews| 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" |
| 11 #include "ui/aura/client/drag_drop_client.h" | 11 #include "ui/aura/client/drag_drop_client.h" |
| 12 #include "ui/aura/client/focus_client.h" | 12 #include "ui/aura/client/focus_client.h" |
| 13 #include "ui/aura/client/transient_window_client.h" | 13 #include "ui/aura/client/transient_window_client.h" |
| 14 #include "ui/aura/env.h" | 14 #include "ui/aura/env.h" |
| 15 #include "ui/aura/mus/window_port_mus.h" | 15 #include "ui/aura/mus/window_port_mus.h" |
| 16 #include "ui/aura/mus/window_tree_host_mus.h" | 16 #include "ui/aura/mus/window_tree_host_mus.h" |
| 17 #include "ui/aura/window.h" | 17 #include "ui/aura/window.h" |
| 18 #include "ui/base/hit_test.h" | 18 #include "ui/base/hit_test.h" |
| 19 #include "ui/display/screen.h" | 19 #include "ui/display/screen.h" |
| 20 #include "ui/gfx/geometry/dip_util.h" | 20 #include "ui/gfx/geometry/dip_util.h" |
| 21 #include "ui/views/corewm/tooltip_aura.h" | 21 #include "ui/views/corewm/tooltip_aura.h" |
| 22 #include "ui/views/mus/mus_client.h" | 22 #include "ui/views/mus/mus_client.h" |
| 23 #include "ui/views/mus/mus_property_mirror.h" | |
| 23 #include "ui/views/mus/window_manager_frame_values.h" | 24 #include "ui/views/mus/window_manager_frame_values.h" |
| 24 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h" | 25 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h" |
| 25 #include "ui/views/widget/native_widget_aura.h" | 26 #include "ui/views/widget/native_widget_aura.h" |
| 26 #include "ui/views/widget/widget_delegate.h" | 27 #include "ui/views/widget/widget_delegate.h" |
| 27 #include "ui/wm/core/cursor_manager.h" | 28 #include "ui/wm/core/cursor_manager.h" |
| 28 #include "ui/wm/core/native_cursor_manager.h" | 29 #include "ui/wm/core/native_cursor_manager.h" |
| 29 #include "ui/wm/core/window_util.h" | 30 #include "ui/wm/core/window_util.h" |
| 30 #include "ui/wm/public/activation_client.h" | 31 #include "ui/wm/public/activation_client.h" |
| 31 | 32 |
| 32 namespace views { | 33 namespace views { |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 175 DesktopNativeWidgetAura* desktop_native_widget_aura, | 176 DesktopNativeWidgetAura* desktop_native_widget_aura, |
| 176 const std::map<std::string, std::vector<uint8_t>>* mus_properties) | 177 const std::map<std::string, std::vector<uint8_t>>* mus_properties) |
| 177 : aura::WindowTreeHostMus(MusClient::Get()->window_tree_client(), | 178 : aura::WindowTreeHostMus(MusClient::Get()->window_tree_client(), |
| 178 mus_properties), | 179 mus_properties), |
| 179 native_widget_delegate_(native_widget_delegate), | 180 native_widget_delegate_(native_widget_delegate), |
| 180 desktop_native_widget_aura_(desktop_native_widget_aura), | 181 desktop_native_widget_aura_(desktop_native_widget_aura), |
| 181 close_widget_factory_(this) { | 182 close_widget_factory_(this) { |
| 182 aura::Env::GetInstance()->AddObserver(this); | 183 aura::Env::GetInstance()->AddObserver(this); |
| 183 MusClient::Get()->AddObserver(this); | 184 MusClient::Get()->AddObserver(this); |
| 184 native_widget_delegate_->AsWidget()->AddObserver(this); | 185 native_widget_delegate_->AsWidget()->AddObserver(this); |
| 186 desktop_native_widget_aura_->content_window()->AddObserver(this); | |
| 185 // DesktopNativeWidgetAura registers the association between |content_window_| | 187 // DesktopNativeWidgetAura registers the association between |content_window_| |
| 186 // and Widget, but code may also want to go from the root (window()) to the | 188 // and Widget, but code may also want to go from the root (window()) to the |
| 187 // Widget. This call enables that. | 189 // Widget. This call enables that. |
| 188 NativeWidgetAura::RegisterNativeWidgetForWindow(desktop_native_widget_aura, | 190 NativeWidgetAura::RegisterNativeWidgetForWindow(desktop_native_widget_aura, |
| 189 window()); | 191 window()); |
| 190 // TODO: use display id and bounds if available, likely need to pass in | 192 // TODO: use display id and bounds if available, likely need to pass in |
| 191 // InitParams for that. | 193 // InitParams for that. |
| 192 } | 194 } |
| 193 | 195 |
| 194 DesktopWindowTreeHostMus::~DesktopWindowTreeHostMus() { | 196 DesktopWindowTreeHostMus::~DesktopWindowTreeHostMus() { |
| 195 // The cursor-client can be accessed during WindowTreeHostMus tear-down. So | 197 // The cursor-client can be accessed during WindowTreeHostMus tear-down. So |
| 196 // the cursor-client needs to be unset on the root-window before | 198 // the cursor-client needs to be unset on the root-window before |
| 197 // |cursor_manager_| is destroyed. | 199 // |cursor_manager_| is destroyed. |
| 198 aura::client::SetCursorClient(window(), nullptr); | 200 aura::client::SetCursorClient(window(), nullptr); |
| 201 desktop_native_widget_aura_->content_window()->RemoveObserver(this); | |
| 199 native_widget_delegate_->AsWidget()->RemoveObserver(this); | 202 native_widget_delegate_->AsWidget()->RemoveObserver(this); |
| 200 MusClient::Get()->RemoveObserver(this); | 203 MusClient::Get()->RemoveObserver(this); |
| 201 aura::Env::GetInstance()->RemoveObserver(this); | 204 aura::Env::GetInstance()->RemoveObserver(this); |
| 202 desktop_native_widget_aura_->OnDesktopWindowTreeHostDestroyed(this); | 205 desktop_native_widget_aura_->OnDesktopWindowTreeHostDestroyed(this); |
| 203 } | 206 } |
| 204 | 207 |
| 205 bool DesktopWindowTreeHostMus::IsDocked() const { | 208 bool DesktopWindowTreeHostMus::IsDocked() const { |
| 206 return window()->GetProperty(aura::client::kShowStateKey) == | 209 return window()->GetProperty(aura::client::kShowStateKey) == |
| 207 ui::SHOW_STATE_DOCKED; | 210 ui::SHOW_STATE_DOCKED; |
| 208 } | 211 } |
| (...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 686 | 689 |
| 687 void DesktopWindowTreeHostMus::OnWidgetActivationChanged(Widget* widget, | 690 void DesktopWindowTreeHostMus::OnWidgetActivationChanged(Widget* widget, |
| 688 bool active) { | 691 bool active) { |
| 689 // TODO(erg): Theoretically, this shouldn't be necessary. We should be able | 692 // TODO(erg): Theoretically, this shouldn't be necessary. We should be able |
| 690 // to just set |is_active_| in OnNativeWidgetActivationChanged() above, | 693 // to just set |is_active_| in OnNativeWidgetActivationChanged() above, |
| 691 // instead of asking the Widget to change the activation and have the widget | 694 // instead of asking the Widget to change the activation and have the widget |
| 692 // then tell us the activation has changed. But if we do that, focus breaks. | 695 // then tell us the activation has changed. But if we do that, focus breaks. |
| 693 is_active_ = active; | 696 is_active_ = active; |
| 694 } | 697 } |
| 695 | 698 |
| 699 void DesktopWindowTreeHostMus::OnWindowPropertyChanged(aura::Window* window, | |
| 700 const void* key, | |
| 701 intptr_t old) { | |
| 702 DCHECK_EQ(window, desktop_native_widget_aura_->content_window()); | |
| 703 aura::Window* root_window = window->GetRootWindow(); | |
|
sky
2017/01/27 23:46:22
root_window is the same as window() in this file.
msw
2017/01/28 00:09:16
Done.
| |
| 704 if (!root_window) | |
| 705 return; | |
| 706 | |
| 707 // Allow mus clients to mirror widget window properties to their root windows. | |
| 708 MusPropertyMirror* property_mirror = MusClient::Get()->mus_property_mirror(); | |
| 709 if (property_mirror) { | |
| 710 property_mirror->MirrorPropertyFromWidgetWindowToRootWindow( | |
| 711 window, root_window, key); | |
| 712 } | |
| 713 } | |
| 714 | |
| 696 void DesktopWindowTreeHostMus::ShowImpl() { | 715 void DesktopWindowTreeHostMus::ShowImpl() { |
| 697 native_widget_delegate_->OnNativeWidgetVisibilityChanging(true); | 716 native_widget_delegate_->OnNativeWidgetVisibilityChanging(true); |
| 698 // Using ui::SHOW_STATE_NORMAL matches that of DesktopWindowTreeHostX11. | 717 // Using ui::SHOW_STATE_NORMAL matches that of DesktopWindowTreeHostX11. |
| 699 ShowWindowWithState(ui::SHOW_STATE_NORMAL); | 718 ShowWindowWithState(ui::SHOW_STATE_NORMAL); |
| 700 WindowTreeHostMus::ShowImpl(); | 719 WindowTreeHostMus::ShowImpl(); |
| 701 native_widget_delegate_->OnNativeWidgetVisibilityChanged(true); | 720 native_widget_delegate_->OnNativeWidgetVisibilityChanged(true); |
| 702 } | 721 } |
| 703 | 722 |
| 704 void DesktopWindowTreeHostMus::HideImpl() { | 723 void DesktopWindowTreeHostMus::HideImpl() { |
| 705 native_widget_delegate_->OnNativeWidgetVisibilityChanging(false); | 724 native_widget_delegate_->OnNativeWidgetVisibilityChanging(false); |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 735 aura::client::FocusClient* focus_client, | 754 aura::client::FocusClient* focus_client, |
| 736 aura::Window* window) { | 755 aura::Window* window) { |
| 737 if (window == this->window()) { | 756 if (window == this->window()) { |
| 738 desktop_native_widget_aura_->HandleActivationChanged(true); | 757 desktop_native_widget_aura_->HandleActivationChanged(true); |
| 739 } else if (is_active_) { | 758 } else if (is_active_) { |
| 740 desktop_native_widget_aura_->HandleActivationChanged(false); | 759 desktop_native_widget_aura_->HandleActivationChanged(false); |
| 741 } | 760 } |
| 742 } | 761 } |
| 743 | 762 |
| 744 } // namespace views | 763 } // namespace views |
| OLD | NEW |