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/window.h" | 7 #include "components/mus/public/cpp/window.h" |
8 #include "mojo/converters/geometry/geometry_type_converters.h" | 8 #include "mojo/converters/geometry/geometry_type_converters.h" |
9 #include "ui/aura/client/default_capture_client.h" | 9 #include "ui/aura/client/default_capture_client.h" |
10 #include "ui/aura/client/window_tree_client.h" | |
10 #include "ui/aura/layout_manager.h" | 11 #include "ui/aura/layout_manager.h" |
11 #include "ui/aura/window.h" | 12 #include "ui/aura/window.h" |
12 #include "ui/base/hit_test.h" | 13 #include "ui/base/hit_test.h" |
13 #include "ui/compositor/clip_transform_recorder.h" | 14 #include "ui/compositor/clip_transform_recorder.h" |
14 #include "ui/compositor/paint_recorder.h" | 15 #include "ui/compositor/paint_recorder.h" |
15 #include "ui/gfx/canvas.h" | 16 #include "ui/gfx/canvas.h" |
16 #include "ui/native_theme/native_theme_aura.h" | 17 #include "ui/native_theme/native_theme_aura.h" |
17 #include "ui/views/mus/window_manager_client_area_insets.h" | 18 #include "ui/views/mus/window_manager_client_area_insets.h" |
18 #include "ui/views/mus/window_tree_host_mus.h" | 19 #include "ui/views/mus/window_tree_host_mus.h" |
19 #include "ui/views/widget/widget_delegate.h" | 20 #include "ui/views/widget/widget_delegate.h" |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
61 const gfx::Rect& requested_bounds) override { | 62 const gfx::Rect& requested_bounds) override { |
62 SetChildBoundsDirect(child, requested_bounds); | 63 SetChildBoundsDirect(child, requested_bounds); |
63 } | 64 } |
64 | 65 |
65 aura::Window* outer_; | 66 aura::Window* outer_; |
66 aura::Window* inner_; | 67 aura::Window* inner_; |
67 | 68 |
68 DISALLOW_COPY_AND_ASSIGN(ContentWindowLayoutManager); | 69 DISALLOW_COPY_AND_ASSIGN(ContentWindowLayoutManager); |
69 }; | 70 }; |
70 | 71 |
72 class NativeWidgetMusWindowTreeClient : public aura::client::WindowTreeClient { | |
sky
2015/11/06 17:07:46
Wow, I hadn't realized we have aura::client::Windo
| |
73 public: | |
74 explicit NativeWidgetMusWindowTreeClient(aura::Window* root_window) | |
75 : root_window_(root_window) { | |
76 aura::client::SetWindowTreeClient(root_window_, this); | |
77 } | |
78 ~NativeWidgetMusWindowTreeClient() override { | |
79 aura::client::SetWindowTreeClient(root_window_, NULL); | |
sky
2015/11/06 17:07:46
nit: nullptr.
| |
80 } | |
81 | |
82 // Overridden from client::WindowTreeClient: | |
83 aura::Window* GetDefaultParent(aura::Window* context, | |
84 aura::Window* window, | |
85 const gfx::Rect& bounds) override { | |
86 return root_window_; | |
87 } | |
88 | |
89 private: | |
90 aura::Window* root_window_; | |
91 | |
92 DISALLOW_COPY_AND_ASSIGN(NativeWidgetMusWindowTreeClient); | |
93 }; | |
94 | |
71 // As the window manager renderers the non-client decorations this class does | 95 // As the window manager renderers the non-client decorations this class does |
72 // very little but honor the client area insets from the window manager. | 96 // very little but honor the client area insets from the window manager. |
73 class ClientSideNonClientFrameView : public NonClientFrameView { | 97 class ClientSideNonClientFrameView : public NonClientFrameView { |
74 public: | 98 public: |
75 explicit ClientSideNonClientFrameView(views::Widget* widget) | 99 explicit ClientSideNonClientFrameView(views::Widget* widget) |
76 : widget_(widget) {} | 100 : widget_(widget) {} |
77 ~ClientSideNonClientFrameView() override {} | 101 ~ClientSideNonClientFrameView() override {} |
78 | 102 |
79 private: | 103 private: |
80 // Returns the default values of client area insets from the window manager. | 104 // Returns the default values of client area insets from the window manager. |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
175 window_tree_host_.reset( | 199 window_tree_host_.reset( |
176 new WindowTreeHostMus(shell_, window_, surface_type_)); | 200 new WindowTreeHostMus(shell_, window_, surface_type_)); |
177 window_tree_host_->InitHost(); | 201 window_tree_host_->InitHost(); |
178 | 202 |
179 focus_client_.reset(new wm::FocusController(new FocusRulesImpl)); | 203 focus_client_.reset(new wm::FocusController(new FocusRulesImpl)); |
180 | 204 |
181 aura::client::SetFocusClient(window_tree_host_->window(), | 205 aura::client::SetFocusClient(window_tree_host_->window(), |
182 focus_client_.get()); | 206 focus_client_.get()); |
183 aura::client::SetActivationClient(window_tree_host_->window(), | 207 aura::client::SetActivationClient(window_tree_host_->window(), |
184 focus_client_.get()); | 208 focus_client_.get()); |
209 window_tree_client_.reset( | |
210 new NativeWidgetMusWindowTreeClient(window_tree_host_->window())); | |
185 window_tree_host_->window()->AddPreTargetHandler(focus_client_.get()); | 211 window_tree_host_->window()->AddPreTargetHandler(focus_client_.get()); |
186 window_tree_host_->window()->SetLayoutManager( | 212 window_tree_host_->window()->SetLayoutManager( |
187 new ContentWindowLayoutManager(window_tree_host_->window(), content_)); | 213 new ContentWindowLayoutManager(window_tree_host_->window(), content_)); |
188 capture_client_.reset( | 214 capture_client_.reset( |
189 new aura::client::DefaultCaptureClient(window_tree_host_->window())); | 215 new aura::client::DefaultCaptureClient(window_tree_host_->window())); |
190 | 216 |
191 content_->SetType(ui::wm::WINDOW_TYPE_NORMAL); | 217 content_->SetType(ui::wm::WINDOW_TYPE_NORMAL); |
192 content_->Init(ui::LAYER_TEXTURED); | 218 content_->Init(ui::LAYER_TEXTURED); |
219 content_->Show(); | |
193 content_->SetTransparent(true); | 220 content_->SetTransparent(true); |
194 content_->SetFillsBoundsCompletely(false); | 221 content_->SetFillsBoundsCompletely(false); |
195 | 222 |
196 window_tree_host_->window()->AddChild(content_); | 223 window_tree_host_->window()->AddChild(content_); |
197 // TODO(beng): much else, see [Desktop]NativeWidgetAura. | 224 // TODO(beng): much else, see [Desktop]NativeWidgetAura. |
198 } | 225 } |
199 | 226 |
200 bool NativeWidgetMus::ShouldUseNativeFrame() const { | 227 bool NativeWidgetMus::ShouldUseNativeFrame() const { |
201 // NOTIMPLEMENTED(); | 228 // NOTIMPLEMENTED(); |
202 return false; | 229 return false; |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
367 const gfx::Rect& restored_bounds) { | 394 const gfx::Rect& restored_bounds) { |
368 // NOTIMPLEMENTED(); | 395 // NOTIMPLEMENTED(); |
369 } | 396 } |
370 | 397 |
371 void NativeWidgetMus::ShowWithWindowState(ui::WindowShowState state) { | 398 void NativeWidgetMus::ShowWithWindowState(ui::WindowShowState state) { |
372 window_tree_host_->Show(); | 399 window_tree_host_->Show(); |
373 GetNativeWindow()->Show(); | 400 GetNativeWindow()->Show(); |
374 } | 401 } |
375 | 402 |
376 bool NativeWidgetMus::IsVisible() const { | 403 bool NativeWidgetMus::IsVisible() const { |
377 // NOTIMPLEMENTED(); | 404 // TODO(beng): this should probably be wired thru PlatformWindow. |
378 return true; | 405 return window_tree_host_->mus_window()->visible(); |
379 } | 406 } |
380 | 407 |
381 void NativeWidgetMus::Activate() { | 408 void NativeWidgetMus::Activate() { |
382 // NOTIMPLEMENTED(); | 409 // NOTIMPLEMENTED(); |
383 } | 410 } |
384 | 411 |
385 void NativeWidgetMus::Deactivate() { | 412 void NativeWidgetMus::Deactivate() { |
386 // NOTIMPLEMENTED(); | 413 // NOTIMPLEMENTED(); |
387 } | 414 } |
388 | 415 |
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
664 } else { | 691 } else { |
665 native_widget_delegate_->OnScrollEvent(event); | 692 native_widget_delegate_->OnScrollEvent(event); |
666 } | 693 } |
667 } | 694 } |
668 | 695 |
669 void NativeWidgetMus::OnGestureEvent(ui::GestureEvent* event) { | 696 void NativeWidgetMus::OnGestureEvent(ui::GestureEvent* event) { |
670 native_widget_delegate_->OnGestureEvent(event); | 697 native_widget_delegate_->OnGestureEvent(event); |
671 } | 698 } |
672 | 699 |
673 } // namespace views | 700 } // namespace views |
OLD | NEW |