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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
75 NativeWidgetAura::NativeWidgetAura(internal::NativeWidgetDelegate* delegate) | 75 NativeWidgetAura::NativeWidgetAura(internal::NativeWidgetDelegate* delegate) |
76 : delegate_(delegate), | 76 : delegate_(delegate), |
77 window_(new aura::Window(this)), | 77 window_(new aura::Window(this)), |
78 ownership_(Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET), | 78 ownership_(Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET), |
79 close_widget_factory_(this), | 79 close_widget_factory_(this), |
80 destroying_(false), | 80 destroying_(false), |
81 cursor_(gfx::kNullCursor), | 81 cursor_(gfx::kNullCursor), |
82 saved_window_state_(ui::SHOW_STATE_DEFAULT) { | 82 saved_window_state_(ui::SHOW_STATE_DEFAULT) { |
83 aura::client::SetFocusChangeObserver(window_, this); | 83 aura::client::SetFocusChangeObserver(window_, this); |
84 aura::client::SetActivationChangeObserver(window_, this); | 84 aura::client::SetActivationChangeObserver(window_, this); |
85 window_->AddObserver(this); | |
sky
2014/08/11 16:09:19
nit: move to init.
jackhou1
2014/08/12 05:23:44
Done.
| |
85 } | 86 } |
86 | 87 |
87 // static | 88 // static |
88 void NativeWidgetAura::RegisterNativeWidgetForWindow( | 89 void NativeWidgetAura::RegisterNativeWidgetForWindow( |
89 internal::NativeWidgetPrivate* native_widget, | 90 internal::NativeWidgetPrivate* native_widget, |
90 aura::Window* window) { | 91 aura::Window* window) { |
91 window->set_user_data(native_widget); | 92 window->set_user_data(native_widget); |
92 } | 93 } |
93 | 94 |
94 //////////////////////////////////////////////////////////////////////////////// | 95 //////////////////////////////////////////////////////////////////////////////// |
(...skipping 696 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
791 | 792 |
792 void NativeWidgetAura::OnPaint(gfx::Canvas* canvas) { | 793 void NativeWidgetAura::OnPaint(gfx::Canvas* canvas) { |
793 delegate_->OnNativeWidgetPaint(canvas); | 794 delegate_->OnNativeWidgetPaint(canvas); |
794 } | 795 } |
795 | 796 |
796 void NativeWidgetAura::OnDeviceScaleFactorChanged(float device_scale_factor) { | 797 void NativeWidgetAura::OnDeviceScaleFactorChanged(float device_scale_factor) { |
797 // Repainting with new scale factor will paint the content at the right scale. | 798 // Repainting with new scale factor will paint the content at the right scale. |
798 } | 799 } |
799 | 800 |
800 void NativeWidgetAura::OnWindowDestroying(aura::Window* window) { | 801 void NativeWidgetAura::OnWindowDestroying(aura::Window* window) { |
802 window_->RemoveObserver(this); | |
801 delegate_->OnNativeWidgetDestroying(); | 803 delegate_->OnNativeWidgetDestroying(); |
802 | 804 |
803 // If the aura::Window is destroyed, we can no longer show tooltips. | 805 // If the aura::Window is destroyed, we can no longer show tooltips. |
804 tooltip_manager_.reset(); | 806 tooltip_manager_.reset(); |
805 } | 807 } |
806 | 808 |
807 void NativeWidgetAura::OnWindowDestroyed(aura::Window* window) { | 809 void NativeWidgetAura::OnWindowDestroyed(aura::Window* window) { |
808 window_ = NULL; | 810 window_ = NULL; |
809 delegate_->OnNativeWidgetDestroyed(); | 811 delegate_->OnNativeWidgetDestroyed(); |
810 if (ownership_ == Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET) | 812 if (ownership_ == Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET) |
811 delete this; | 813 delete this; |
812 } | 814 } |
813 | 815 |
814 void NativeWidgetAura::OnWindowTargetVisibilityChanged(bool visible) { | 816 void NativeWidgetAura::OnWindowTargetVisibilityChanged(bool visible) { |
815 delegate_->OnNativeWidgetVisibilityChanged(visible); | 817 delegate_->OnNativeWidgetVisibilityChanged(visible); |
816 } | 818 } |
817 | 819 |
818 bool NativeWidgetAura::HasHitTestMask() const { | 820 bool NativeWidgetAura::HasHitTestMask() const { |
819 return delegate_->HasHitTestMask(); | 821 return delegate_->HasHitTestMask(); |
820 } | 822 } |
821 | 823 |
822 void NativeWidgetAura::GetHitTestMask(gfx::Path* mask) const { | 824 void NativeWidgetAura::GetHitTestMask(gfx::Path* mask) const { |
823 DCHECK(mask); | 825 DCHECK(mask); |
824 delegate_->GetHitTestMask(mask); | 826 delegate_->GetHitTestMask(mask); |
825 } | 827 } |
826 | 828 |
827 //////////////////////////////////////////////////////////////////////////////// | 829 //////////////////////////////////////////////////////////////////////////////// |
830 // NativeWidgetAura, aura::WindowObserver implementation: | |
831 | |
832 void NativeWidgetAura::OnWindowPropertyChanged(aura::Window* window, | |
833 const void* key, | |
834 intptr_t old) { | |
835 if (key == aura::client::kShowStateKey) | |
836 delegate_->OnNativeWidgetWindowShowStateChanged(); | |
837 } | |
838 | |
839 //////////////////////////////////////////////////////////////////////////////// | |
828 // NativeWidgetAura, ui::EventHandler implementation: | 840 // NativeWidgetAura, ui::EventHandler implementation: |
829 | 841 |
830 void NativeWidgetAura::OnKeyEvent(ui::KeyEvent* event) { | 842 void NativeWidgetAura::OnKeyEvent(ui::KeyEvent* event) { |
831 DCHECK(window_); | 843 DCHECK(window_); |
832 if (event->is_char()) { | 844 if (event->is_char()) { |
833 // If a ui::InputMethod object is attached to the root window, character | 845 // If a ui::InputMethod object is attached to the root window, character |
834 // events are handled inside the object and are not passed to this function. | 846 // events are handled inside the object and are not passed to this function. |
835 // If such object is not attached, character events might be sent (e.g. on | 847 // If such object is not attached, character events might be sent (e.g. on |
836 // Windows). In this case, we just skip these. | 848 // Windows). In this case, we just skip these. |
837 return; | 849 return; |
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1152 l10n_util::AdjustUIFont(&(ncm.lfCaptionFont)); | 1164 l10n_util::AdjustUIFont(&(ncm.lfCaptionFont)); |
1153 base::win::ScopedHFONT caption_font(CreateFontIndirect(&(ncm.lfCaptionFont))); | 1165 base::win::ScopedHFONT caption_font(CreateFontIndirect(&(ncm.lfCaptionFont))); |
1154 return gfx::FontList(gfx::Font(caption_font)); | 1166 return gfx::FontList(gfx::Font(caption_font)); |
1155 #else | 1167 #else |
1156 return gfx::FontList(); | 1168 return gfx::FontList(); |
1157 #endif | 1169 #endif |
1158 } | 1170 } |
1159 | 1171 |
1160 } // namespace internal | 1172 } // namespace internal |
1161 } // namespace views | 1173 } // namespace views |
OLD | NEW |