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

Side by Side Diff: mojo/services/view_manager/window_tree_host_impl.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 | « mojo/services/view_manager/view_manager_service_impl.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/services/view_manager/root_node_manager.h"
6 #include "mojo/services/view_manager/window_tree_host_impl.h" 5 #include "mojo/services/view_manager/window_tree_host_impl.h"
6
7 #include "mojo/public/c/gles2/gles2.h" 7 #include "mojo/public/c/gles2/gles2.h"
8 #include "mojo/services/public/cpp/geometry/geometry_type_converters.h" 8 #include "mojo/services/public/cpp/geometry/geometry_type_converters.h"
9 #include "mojo/services/view_manager/context_factory_impl.h" 9 #include "mojo/services/view_manager/context_factory_impl.h"
10 #include "ui/aura/env.h" 10 #include "ui/aura/env.h"
11 #include "ui/aura/layout_manager.h"
12 #include "ui/aura/window.h" 11 #include "ui/aura/window.h"
13 #include "ui/aura/window_event_dispatcher.h" 12 #include "ui/aura/window_event_dispatcher.h"
14 #include "ui/compositor/compositor.h" 13 #include "ui/compositor/compositor.h"
15 #include "ui/events/event.h" 14 #include "ui/events/event.h"
16 #include "ui/events/event_constants.h" 15 #include "ui/events/event_constants.h"
17 #include "ui/gfx/geometry/insets.h" 16 #include "ui/gfx/geometry/insets.h"
18 #include "ui/gfx/geometry/rect.h" 17 #include "ui/gfx/geometry/rect.h"
19 18
20 namespace mojo { 19 namespace mojo {
21 namespace view_manager { 20 namespace view_manager {
22 namespace service { 21 namespace service {
23 22
24 // TODO(sky): nuke this. It shouldn't be static. 23 // TODO(sky): nuke this. It shouldn't be static.
25 // static 24 // static
26 ContextFactoryImpl* WindowTreeHostImpl::context_factory_ = NULL; 25 ContextFactoryImpl* WindowTreeHostImpl::context_factory_ = NULL;
27 26
28 //////////////////////////////////////////////////////////////////////////////// 27 ////////////////////////////////////////////////////////////////////////////////
29 // RootLayoutManager, layout management for the root window's (one) child
30
31 class RootLayoutManager : public aura::LayoutManager {
32 public:
33 RootLayoutManager() : child_(NULL) { }
34
35 // Overridden from aura::LayoutManager
36 virtual void OnWindowResized() OVERRIDE;
37 virtual void OnWindowAddedToLayout(aura::Window* child) OVERRIDE;
38 virtual void OnWillRemoveWindowFromLayout(aura::Window* child) OVERRIDE {}
39 virtual void OnWindowRemovedFromLayout(aura::Window* child) OVERRIDE {}
40 virtual void OnChildWindowVisibilityChanged(aura::Window* child,
41 bool visible) OVERRIDE {}
42 virtual void SetChildBounds(aura::Window* child,
43 const gfx::Rect& requested_bounds) OVERRIDE;
44 private:
45 aura::Window* child_;
46
47 DISALLOW_COPY_AND_ASSIGN(RootLayoutManager);
48 };
49
50 void RootLayoutManager::OnWindowResized() {
51 if (child_) {
52 gfx::Rect bounds = child_->parent()->bounds();
53 child_->SetBounds(gfx::Rect(0, 0, bounds.width(), bounds.height()));
54 }
55 }
56
57 void RootLayoutManager::OnWindowAddedToLayout(aura::Window* child) {
58 DCHECK(!child_);
59 child_ = child;
60 }
61
62 void RootLayoutManager::SetChildBounds(aura::Window* child,
63 const gfx::Rect& requested_bounds) {
64 SetChildBoundsDirect(child, gfx::Rect(
65 requested_bounds.width(),
66 requested_bounds.height()));
67 }
68
69 ////////////////////////////////////////////////////////////////////////////////
70 // WindowTreeHostImpl, public: 28 // WindowTreeHostImpl, public:
71 29
72 WindowTreeHostImpl::WindowTreeHostImpl( 30 WindowTreeHostImpl::WindowTreeHostImpl(
73 NativeViewportPtr viewport, 31 NativeViewportPtr viewport,
74 const gfx::Rect& bounds, 32 const gfx::Rect& bounds,
75 const base::Callback<void()>& compositor_created_callback) 33 const base::Callback<void()>& compositor_created_callback)
76 : native_viewport_(viewport.Pass()), 34 : native_viewport_(viewport.Pass()),
77 compositor_created_callback_(compositor_created_callback), 35 compositor_created_callback_(compositor_created_callback),
78 bounds_(bounds) { 36 bounds_(bounds) {
79 native_viewport_.set_client(this); 37 native_viewport_.set_client(this);
80 native_viewport_->Create(Rect::From(bounds)); 38 native_viewport_->Create(Rect::From(bounds));
81 39
82 MessagePipe pipe; 40 MessagePipe pipe;
83 native_viewport_->CreateGLES2Context( 41 native_viewport_->CreateGLES2Context(
84 MakeRequest<CommandBuffer>(pipe.handle0.Pass())); 42 MakeRequest<CommandBuffer>(pipe.handle0.Pass()));
85 43
86 // The ContextFactory must exist before any Compositors are created. 44 // The ContextFactory must exist before any Compositors are created.
87 if (context_factory_) { 45 if (context_factory_) {
88 delete context_factory_; 46 delete context_factory_;
89 context_factory_ = NULL; 47 context_factory_ = NULL;
90 } 48 }
91 context_factory_ = new ContextFactoryImpl(pipe.handle1.Pass()); 49 context_factory_ = new ContextFactoryImpl(pipe.handle1.Pass());
92 aura::Env::GetInstance()->set_context_factory(context_factory_); 50 aura::Env::GetInstance()->set_context_factory(context_factory_);
93
94 window()->SetLayoutManager(new RootLayoutManager());
95 } 51 }
96 52
97 WindowTreeHostImpl::~WindowTreeHostImpl() { 53 WindowTreeHostImpl::~WindowTreeHostImpl() {
98 DestroyCompositor(); 54 DestroyCompositor();
99 DestroyDispatcher(); 55 DestroyDispatcher();
100 } 56 }
101 57
102 //////////////////////////////////////////////////////////////////////////////// 58 ////////////////////////////////////////////////////////////////////////////////
103 // WindowTreeHostImpl, aura::WindowTreeHost implementation: 59 // WindowTreeHostImpl, aura::WindowTreeHost implementation:
104 60
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 break; 175 break;
220 } 176 }
221 // TODO(beng): touch, etc. 177 // TODO(beng): touch, etc.
222 } 178 }
223 callback.Run(); 179 callback.Run();
224 }; 180 };
225 181
226 } // namespace service 182 } // namespace service
227 } // namespace view_manager 183 } // namespace view_manager
228 } // namespace mojo 184 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/services/view_manager/view_manager_service_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698