| 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 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 // TODO: use display id and bounds if available, likely need to pass in | 123 // TODO: use display id and bounds if available, likely need to pass in |
| 124 // InitParams for that. | 124 // InitParams for that. |
| 125 } | 125 } |
| 126 | 126 |
| 127 DesktopWindowTreeHostMus::~DesktopWindowTreeHostMus() { | 127 DesktopWindowTreeHostMus::~DesktopWindowTreeHostMus() { |
| 128 MusClient::Get()->RemoveObserver(this); | 128 MusClient::Get()->RemoveObserver(this); |
| 129 aura::Env::GetInstance()->RemoveObserver(this); | 129 aura::Env::GetInstance()->RemoveObserver(this); |
| 130 desktop_native_widget_aura_->OnDesktopWindowTreeHostDestroyed(this); | 130 desktop_native_widget_aura_->OnDesktopWindowTreeHostDestroyed(this); |
| 131 } | 131 } |
| 132 | 132 |
| 133 // static | |
| 134 int DesktopWindowTreeHostMus::GetResizeBehaviorFromDelegate( | |
| 135 WidgetDelegate* delegate) { | |
| 136 if (!delegate) | |
| 137 return ui::mojom::kResizeBehaviorNone; | |
| 138 | |
| 139 int32_t behavior = ui::mojom::kResizeBehaviorNone; | |
| 140 if (delegate->CanResize()) | |
| 141 behavior |= ui::mojom::kResizeBehaviorCanResize; | |
| 142 if (delegate->CanMaximize()) | |
| 143 behavior |= ui::mojom::kResizeBehaviorCanMaximize; | |
| 144 if (delegate->CanMinimize()) | |
| 145 behavior |= ui::mojom::kResizeBehaviorCanMinimize; | |
| 146 return behavior; | |
| 147 } | |
| 148 | |
| 149 bool DesktopWindowTreeHostMus::IsDocked() const { | 133 bool DesktopWindowTreeHostMus::IsDocked() const { |
| 150 return window()->GetProperty(aura::client::kShowStateKey) == | 134 return window()->GetProperty(aura::client::kShowStateKey) == |
| 151 ui::SHOW_STATE_DOCKED; | 135 ui::SHOW_STATE_DOCKED; |
| 152 } | 136 } |
| 153 | 137 |
| 154 // TODO(erg): In addition to being called on system events, this also needs to | 138 // TODO(erg): In addition to being called on system events, this also needs to |
| 155 // be called after window size changed. | 139 // be called after window size changed. |
| 156 void DesktopWindowTreeHostMus::SendClientAreaToServer() { | 140 void DesktopWindowTreeHostMus::SendClientAreaToServer() { |
| 157 NonClientView* non_client_view = | 141 NonClientView* non_client_view = |
| 158 native_widget_delegate_->AsWidget()->non_client_view(); | 142 native_widget_delegate_->AsWidget()->non_client_view(); |
| (...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 543 | 527 |
| 544 bool DesktopWindowTreeHostMus::IsAnimatingClosed() const { | 528 bool DesktopWindowTreeHostMus::IsAnimatingClosed() const { |
| 545 return false; | 529 return false; |
| 546 } | 530 } |
| 547 | 531 |
| 548 bool DesktopWindowTreeHostMus::IsTranslucentWindowOpacitySupported() const { | 532 bool DesktopWindowTreeHostMus::IsTranslucentWindowOpacitySupported() const { |
| 549 return true; | 533 return true; |
| 550 } | 534 } |
| 551 | 535 |
| 552 void DesktopWindowTreeHostMus::SizeConstraintsChanged() { | 536 void DesktopWindowTreeHostMus::SizeConstraintsChanged() { |
| 537 int32_t behavior = ui::mojom::kResizeBehaviorNone; |
| 553 Widget* widget = native_widget_delegate_->AsWidget(); | 538 Widget* widget = native_widget_delegate_->AsWidget(); |
| 554 window()->SetProperty(aura::client::kCanMaximizeKey, | 539 if (widget->widget_delegate()) |
| 555 widget->widget_delegate()->CanMaximize()); | 540 behavior = widget->widget_delegate()->GetResizeBehavior(); |
| 556 window()->SetProperty(aura::client::kCanMinimizeKey, | 541 window()->SetProperty(aura::client::kResizeBehaviorKey, behavior); |
| 557 widget->widget_delegate()->CanMinimize()); | |
| 558 window()->SetProperty(aura::client::kCanResizeKey, | |
| 559 widget->widget_delegate()->CanResize()); | |
| 560 // TODO: replace above keys with kResizeBehaviorKey. http://crbug.com/669290. | |
| 561 window()->SetProperty( | |
| 562 aura::client::kResizeBehaviorKey, | |
| 563 GetResizeBehaviorFromDelegate(widget->widget_delegate())); | |
| 564 } | 542 } |
| 565 | 543 |
| 566 void DesktopWindowTreeHostMus::OnWindowManagerFrameValuesChanged() { | 544 void DesktopWindowTreeHostMus::OnWindowManagerFrameValuesChanged() { |
| 567 NonClientView* non_client_view = | 545 NonClientView* non_client_view = |
| 568 native_widget_delegate_->AsWidget()->non_client_view(); | 546 native_widget_delegate_->AsWidget()->non_client_view(); |
| 569 if (non_client_view) { | 547 if (non_client_view) { |
| 570 non_client_view->Layout(); | 548 non_client_view->Layout(); |
| 571 non_client_view->SchedulePaint(); | 549 non_client_view->SchedulePaint(); |
| 572 } | 550 } |
| 573 | 551 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 613 if (window == this->window()) { | 591 if (window == this->window()) { |
| 614 is_active_ = true; | 592 is_active_ = true; |
| 615 desktop_native_widget_aura_->HandleActivationChanged(true); | 593 desktop_native_widget_aura_->HandleActivationChanged(true); |
| 616 } else if (is_active_) { | 594 } else if (is_active_) { |
| 617 is_active_ = false; | 595 is_active_ = false; |
| 618 desktop_native_widget_aura_->HandleActivationChanged(false); | 596 desktop_native_widget_aura_->HandleActivationChanged(false); |
| 619 } | 597 } |
| 620 } | 598 } |
| 621 | 599 |
| 622 } // namespace views | 600 } // namespace views |
| OLD | NEW |