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

Side by Side Diff: mojo/views/native_widget_view_manager.cc

Issue 383123006: Preliminary interactive layout of window manager's demo_launcher (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: OK 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
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/views/native_widget_view_manager.h" 5 #include "mojo/views/native_widget_view_manager.h"
6 6
7 #include "mojo/aura/window_tree_host_mojo.h" 7 #include "mojo/aura/window_tree_host_mojo.h"
8 #include "mojo/services/public/cpp/input_events/input_events_type_converters.h" 8 #include "mojo/services/public/cpp/input_events/input_events_type_converters.h"
9 #include "mojo/services/public/cpp/view_manager/view.h" 9 #include "mojo/services/public/cpp/view_manager/view.h"
10 #include "ui/aura/client/aura_constants.h" 10 #include "ui/aura/client/aura_constants.h"
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 aura::client::SetActivationClient(window_tree_host_->window(), 106 aura::client::SetActivationClient(window_tree_host_->window(),
107 focus_client_.get()); 107 focus_client_.get());
108 window_tree_host_->window()->AddPreTargetHandler(focus_client_.get()); 108 window_tree_host_->window()->AddPreTargetHandler(focus_client_.get());
109 109
110 aura::client::SetCaptureClient( 110 aura::client::SetCaptureClient(
111 window_tree_host_->window(), 111 window_tree_host_->window(),
112 new aura::client::DefaultCaptureClient(window_tree_host_->window())); 112 new aura::client::DefaultCaptureClient(window_tree_host_->window()));
113 } 113 }
114 114
115 NativeWidgetViewManager::~NativeWidgetViewManager() { 115 NativeWidgetViewManager::~NativeWidgetViewManager() {
116 if (node_->active_view()) 116 if (node_) {
117 node_->active_view()->RemoveObserver(this); 117 if (node_->active_view())
118 node_->RemoveObserver(this); 118 node_->active_view()->RemoveObserver(this);
119 node_->RemoveObserver(this);
120 }
119 } 121 }
120 122
121 void NativeWidgetViewManager::InitNativeWidget( 123 void NativeWidgetViewManager::InitNativeWidget(
122 const views::Widget::InitParams& in_params) { 124 const views::Widget::InitParams& in_params) {
123 views::Widget::InitParams params(in_params); 125 views::Widget::InitParams params(in_params);
124 params.parent = window_tree_host_->window(); 126 params.parent = window_tree_host_->window();
125 NativeWidgetAura::InitNativeWidget(params); 127 NativeWidgetAura::InitNativeWidget(params);
126 capture_client_.reset( 128 capture_client_.reset(
127 new wm::ScopedCaptureClient(window_tree_host_->window())); 129 new wm::ScopedCaptureClient(window_tree_host_->window()));
128 } 130 }
129 131
130 void NativeWidgetViewManager::CompositorContentsChanged( 132 void NativeWidgetViewManager::CompositorContentsChanged(
131 const SkBitmap& bitmap) { 133 const SkBitmap& bitmap) {
132 node_->active_view()->SetContents(bitmap); 134 node_->active_view()->SetContents(bitmap);
133 } 135 }
134 136
135 void NativeWidgetViewManager::OnNodeDestroyed(view_manager::Node* node) { 137 void NativeWidgetViewManager::OnNodeDestroyed(view_manager::Node* node) {
138 DCHECK_EQ(node, node_);
139 node->RemoveObserver(this);
sky 2014/07/15 17:47:49 You should remove the observer from the active_vie
hansmuller 2014/07/15 20:07:34 I'll remove the view's observer when the view is d
140 node_ = NULL;
136 window_tree_host_.reset(); 141 window_tree_host_.reset();
137 } 142 }
138 143
144 void NativeWidgetViewManager::OnNodeBoundsChanged(view_manager::Node* node,
145 const gfx::Rect& old_bounds,
146 const gfx::Rect& new_bounds) {
147 GetWidget()->SetBounds(gfx::Rect(node->bounds().size()));
148 }
149
139 void NativeWidgetViewManager::OnNodeActiveViewChanged( 150 void NativeWidgetViewManager::OnNodeActiveViewChanged(
140 view_manager::Node* node, 151 view_manager::Node* node,
141 view_manager::View* old_view, 152 view_manager::View* old_view,
142 view_manager::View* new_view) { 153 view_manager::View* new_view) {
143 if (old_view) 154 if (old_view)
144 old_view->RemoveObserver(this); 155 old_view->RemoveObserver(this);
145 if (new_view) 156 if (new_view)
146 new_view->AddObserver(this); 157 new_view->AddObserver(this);
147 } 158 }
148 159
149 void NativeWidgetViewManager::OnViewInputEvent(view_manager::View* view, 160 void NativeWidgetViewManager::OnViewInputEvent(view_manager::View* view,
150 const EventPtr& event) { 161 const EventPtr& event) {
151 scoped_ptr<ui::Event> ui_event(event.To<scoped_ptr<ui::Event> >()); 162 scoped_ptr<ui::Event> ui_event(event.To<scoped_ptr<ui::Event> >());
152 if (ui_event.get()) 163 if (ui_event.get())
153 window_tree_host_->SendEventToProcessor(ui_event.get()); 164 window_tree_host_->SendEventToProcessor(ui_event.get());
154 } 165 }
155 166
156 } // namespace mojo 167 } // namespace mojo
OLDNEW
« mojo/examples/window_manager/window_manager.cc ('K') | « mojo/views/native_widget_view_manager.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698