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/trace_event/trace_event.h" | 8 #include "base/trace_event/trace_event.h" |
9 #include "ui/aura/client/aura_constants.h" | 9 #include "ui/aura/client/aura_constants.h" |
10 #include "ui/aura/client/cursor_client.h" | 10 #include "ui/aura/client/cursor_client.h" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 #include "ui/views/widget/root_view.h" | 44 #include "ui/views/widget/root_view.h" |
45 #include "ui/views/widget/tooltip_manager_aura.h" | 45 #include "ui/views/widget/tooltip_manager_aura.h" |
46 #include "ui/views/widget/widget.h" | 46 #include "ui/views/widget/widget.h" |
47 #include "ui/views/widget/widget_aura_utils.h" | 47 #include "ui/views/widget/widget_aura_utils.h" |
48 #include "ui/views/widget/widget_delegate.h" | 48 #include "ui/views/widget/widget_delegate.h" |
49 #include "ui/views/widget/window_reorderer.h" | 49 #include "ui/views/widget/window_reorderer.h" |
50 #include "ui/views/window/native_frame_view.h" | 50 #include "ui/views/window/native_frame_view.h" |
51 #include "ui/wm/core/compound_event_filter.h" | 51 #include "ui/wm/core/compound_event_filter.h" |
52 #include "ui/wm/core/cursor_manager.h" | 52 #include "ui/wm/core/cursor_manager.h" |
53 #include "ui/wm/core/focus_controller.h" | 53 #include "ui/wm/core/focus_controller.h" |
54 #include "ui/wm/core/input_method_event_filter.h" | |
55 #include "ui/wm/core/native_cursor_manager.h" | 54 #include "ui/wm/core/native_cursor_manager.h" |
56 #include "ui/wm/core/shadow_controller.h" | 55 #include "ui/wm/core/shadow_controller.h" |
57 #include "ui/wm/core/shadow_types.h" | 56 #include "ui/wm/core/shadow_types.h" |
58 #include "ui/wm/core/visibility_controller.h" | 57 #include "ui/wm/core/visibility_controller.h" |
59 #include "ui/wm/core/window_animations.h" | 58 #include "ui/wm/core/window_animations.h" |
60 #include "ui/wm/core/window_modality_controller.h" | 59 #include "ui/wm/core/window_modality_controller.h" |
61 #include "ui/wm/public/activation_client.h" | 60 #include "ui/wm/public/activation_client.h" |
62 #include "ui/wm/public/drag_drop_client.h" | 61 #include "ui/wm/public/drag_drop_client.h" |
63 | 62 |
64 #if defined(OS_WIN) | 63 #if defined(OS_WIN) |
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
303 // DesktopWindowTreeHost owns the ActivationController which ShadowController | 302 // DesktopWindowTreeHost owns the ActivationController which ShadowController |
304 // references. Make sure we destroy ShadowController early on. | 303 // references. Make sure we destroy ShadowController early on. |
305 shadow_controller_.reset(); | 304 shadow_controller_.reset(); |
306 tooltip_manager_.reset(); | 305 tooltip_manager_.reset(); |
307 if (tooltip_controller_.get()) { | 306 if (tooltip_controller_.get()) { |
308 host_->window()->RemovePreTargetHandler(tooltip_controller_.get()); | 307 host_->window()->RemovePreTargetHandler(tooltip_controller_.get()); |
309 aura::client::SetTooltipClient(host_->window(), NULL); | 308 aura::client::SetTooltipClient(host_->window(), NULL); |
310 tooltip_controller_.reset(); | 309 tooltip_controller_.reset(); |
311 } | 310 } |
312 | 311 |
313 root_window_event_filter_->RemoveHandler(input_method_event_filter_.get()); | |
314 | |
315 window_tree_client_.reset(); // Uses host_->dispatcher() at destruction. | 312 window_tree_client_.reset(); // Uses host_->dispatcher() at destruction. |
316 | 313 |
317 capture_client_.reset(); // Uses host_->dispatcher() at destruction. | 314 capture_client_.reset(); // Uses host_->dispatcher() at destruction. |
318 | 315 |
319 // FocusController uses |content_window_|. Destroy it now so that we don't | 316 // FocusController uses |content_window_|. Destroy it now so that we don't |
320 // have to worry about the possibility of FocusController attempting to use | 317 // have to worry about the possibility of FocusController attempting to use |
321 // |content_window_| after it's been destroyed but before all child windows | 318 // |content_window_| after it's been destroyed but before all child windows |
322 // have been destroyed. | 319 // have been destroyed. |
323 host_->window()->RemovePreTargetHandler(focus_client_.get()); | 320 host_->window()->RemovePreTargetHandler(focus_client_.get()); |
324 aura::client::SetFocusClient(host_->window(), NULL); | 321 aura::client::SetFocusClient(host_->window(), NULL); |
325 aura::client::SetActivationClient(host_->window(), NULL); | 322 aura::client::SetActivationClient(host_->window(), NULL); |
326 focus_client_.reset(); | 323 focus_client_.reset(); |
327 | 324 |
328 host_->RemoveObserver(this); | 325 host_->RemoveObserver(this); |
329 host_.reset(); // Uses input_method_event_filter_ at destruction. | 326 host_.reset(); |
330 // WindowEventDispatcher owns |desktop_window_tree_host_|. | 327 // WindowEventDispatcher owns |desktop_window_tree_host_|. |
331 desktop_window_tree_host_ = NULL; | 328 desktop_window_tree_host_ = NULL; |
332 content_window_ = NULL; | 329 content_window_ = NULL; |
333 | 330 |
334 native_widget_delegate_->OnNativeWidgetDestroyed(); | 331 native_widget_delegate_->OnNativeWidgetDestroyed(); |
335 if (ownership_ == Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET) | 332 if (ownership_ == Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET) |
336 delete this; | 333 delete this; |
337 } | 334 } |
338 | 335 |
339 void DesktopNativeWidgetAura::OnDesktopWindowTreeHostDestroyed( | 336 void DesktopNativeWidgetAura::OnDesktopWindowTreeHostDestroyed( |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
479 aura::client::SetFocusClient(host_->window(), focus_controller); | 476 aura::client::SetFocusClient(host_->window(), focus_controller); |
480 aura::client::SetActivationClient(host_->window(), focus_controller); | 477 aura::client::SetActivationClient(host_->window(), focus_controller); |
481 host_->window()->AddPreTargetHandler(focus_controller); | 478 host_->window()->AddPreTargetHandler(focus_controller); |
482 | 479 |
483 dispatcher_client_.reset(new DesktopDispatcherClient); | 480 dispatcher_client_.reset(new DesktopDispatcherClient); |
484 aura::client::SetDispatcherClient(host_->window(), | 481 aura::client::SetDispatcherClient(host_->window(), |
485 dispatcher_client_.get()); | 482 dispatcher_client_.get()); |
486 | 483 |
487 position_client_.reset(new DesktopScreenPositionClient(host_->window())); | 484 position_client_.reset(new DesktopScreenPositionClient(host_->window())); |
488 | 485 |
489 InstallInputMethodEventFilter(); | |
490 | |
491 drag_drop_client_ = desktop_window_tree_host_->CreateDragDropClient( | 486 drag_drop_client_ = desktop_window_tree_host_->CreateDragDropClient( |
492 native_cursor_manager_); | 487 native_cursor_manager_); |
493 aura::client::SetDragDropClient(host_->window(), | 488 aura::client::SetDragDropClient(host_->window(), |
494 drag_drop_client_.get()); | 489 drag_drop_client_.get()); |
495 | 490 |
496 static_cast<aura::client::FocusClient*>(focus_client_.get())-> | 491 static_cast<aura::client::FocusClient*>(focus_client_.get())-> |
497 FocusWindow(content_window_); | 492 FocusWindow(content_window_); |
498 | 493 |
499 OnHostResized(host()); | 494 OnHostResized(host()); |
500 | 495 |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
630 | 625 |
631 bool DesktopNativeWidgetAura::HasCapture() const { | 626 bool DesktopNativeWidgetAura::HasCapture() const { |
632 return content_window_ && content_window_->HasCapture() && | 627 return content_window_ && content_window_->HasCapture() && |
633 desktop_window_tree_host_->HasCapture(); | 628 desktop_window_tree_host_->HasCapture(); |
634 } | 629 } |
635 | 630 |
636 InputMethod* DesktopNativeWidgetAura::CreateInputMethod() { | 631 InputMethod* DesktopNativeWidgetAura::CreateInputMethod() { |
637 if (switches::IsTextInputFocusManagerEnabled()) | 632 if (switches::IsTextInputFocusManagerEnabled()) |
638 return new NullInputMethod(); | 633 return new NullInputMethod(); |
639 | 634 |
640 ui::InputMethod* host = input_method_event_filter_->input_method(); | 635 return new InputMethodBridge(this, GetHostInputMethod(), false); |
641 return new InputMethodBridge(this, host, false); | |
642 } | 636 } |
643 | 637 |
644 internal::InputMethodDelegate* | 638 internal::InputMethodDelegate* |
645 DesktopNativeWidgetAura::GetInputMethodDelegate() { | 639 DesktopNativeWidgetAura::GetInputMethodDelegate() { |
646 return this; | 640 return this; |
647 } | 641 } |
648 | 642 |
649 ui::InputMethod* DesktopNativeWidgetAura::GetHostInputMethod() { | 643 ui::InputMethod* DesktopNativeWidgetAura::GetHostInputMethod() { |
650 return input_method_event_filter_->input_method(); | 644 return host()->GetInputMethod(); |
651 } | 645 } |
652 | 646 |
653 void DesktopNativeWidgetAura::CenterWindow(const gfx::Size& size) { | 647 void DesktopNativeWidgetAura::CenterWindow(const gfx::Size& size) { |
654 if (content_window_) | 648 if (content_window_) |
655 desktop_window_tree_host_->CenterWindow(size); | 649 desktop_window_tree_host_->CenterWindow(size); |
656 } | 650 } |
657 | 651 |
658 void DesktopNativeWidgetAura::GetWindowPlacement( | 652 void DesktopNativeWidgetAura::GetWindowPlacement( |
659 gfx::Rect* bounds, | 653 gfx::Rect* bounds, |
660 ui::WindowShowState* maximized) const { | 654 ui::WindowShowState* maximized) const { |
(...skipping 557 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1218 const gfx::Point& new_origin) { | 1212 const gfx::Point& new_origin) { |
1219 TRACE_EVENT1("views", "DesktopNativeWidgetAura::OnHostMoved", | 1213 TRACE_EVENT1("views", "DesktopNativeWidgetAura::OnHostMoved", |
1220 "new_origin", new_origin.ToString()); | 1214 "new_origin", new_origin.ToString()); |
1221 | 1215 |
1222 native_widget_delegate_->OnNativeWidgetMove(); | 1216 native_widget_delegate_->OnNativeWidgetMove(); |
1223 } | 1217 } |
1224 | 1218 |
1225 //////////////////////////////////////////////////////////////////////////////// | 1219 //////////////////////////////////////////////////////////////////////////////// |
1226 // DesktopNativeWidgetAura, private: | 1220 // DesktopNativeWidgetAura, private: |
1227 | 1221 |
1228 void DesktopNativeWidgetAura::InstallInputMethodEventFilter() { | |
1229 DCHECK(!input_method_event_filter_.get()); | |
1230 | |
1231 input_method_event_filter_.reset(new wm::InputMethodEventFilter( | |
1232 host_->GetAcceleratedWidget())); | |
1233 input_method_event_filter_->SetInputMethodPropertyInRootWindow( | |
1234 host_->window()); | |
1235 root_window_event_filter_->AddHandler(input_method_event_filter_.get()); | |
1236 } | |
1237 | |
1238 void DesktopNativeWidgetAura::UpdateWindowTransparency() { | 1222 void DesktopNativeWidgetAura::UpdateWindowTransparency() { |
1239 content_window_->SetTransparent( | 1223 content_window_->SetTransparent( |
1240 desktop_window_tree_host_->ShouldWindowContentsBeTransparent()); | 1224 desktop_window_tree_host_->ShouldWindowContentsBeTransparent()); |
1241 // Regardless of transparency or not, this root content window will always | 1225 // Regardless of transparency or not, this root content window will always |
1242 // fill its bounds completely, so set this flag to true to avoid an | 1226 // fill its bounds completely, so set this flag to true to avoid an |
1243 // unecessary clear before update. | 1227 // unecessary clear before update. |
1244 content_window_->SetFillsBoundsCompletely(true); | 1228 content_window_->SetFillsBoundsCompletely(true); |
1245 } | 1229 } |
1246 | 1230 |
1247 void DesktopNativeWidgetAura::RootWindowDestroyed() { | 1231 void DesktopNativeWidgetAura::RootWindowDestroyed() { |
1248 cursor_reference_count_--; | 1232 cursor_reference_count_--; |
1249 if (cursor_reference_count_ == 0) { | 1233 if (cursor_reference_count_ == 0) { |
1250 // We are the last DesktopNativeWidgetAura instance, and we are responsible | 1234 // We are the last DesktopNativeWidgetAura instance, and we are responsible |
1251 // for cleaning up |cursor_manager_|. | 1235 // for cleaning up |cursor_manager_|. |
1252 delete cursor_manager_; | 1236 delete cursor_manager_; |
1253 native_cursor_manager_ = NULL; | 1237 native_cursor_manager_ = NULL; |
1254 cursor_manager_ = NULL; | 1238 cursor_manager_ = NULL; |
1255 } | 1239 } |
1256 } | 1240 } |
1257 | 1241 |
1258 } // namespace views | 1242 } // namespace views |
OLD | NEW |