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

Side by Side Diff: mojo/examples/window_manager/window_manager.cc

Issue 378243002: Revert of Connect X11 ConfigureNotify events to Mojo (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 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 | « no previous file | mojo/services/gles2/command_buffer_impl.h » ('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 "base/basictypes.h" 5 #include "base/basictypes.h"
6 #include "base/bind.h" 6 #include "base/bind.h"
7 #include "mojo/examples/keyboard/keyboard.mojom.h" 7 #include "mojo/examples/keyboard/keyboard.mojom.h"
8 #include "mojo/examples/window_manager/debug_panel.h" 8 #include "mojo/examples/window_manager/debug_panel.h"
9 #include "mojo/examples/window_manager/window_manager.mojom.h" 9 #include "mojo/examples/window_manager/window_manager.mojom.h"
10 #include "mojo/public/cpp/application/application_connection.h" 10 #include "mojo/public/cpp/application/application_connection.h"
11 #include "mojo/public/cpp/application/application_delegate.h" 11 #include "mojo/public/cpp/application/application_delegate.h"
12 #include "mojo/public/cpp/application/application_impl.h" 12 #include "mojo/public/cpp/application/application_impl.h"
13 #include "mojo/services/public/cpp/geometry/geometry_type_converters.h" 13 #include "mojo/services/public/cpp/geometry/geometry_type_converters.h"
14 #include "mojo/services/public/cpp/input_events/input_events_type_converters.h" 14 #include "mojo/services/public/cpp/input_events/input_events_type_converters.h"
15 #include "mojo/services/public/cpp/view_manager/node.h" 15 #include "mojo/services/public/cpp/view_manager/node.h"
16 #include "mojo/services/public/cpp/view_manager/node_observer.h"
17 #include "mojo/services/public/cpp/view_manager/view.h" 16 #include "mojo/services/public/cpp/view_manager/view.h"
18 #include "mojo/services/public/cpp/view_manager/view_event_dispatcher.h" 17 #include "mojo/services/public/cpp/view_manager/view_event_dispatcher.h"
19 #include "mojo/services/public/cpp/view_manager/view_manager.h" 18 #include "mojo/services/public/cpp/view_manager/view_manager.h"
20 #include "mojo/services/public/cpp/view_manager/view_manager_delegate.h" 19 #include "mojo/services/public/cpp/view_manager/view_manager_delegate.h"
21 #include "mojo/services/public/cpp/view_manager/view_observer.h" 20 #include "mojo/services/public/cpp/view_manager/view_observer.h"
22 #include "mojo/services/public/interfaces/input_events/input_events.mojom.h" 21 #include "mojo/services/public/interfaces/input_events/input_events.mojom.h"
23 #include "mojo/services/public/interfaces/launcher/launcher.mojom.h" 22 #include "mojo/services/public/interfaces/launcher/launcher.mojom.h"
24 #include "mojo/services/public/interfaces/navigation/navigation.mojom.h" 23 #include "mojo/services/public/interfaces/navigation/navigation.mojom.h"
25 #include "mojo/views/views_init.h" 24 #include "mojo/views/views_init.h"
26 #include "ui/events/event.h" 25 #include "ui/events/event.h"
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 149
151 KeyboardServicePtr keyboard_service_; 150 KeyboardServicePtr keyboard_service_;
152 ViewManager* view_manager_; 151 ViewManager* view_manager_;
153 152
154 // Node the keyboard is attached to. 153 // Node the keyboard is attached to.
155 Node* node_; 154 Node* node_;
156 155
157 DISALLOW_COPY_AND_ASSIGN(KeyboardManager); 156 DISALLOW_COPY_AND_ASSIGN(KeyboardManager);
158 }; 157 };
159 158
160 class RootLayoutManager : public NodeObserver {
161 public:
162 explicit RootLayoutManager(ViewManager* view_manager,
163 Node* root,
164 Id content_node_id)
165 : root_(root),
166 view_manager_(view_manager),
167 content_node_id_(content_node_id) {}
168 virtual ~RootLayoutManager() {}
169
170 private:
171 // Overridden from NodeObserver:
172 virtual void OnNodeBoundsChanged(Node* node,
173 const gfx::Rect& /*old_bounds*/,
174 const gfx::Rect& new_bounds) OVERRIDE {
175 DCHECK_EQ(node, root_);
176 Node* content_node = view_manager_->GetNodeById(content_node_id_);
177 content_node->SetBounds(new_bounds);
178 // Force the view's bitmap to be recreated
179 content_node->active_view()->SetColor(SK_ColorBLUE);
180 // TODO(hansmuller): Do Layout
181 }
182
183 Node* root_;
184 ViewManager* view_manager_;
185 Id content_node_id_;
186
187 DISALLOW_COPY_AND_ASSIGN(RootLayoutManager);
188 };
189
190 class WindowManager : public ApplicationDelegate, 159 class WindowManager : public ApplicationDelegate,
191 public DebugPanel::Delegate, 160 public DebugPanel::Delegate,
192 public ViewObserver, 161 public ViewObserver,
193 public ViewManagerDelegate, 162 public ViewManagerDelegate,
194 public ViewEventDispatcher { 163 public ViewEventDispatcher {
195 public: 164 public:
196 WindowManager() 165 WindowManager()
197 : launcher_ui_(NULL), 166 : launcher_ui_(NULL),
198 view_manager_(NULL), 167 view_manager_(NULL),
199 app_(NULL) { 168 app_(NULL) {
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 return true; 243 return true;
275 } 244 }
276 245
277 // Overridden from ViewManagerDelegate: 246 // Overridden from ViewManagerDelegate:
278 virtual void OnRootAdded(ViewManager* view_manager, Node* root) OVERRIDE { 247 virtual void OnRootAdded(ViewManager* view_manager, Node* root) OVERRIDE {
279 DCHECK(!view_manager_); 248 DCHECK(!view_manager_);
280 view_manager_ = view_manager; 249 view_manager_ = view_manager;
281 view_manager_->SetEventDispatcher(this); 250 view_manager_->SetEventDispatcher(this);
282 251
283 Node* node = Node::Create(view_manager); 252 Node* node = Node::Create(view_manager);
284 root->AddChild(node); 253 view_manager->GetRoots().front()->AddChild(node);
285 node->SetBounds(gfx::Rect(root->bounds().size())); 254 node->SetBounds(gfx::Rect(800, 600));
286 content_node_id_ = node->id(); 255 content_node_id_ = node->id();
287 256
288 root_layout_manager_.reset(
289 new RootLayoutManager(view_manager, root, content_node_id_));
290 root->AddObserver(root_layout_manager_.get());
291
292 View* view = View::Create(view_manager); 257 View* view = View::Create(view_manager);
293 node->SetActiveView(view); 258 node->SetActiveView(view);
294 view->SetColor(SK_ColorBLUE); 259 view->SetColor(SK_ColorBLUE);
295 view->AddObserver(this); 260 view->AddObserver(this);
296 261
297 CreateLauncherUI(); 262 CreateLauncherUI();
298 CreateControlPanel(node); 263 CreateControlPanel(node);
299 } 264 }
300 265
301 // Overridden from ViewEventDispatcher: 266 // Overridden from ViewEventDispatcher:
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
423 388
424 debug_panel_ = new DebugPanel(this, node); 389 debug_panel_ = new DebugPanel(this, node);
425 } 390 }
426 391
427 scoped_ptr<ViewsInit> views_init_; 392 scoped_ptr<ViewsInit> views_init_;
428 DebugPanel* debug_panel_; 393 DebugPanel* debug_panel_;
429 launcher::LauncherPtr launcher_; 394 launcher::LauncherPtr launcher_;
430 Node* launcher_ui_; 395 Node* launcher_ui_;
431 std::vector<Node*> windows_; 396 std::vector<Node*> windows_;
432 ViewManager* view_manager_; 397 ViewManager* view_manager_;
433 scoped_ptr<RootLayoutManager> root_layout_manager_;
434 398
435 // Id of the node most content is added to. The keyboard is NOT added here. 399 // Id of the node most content is added to. The keyboard is NOT added here.
436 Id content_node_id_; 400 Id content_node_id_;
437 401
438 scoped_ptr<KeyboardManager> keyboard_manager_; 402 scoped_ptr<KeyboardManager> keyboard_manager_;
439 ApplicationImpl* app_; 403 ApplicationImpl* app_;
440 404
441 DISALLOW_COPY_AND_ASSIGN(WindowManager); 405 DISALLOW_COPY_AND_ASSIGN(WindowManager);
442 }; 406 };
443 407
(...skipping 22 matching lines...) Expand all
466 } 430 }
467 431
468 } // namespace examples 432 } // namespace examples
469 433
470 // static 434 // static
471 ApplicationDelegate* ApplicationDelegate::Create() { 435 ApplicationDelegate* ApplicationDelegate::Create() {
472 return new examples::WindowManager; 436 return new examples::WindowManager;
473 } 437 }
474 438
475 } // namespace mojo 439 } // namespace mojo
OLDNEW
« no previous file with comments | « no previous file | mojo/services/gles2/command_buffer_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698