OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/native_widget_aura.h" | 5 #include "ui/views/widget/native_widget_aura.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
9 #include "ui/aura/client/aura_constants.h" | 9 #include "ui/aura/client/aura_constants.h" |
10 #include "ui/aura/client/drag_drop_client.h" | 10 #include "ui/aura/client/drag_drop_client.h" |
(...skipping 549 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
560 GetWidget()->widget_delegate()->OnWidgetMove(); | 560 GetWidget()->widget_delegate()->OnWidgetMove(); |
561 if (old_bounds.size() != new_bounds.size()) | 561 if (old_bounds.size() != new_bounds.size()) |
562 delegate_->OnNativeWidgetSizeChanged(new_bounds.size()); | 562 delegate_->OnNativeWidgetSizeChanged(new_bounds.size()); |
563 } | 563 } |
564 | 564 |
565 void NativeWidgetAura::OnFocus() { | 565 void NativeWidgetAura::OnFocus() { |
566 Widget* widget = GetWidget(); | 566 Widget* widget = GetWidget(); |
567 if (widget->is_top_level()) { | 567 if (widget->is_top_level()) { |
568 InputMethod* input_method = widget->GetInputMethod(); | 568 InputMethod* input_method = widget->GetInputMethod(); |
569 input_method->OnFocus(); | 569 input_method->OnFocus(); |
| 570 // See description of got_initial_focus_in_ for details on this. |
| 571 // TODO(mazda): Investigate this is actually necessary. |
| 572 // widget->GetFocusManager()->RestoreFocusedView(); |
570 } | 573 } |
571 delegate_->OnNativeFocus(window_); | 574 delegate_->OnNativeFocus(window_); |
572 } | 575 } |
573 | 576 |
574 void NativeWidgetAura::OnBlur() { | 577 void NativeWidgetAura::OnBlur() { |
575 Widget* widget = GetWidget(); | 578 Widget* widget = GetWidget(); |
576 if (widget->is_top_level()) { | 579 if (widget->is_top_level()) { |
577 InputMethod* input_method = widget->GetInputMethod(); | 580 InputMethod* input_method = widget->GetInputMethod(); |
578 input_method->OnBlur(); | 581 input_method->OnBlur(); |
| 582 widget->GetFocusManager()->StoreFocusedView(); |
579 } | 583 } |
580 delegate_->OnNativeBlur(NULL); | 584 delegate_->OnNativeBlur(NULL); |
581 } | 585 } |
582 | 586 |
583 bool NativeWidgetAura::OnKeyEvent(aura::KeyEvent* event) { | 587 bool NativeWidgetAura::OnKeyEvent(aura::KeyEvent* event) { |
584 // TODO(beng): Need an InputMethodAura to properly handle character events. | 588 // TODO(beng): Need an InputMethodAura to properly handle character events. |
585 // Right now, we just skip these. | 589 // Right now, we just skip these. |
586 if (event->is_char()) | 590 if (event->is_char()) |
587 return false; | 591 return false; |
588 | 592 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
623 | 627 |
624 bool NativeWidgetAura::CanFocus() { | 628 bool NativeWidgetAura::CanFocus() { |
625 return true; | 629 return true; |
626 } | 630 } |
627 | 631 |
628 bool NativeWidgetAura::ShouldActivate(aura::Event* event) { | 632 bool NativeWidgetAura::ShouldActivate(aura::Event* event) { |
629 return can_activate_; | 633 return can_activate_; |
630 } | 634 } |
631 | 635 |
632 void NativeWidgetAura::OnActivated() { | 636 void NativeWidgetAura::OnActivated() { |
633 GetWidget()->GetFocusManager()->RestoreFocusedView(); | |
634 delegate_->OnNativeWidgetActivationChanged(true); | 637 delegate_->OnNativeWidgetActivationChanged(true); |
635 if (IsVisible() && GetWidget()->non_client_view()) | 638 if (IsVisible() && GetWidget()->non_client_view()) |
636 GetWidget()->non_client_view()->SchedulePaint(); | 639 GetWidget()->non_client_view()->SchedulePaint(); |
637 } | 640 } |
638 | 641 |
639 void NativeWidgetAura::OnLostActive() { | 642 void NativeWidgetAura::OnLostActive() { |
640 GetWidget()->GetFocusManager()->StoreFocusedView(); | |
641 delegate_->OnNativeWidgetActivationChanged(false); | 643 delegate_->OnNativeWidgetActivationChanged(false); |
642 if (IsVisible() && GetWidget()->non_client_view()) | 644 if (IsVisible() && GetWidget()->non_client_view()) |
643 GetWidget()->non_client_view()->SchedulePaint(); | 645 GetWidget()->non_client_view()->SchedulePaint(); |
644 } | 646 } |
645 | 647 |
646 void NativeWidgetAura::OnCaptureLost() { | 648 void NativeWidgetAura::OnCaptureLost() { |
647 delegate_->OnMouseCaptureLost(); | 649 delegate_->OnMouseCaptureLost(); |
648 } | 650 } |
649 | 651 |
650 void NativeWidgetAura::OnPaint(gfx::Canvas* canvas) { | 652 void NativeWidgetAura::OnPaint(gfx::Canvas* canvas) { |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
800 } | 802 } |
801 } | 803 } |
802 | 804 |
803 // static | 805 // static |
804 bool NativeWidgetPrivate::IsMouseButtonDown() { | 806 bool NativeWidgetPrivate::IsMouseButtonDown() { |
805 return aura::RootWindow::GetInstance()->IsMouseButtonDown(); | 807 return aura::RootWindow::GetInstance()->IsMouseButtonDown(); |
806 } | 808 } |
807 | 809 |
808 } // namespace internal | 810 } // namespace internal |
809 } // namespace views | 811 } // namespace views |
OLD | NEW |