| 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/cursor_client.h" | 9 #include "ui/aura/client/cursor_client.h" |
| 10 #include "ui/aura/client/drag_drop_client.h" | 10 #include "ui/aura/client/drag_drop_client.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 #include "ui/views/widget/widget_delegate.h" | 24 #include "ui/views/widget/widget_delegate.h" |
| 25 #include "ui/wm/core/cursor_manager.h" | 25 #include "ui/wm/core/cursor_manager.h" |
| 26 #include "ui/wm/core/native_cursor_manager.h" | 26 #include "ui/wm/core/native_cursor_manager.h" |
| 27 #include "ui/wm/core/window_util.h" | 27 #include "ui/wm/core/window_util.h" |
| 28 #include "ui/wm/public/activation_client.h" | 28 #include "ui/wm/public/activation_client.h" |
| 29 | 29 |
| 30 namespace views { | 30 namespace views { |
| 31 | 31 |
| 32 namespace { | 32 namespace { |
| 33 | 33 |
| 34 bool ShouldSetClientArea(views::Widget::InitParams::Type type) { |
| 35 using WIP = views::Widget::InitParams; |
| 36 return type == WIP::TYPE_WINDOW || type == WIP::TYPE_PANEL; |
| 37 } |
| 38 |
| 34 // As the window manager renderers the non-client decorations this class does | 39 // As the window manager renderers the non-client decorations this class does |
| 35 // very little but honor the client area insets from the window manager. | 40 // very little but honor the client area insets from the window manager. |
| 36 class ClientSideNonClientFrameView : public NonClientFrameView { | 41 class ClientSideNonClientFrameView : public NonClientFrameView { |
| 37 public: | 42 public: |
| 38 explicit ClientSideNonClientFrameView(views::Widget* widget) | 43 explicit ClientSideNonClientFrameView(views::Widget* widget) |
| 39 : widget_(widget) {} | 44 : widget_(widget) {} |
| 40 ~ClientSideNonClientFrameView() override {} | 45 ~ClientSideNonClientFrameView() override {} |
| 41 | 46 |
| 42 private: | 47 private: |
| 43 // Returns the default values of client area insets from the window manager. | 48 // Returns the default values of client area insets from the window manager. |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 aura::Env::GetInstance()->RemoveObserver(this); | 194 aura::Env::GetInstance()->RemoveObserver(this); |
| 190 desktop_native_widget_aura_->OnDesktopWindowTreeHostDestroyed(this); | 195 desktop_native_widget_aura_->OnDesktopWindowTreeHostDestroyed(this); |
| 191 } | 196 } |
| 192 | 197 |
| 193 bool DesktopWindowTreeHostMus::IsDocked() const { | 198 bool DesktopWindowTreeHostMus::IsDocked() const { |
| 194 return window()->GetProperty(aura::client::kShowStateKey) == | 199 return window()->GetProperty(aura::client::kShowStateKey) == |
| 195 ui::SHOW_STATE_DOCKED; | 200 ui::SHOW_STATE_DOCKED; |
| 196 } | 201 } |
| 197 | 202 |
| 198 void DesktopWindowTreeHostMus::SendClientAreaToServer() { | 203 void DesktopWindowTreeHostMus::SendClientAreaToServer() { |
| 204 if (!ShouldSetClientArea(desktop_native_widget_aura_->widget_type())) |
| 205 return; |
| 206 |
| 199 NonClientView* non_client_view = | 207 NonClientView* non_client_view = |
| 200 native_widget_delegate_->AsWidget()->non_client_view(); | 208 native_widget_delegate_->AsWidget()->non_client_view(); |
| 201 if (!non_client_view || !non_client_view->client_view()) | 209 if (!non_client_view || !non_client_view->client_view()) |
| 202 return; | 210 return; |
| 203 | 211 |
| 204 const gfx::Rect client_area_rect(non_client_view->client_view()->bounds()); | 212 const gfx::Rect client_area_rect(non_client_view->client_view()->bounds()); |
| 205 SetClientArea(gfx::Insets( | 213 SetClientArea(gfx::Insets( |
| 206 client_area_rect.y(), client_area_rect.x(), | 214 client_area_rect.y(), client_area_rect.x(), |
| 207 non_client_view->bounds().height() - client_area_rect.bottom(), | 215 non_client_view->bounds().height() - client_area_rect.bottom(), |
| 208 non_client_view->bounds().width() - client_area_rect.right())); | 216 non_client_view->bounds().width() - client_area_rect.right())); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 248 | 256 |
| 249 void DesktopWindowTreeHostMus::OnNativeWidgetCreated( | 257 void DesktopWindowTreeHostMus::OnNativeWidgetCreated( |
| 250 const Widget::InitParams& params) { | 258 const Widget::InitParams& params) { |
| 251 if (params.parent && params.parent->GetHost()) { | 259 if (params.parent && params.parent->GetHost()) { |
| 252 parent_ = static_cast<DesktopWindowTreeHostMus*>(params.parent->GetHost()); | 260 parent_ = static_cast<DesktopWindowTreeHostMus*>(params.parent->GetHost()); |
| 253 parent_->children_.insert(this); | 261 parent_->children_.insert(this); |
| 254 } | 262 } |
| 255 native_widget_delegate_->OnNativeWidgetCreated(true); | 263 native_widget_delegate_->OnNativeWidgetCreated(true); |
| 256 } | 264 } |
| 257 | 265 |
| 266 void DesktopWindowTreeHostMus::OnWidgetInitDone() { |
| 267 // Because of construction order it's possible the bounds have changed before |
| 268 // the NonClientView was created, which means we may not have sent the |
| 269 // client-area and hit-test-mask. |
| 270 SendClientAreaToServer(); |
| 271 SendHitTestMaskToServer(); |
| 272 } |
| 273 |
| 258 std::unique_ptr<corewm::Tooltip> DesktopWindowTreeHostMus::CreateTooltip() { | 274 std::unique_ptr<corewm::Tooltip> DesktopWindowTreeHostMus::CreateTooltip() { |
| 259 return base::MakeUnique<corewm::TooltipAura>(); | 275 return base::MakeUnique<corewm::TooltipAura>(); |
| 260 } | 276 } |
| 261 | 277 |
| 262 std::unique_ptr<aura::client::DragDropClient> | 278 std::unique_ptr<aura::client::DragDropClient> |
| 263 DesktopWindowTreeHostMus::CreateDragDropClient( | 279 DesktopWindowTreeHostMus::CreateDragDropClient( |
| 264 DesktopNativeCursorManager* cursor_manager) { | 280 DesktopNativeCursorManager* cursor_manager) { |
| 265 // aura-mus handles installing a DragDropClient. | 281 // aura-mus handles installing a DragDropClient. |
| 266 return nullptr; | 282 return nullptr; |
| 267 } | 283 } |
| (...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 530 void DesktopWindowTreeHostMus::EndMoveLoop() { | 546 void DesktopWindowTreeHostMus::EndMoveLoop() { |
| 531 NOTIMPLEMENTED(); | 547 NOTIMPLEMENTED(); |
| 532 } | 548 } |
| 533 | 549 |
| 534 void DesktopWindowTreeHostMus::SetVisibilityChangedAnimationsEnabled( | 550 void DesktopWindowTreeHostMus::SetVisibilityChangedAnimationsEnabled( |
| 535 bool value) { | 551 bool value) { |
| 536 window()->SetProperty(aura::client::kAnimationsDisabledKey, !value); | 552 window()->SetProperty(aura::client::kAnimationsDisabledKey, !value); |
| 537 } | 553 } |
| 538 | 554 |
| 539 NonClientFrameView* DesktopWindowTreeHostMus::CreateNonClientFrameView() { | 555 NonClientFrameView* DesktopWindowTreeHostMus::CreateNonClientFrameView() { |
| 556 if (!ShouldSetClientArea(desktop_native_widget_aura_->widget_type())) |
| 557 return nullptr; |
| 558 |
| 540 return new ClientSideNonClientFrameView(native_widget_delegate_->AsWidget()); | 559 return new ClientSideNonClientFrameView(native_widget_delegate_->AsWidget()); |
| 541 } | 560 } |
| 542 | 561 |
| 543 bool DesktopWindowTreeHostMus::ShouldUseNativeFrame() const { | 562 bool DesktopWindowTreeHostMus::ShouldUseNativeFrame() const { |
| 544 return false; | 563 return false; |
| 545 } | 564 } |
| 546 | 565 |
| 547 bool DesktopWindowTreeHostMus::ShouldWindowContentsBeTransparent() const { | 566 bool DesktopWindowTreeHostMus::ShouldWindowContentsBeTransparent() const { |
| 548 return false; | 567 return false; |
| 549 } | 568 } |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 670 if (window == this->window()) { | 689 if (window == this->window()) { |
| 671 is_active_ = true; | 690 is_active_ = true; |
| 672 desktop_native_widget_aura_->HandleActivationChanged(true); | 691 desktop_native_widget_aura_->HandleActivationChanged(true); |
| 673 } else if (is_active_) { | 692 } else if (is_active_) { |
| 674 is_active_ = false; | 693 is_active_ = false; |
| 675 desktop_native_widget_aura_->HandleActivationChanged(false); | 694 desktop_native_widget_aura_->HandleActivationChanged(false); |
| 676 } | 695 } |
| 677 } | 696 } |
| 678 | 697 |
| 679 } // namespace views | 698 } // namespace views |
| OLD | NEW |