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 "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. |
|
msw
2016/11/08 23:38:27
optional nit: cite a bug? ditto on line 387
sky
2016/11/09 00:06:01
Done.
| |
| 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 *bounds = GetRestoredBounds(); |
|
msw
2016/11/08 23:38:27
q: Why restored bounds? maybe comment?
sky
2016/11/09 00:06:01
Done.
| |
| 148 *show_state = window()->GetProperty(aura::client::kShowStateKey); | |
| 146 } | 149 } |
| 150 | |
| 147 gfx::Rect DesktopWindowTreeHostMus::GetWindowBoundsInScreen() const { | 151 gfx::Rect DesktopWindowTreeHostMus::GetWindowBoundsInScreen() const { |
| 148 // TODO: convert to dips. | 152 // TODO: convert to dips. |
| 149 return GetBounds(); | 153 return GetBounds(); |
| 150 } | 154 } |
| 151 | 155 |
| 152 gfx::Rect DesktopWindowTreeHostMus::GetClientAreaBoundsInScreen() const { | 156 gfx::Rect DesktopWindowTreeHostMus::GetClientAreaBoundsInScreen() const { |
| 153 // View-to-screen coordinate system transformations depend on this returning | 157 // View-to-screen coordinate system transformations depend on this returning |
| 154 // the full window bounds, for example View::ConvertPointToScreen(). | 158 // the full window bounds, for example View::ConvertPointToScreen(). |
| 155 return GetWindowBoundsInScreen(); | 159 return GetWindowBoundsInScreen(); |
| 156 } | 160 } |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 359 void DesktopWindowTreeHostMus::SizeConstraintsChanged() { | 363 void DesktopWindowTreeHostMus::SizeConstraintsChanged() { |
| 360 Widget* widget = native_widget_delegate_->AsWidget(); | 364 Widget* widget = native_widget_delegate_->AsWidget(); |
| 361 window()->SetProperty(aura::client::kCanMaximizeKey, | 365 window()->SetProperty(aura::client::kCanMaximizeKey, |
| 362 widget->widget_delegate()->CanMaximize()); | 366 widget->widget_delegate()->CanMaximize()); |
| 363 window()->SetProperty(aura::client::kCanMinimizeKey, | 367 window()->SetProperty(aura::client::kCanMinimizeKey, |
| 364 widget->widget_delegate()->CanMinimize()); | 368 widget->widget_delegate()->CanMinimize()); |
| 365 window()->SetProperty(aura::client::kCanResizeKey, | 369 window()->SetProperty(aura::client::kCanResizeKey, |
| 366 widget->widget_delegate()->CanResize()); | 370 widget->widget_delegate()->CanResize()); |
| 367 } | 371 } |
| 368 | 372 |
| 373 void DesktopWindowTreeHostMus::ShowImpl() { | |
| 374 native_widget_delegate_->OnNativeWidgetVisibilityChanging(true); | |
| 375 ShowWindowWithState(ui::SHOW_STATE_NORMAL); | |
|
msw
2016/11/08 23:38:27
q: Should this ever be showing with the prior stat
sky
2016/11/09 00:06:01
This matches that of DesktopWindowTreeHostX11. I a
| |
| 376 WindowTreeHostMus::ShowImpl(); | |
| 377 native_widget_delegate_->OnNativeWidgetVisibilityChanged(true); | |
| 378 } | |
| 379 | |
| 380 void DesktopWindowTreeHostMus::HideImpl() { | |
| 381 native_widget_delegate_->OnNativeWidgetVisibilityChanging(false); | |
| 382 WindowTreeHostMus::HideImpl(); | |
| 383 native_widget_delegate_->OnNativeWidgetVisibilityChanged(false); | |
| 384 } | |
| 385 | |
| 386 void DesktopWindowTreeHostMus::SetBounds(const gfx::Rect& bounds_in_pixels) { | |
| 387 // TODO: device scale. | |
| 388 gfx::Rect final_bounds_in_pixels = bounds_in_pixels; | |
| 389 if (GetBounds().size() != bounds_in_pixels.size()) { | |
| 390 gfx::Size size = bounds_in_pixels.size(); | |
| 391 size.SetToMax(native_widget_delegate_->GetMinimumSize()); | |
| 392 const gfx::Size max_size = native_widget_delegate_->GetMaximumSize(); | |
| 393 if (!max_size.IsEmpty()) | |
| 394 size.SetToMin(max_size); | |
| 395 final_bounds_in_pixels.set_size(size); | |
| 396 } | |
| 397 WindowTreeHostPlatform::SetBounds(final_bounds_in_pixels); | |
| 398 } | |
| 399 | |
| 369 void DesktopWindowTreeHostMus::OnWindowInitialized(aura::Window* window) {} | 400 void DesktopWindowTreeHostMus::OnWindowInitialized(aura::Window* window) {} |
| 370 | 401 |
| 371 void DesktopWindowTreeHostMus::OnActiveFocusClientChanged( | 402 void DesktopWindowTreeHostMus::OnActiveFocusClientChanged( |
| 372 aura::client::FocusClient* focus_client, | 403 aura::client::FocusClient* focus_client, |
| 373 aura::Window* window) { | 404 aura::Window* window) { |
| 374 if (window == this->window()) { | 405 if (window == this->window()) { |
| 375 is_active_ = true; | 406 is_active_ = true; |
| 376 desktop_native_widget_aura_->HandleActivationChanged(true); | 407 desktop_native_widget_aura_->HandleActivationChanged(true); |
| 377 } else if (is_active_) { | 408 } else if (is_active_) { |
| 378 is_active_ = false; | 409 is_active_ = false; |
| 379 desktop_native_widget_aura_->HandleActivationChanged(false); | 410 desktop_native_widget_aura_->HandleActivationChanged(false); |
| 380 } | 411 } |
| 381 } | 412 } |
| 382 | 413 |
| 383 } // namespace views | 414 } // namespace views |
| OLD | NEW |