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