| 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 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 window()->SetProperty(aura::client::kRestoreBoundsKey, | 118 window()->SetProperty(aura::client::kRestoreBoundsKey, |
| 119 new gfx::Rect(restored_bounds)); | 119 new gfx::Rect(restored_bounds)); |
| 120 ShowWindowWithState(ui::SHOW_STATE_MAXIMIZED); | 120 ShowWindowWithState(ui::SHOW_STATE_MAXIMIZED); |
| 121 } | 121 } |
| 122 | 122 |
| 123 bool DesktopWindowTreeHostMus::IsVisible() const { | 123 bool DesktopWindowTreeHostMus::IsVisible() const { |
| 124 return window()->IsVisible(); | 124 return window()->IsVisible(); |
| 125 } | 125 } |
| 126 | 126 |
| 127 void DesktopWindowTreeHostMus::SetSize(const gfx::Size& size) { | 127 void DesktopWindowTreeHostMus::SetSize(const gfx::Size& size) { |
| 128 window()->SetBounds(gfx::Rect(window()->bounds().origin(), size)); | 128 // TODO: handle device scale, http://crbug.com/663524. |
| 129 SetBounds(gfx::Rect(window()->bounds().origin(), size)); |
| 129 } | 130 } |
| 130 | 131 |
| 131 void DesktopWindowTreeHostMus::StackAbove(aura::Window* window) { | 132 void DesktopWindowTreeHostMus::StackAbove(aura::Window* window) { |
| 132 NOTIMPLEMENTED(); | 133 NOTIMPLEMENTED(); |
| 133 } | 134 } |
| 134 | 135 |
| 135 void DesktopWindowTreeHostMus::StackAtTop() { | 136 void DesktopWindowTreeHostMus::StackAtTop() { |
| 136 NOTIMPLEMENTED(); | 137 NOTIMPLEMENTED(); |
| 137 } | 138 } |
| 138 | 139 |
| 139 void DesktopWindowTreeHostMus::CenterWindow(const gfx::Size& size) { | 140 void DesktopWindowTreeHostMus::CenterWindow(const gfx::Size& size) { |
| 140 NOTIMPLEMENTED(); | 141 NOTIMPLEMENTED(); |
| 141 } | 142 } |
| 143 |
| 142 void DesktopWindowTreeHostMus::GetWindowPlacement( | 144 void DesktopWindowTreeHostMus::GetWindowPlacement( |
| 143 gfx::Rect* bounds, | 145 gfx::Rect* bounds, |
| 144 ui::WindowShowState* show_state) const { | 146 ui::WindowShowState* show_state) const { |
| 145 NOTIMPLEMENTED(); | 147 // Implementation matches that of NativeWidgetAura. |
| 148 *bounds = GetRestoredBounds(); |
| 149 *show_state = window()->GetProperty(aura::client::kShowStateKey); |
| 146 } | 150 } |
| 151 |
| 147 gfx::Rect DesktopWindowTreeHostMus::GetWindowBoundsInScreen() const { | 152 gfx::Rect DesktopWindowTreeHostMus::GetWindowBoundsInScreen() const { |
| 148 // TODO: convert to dips. | 153 // TODO: convert to dips, http://crbug.com/663524. |
| 149 return GetBounds(); | 154 return GetBounds(); |
| 150 } | 155 } |
| 151 | 156 |
| 152 gfx::Rect DesktopWindowTreeHostMus::GetClientAreaBoundsInScreen() const { | 157 gfx::Rect DesktopWindowTreeHostMus::GetClientAreaBoundsInScreen() const { |
| 153 // View-to-screen coordinate system transformations depend on this returning | 158 // View-to-screen coordinate system transformations depend on this returning |
| 154 // the full window bounds, for example View::ConvertPointToScreen(). | 159 // the full window bounds, for example View::ConvertPointToScreen(). |
| 155 return GetWindowBoundsInScreen(); | 160 return GetWindowBoundsInScreen(); |
| 156 } | 161 } |
| 157 | 162 |
| 158 gfx::Rect DesktopWindowTreeHostMus::GetRestoredBounds() const { | 163 gfx::Rect DesktopWindowTreeHostMus::GetRestoredBounds() const { |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 359 void DesktopWindowTreeHostMus::SizeConstraintsChanged() { | 364 void DesktopWindowTreeHostMus::SizeConstraintsChanged() { |
| 360 Widget* widget = native_widget_delegate_->AsWidget(); | 365 Widget* widget = native_widget_delegate_->AsWidget(); |
| 361 window()->SetProperty(aura::client::kCanMaximizeKey, | 366 window()->SetProperty(aura::client::kCanMaximizeKey, |
| 362 widget->widget_delegate()->CanMaximize()); | 367 widget->widget_delegate()->CanMaximize()); |
| 363 window()->SetProperty(aura::client::kCanMinimizeKey, | 368 window()->SetProperty(aura::client::kCanMinimizeKey, |
| 364 widget->widget_delegate()->CanMinimize()); | 369 widget->widget_delegate()->CanMinimize()); |
| 365 window()->SetProperty(aura::client::kCanResizeKey, | 370 window()->SetProperty(aura::client::kCanResizeKey, |
| 366 widget->widget_delegate()->CanResize()); | 371 widget->widget_delegate()->CanResize()); |
| 367 } | 372 } |
| 368 | 373 |
| 374 void DesktopWindowTreeHostMus::ShowImpl() { |
| 375 native_widget_delegate_->OnNativeWidgetVisibilityChanging(true); |
| 376 // Using ui::SHOW_STATE_NORMAL matches that of DesktopWindowTreeHostX11. |
| 377 ShowWindowWithState(ui::SHOW_STATE_NORMAL); |
| 378 WindowTreeHostMus::ShowImpl(); |
| 379 native_widget_delegate_->OnNativeWidgetVisibilityChanged(true); |
| 380 } |
| 381 |
| 382 void DesktopWindowTreeHostMus::HideImpl() { |
| 383 native_widget_delegate_->OnNativeWidgetVisibilityChanging(false); |
| 384 WindowTreeHostMus::HideImpl(); |
| 385 native_widget_delegate_->OnNativeWidgetVisibilityChanged(false); |
| 386 } |
| 387 |
| 388 void DesktopWindowTreeHostMus::SetBounds(const gfx::Rect& bounds_in_pixels) { |
| 389 // TODO: handle conversion to dips, http://crbug.com/663524. |
| 390 gfx::Rect final_bounds_in_pixels = bounds_in_pixels; |
| 391 if (GetBounds().size() != bounds_in_pixels.size()) { |
| 392 gfx::Size size = bounds_in_pixels.size(); |
| 393 size.SetToMax(native_widget_delegate_->GetMinimumSize()); |
| 394 const gfx::Size max_size = native_widget_delegate_->GetMaximumSize(); |
| 395 if (!max_size.IsEmpty()) |
| 396 size.SetToMin(max_size); |
| 397 final_bounds_in_pixels.set_size(size); |
| 398 } |
| 399 WindowTreeHostPlatform::SetBounds(final_bounds_in_pixels); |
| 400 } |
| 401 |
| 369 void DesktopWindowTreeHostMus::OnWindowInitialized(aura::Window* window) {} | 402 void DesktopWindowTreeHostMus::OnWindowInitialized(aura::Window* window) {} |
| 370 | 403 |
| 371 void DesktopWindowTreeHostMus::OnActiveFocusClientChanged( | 404 void DesktopWindowTreeHostMus::OnActiveFocusClientChanged( |
| 372 aura::client::FocusClient* focus_client, | 405 aura::client::FocusClient* focus_client, |
| 373 aura::Window* window) { | 406 aura::Window* window) { |
| 374 if (window == this->window()) { | 407 if (window == this->window()) { |
| 375 is_active_ = true; | 408 is_active_ = true; |
| 376 desktop_native_widget_aura_->HandleActivationChanged(true); | 409 desktop_native_widget_aura_->HandleActivationChanged(true); |
| 377 } else if (is_active_) { | 410 } else if (is_active_) { |
| 378 is_active_ = false; | 411 is_active_ = false; |
| 379 desktop_native_widget_aura_->HandleActivationChanged(false); | 412 desktop_native_widget_aura_->HandleActivationChanged(false); |
| 380 } | 413 } |
| 381 } | 414 } |
| 382 | 415 |
| 383 } // namespace views | 416 } // namespace views |
| OLD | NEW |