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 "mandoline/ui/aura/native_widget_view_manager.h" | 5 #include "mandoline/ui/aura/native_widget_view_manager.h" |
6 | 6 |
7 #include "mandoline/ui/aura/input_method_mandoline.h" | 7 #include "mandoline/ui/aura/input_method_mandoline.h" |
8 #include "mandoline/ui/aura/window_tree_host_mojo.h" | 8 #include "mandoline/ui/aura/window_tree_host_mojo.h" |
9 #include "mojo/converters/geometry/geometry_type_converters.h" | 9 #include "mojo/converters/geometry/geometry_type_converters.h" |
10 #include "mojo/converters/input_events/input_events_type_converters.h" | 10 #include "mojo/converters/input_events/input_events_type_converters.h" |
(...skipping 20 matching lines...) Expand all Loading... |
31 | 31 |
32 private: | 32 private: |
33 DISALLOW_COPY_AND_ASSIGN(FocusRulesImpl); | 33 DISALLOW_COPY_AND_ASSIGN(FocusRulesImpl); |
34 }; | 34 }; |
35 | 35 |
36 } // namespace | 36 } // namespace |
37 | 37 |
38 NativeWidgetViewManager::NativeWidgetViewManager( | 38 NativeWidgetViewManager::NativeWidgetViewManager( |
39 views::internal::NativeWidgetDelegate* delegate, | 39 views::internal::NativeWidgetDelegate* delegate, |
40 mojo::Shell* shell, | 40 mojo::Shell* shell, |
41 mus::View* view) | 41 mojo::View* view) |
42 : NativeWidgetAura(delegate), view_(view) { | 42 : NativeWidgetAura(delegate), view_(view) { |
43 view_->AddObserver(this); | 43 view_->AddObserver(this); |
44 window_tree_host_.reset(new WindowTreeHostMojo(shell, view_)); | 44 window_tree_host_.reset(new WindowTreeHostMojo(shell, view_)); |
45 window_tree_host_->InitHost(); | 45 window_tree_host_->InitHost(); |
46 | 46 |
47 focus_client_.reset(new wm::FocusController(new FocusRulesImpl)); | 47 focus_client_.reset(new wm::FocusController(new FocusRulesImpl)); |
48 | 48 |
49 aura::client::SetFocusClient(window_tree_host_->window(), | 49 aura::client::SetFocusClient(window_tree_host_->window(), |
50 focus_client_.get()); | 50 focus_client_.get()); |
51 aura::client::SetActivationClient(window_tree_host_->window(), | 51 aura::client::SetActivationClient(window_tree_host_->window(), |
(...skipping 17 matching lines...) Expand all Loading... |
69 } | 69 } |
70 | 70 |
71 void NativeWidgetViewManager::OnWindowVisibilityChanged(aura::Window* window, | 71 void NativeWidgetViewManager::OnWindowVisibilityChanged(aura::Window* window, |
72 bool visible) { | 72 bool visible) { |
73 view_->SetVisible(visible); | 73 view_->SetVisible(visible); |
74 // NOTE: We could also update aura::Window's visibility when the View's | 74 // NOTE: We could also update aura::Window's visibility when the View's |
75 // visibilty changes, but this code isn't going to be around for very long so | 75 // visibilty changes, but this code isn't going to be around for very long so |
76 // I'm not bothering. | 76 // I'm not bothering. |
77 } | 77 } |
78 | 78 |
79 void NativeWidgetViewManager::OnViewDestroyed(mus::View* view) { | 79 void NativeWidgetViewManager::OnViewDestroyed(mojo::View* view) { |
80 DCHECK_EQ(view, view_); | 80 DCHECK_EQ(view, view_); |
81 view->RemoveObserver(this); | 81 view->RemoveObserver(this); |
82 view_ = NULL; | 82 view_ = NULL; |
83 // TODO(sky): WindowTreeHostMojo assumes the View outlives it. | 83 // TODO(sky): WindowTreeHostMojo assumes the View outlives it. |
84 // NativeWidgetViewManager needs to deal, likely by deleting this. | 84 // NativeWidgetViewManager needs to deal, likely by deleting this. |
85 } | 85 } |
86 | 86 |
87 void NativeWidgetViewManager::OnViewBoundsChanged( | 87 void NativeWidgetViewManager::OnViewBoundsChanged( |
88 mus::View* view, | 88 mojo::View* view, |
89 const mojo::Rect& old_bounds, | 89 const mojo::Rect& old_bounds, |
90 const mojo::Rect& new_bounds) { | 90 const mojo::Rect& new_bounds) { |
91 gfx::Rect view_rect = view->bounds().To<gfx::Rect>(); | 91 gfx::Rect view_rect = view->bounds().To<gfx::Rect>(); |
92 GetWidget()->SetBounds(gfx::Rect(view_rect.size())); | 92 GetWidget()->SetBounds(gfx::Rect(view_rect.size())); |
93 } | 93 } |
94 | 94 |
95 void NativeWidgetViewManager::OnViewFocusChanged(mus::View* gained_focus, | 95 void NativeWidgetViewManager::OnViewFocusChanged(mojo::View* gained_focus, |
96 mus::View* lost_focus) { | 96 mojo::View* lost_focus) { |
97 if (gained_focus == view_) | 97 if (gained_focus == view_) |
98 window_tree_host_->GetInputMethod()->OnFocus(); | 98 window_tree_host_->GetInputMethod()->OnFocus(); |
99 else if (lost_focus == view_) | 99 else if (lost_focus == view_) |
100 window_tree_host_->GetInputMethod()->OnBlur(); | 100 window_tree_host_->GetInputMethod()->OnBlur(); |
101 } | 101 } |
102 | 102 |
103 void NativeWidgetViewManager::OnViewInputEvent(mus::View* view, | 103 void NativeWidgetViewManager::OnViewInputEvent(mojo::View* view, |
104 const mojo::EventPtr& event) { | 104 const mojo::EventPtr& event) { |
105 scoped_ptr<ui::Event> ui_event(event.To<scoped_ptr<ui::Event>>()); | 105 scoped_ptr<ui::Event> ui_event(event.To<scoped_ptr<ui::Event>>()); |
106 if (!ui_event) | 106 if (!ui_event) |
107 return; | 107 return; |
108 | 108 |
109 if (ui_event->IsKeyEvent()) { | 109 if (ui_event->IsKeyEvent()) { |
110 window_tree_host_->GetInputMethod()->DispatchKeyEvent( | 110 window_tree_host_->GetInputMethod()->DispatchKeyEvent( |
111 static_cast<ui::KeyEvent*>(ui_event.get())); | 111 static_cast<ui::KeyEvent*>(ui_event.get())); |
112 } else { | 112 } else { |
113 window_tree_host_->SendEventToProcessor(ui_event.get()); | 113 window_tree_host_->SendEventToProcessor(ui_event.get()); |
114 } | 114 } |
115 } | 115 } |
116 | 116 |
117 } // namespace mandoline | 117 } // namespace mandoline |
OLD | NEW |