OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ui/views/widget/desktop_aura/desktop_native_widget_aura.h" | 5 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/debug/trace_event.h" | 8 #include "base/debug/trace_event.h" |
9 #include "ui/aura/client/activation_client.h" | 9 #include "ui/aura/client/activation_client.h" |
10 #include "ui/aura/client/aura_constants.h" | 10 #include "ui/aura/client/aura_constants.h" |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
203 | 203 |
204 private: | 204 private: |
205 DesktopNativeWidgetAura* desktop_native_widget_aura_; | 205 DesktopNativeWidgetAura* desktop_native_widget_aura_; |
206 | 206 |
207 DISALLOW_COPY_AND_ASSIGN(FocusManagerEventHandler); | 207 DISALLOW_COPY_AND_ASSIGN(FocusManagerEventHandler); |
208 }; | 208 }; |
209 | 209 |
210 //////////////////////////////////////////////////////////////////////////////// | 210 //////////////////////////////////////////////////////////////////////////////// |
211 // DesktopNativeWidgetAura, public: | 211 // DesktopNativeWidgetAura, public: |
212 | 212 |
213 int DesktopNativeWidgetAura::cursor_reference_count_ = 0; | |
213 DesktopNativeCursorManager* DesktopNativeWidgetAura::native_cursor_manager_ = | 214 DesktopNativeCursorManager* DesktopNativeWidgetAura::native_cursor_manager_ = |
214 NULL; | 215 NULL; |
215 views::corewm::CursorManager* DesktopNativeWidgetAura::cursor_manager_ = NULL; | 216 views::corewm::CursorManager* DesktopNativeWidgetAura::cursor_manager_ = NULL; |
216 | 217 |
217 DesktopNativeWidgetAura::DesktopNativeWidgetAura( | 218 DesktopNativeWidgetAura::DesktopNativeWidgetAura( |
218 internal::NativeWidgetDelegate* delegate) | 219 internal::NativeWidgetDelegate* delegate) |
219 : ownership_(Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET), | 220 : ownership_(Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET), |
220 close_widget_factory_(this), | 221 close_widget_factory_(this), |
221 can_activate_(true), | 222 can_activate_(true), |
222 desktop_root_window_host_(NULL), | 223 desktop_root_window_host_(NULL), |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
294 aura::client::SetFocusClient(root->window(), NULL); | 295 aura::client::SetFocusClient(root->window(), NULL); |
295 aura::client::SetActivationClient(root->window(), NULL); | 296 aura::client::SetActivationClient(root->window(), NULL); |
296 focus_client_.reset(); | 297 focus_client_.reset(); |
297 | 298 |
298 aura::client::SetDispatcherClient(root->window(), NULL); | 299 aura::client::SetDispatcherClient(root->window(), NULL); |
299 dispatcher_client_.reset(); | 300 dispatcher_client_.reset(); |
300 | 301 |
301 aura::client::SetCursorClient(root->window(), NULL); | 302 aura::client::SetCursorClient(root->window(), NULL); |
302 native_cursor_manager_->RemoveRootWindow(root); | 303 native_cursor_manager_->RemoveRootWindow(root); |
303 | 304 |
305 cursor_reference_count_--; | |
306 if (cursor_reference_count_ == 0) { | |
307 // We are the last DesktopNativeWidgetAura instance, and we are responsible | |
308 // for cleaning up |cursor_manager_|. | |
309 delete cursor_manager_; | |
310 native_cursor_manager_ = NULL; | |
311 cursor_manager_ = NULL; | |
312 } | |
sadrul
2014/01/15 22:15:01
This looks a bit hairy. Perhaps there could be a [
| |
313 | |
304 aura::client::SetScreenPositionClient(root->window(), NULL); | 314 aura::client::SetScreenPositionClient(root->window(), NULL); |
305 position_client_.reset(); | 315 position_client_.reset(); |
306 | 316 |
307 aura::client::SetDragDropClient(root->window(), NULL); | 317 aura::client::SetDragDropClient(root->window(), NULL); |
308 drag_drop_client_.reset(); | 318 drag_drop_client_.reset(); |
309 | 319 |
310 aura::client::SetEventClient(root->window(), NULL); | 320 aura::client::SetEventClient(root->window(), NULL); |
311 event_client_.reset(); | 321 event_client_.reset(); |
312 } | 322 } |
313 | 323 |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
390 // CEF sets focus to the window the user clicks down on. | 400 // CEF sets focus to the window the user clicks down on. |
391 // TODO(beng): see if we can't do this some other way. CEF seems a heavy- | 401 // TODO(beng): see if we can't do this some other way. CEF seems a heavy- |
392 // handed way of accomplishing focus. | 402 // handed way of accomplishing focus. |
393 // No event filter for aura::Env. Create CompoundEvnetFilter per RootWindow. | 403 // No event filter for aura::Env. Create CompoundEvnetFilter per RootWindow. |
394 root_window_event_filter_ = new corewm::CompoundEventFilter; | 404 root_window_event_filter_ = new corewm::CompoundEventFilter; |
395 // Pass ownership of the filter to the root_window. | 405 // Pass ownership of the filter to the root_window. |
396 root_window_->window()->SetEventFilter(root_window_event_filter_); | 406 root_window_->window()->SetEventFilter(root_window_event_filter_); |
397 | 407 |
398 // |root_window_| must be added to |native_cursor_manager_| before | 408 // |root_window_| must be added to |native_cursor_manager_| before |
399 // OnRootWindowCreated() is called. | 409 // OnRootWindowCreated() is called. |
410 cursor_reference_count_++; | |
400 if (!native_cursor_manager_) { | 411 if (!native_cursor_manager_) { |
401 native_cursor_manager_ = new DesktopNativeCursorManager( | 412 native_cursor_manager_ = new DesktopNativeCursorManager( |
402 DesktopCursorLoaderUpdater::Create()); | 413 DesktopCursorLoaderUpdater::Create()); |
403 } | 414 } |
404 if (!cursor_manager_) { | 415 if (!cursor_manager_) { |
405 cursor_manager_ = new views::corewm::CursorManager( | 416 cursor_manager_ = new views::corewm::CursorManager( |
406 scoped_ptr<corewm::NativeCursorManager>(native_cursor_manager_)); | 417 scoped_ptr<corewm::NativeCursorManager>(native_cursor_manager_)); |
407 } | 418 } |
408 native_cursor_manager_->AddRootWindow(root_window_.get()); | 419 native_cursor_manager_->AddRootWindow(root_window_.get()); |
409 aura::client::SetCursorClient(root_window_->window(), cursor_manager_); | 420 aura::client::SetCursorClient(root_window_->window(), cursor_manager_); |
(...skipping 712 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1122 input_method_event_filter_->SetInputMethodPropertyInRootWindow( | 1133 input_method_event_filter_->SetInputMethodPropertyInRootWindow( |
1123 root_window_->window()); | 1134 root_window_->window()); |
1124 root_window_event_filter_->AddHandler(input_method_event_filter_.get()); | 1135 root_window_event_filter_->AddHandler(input_method_event_filter_.get()); |
1125 } | 1136 } |
1126 | 1137 |
1127 void DesktopNativeWidgetAura::UpdateWindowTransparency() { | 1138 void DesktopNativeWidgetAura::UpdateWindowTransparency() { |
1128 content_window_->SetTransparent(ShouldUseNativeFrame()); | 1139 content_window_->SetTransparent(ShouldUseNativeFrame()); |
1129 } | 1140 } |
1130 | 1141 |
1131 } // namespace views | 1142 } // namespace views |
OLD | NEW |