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/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/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
9 #include "third_party/skia/include/core/SkRegion.h" | 9 #include "third_party/skia/include/core/SkRegion.h" |
10 #include "ui/aura/client/activation_client.h" | 10 #include "ui/aura/client/activation_client.h" |
(...skipping 870 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
881 } | 881 } |
882 | 882 |
883 //////////////////////////////////////////////////////////////////////////////// | 883 //////////////////////////////////////////////////////////////////////////////// |
884 // NativeWidgetAura, aura::client::FocusChangeObserver: | 884 // NativeWidgetAura, aura::client::FocusChangeObserver: |
885 | 885 |
886 void NativeWidgetAura::OnWindowFocused(aura::Window* gained_focus, | 886 void NativeWidgetAura::OnWindowFocused(aura::Window* gained_focus, |
887 aura::Window* lost_focus) { | 887 aura::Window* lost_focus) { |
888 if (window_ == gained_focus) { | 888 if (window_ == gained_focus) { |
889 // In aura, it is possible for child native widgets to take input and focus, | 889 // In aura, it is possible for child native widgets to take input and focus, |
890 // this differs from the behavior on windows. | 890 // this differs from the behavior on windows. |
| 891 if (GetWidget()->GetInputMethod()) // Null in tests. |
| 892 GetWidget()->GetInputMethod()->OnFocus(); |
891 delegate_->OnNativeFocus(lost_focus); | 893 delegate_->OnNativeFocus(lost_focus); |
892 } else if (window_ == lost_focus) { | 894 } else if (window_ == lost_focus) { |
893 if (destroying_) | 895 // GetInputMethod() recreates the input method if it's previously been |
| 896 // destroyed. If we get called during destruction, the input method will be |
| 897 // gone, and creating a new one and telling it that we lost the focus will |
| 898 // trigger a DCHECK (the new input method doesn't think that we have the |
| 899 // focus and doesn't expect a blur). OnBlur() shouldn't be called during |
| 900 // destruction unless WIDGET_OWNS_NATIVE_WIDGET is set (which is just the |
| 901 // case in tests). |
| 902 if (!destroying_) { |
| 903 if (GetWidget()->GetInputMethod()) |
| 904 GetWidget()->GetInputMethod()->OnBlur(); |
| 905 } else { |
894 DCHECK_EQ(ownership_, Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET); | 906 DCHECK_EQ(ownership_, Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET); |
| 907 } |
895 | 908 |
896 aura::client::FocusClient* client = aura::client::GetFocusClient(window_); | 909 aura::client::FocusClient* client = aura::client::GetFocusClient(window_); |
897 if (client) // NULL during destruction of aura::Window. | 910 if (client) // NULL during destruction of aura::Window. |
898 delegate_->OnNativeBlur(client->GetFocusedWindow()); | 911 delegate_->OnNativeBlur(client->GetFocusedWindow()); |
899 } | 912 } |
900 } | 913 } |
901 | 914 |
902 //////////////////////////////////////////////////////////////////////////////// | 915 //////////////////////////////////////////////////////////////////////////////// |
903 // NativeWidgetAura, aura::WindowDragDropDelegate implementation: | 916 // NativeWidgetAura, aura::WindowDragDropDelegate implementation: |
904 | 917 |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1110 return aura::Env::GetInstance()->is_mouse_button_down(); | 1123 return aura::Env::GetInstance()->is_mouse_button_down(); |
1111 } | 1124 } |
1112 | 1125 |
1113 // static | 1126 // static |
1114 bool NativeWidgetPrivate::IsTouchDown() { | 1127 bool NativeWidgetPrivate::IsTouchDown() { |
1115 return aura::Env::GetInstance()->is_touch_down(); | 1128 return aura::Env::GetInstance()->is_touch_down(); |
1116 } | 1129 } |
1117 | 1130 |
1118 } // namespace internal | 1131 } // namespace internal |
1119 } // namespace views | 1132 } // namespace views |
OLD | NEW |