OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "services/window_manager/window_manager_app.h" | 5 #include "services/window_manager/window_manager_app.h" |
6 | 6 |
7 #include "base/message_loop/message_loop.h" | 7 #include "base/message_loop/message_loop.h" |
8 #include "base/stl_util.h" | 8 #include "base/stl_util.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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
80 connections_.insert(connection); | 80 connections_.insert(connection); |
81 } | 81 } |
82 | 82 |
83 void WindowManagerApp::RemoveConnection(WindowManagerImpl* connection) { | 83 void WindowManagerApp::RemoveConnection(WindowManagerImpl* connection) { |
84 DCHECK(connections_.find(connection) != connections_.end()); | 84 DCHECK(connections_.find(connection) != connections_.end()); |
85 connections_.erase(connection); | 85 connections_.erase(connection); |
86 } | 86 } |
87 | 87 |
88 bool WindowManagerApp::SetCapture(Id view_id) { | 88 bool WindowManagerApp::SetCapture(Id view_id) { |
89 View* view = view_manager()->GetViewById(view_id); | 89 View* view = view_manager()->GetViewById(view_id); |
90 if (!view) | 90 return view && SetCapture(view); |
91 return false; | |
92 capture_controller_->SetCapture(view); | |
93 return capture_controller_->GetCapture() == view; | |
94 } | 91 } |
95 | 92 |
96 bool WindowManagerApp::FocusWindow(Id view_id) { | 93 bool WindowManagerApp::FocusWindow(Id view_id) { |
97 View* view = view_manager()->GetViewById(view_id); | 94 View* view = view_manager()->GetViewById(view_id); |
98 if (!view) | 95 return view && FocusWindow(view); |
99 return false; | |
100 focus_controller_->FocusView(view); | |
101 return focus_controller_->GetFocusedView() == view; | |
102 } | 96 } |
103 | 97 |
104 bool WindowManagerApp::ActivateWindow(Id view_id) { | 98 bool WindowManagerApp::ActivateWindow(Id view_id) { |
105 View* view = view_manager()->GetViewById(view_id); | 99 View* view = view_manager()->GetViewById(view_id); |
106 if (!view) | 100 return view && ActivateWindow(view); |
107 return false; | |
108 focus_controller_->ActivateView(view); | |
109 return focus_controller_->GetActiveView() == view; | |
110 } | 101 } |
111 | 102 |
112 bool WindowManagerApp::IsReady() const { | 103 bool WindowManagerApp::IsReady() const { |
113 return root_; | 104 return root_; |
114 } | 105 } |
115 | 106 |
116 void WindowManagerApp::InitFocus(scoped_ptr<FocusRules> rules) { | 107 void WindowManagerApp::InitFocus(scoped_ptr<FocusRules> rules) { |
117 DCHECK(root_); | 108 DCHECK(root_); |
118 | 109 |
119 focus_controller_.reset(new FocusController(rules.Pass())); | 110 focus_controller_.reset(new FocusController(rules.Pass())); |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
184 void WindowManagerApp::OnViewManagerDisconnected( | 175 void WindowManagerApp::OnViewManagerDisconnected( |
185 mojo::ViewManager* view_manager) { | 176 mojo::ViewManager* view_manager) { |
186 if (wrapped_view_manager_delegate_) | 177 if (wrapped_view_manager_delegate_) |
187 wrapped_view_manager_delegate_->OnViewManagerDisconnected(view_manager); | 178 wrapped_view_manager_delegate_->OnViewManagerDisconnected(view_manager); |
188 | 179 |
189 base::MessageLoop* message_loop = base::MessageLoop::current(); | 180 base::MessageLoop* message_loop = base::MessageLoop::current(); |
190 if (message_loop && message_loop->is_running()) | 181 if (message_loop && message_loop->is_running()) |
191 message_loop->Quit(); | 182 message_loop->Quit(); |
192 } | 183 } |
193 | 184 |
185 void WindowManagerApp::OnPerformAction(mojo::View* view, | |
msw
2015/02/25 22:29:30
nit: match the function definition order of this "
sky
2015/02/25 23:20:27
The order here and in the header is consistent, bu
| |
186 const std::string& action) { | |
187 if (!view) | |
188 return; | |
189 if (action == "capture") | |
190 SetCapture(view); | |
191 else if (action == "focus") | |
192 FocusWindow(view); | |
193 else if (action == "activate") | |
194 ActivateWindow(view); | |
195 } | |
196 | |
194 //////////////////////////////////////////////////////////////////////////////// | 197 //////////////////////////////////////////////////////////////////////////////// |
195 // WindowManagerApp, ViewObserver implementation: | 198 // WindowManagerApp, ViewObserver implementation: |
196 | 199 |
197 void WindowManagerApp::OnTreeChanged( | 200 void WindowManagerApp::OnTreeChanged( |
198 const ViewObserver::TreeChangeParams& params) { | 201 const ViewObserver::TreeChangeParams& params) { |
199 if (params.receiver != root_) | 202 if (params.receiver != root_) |
200 return; | 203 return; |
201 DCHECK(params.old_parent || params.new_parent); | 204 DCHECK(params.old_parent || params.new_parent); |
202 if (!params.target) | 205 if (!params.target) |
203 return; | 206 return; |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
271 it != connections_.end(); ++it) { | 274 it != connections_.end(); ++it) { |
272 (*it)->NotifyCaptureChanged(GetIdForView(gained_capture)); | 275 (*it)->NotifyCaptureChanged(GetIdForView(gained_capture)); |
273 } | 276 } |
274 if (gained_capture) | 277 if (gained_capture) |
275 gained_capture->MoveToFront(); | 278 gained_capture->MoveToFront(); |
276 } | 279 } |
277 | 280 |
278 //////////////////////////////////////////////////////////////////////////////// | 281 //////////////////////////////////////////////////////////////////////////////// |
279 // WindowManagerApp, private: | 282 // WindowManagerApp, private: |
280 | 283 |
284 bool WindowManagerApp::SetCapture(View* view) { | |
285 CHECK(view); | |
286 capture_controller_->SetCapture(view); | |
287 return capture_controller_->GetCapture() == view; | |
288 } | |
289 | |
290 bool WindowManagerApp::FocusWindow(View* view) { | |
291 CHECK(view); | |
292 focus_controller_->FocusView(view); | |
293 return focus_controller_->GetFocusedView() == view; | |
294 } | |
295 | |
296 bool WindowManagerApp::ActivateWindow(View* view) { | |
297 CHECK(view); | |
298 focus_controller_->ActivateView(view); | |
299 return focus_controller_->GetActiveView() == view; | |
300 } | |
301 | |
281 void WindowManagerApp::RegisterSubtree(View* view) { | 302 void WindowManagerApp::RegisterSubtree(View* view) { |
282 view->AddObserver(this); | 303 view->AddObserver(this); |
283 DCHECK(registered_view_id_set_.find(view->id()) == | 304 DCHECK(registered_view_id_set_.find(view->id()) == |
284 registered_view_id_set_.end()); | 305 registered_view_id_set_.end()); |
285 // All events pass through the root during dispatch, so we only need a handler | 306 // All events pass through the root during dispatch, so we only need a handler |
286 // installed there. | 307 // installed there. |
287 if (view == root_) { | 308 if (view == root_) { |
288 ViewTarget* target = ViewTarget::TargetFromView(view); | 309 ViewTarget* target = ViewTarget::TargetFromView(view); |
289 target->SetEventTargeter(scoped_ptr<ViewTargeter>(new ViewTargeter())); | 310 target->SetEventTargeter(scoped_ptr<ViewTargeter>(new ViewTargeter())); |
290 target->AddPreTargetHandler(this); | 311 target->AddPreTargetHandler(this); |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
377 void WindowManagerApp::SetViewManagerClient( | 398 void WindowManagerApp::SetViewManagerClient( |
378 mojo::ScopedMessagePipeHandle view_manager_client_request) { | 399 mojo::ScopedMessagePipeHandle view_manager_client_request) { |
379 view_manager_client_.reset( | 400 view_manager_client_.reset( |
380 mojo::ViewManagerClientFactory::WeakBindViewManagerToPipe( | 401 mojo::ViewManagerClientFactory::WeakBindViewManagerToPipe( |
381 mojo::MakeRequest<mojo::ViewManagerClient>( | 402 mojo::MakeRequest<mojo::ViewManagerClient>( |
382 view_manager_client_request.Pass()), | 403 view_manager_client_request.Pass()), |
383 view_manager_service_.Pass(), shell_, this)); | 404 view_manager_service_.Pass(), shell_, this)); |
384 } | 405 } |
385 | 406 |
386 } // namespace window_manager | 407 } // namespace window_manager |
OLD | NEW |