| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/native_widget_mus.h" | 5 #include "ui/views/mus/native_widget_mus.h" |
| 6 | 6 |
| 7 #include "base/macros.h" | 7 #include "base/macros.h" |
| 8 #include "base/thread_task_runner_handle.h" | 8 #include "base/thread_task_runner_handle.h" |
| 9 #include "components/mus/public/cpp/property_type_converters.h" | 9 #include "components/mus/public/cpp/property_type_converters.h" |
| 10 #include "components/mus/public/cpp/window.h" | 10 #include "components/mus/public/cpp/window.h" |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 const gfx::Rect& bounds) override { | 101 const gfx::Rect& bounds) override { |
| 102 return root_window_; | 102 return root_window_; |
| 103 } | 103 } |
| 104 | 104 |
| 105 private: | 105 private: |
| 106 aura::Window* root_window_; | 106 aura::Window* root_window_; |
| 107 | 107 |
| 108 DISALLOW_COPY_AND_ASSIGN(NativeWidgetMusWindowTreeClient); | 108 DISALLOW_COPY_AND_ASSIGN(NativeWidgetMusWindowTreeClient); |
| 109 }; | 109 }; |
| 110 | 110 |
| 111 // A screen position client that applies the offset of the mus::Window. |
| 112 class ScreenPositionClientMus : public wm::DefaultScreenPositionClient { |
| 113 public: |
| 114 explicit ScreenPositionClientMus(mus::Window* mus_window) |
| 115 : mus_window_(mus_window) {} |
| 116 ~ScreenPositionClientMus() override {} |
| 117 |
| 118 // wm::DefaultScreenPositionClient: |
| 119 void ConvertPointToScreen(const aura::Window* window, |
| 120 gfx::Point* point) override { |
| 121 wm::DefaultScreenPositionClient::ConvertPointToScreen(window, point); |
| 122 gfx::Rect mus_bounds = mus_window_->GetBoundsInRoot(); |
| 123 point->Offset(-mus_bounds.x(), -mus_bounds.y()); |
| 124 } |
| 125 void ConvertPointFromScreen(const aura::Window* window, |
| 126 gfx::Point* point) override { |
| 127 gfx::Rect mus_bounds = mus_window_->GetBoundsInRoot(); |
| 128 point->Offset(mus_bounds.x(), mus_bounds.y()); |
| 129 wm::DefaultScreenPositionClient::ConvertPointFromScreen(window, point); |
| 130 } |
| 131 // TODO(jamescook): ConvertHostPointToScreen? SetBounds? |
| 132 |
| 133 private: |
| 134 mus::Window* mus_window_; |
| 135 |
| 136 DISALLOW_COPY_AND_ASSIGN(ScreenPositionClientMus); |
| 137 }; |
| 138 |
| 111 // As the window manager renderers the non-client decorations this class does | 139 // As the window manager renderers the non-client decorations this class does |
| 112 // very little but honor the client area insets from the window manager. | 140 // very little but honor the client area insets from the window manager. |
| 113 class ClientSideNonClientFrameView : public NonClientFrameView { | 141 class ClientSideNonClientFrameView : public NonClientFrameView { |
| 114 public: | 142 public: |
| 115 explicit ClientSideNonClientFrameView(views::Widget* widget) | 143 explicit ClientSideNonClientFrameView(views::Widget* widget) |
| 116 : widget_(widget) {} | 144 : widget_(widget) {} |
| 117 ~ClientSideNonClientFrameView() override {} | 145 ~ClientSideNonClientFrameView() override {} |
| 118 | 146 |
| 119 private: | 147 private: |
| 120 // Returns the default values of client area insets from the window manager. | 148 // Returns the default values of client area insets from the window manager. |
| (...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 390 window_tree_host_->AddObserver(this); | 418 window_tree_host_->AddObserver(this); |
| 391 window_tree_host_->InitHost(); | 419 window_tree_host_->InitHost(); |
| 392 window_tree_host_->window()->SetProperty(kMusWindow, window_); | 420 window_tree_host_->window()->SetProperty(kMusWindow, window_); |
| 393 | 421 |
| 394 focus_client_.reset(new wm::FocusController(new FocusRulesImpl)); | 422 focus_client_.reset(new wm::FocusController(new FocusRulesImpl)); |
| 395 | 423 |
| 396 aura::client::SetFocusClient(window_tree_host_->window(), | 424 aura::client::SetFocusClient(window_tree_host_->window(), |
| 397 focus_client_.get()); | 425 focus_client_.get()); |
| 398 aura::client::SetActivationClient(window_tree_host_->window(), | 426 aura::client::SetActivationClient(window_tree_host_->window(), |
| 399 focus_client_.get()); | 427 focus_client_.get()); |
| 400 screen_position_client_.reset(new wm::DefaultScreenPositionClient()); | 428 screen_position_client_.reset(new ScreenPositionClientMus(window_)); |
| 401 aura::client::SetScreenPositionClient(window_tree_host_->window(), | 429 aura::client::SetScreenPositionClient(window_tree_host_->window(), |
| 402 screen_position_client_.get()); | 430 screen_position_client_.get()); |
| 403 | 431 |
| 404 window_tree_client_.reset( | 432 window_tree_client_.reset( |
| 405 new NativeWidgetMusWindowTreeClient(window_tree_host_->window())); | 433 new NativeWidgetMusWindowTreeClient(window_tree_host_->window())); |
| 406 window_tree_host_->window()->AddPreTargetHandler(focus_client_.get()); | 434 window_tree_host_->window()->AddPreTargetHandler(focus_client_.get()); |
| 407 window_tree_host_->window()->SetLayoutManager( | 435 window_tree_host_->window()->SetLayoutManager( |
| 408 new ContentWindowLayoutManager(window_tree_host_->window(), content_)); | 436 new ContentWindowLayoutManager(window_tree_host_->window(), content_)); |
| 409 capture_client_.reset( | 437 capture_client_.reset( |
| 410 new aura::client::DefaultCaptureClient(window_tree_host_->window())); | 438 new aura::client::DefaultCaptureClient(window_tree_host_->window())); |
| (...skipping 607 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1018 window_tree_host_->Show(); | 1046 window_tree_host_->Show(); |
| 1019 GetNativeWindow()->Show(); | 1047 GetNativeWindow()->Show(); |
| 1020 } else { | 1048 } else { |
| 1021 window_tree_host_->Hide(); | 1049 window_tree_host_->Hide(); |
| 1022 GetNativeWindow()->Hide(); | 1050 GetNativeWindow()->Hide(); |
| 1023 } | 1051 } |
| 1024 native_widget_delegate_->OnNativeWidgetVisibilityChanged(window->visible()); | 1052 native_widget_delegate_->OnNativeWidgetVisibilityChanged(window->visible()); |
| 1025 } | 1053 } |
| 1026 | 1054 |
| 1027 } // namespace views | 1055 } // namespace views |
| OLD | NEW |