| 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 "ui/aura/client/stacking_client.h" | 8 #include "ui/aura/client/stacking_client.h" |
| 9 #include "ui/aura/focus_manager.h" | 9 #include "ui/aura/focus_manager.h" |
| 10 #include "ui/aura/root_window.h" | 10 #include "ui/aura/root_window.h" |
| (...skipping 610 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 621 aura::Window* lost_active) { | 621 aura::Window* lost_active) { |
| 622 DCHECK(window_ == gained_active || window_ == lost_active); | 622 DCHECK(window_ == gained_active || window_ == lost_active); |
| 623 if ((window_ == gained_active || window_ == lost_active) && | 623 if ((window_ == gained_active || window_ == lost_active) && |
| 624 IsVisible() && GetWidget()->non_client_view()) { | 624 IsVisible() && GetWidget()->non_client_view()) { |
| 625 GetWidget()->non_client_view()->SchedulePaint(); | 625 GetWidget()->non_client_view()->SchedulePaint(); |
| 626 } | 626 } |
| 627 if (gained_active == window_ && restore_focus_on_activate_) { | 627 if (gained_active == window_ && restore_focus_on_activate_) { |
| 628 restore_focus_on_activate_ = false; | 628 restore_focus_on_activate_ = false; |
| 629 GetWidget()->GetFocusManager()->RestoreFocusedView(); | 629 GetWidget()->GetFocusManager()->RestoreFocusedView(); |
| 630 } else if (lost_active == window_ && GetWidget()->HasFocusManager()) { | 630 } else if (lost_active == window_ && GetWidget()->HasFocusManager()) { |
| 631 DCHECK(!restore_focus_on_activate_); | 631 // If we're losing focus to a window that is a top level (such as a bubble) |
| 632 restore_focus_on_activate_ = true; | 632 // store the focus. Such a window shares the same RootWindowHost, so that |
| 633 // Pass in false so that ClearNativeFocus() isn't invoked. | 633 // such a change won't trigger an activation change (which calls |
| 634 GetWidget()->GetFocusManager()->StoreFocusedView(false); | 634 // StoreFocusedView()). Without this the focused view is never told it lost |
| 635 // focus. |
| 636 aura::Window* focused_window = |
| 637 aura::client::GetFocusClient(window_)->GetFocusedWindow(); |
| 638 if (focused_window && focused_window != window_) { |
| 639 Widget* focused_widget = Widget::GetWidgetForNativeWindow(focused_window); |
| 640 if (focused_widget && focused_widget != GetWidget() && |
| 641 focused_widget->is_top_level()) { |
| 642 DCHECK(!restore_focus_on_activate_); |
| 643 restore_focus_on_activate_ = true; |
| 644 // Pass in false so that ClearNativeFocus() isn't invoked. |
| 645 GetWidget()->GetFocusManager()->StoreFocusedView(false); |
| 646 } |
| 647 } |
| 635 } | 648 } |
| 636 } | 649 } |
| 637 | 650 |
| 638 //////////////////////////////////////////////////////////////////////////////// | 651 //////////////////////////////////////////////////////////////////////////////// |
| 639 // DesktopNativeWidgetAura, aura::client::FocusChangeObserver implementation: | 652 // DesktopNativeWidgetAura, aura::client::FocusChangeObserver implementation: |
| 640 | 653 |
| 641 void DesktopNativeWidgetAura::OnWindowFocused(aura::Window* gained_focus, | 654 void DesktopNativeWidgetAura::OnWindowFocused(aura::Window* gained_focus, |
| 642 aura::Window* lost_focus) { | 655 aura::Window* lost_focus) { |
| 643 if (window_ == gained_focus) { | 656 if (window_ == gained_focus) { |
| 644 desktop_root_window_host_->OnNativeWidgetFocus(); | 657 desktop_root_window_host_->OnNativeWidgetFocus(); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 690 drop_helper_->OnDragExit(); | 703 drop_helper_->OnDragExit(); |
| 691 } | 704 } |
| 692 | 705 |
| 693 int DesktopNativeWidgetAura::OnPerformDrop(const ui::DropTargetEvent& event) { | 706 int DesktopNativeWidgetAura::OnPerformDrop(const ui::DropTargetEvent& event) { |
| 694 DCHECK(drop_helper_.get() != NULL); | 707 DCHECK(drop_helper_.get() != NULL); |
| 695 return drop_helper_->OnDrop(event.data(), event.location(), | 708 return drop_helper_->OnDrop(event.data(), event.location(), |
| 696 last_drop_operation_); | 709 last_drop_operation_); |
| 697 } | 710 } |
| 698 | 711 |
| 699 } // namespace views | 712 } // namespace views |
| OLD | NEW |