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 |
| 132 private: |
| 133 mus::Window* mus_window_; |
| 134 |
| 135 DISALLOW_COPY_AND_ASSIGN(ScreenPositionClientMus); |
| 136 }; |
| 137 |
111 // As the window manager renderers the non-client decorations this class does | 138 // 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. | 139 // very little but honor the client area insets from the window manager. |
113 class ClientSideNonClientFrameView : public NonClientFrameView { | 140 class ClientSideNonClientFrameView : public NonClientFrameView { |
114 public: | 141 public: |
115 explicit ClientSideNonClientFrameView(views::Widget* widget) | 142 explicit ClientSideNonClientFrameView(views::Widget* widget) |
116 : widget_(widget) {} | 143 : widget_(widget) {} |
117 ~ClientSideNonClientFrameView() override {} | 144 ~ClientSideNonClientFrameView() override {} |
118 | 145 |
119 private: | 146 private: |
120 // Returns the default values of client area insets from the window manager. | 147 // 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); | 417 window_tree_host_->AddObserver(this); |
391 window_tree_host_->InitHost(); | 418 window_tree_host_->InitHost(); |
392 window_tree_host_->window()->SetProperty(kMusWindow, window_); | 419 window_tree_host_->window()->SetProperty(kMusWindow, window_); |
393 | 420 |
394 focus_client_.reset(new wm::FocusController(new FocusRulesImpl)); | 421 focus_client_.reset(new wm::FocusController(new FocusRulesImpl)); |
395 | 422 |
396 aura::client::SetFocusClient(window_tree_host_->window(), | 423 aura::client::SetFocusClient(window_tree_host_->window(), |
397 focus_client_.get()); | 424 focus_client_.get()); |
398 aura::client::SetActivationClient(window_tree_host_->window(), | 425 aura::client::SetActivationClient(window_tree_host_->window(), |
399 focus_client_.get()); | 426 focus_client_.get()); |
400 screen_position_client_.reset(new wm::DefaultScreenPositionClient()); | 427 screen_position_client_.reset(new ScreenPositionClientMus(window_)); |
401 aura::client::SetScreenPositionClient(window_tree_host_->window(), | 428 aura::client::SetScreenPositionClient(window_tree_host_->window(), |
402 screen_position_client_.get()); | 429 screen_position_client_.get()); |
403 | 430 |
404 window_tree_client_.reset( | 431 window_tree_client_.reset( |
405 new NativeWidgetMusWindowTreeClient(window_tree_host_->window())); | 432 new NativeWidgetMusWindowTreeClient(window_tree_host_->window())); |
406 window_tree_host_->window()->AddPreTargetHandler(focus_client_.get()); | 433 window_tree_host_->window()->AddPreTargetHandler(focus_client_.get()); |
407 window_tree_host_->window()->SetLayoutManager( | 434 window_tree_host_->window()->SetLayoutManager( |
408 new ContentWindowLayoutManager(window_tree_host_->window(), content_)); | 435 new ContentWindowLayoutManager(window_tree_host_->window(), content_)); |
409 capture_client_.reset( | 436 capture_client_.reset( |
410 new aura::client::DefaultCaptureClient(window_tree_host_->window())); | 437 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(); | 1045 window_tree_host_->Show(); |
1019 GetNativeWindow()->Show(); | 1046 GetNativeWindow()->Show(); |
1020 } else { | 1047 } else { |
1021 window_tree_host_->Hide(); | 1048 window_tree_host_->Hide(); |
1022 GetNativeWindow()->Hide(); | 1049 GetNativeWindow()->Hide(); |
1023 } | 1050 } |
1024 native_widget_delegate_->OnNativeWidgetVisibilityChanged(window->visible()); | 1051 native_widget_delegate_->OnNativeWidgetVisibilityChanged(window->visible()); |
1025 } | 1052 } |
1026 | 1053 |
1027 } // namespace views | 1054 } // namespace views |
OLD | NEW |