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

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

Issue 817573003: Move wm_flow off of views and onto Sky (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Fix comments Created 5 years, 11 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
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 <vector>
6
7 #include "examples/wm_flow/wm/frame_controller.h" 5 #include "examples/wm_flow/wm/frame_controller.h"
8 #include "mojo/application/application_runner_chromium.h" 6 #include "mojo/application/application_runner_chromium.h"
9 #include "mojo/public/c/system/main.h" 7 #include "mojo/public/c/system/main.h"
10 #include "mojo/public/cpp/application/application_delegate.h" 8 #include "mojo/public/cpp/application/application_delegate.h"
11 #include "mojo/public/cpp/application/application_impl.h" 9 #include "mojo/public/cpp/application/application_impl.h"
12 #include "mojo/public/cpp/application/service_provider_impl.h" 10 #include "mojo/public/cpp/application/service_provider_impl.h"
13 #include "mojo/services/input_events/public/interfaces/input_events.mojom.h" 11 #include "mojo/services/input_events/public/interfaces/input_events.mojom.h"
14 #include "mojo/services/view_manager/public/cpp/view_manager.h" 12 #include "mojo/services/view_manager/public/cpp/view_manager.h"
15 #include "mojo/services/view_manager/public/cpp/view_manager_delegate.h" 13 #include "mojo/services/view_manager/public/cpp/view_manager_delegate.h"
16 #include "mojo/services/view_manager/public/cpp/view_observer.h" 14 #include "mojo/services/view_manager/public/cpp/view_observer.h"
17 #include "mojo/views/views_init.h"
18 #include "services/window_manager/basic_focus_rules.h" 15 #include "services/window_manager/basic_focus_rules.h"
19 #include "services/window_manager/window_manager_app.h" 16 #include "services/window_manager/window_manager_app.h"
20 #include "services/window_manager/window_manager_delegate.h" 17 #include "services/window_manager/window_manager_delegate.h"
18 #include "url/gurl.h"
21 19
22 namespace examples { 20 namespace examples {
23 21
24 class SimpleWM : public mojo::ApplicationDelegate, 22 class SimpleWM : public mojo::ApplicationDelegate,
25 public mojo::ViewManagerDelegate, 23 public mojo::ViewManagerDelegate,
26 public window_manager::WindowManagerDelegate, 24 public window_manager::WindowManagerDelegate,
27 public mojo::ViewObserver { 25 public mojo::ViewObserver {
28 public: 26 public:
29 SimpleWM() 27 SimpleWM()
30 : shell_(nullptr), 28 : window_manager_app_(new window_manager::WindowManagerApp(this, this)),
31 window_manager_app_(new window_manager::WindowManagerApp(this, this)),
32 root_(NULL), 29 root_(NULL),
33 window_container_(NULL), 30 window_container_(NULL),
34 next_window_origin_(10, 10) {} 31 next_window_origin_(10, 10) {}
35 virtual ~SimpleWM() {} 32 virtual ~SimpleWM() {}
36 33
37 private: 34 private:
38 // Overridden from mojo::ApplicationDelegate: 35 // Overridden from mojo::ApplicationDelegate:
39 virtual void Initialize(mojo::ApplicationImpl* impl) override { 36 virtual void Initialize(mojo::ApplicationImpl* impl) override {
40 // Create views_init here as we need ApplicationRunnerChromium to install 37 // FIXME: Mojo applications don't know their URLs yet:
41 // an AtExitManager and CommandLine. 38 // https://docs.google.com/a/chromium.org/document/d/1AQ2y6ekzvbdaMF5WrUQmne yXJnke-MnYYL4Gz1AKDos
42 if (!views_init_.get()) 39 url_ = GURL(impl->args()[1]);
43 views_init_.reset(new mojo::ViewsInit);
44 shell_ = impl->shell();
45 window_manager_app_->Initialize(impl); 40 window_manager_app_->Initialize(impl);
46 } 41 }
47 virtual bool ConfigureIncomingConnection( 42 virtual bool ConfigureIncomingConnection(
48 mojo::ApplicationConnection* connection) override { 43 mojo::ApplicationConnection* connection) override {
49 window_manager_app_->ConfigureIncomingConnection(connection); 44 window_manager_app_->ConfigureIncomingConnection(connection);
50 return true; 45 return true;
51 } 46 }
52 47
53 // Overridden from mojo::ViewManagerDelegate: 48 // Overridden from mojo::ViewManagerDelegate:
54 virtual void OnEmbed( 49 virtual void OnEmbed(
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 mojo::View* frame_view = root_->view_manager()->CreateView(); 105 mojo::View* frame_view = root_->view_manager()->CreateView();
111 // Add the View to it's parent before showing so that animations can happen. 106 // Add the View to it's parent before showing so that animations can happen.
112 window_container_->AddChild(frame_view); 107 window_container_->AddChild(frame_view);
113 mojo::Rect rect; 108 mojo::Rect rect;
114 rect.x = next_window_origin_.x(); 109 rect.x = next_window_origin_.x();
115 rect.y = next_window_origin_.y(); 110 rect.y = next_window_origin_.y();
116 rect.width = rect.height = 400; 111 rect.width = rect.height = 400;
117 frame_view->SetBounds(rect); 112 frame_view->SetBounds(rect);
118 next_window_origin_.Offset(50, 50); 113 next_window_origin_.Offset(50, 50);
119 114
120 new FrameController( 115 GURL frame_url = url_.Resolve("/examples/wm_flow/wm/window_frame.sky");
121 shell_, frame_view, app_view, window_manager_app_.get()); 116 new FrameController(frame_url, frame_view, app_view,
117 window_manager_app_.get());
122 return frame_view; 118 return frame_view;
123 } 119 }
124 120
125 mojo::Shell* shell_;
126
127 scoped_ptr<mojo::ViewsInit> views_init_;
128
129 scoped_ptr<window_manager::WindowManagerApp> window_manager_app_; 121 scoped_ptr<window_manager::WindowManagerApp> window_manager_app_;
130 122
123 GURL url_;
131 mojo::View* root_; 124 mojo::View* root_;
132 mojo::View* window_container_; 125 mojo::View* window_container_;
133 126
134 gfx::Point next_window_origin_; 127 gfx::Point next_window_origin_;
135 128
136 DISALLOW_COPY_AND_ASSIGN(SimpleWM); 129 DISALLOW_COPY_AND_ASSIGN(SimpleWM);
137 }; 130 };
138 131
139 } // namespace examples 132 } // namespace examples
140 133
141 MojoResult MojoMain(MojoHandle shell_handle) { 134 MojoResult MojoMain(MojoHandle shell_handle) {
142 mojo::ApplicationRunnerChromium runner(new examples::SimpleWM); 135 mojo::ApplicationRunnerChromium runner(new examples::SimpleWM);
143 return runner.Run(shell_handle); 136 return runner.Run(shell_handle);
144 } 137 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698