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/aura_constants.h" | 10 #include "ui/aura/client/aura_constants.h" |
(...skipping 881 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
892 // NativeWidgetAura, aura::client::FocusChangeObserver: | 892 // NativeWidgetAura, aura::client::FocusChangeObserver: |
893 | 893 |
894 void NativeWidgetAura::OnWindowFocused(aura::Window* gained_focus, | 894 void NativeWidgetAura::OnWindowFocused(aura::Window* gained_focus, |
895 aura::Window* lost_focus) { | 895 aura::Window* lost_focus) { |
896 if (window_ == gained_focus) { | 896 if (window_ == gained_focus) { |
897 // In aura, it is possible for child native widgets to take input and focus, | 897 // In aura, it is possible for child native widgets to take input and focus, |
898 // this differs from the behavior on windows. | 898 // this differs from the behavior on windows. |
899 if (GetWidget()->GetInputMethod()) // Null in tests. | 899 if (GetWidget()->GetInputMethod()) // Null in tests. |
900 GetWidget()->GetInputMethod()->OnFocus(); | 900 GetWidget()->GetInputMethod()->OnFocus(); |
901 delegate_->OnNativeFocus(lost_focus); | 901 delegate_->OnNativeFocus(lost_focus); |
| 902 GetWidget()->GetFocusManager()->RestoreFocusedView(); |
902 } else if (window_ == lost_focus) { | 903 } else if (window_ == lost_focus) { |
903 // GetInputMethod() recreates the input method if it's previously been | 904 // GetInputMethod() recreates the input method if it's previously been |
904 // destroyed. If we get called during destruction, the input method will be | 905 // destroyed. If we get called during destruction, the input method will be |
905 // gone, and creating a new one and telling it that we lost the focus will | 906 // gone, and creating a new one and telling it that we lost the focus will |
906 // trigger a DCHECK (the new input method doesn't think that we have the | 907 // trigger a DCHECK (the new input method doesn't think that we have the |
907 // focus and doesn't expect a blur). OnBlur() shouldn't be called during | 908 // focus and doesn't expect a blur). OnBlur() shouldn't be called during |
908 // destruction unless WIDGET_OWNS_NATIVE_WIDGET is set (which is just the | 909 // destruction unless WIDGET_OWNS_NATIVE_WIDGET is set (which is just the |
909 // case in tests). | 910 // case in tests). |
910 if (!destroying_) { | 911 if (!destroying_) { |
911 if (GetWidget()->GetInputMethod()) | 912 if (GetWidget()->GetInputMethod()) |
912 GetWidget()->GetInputMethod()->OnBlur(); | 913 GetWidget()->GetInputMethod()->OnBlur(); |
913 } else { | 914 } else { |
914 DCHECK_EQ(ownership_, Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET); | 915 DCHECK_EQ(ownership_, Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET); |
915 } | 916 } |
916 | 917 |
917 aura::client::FocusClient* client = aura::client::GetFocusClient(window_); | 918 delegate_->OnNativeBlur(gained_focus); |
918 if (client) // NULL during destruction of aura::Window. | 919 GetWidget()->GetFocusManager()->StoreFocusedView(true); |
919 delegate_->OnNativeBlur(client->GetFocusedWindow()); | |
920 } | 920 } |
921 } | 921 } |
922 | 922 |
923 //////////////////////////////////////////////////////////////////////////////// | 923 //////////////////////////////////////////////////////////////////////////////// |
924 // NativeWidgetAura, aura::WindowDragDropDelegate implementation: | 924 // NativeWidgetAura, aura::WindowDragDropDelegate implementation: |
925 | 925 |
926 void NativeWidgetAura::OnDragEntered(const ui::DropTargetEvent& event) { | 926 void NativeWidgetAura::OnDragEntered(const ui::DropTargetEvent& event) { |
927 DCHECK(drop_helper_.get() != NULL); | 927 DCHECK(drop_helper_.get() != NULL); |
928 last_drop_operation_ = drop_helper_->OnDragOver(event.data(), | 928 last_drop_operation_ = drop_helper_->OnDragOver(event.data(), |
929 event.location(), event.source_operations()); | 929 event.location(), event.source_operations()); |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1157 l10n_util::AdjustUIFont(&(ncm.lfCaptionFont)); | 1157 l10n_util::AdjustUIFont(&(ncm.lfCaptionFont)); |
1158 base::win::ScopedHFONT caption_font(CreateFontIndirect(&(ncm.lfCaptionFont))); | 1158 base::win::ScopedHFONT caption_font(CreateFontIndirect(&(ncm.lfCaptionFont))); |
1159 return gfx::FontList(gfx::Font(caption_font)); | 1159 return gfx::FontList(gfx::Font(caption_font)); |
1160 #else | 1160 #else |
1161 return gfx::FontList(); | 1161 return gfx::FontList(); |
1162 #endif | 1162 #endif |
1163 } | 1163 } |
1164 | 1164 |
1165 } // namespace internal | 1165 } // namespace internal |
1166 } // namespace views | 1166 } // namespace views |
OLD | NEW |