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 "components/mus/public/cpp/property_type_converters.h" | 7 #include "components/mus/public/cpp/property_type_converters.h" |
8 #include "components/mus/public/cpp/window.h" | 8 #include "components/mus/public/cpp/window.h" |
9 #include "mojo/converters/geometry/geometry_type_converters.h" | 9 #include "mojo/converters/geometry/geometry_type_converters.h" |
10 #include "ui/aura/client/default_capture_client.h" | 10 #include "ui/aura/client/default_capture_client.h" |
| 11 #include "ui/aura/client/window_tree_client.h" |
11 #include "ui/aura/layout_manager.h" | 12 #include "ui/aura/layout_manager.h" |
12 #include "ui/aura/window.h" | 13 #include "ui/aura/window.h" |
13 #include "ui/base/hit_test.h" | 14 #include "ui/base/hit_test.h" |
14 #include "ui/compositor/clip_transform_recorder.h" | 15 #include "ui/compositor/clip_transform_recorder.h" |
15 #include "ui/compositor/paint_recorder.h" | 16 #include "ui/compositor/paint_recorder.h" |
16 #include "ui/gfx/canvas.h" | 17 #include "ui/gfx/canvas.h" |
17 #include "ui/native_theme/native_theme_aura.h" | 18 #include "ui/native_theme/native_theme_aura.h" |
18 #include "ui/views/mus/window_manager_client_area_insets.h" | 19 #include "ui/views/mus/window_manager_client_area_insets.h" |
19 #include "ui/views/mus/window_tree_host_mus.h" | 20 #include "ui/views/mus/window_tree_host_mus.h" |
20 #include "ui/views/widget/widget_delegate.h" | 21 #include "ui/views/widget/widget_delegate.h" |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 const gfx::Rect& requested_bounds) override { | 63 const gfx::Rect& requested_bounds) override { |
63 SetChildBoundsDirect(child, requested_bounds); | 64 SetChildBoundsDirect(child, requested_bounds); |
64 } | 65 } |
65 | 66 |
66 aura::Window* outer_; | 67 aura::Window* outer_; |
67 aura::Window* inner_; | 68 aura::Window* inner_; |
68 | 69 |
69 DISALLOW_COPY_AND_ASSIGN(ContentWindowLayoutManager); | 70 DISALLOW_COPY_AND_ASSIGN(ContentWindowLayoutManager); |
70 }; | 71 }; |
71 | 72 |
| 73 class NativeWidgetMusWindowTreeClient : public aura::client::WindowTreeClient { |
| 74 public: |
| 75 explicit NativeWidgetMusWindowTreeClient(aura::Window* root_window) |
| 76 : root_window_(root_window) { |
| 77 aura::client::SetWindowTreeClient(root_window_, this); |
| 78 } |
| 79 ~NativeWidgetMusWindowTreeClient() override { |
| 80 aura::client::SetWindowTreeClient(root_window_, nullptr); |
| 81 } |
| 82 |
| 83 // Overridden from client::WindowTreeClient: |
| 84 aura::Window* GetDefaultParent(aura::Window* context, |
| 85 aura::Window* window, |
| 86 const gfx::Rect& bounds) override { |
| 87 return root_window_; |
| 88 } |
| 89 |
| 90 private: |
| 91 aura::Window* root_window_; |
| 92 |
| 93 DISALLOW_COPY_AND_ASSIGN(NativeWidgetMusWindowTreeClient); |
| 94 }; |
| 95 |
72 // As the window manager renderers the non-client decorations this class does | 96 // As the window manager renderers the non-client decorations this class does |
73 // very little but honor the client area insets from the window manager. | 97 // very little but honor the client area insets from the window manager. |
74 class ClientSideNonClientFrameView : public NonClientFrameView { | 98 class ClientSideNonClientFrameView : public NonClientFrameView { |
75 public: | 99 public: |
76 explicit ClientSideNonClientFrameView(views::Widget* widget) | 100 explicit ClientSideNonClientFrameView(views::Widget* widget) |
77 : widget_(widget) {} | 101 : widget_(widget) {} |
78 ~ClientSideNonClientFrameView() override {} | 102 ~ClientSideNonClientFrameView() override {} |
79 | 103 |
80 private: | 104 private: |
81 // Returns the default values of client area insets from the window manager. | 105 // Returns the default values of client area insets from the window manager. |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 window_tree_host_.reset( | 208 window_tree_host_.reset( |
185 new WindowTreeHostMus(shell_, window_, surface_type_)); | 209 new WindowTreeHostMus(shell_, window_, surface_type_)); |
186 window_tree_host_->InitHost(); | 210 window_tree_host_->InitHost(); |
187 | 211 |
188 focus_client_.reset(new wm::FocusController(new FocusRulesImpl)); | 212 focus_client_.reset(new wm::FocusController(new FocusRulesImpl)); |
189 | 213 |
190 aura::client::SetFocusClient(window_tree_host_->window(), | 214 aura::client::SetFocusClient(window_tree_host_->window(), |
191 focus_client_.get()); | 215 focus_client_.get()); |
192 aura::client::SetActivationClient(window_tree_host_->window(), | 216 aura::client::SetActivationClient(window_tree_host_->window(), |
193 focus_client_.get()); | 217 focus_client_.get()); |
| 218 window_tree_client_.reset( |
| 219 new NativeWidgetMusWindowTreeClient(window_tree_host_->window())); |
194 window_tree_host_->window()->AddPreTargetHandler(focus_client_.get()); | 220 window_tree_host_->window()->AddPreTargetHandler(focus_client_.get()); |
195 window_tree_host_->window()->SetLayoutManager( | 221 window_tree_host_->window()->SetLayoutManager( |
196 new ContentWindowLayoutManager(window_tree_host_->window(), content_)); | 222 new ContentWindowLayoutManager(window_tree_host_->window(), content_)); |
197 capture_client_.reset( | 223 capture_client_.reset( |
198 new aura::client::DefaultCaptureClient(window_tree_host_->window())); | 224 new aura::client::DefaultCaptureClient(window_tree_host_->window())); |
199 | 225 |
200 content_->SetType(ui::wm::WINDOW_TYPE_NORMAL); | 226 content_->SetType(ui::wm::WINDOW_TYPE_NORMAL); |
201 content_->Init(ui::LAYER_TEXTURED); | 227 content_->Init(ui::LAYER_TEXTURED); |
| 228 content_->Show(); |
202 content_->SetTransparent(true); | 229 content_->SetTransparent(true); |
203 content_->SetFillsBoundsCompletely(false); | 230 content_->SetFillsBoundsCompletely(false); |
204 | 231 |
205 window_tree_host_->window()->AddChild(content_); | 232 window_tree_host_->window()->AddChild(content_); |
206 // TODO(beng): much else, see [Desktop]NativeWidgetAura. | 233 // TODO(beng): much else, see [Desktop]NativeWidgetAura. |
207 } | 234 } |
208 | 235 |
209 bool NativeWidgetMus::ShouldUseNativeFrame() const { | 236 bool NativeWidgetMus::ShouldUseNativeFrame() const { |
210 // NOTIMPLEMENTED(); | 237 // NOTIMPLEMENTED(); |
211 return false; | 238 return false; |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
376 const gfx::Rect& restored_bounds) { | 403 const gfx::Rect& restored_bounds) { |
377 // NOTIMPLEMENTED(); | 404 // NOTIMPLEMENTED(); |
378 } | 405 } |
379 | 406 |
380 void NativeWidgetMus::ShowWithWindowState(ui::WindowShowState state) { | 407 void NativeWidgetMus::ShowWithWindowState(ui::WindowShowState state) { |
381 window_tree_host_->Show(); | 408 window_tree_host_->Show(); |
382 GetNativeWindow()->Show(); | 409 GetNativeWindow()->Show(); |
383 } | 410 } |
384 | 411 |
385 bool NativeWidgetMus::IsVisible() const { | 412 bool NativeWidgetMus::IsVisible() const { |
386 // NOTIMPLEMENTED(); | 413 // TODO(beng): this should probably be wired thru PlatformWindow. |
387 return true; | 414 return window_tree_host_->mus_window()->visible(); |
388 } | 415 } |
389 | 416 |
390 void NativeWidgetMus::Activate() { | 417 void NativeWidgetMus::Activate() { |
391 // NOTIMPLEMENTED(); | 418 // NOTIMPLEMENTED(); |
392 } | 419 } |
393 | 420 |
394 void NativeWidgetMus::Deactivate() { | 421 void NativeWidgetMus::Deactivate() { |
395 // NOTIMPLEMENTED(); | 422 // NOTIMPLEMENTED(); |
396 } | 423 } |
397 | 424 |
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
690 return; | 717 return; |
691 | 718 |
692 const gfx::Rect client_area_rect(non_client_view->client_view()->bounds()); | 719 const gfx::Rect client_area_rect(non_client_view->client_view()->bounds()); |
693 window_->SetClientArea(gfx::Insets( | 720 window_->SetClientArea(gfx::Insets( |
694 client_area_rect.y(), client_area_rect.x(), | 721 client_area_rect.y(), client_area_rect.x(), |
695 non_client_view->bounds().height() - client_area_rect.bottom(), | 722 non_client_view->bounds().height() - client_area_rect.bottom(), |
696 non_client_view->bounds().width() - client_area_rect.right())); | 723 non_client_view->bounds().width() - client_area_rect.right())); |
697 } | 724 } |
698 | 725 |
699 } // namespace views | 726 } // namespace views |
OLD | NEW |