Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(15)

Side by Side Diff: mojo/examples/wm_flow/wm/wm.cc

Issue 474883003: Move focus from the view manager to the window manager. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « mojo/examples/window_manager/window_manager.cc ('k') | mojo/mojo_examples.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "mojo/public/cpp/application/application_delegate.h" 5 #include "mojo/public/cpp/application/application_delegate.h"
6 #include "mojo/public/cpp/application/service_provider_impl.h" 6 #include "mojo/public/cpp/application/service_provider_impl.h"
7 #include "mojo/services/public/cpp/view_manager/view_manager.h" 7 #include "mojo/services/public/cpp/view_manager/view_manager.h"
8 #include "mojo/services/public/cpp/view_manager/view_manager_delegate.h" 8 #include "mojo/services/public/cpp/view_manager/view_manager_delegate.h"
9 #include "mojo/services/public/cpp/view_manager/window_manager_delegate.h" 9 #include "mojo/services/public/cpp/view_manager/window_manager_delegate.h"
10 #include "mojo/services/window_manager/window_manager_app.h" 10 #include "mojo/services/window_manager/window_manager_app.h"
11 11
12 namespace examples { 12 namespace examples {
13 13
14 class SimpleWM : public mojo::ApplicationDelegate, 14 class SimpleWM : public mojo::ApplicationDelegate,
15 public mojo::ViewManagerDelegate, 15 public mojo::ViewManagerDelegate,
16 public mojo::WindowManagerDelegate { 16 public mojo::WindowManagerDelegate {
17 public: 17 public:
18 SimpleWM() 18 SimpleWM()
19 : window_manager_app_(new mojo::WindowManagerApp(this)), 19 : window_manager_app_(new mojo::WindowManagerApp(this, this)),
20 view_manager_(NULL), 20 view_manager_(NULL),
21 root_(NULL), 21 root_(NULL),
22 window_container_(NULL), 22 window_container_(NULL),
23 next_window_origin_(10, 10) {} 23 next_window_origin_(10, 10) {}
24 virtual ~SimpleWM() {} 24 virtual ~SimpleWM() {}
25 25
26 private: 26 private:
27 // Overridden from mojo::ApplicationDelegate: 27 // Overridden from mojo::ApplicationDelegate:
28 virtual void Initialize(mojo::ApplicationImpl* impl) MOJO_OVERRIDE { 28 virtual void Initialize(mojo::ApplicationImpl* impl) MOJO_OVERRIDE {
29 window_manager_app_->Initialize(impl); 29 window_manager_app_->Initialize(impl);
30 } 30 }
31 virtual bool ConfigureIncomingConnection( 31 virtual bool ConfigureIncomingConnection(
32 mojo::ApplicationConnection* connection) MOJO_OVERRIDE { 32 mojo::ApplicationConnection* connection) MOJO_OVERRIDE {
33 window_manager_app_->ConfigureIncomingConnection(connection); 33 window_manager_app_->ConfigureIncomingConnection(connection);
34 return true; 34 return true;
35 } 35 }
36 36
37 // Overridden from mojo::ViewManagerDelegate: 37 // Overridden from mojo::ViewManagerDelegate:
38 virtual void OnEmbed( 38 virtual void OnEmbed(
39 mojo::ViewManager* view_manager, 39 mojo::ViewManager* view_manager,
40 mojo::View* root, 40 mojo::View* root,
41 mojo::ServiceProviderImpl* exported_services, 41 mojo::ServiceProviderImpl* exported_services,
42 scoped_ptr<mojo::ServiceProvider> remote_service_provider) MOJO_OVERRIDE { 42 scoped_ptr<mojo::ServiceProvider> remote_service_provider) MOJO_OVERRIDE {
43 view_manager_ = view_manager; 43 view_manager_ = view_manager;
44 root_ = root; 44 root_ = root;
45 view_manager_->SetWindowManagerDelegate(this);
46 45
47 window_container_ = mojo::View::Create(view_manager_); 46 window_container_ = mojo::View::Create(view_manager_);
48 window_container_->SetBounds(root_->bounds()); 47 window_container_->SetBounds(root_->bounds());
49 root_->AddChild(window_container_); 48 root_->AddChild(window_container_);
50 49
51 } 50 }
52 virtual void OnViewManagerDisconnected( 51 virtual void OnViewManagerDisconnected(
53 mojo::ViewManager* view_manager) MOJO_OVERRIDE { 52 mojo::ViewManager* view_manager) MOJO_OVERRIDE {
54 view_manager_ = NULL; 53 view_manager_ = NULL;
55 root_ = NULL; 54 root_ = NULL;
56 } 55 }
57 56
58 // Overridden from mojo::WindowManagerDelegate: 57 // Overridden from mojo::WindowManagerDelegate:
59 virtual void Embed( 58 virtual void Embed(
60 const mojo::String& url, 59 const mojo::String& url,
61 mojo::InterfaceRequest<mojo::ServiceProvider> service_provider) 60 mojo::InterfaceRequest<mojo::ServiceProvider> service_provider)
62 MOJO_OVERRIDE { 61 MOJO_OVERRIDE {
63 mojo::View* embed_view = mojo::View::Create(view_manager_); 62 mojo::View* embed_view = mojo::View::Create(view_manager_);
64 embed_view->SetBounds(gfx::Rect(next_window_origin_, gfx::Size(400, 400))); 63 embed_view->SetBounds(gfx::Rect(next_window_origin_, gfx::Size(400, 400)));
65 window_container_->AddChild(embed_view); 64 window_container_->AddChild(embed_view);
66 65
67 // TODO(beng): We're dropping the |service_provider| passed from the client 66 // TODO(beng): We're dropping the |service_provider| passed from the client
68 // on the floor here and passing our own. Seems like we should 67 // on the floor here and passing our own. Seems like we should
69 // be sending both. I'm not yet sure how this sould work for 68 // be sending both. I'm not yet sure how this sould work for
70 // N levels of proxying. 69 // N levels of proxying.
71 embed_view->Embed(url, scoped_ptr<mojo::ServiceProviderImpl>( 70 embed_view->Embed(url, scoped_ptr<mojo::ServiceProviderImpl>(
72 new mojo::ServiceProviderImpl).Pass()); 71 new mojo::ServiceProviderImpl).Pass());
73 next_window_origin_.Offset(50, 50); 72 next_window_origin_.Offset(50, 50);
74 } 73 }
75 virtual void DispatchEvent(mojo::View* target, 74 virtual void DispatchEvent(mojo::EventPtr event) MOJO_OVERRIDE {}
76 mojo::EventPtr event) MOJO_OVERRIDE {
77 view_manager_->DispatchEvent(target, event.Pass());
78 }
79 75
80 scoped_ptr<mojo::WindowManagerApp> window_manager_app_; 76 scoped_ptr<mojo::WindowManagerApp> window_manager_app_;
81 77
82 mojo::ViewManager* view_manager_; 78 mojo::ViewManager* view_manager_;
83 mojo::View* root_; 79 mojo::View* root_;
84 mojo::View* window_container_; 80 mojo::View* window_container_;
85 81
86 gfx::Point next_window_origin_; 82 gfx::Point next_window_origin_;
87 83
88 DISALLOW_COPY_AND_ASSIGN(SimpleWM); 84 DISALLOW_COPY_AND_ASSIGN(SimpleWM);
89 }; 85 };
90 86
91 } // namespace examples 87 } // namespace examples
92 88
93 namespace mojo { 89 namespace mojo {
94 90
95 // static 91 // static
96 ApplicationDelegate* ApplicationDelegate::Create() { 92 ApplicationDelegate* ApplicationDelegate::Create() {
97 return new examples::SimpleWM; 93 return new examples::SimpleWM;
98 } 94 }
99 95
100 } // namespace 96 } // namespace
OLDNEW
« no previous file with comments | « mojo/examples/window_manager/window_manager.cc ('k') | mojo/mojo_examples.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698