| 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" |
| 11 #include "ui/aura/env.h" | |
| 12 #include "ui/aura/mus/window_tree_host_mus.h" | 11 #include "ui/aura/mus/window_tree_host_mus.h" |
| 13 #include "ui/aura/window.h" | 12 #include "ui/aura/window.h" |
| 14 #include "ui/display/screen.h" | 13 #include "ui/display/screen.h" |
| 15 #include "ui/views/corewm/tooltip_aura.h" | 14 #include "ui/views/corewm/tooltip_aura.h" |
| 16 #include "ui/views/mus/mus_client.h" | 15 #include "ui/views/mus/mus_client.h" |
| 17 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h" | 16 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h" |
| 18 #include "ui/views/widget/native_widget_aura.h" | 17 #include "ui/views/widget/native_widget_aura.h" |
| 19 #include "ui/views/widget/widget_delegate.h" | 18 #include "ui/views/widget/widget_delegate.h" |
| 20 #include "ui/wm/core/window_util.h" | 19 #include "ui/wm/core/window_util.h" |
| 21 #include "ui/wm/public/activation_client.h" | 20 #include "ui/wm/public/activation_client.h" |
| 22 | 21 |
| 23 namespace views { | 22 namespace views { |
| 24 | 23 |
| 25 DesktopWindowTreeHostMus::DesktopWindowTreeHostMus( | 24 DesktopWindowTreeHostMus::DesktopWindowTreeHostMus( |
| 26 internal::NativeWidgetDelegate* native_widget_delegate, | 25 internal::NativeWidgetDelegate* native_widget_delegate, |
| 27 DesktopNativeWidgetAura* desktop_native_widget_aura) | 26 DesktopNativeWidgetAura* desktop_native_widget_aura) |
| 28 : aura::WindowTreeHostMus(MusClient::Get()->window_tree_client()), | 27 : aura::WindowTreeHostMus(MusClient::Get()->window_tree_client()), |
| 29 native_widget_delegate_(native_widget_delegate), | 28 native_widget_delegate_(native_widget_delegate), |
| 30 desktop_native_widget_aura_(desktop_native_widget_aura), | 29 desktop_native_widget_aura_(desktop_native_widget_aura), |
| 31 fullscreen_restore_state_(ui::SHOW_STATE_DEFAULT), | 30 fullscreen_restore_state_(ui::SHOW_STATE_DEFAULT), |
| 32 close_widget_factory_(this) { | 31 close_widget_factory_(this) { |
| 33 aura::Env::GetInstance()->AddObserver(this); | |
| 34 // TODO: use display id and bounds if available, likely need to pass in | 32 // TODO: use display id and bounds if available, likely need to pass in |
| 35 // InitParams for that. | 33 // InitParams for that. |
| 36 } | 34 } |
| 37 | 35 |
| 38 DesktopWindowTreeHostMus::~DesktopWindowTreeHostMus() { | 36 DesktopWindowTreeHostMus::~DesktopWindowTreeHostMus() { |
| 39 aura::Env::GetInstance()->RemoveObserver(this); | |
| 40 desktop_native_widget_aura_->OnDesktopWindowTreeHostDestroyed(this); | 37 desktop_native_widget_aura_->OnDesktopWindowTreeHostDestroyed(this); |
| 41 } | 38 } |
| 42 | 39 |
| 43 bool DesktopWindowTreeHostMus::IsDocked() const { | 40 bool DesktopWindowTreeHostMus::IsDocked() const { |
| 44 return window()->GetProperty(aura::client::kShowStateKey) == | 41 return window()->GetProperty(aura::client::kShowStateKey) == |
| 45 ui::SHOW_STATE_DOCKED; | 42 ui::SHOW_STATE_DOCKED; |
| 46 } | 43 } |
| 47 | 44 |
| 48 void DesktopWindowTreeHostMus::Init(aura::Window* content_window, | 45 void DesktopWindowTreeHostMus::Init(aura::Window* content_window, |
| 49 const Widget::InitParams& params) {} | 46 const Widget::InitParams& params) {} |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 ->GetDisplayNearestWindow(const_cast<aura::Window*>(window())) | 192 ->GetDisplayNearestWindow(const_cast<aura::Window*>(window())) |
| 196 .work_area(); | 193 .work_area(); |
| 197 } | 194 } |
| 198 | 195 |
| 199 void DesktopWindowTreeHostMus::SetShape( | 196 void DesktopWindowTreeHostMus::SetShape( |
| 200 std::unique_ptr<SkRegion> native_region) { | 197 std::unique_ptr<SkRegion> native_region) { |
| 201 NOTIMPLEMENTED(); | 198 NOTIMPLEMENTED(); |
| 202 } | 199 } |
| 203 | 200 |
| 204 void DesktopWindowTreeHostMus::Activate() { | 201 void DesktopWindowTreeHostMus::Activate() { |
| 205 aura::Env::GetInstance()->SetActiveFocusClient( | 202 window()->Focus(); |
| 206 aura::client::GetFocusClient(window()), window()); | 203 if (window()->GetProperty(aura::client::kDrawAttentionKey)) |
| 207 if (is_active_) { | 204 window()->SetProperty(aura::client::kDrawAttentionKey, false); |
| 208 window()->Focus(); | |
| 209 if (window()->GetProperty(aura::client::kDrawAttentionKey)) | |
| 210 window()->SetProperty(aura::client::kDrawAttentionKey, false); | |
| 211 } | |
| 212 } | 205 } |
| 213 | 206 |
| 214 void DesktopWindowTreeHostMus::Deactivate() { | 207 void DesktopWindowTreeHostMus::Deactivate() { |
| 215 // TODO: Deactivate() means focus next window, that needs to go to mus. | 208 aura::client::GetActivationClient(window()->GetRootWindow()) |
| 216 NOTIMPLEMENTED(); | 209 ->DeactivateWindow(window()); |
| 217 } | 210 } |
| 218 | 211 |
| 219 bool DesktopWindowTreeHostMus::IsActive() const { | 212 bool DesktopWindowTreeHostMus::IsActive() const { |
| 220 return is_active_; | 213 return wm::IsActiveWindow(const_cast<aura::Window*>(window())); |
| 221 } | 214 } |
| 222 | 215 |
| 223 void DesktopWindowTreeHostMus::Maximize() { | 216 void DesktopWindowTreeHostMus::Maximize() { |
| 224 window()->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); | 217 window()->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); |
| 225 } | 218 } |
| 226 void DesktopWindowTreeHostMus::Minimize() { | 219 void DesktopWindowTreeHostMus::Minimize() { |
| 227 window()->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MINIMIZED); | 220 window()->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MINIMIZED); |
| 228 } | 221 } |
| 229 | 222 |
| 230 void DesktopWindowTreeHostMus::Restore() { | 223 void DesktopWindowTreeHostMus::Restore() { |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 353 void DesktopWindowTreeHostMus::SizeConstraintsChanged() { | 346 void DesktopWindowTreeHostMus::SizeConstraintsChanged() { |
| 354 Widget* widget = native_widget_delegate_->AsWidget(); | 347 Widget* widget = native_widget_delegate_->AsWidget(); |
| 355 window()->SetProperty(aura::client::kCanMaximizeKey, | 348 window()->SetProperty(aura::client::kCanMaximizeKey, |
| 356 widget->widget_delegate()->CanMaximize()); | 349 widget->widget_delegate()->CanMaximize()); |
| 357 window()->SetProperty(aura::client::kCanMinimizeKey, | 350 window()->SetProperty(aura::client::kCanMinimizeKey, |
| 358 widget->widget_delegate()->CanMinimize()); | 351 widget->widget_delegate()->CanMinimize()); |
| 359 window()->SetProperty(aura::client::kCanResizeKey, | 352 window()->SetProperty(aura::client::kCanResizeKey, |
| 360 widget->widget_delegate()->CanResize()); | 353 widget->widget_delegate()->CanResize()); |
| 361 } | 354 } |
| 362 | 355 |
| 363 void DesktopWindowTreeHostMus::OnWindowInitialized(aura::Window* window) {} | |
| 364 | |
| 365 void DesktopWindowTreeHostMus::OnActiveFocusClientChanged( | |
| 366 aura::client::FocusClient* focus_client, | |
| 367 aura::Window* window) { | |
| 368 if (window == this->window()) { | |
| 369 is_active_ = true; | |
| 370 desktop_native_widget_aura_->HandleActivationChanged(true); | |
| 371 } else if (is_active_) { | |
| 372 is_active_ = false; | |
| 373 desktop_native_widget_aura_->HandleActivationChanged(false); | |
| 374 } | |
| 375 } | |
| 376 | |
| 377 } // namespace views | 356 } // namespace views |
| OLD | NEW |