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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 : delegate_(delegate), | 73 : delegate_(delegate), |
74 window_(new aura::Window(this)), | 74 window_(new aura::Window(this)), |
75 ownership_(Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET), | 75 ownership_(Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET), |
76 close_widget_factory_(this), | 76 close_widget_factory_(this), |
77 can_activate_(true), | 77 can_activate_(true), |
78 destroying_(false), | 78 destroying_(false), |
79 cursor_(gfx::kNullCursor), | 79 cursor_(gfx::kNullCursor), |
80 saved_window_state_(ui::SHOW_STATE_DEFAULT) { | 80 saved_window_state_(ui::SHOW_STATE_DEFAULT) { |
81 aura::client::SetFocusChangeObserver(window_, this); | 81 aura::client::SetFocusChangeObserver(window_, this); |
82 aura::client::SetActivationChangeObserver(window_, this); | 82 aura::client::SetActivationChangeObserver(window_, this); |
| 83 wm::SetCursorDelegate(window_, this); |
83 } | 84 } |
84 | 85 |
85 // static | 86 // static |
86 gfx::FontList NativeWidgetAura::GetWindowTitleFontList() { | 87 gfx::FontList NativeWidgetAura::GetWindowTitleFontList() { |
87 #if defined(OS_WIN) | 88 #if defined(OS_WIN) |
88 NONCLIENTMETRICS ncm; | 89 NONCLIENTMETRICS ncm; |
89 base::win::GetNonClientMetrics(&ncm); | 90 base::win::GetNonClientMetrics(&ncm); |
90 l10n_util::AdjustUIFont(&(ncm.lfCaptionFont)); | 91 l10n_util::AdjustUIFont(&(ncm.lfCaptionFont)); |
91 base::win::ScopedHFONT caption_font(CreateFontIndirect(&(ncm.lfCaptionFont))); | 92 base::win::ScopedHFONT caption_font(CreateFontIndirect(&(ncm.lfCaptionFont))); |
92 return gfx::FontList(gfx::Font(caption_font)); | 93 return gfx::FontList(gfx::Font(caption_font)); |
(...skipping 625 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
718 // handles the case of a maximize animation acquiring the layer (acquiring a | 719 // handles the case of a maximize animation acquiring the layer (acquiring a |
719 // layer results in clearing the bounds). | 720 // layer results in clearing the bounds). |
720 if (old_bounds.origin() != new_bounds.origin() || | 721 if (old_bounds.origin() != new_bounds.origin() || |
721 (old_bounds == gfx::Rect(0, 0, 0, 0) && !new_bounds.IsEmpty())) { | 722 (old_bounds == gfx::Rect(0, 0, 0, 0) && !new_bounds.IsEmpty())) { |
722 delegate_->OnNativeWidgetMove(); | 723 delegate_->OnNativeWidgetMove(); |
723 } | 724 } |
724 if (old_bounds.size() != new_bounds.size()) | 725 if (old_bounds.size() != new_bounds.size()) |
725 delegate_->OnNativeWidgetSizeChanged(new_bounds.size()); | 726 delegate_->OnNativeWidgetSizeChanged(new_bounds.size()); |
726 } | 727 } |
727 | 728 |
728 gfx::NativeCursor NativeWidgetAura::GetCursor(const gfx::Point& point) { | |
729 return cursor_; | |
730 } | |
731 | |
732 int NativeWidgetAura::GetNonClientComponent(const gfx::Point& point) const { | 729 int NativeWidgetAura::GetNonClientComponent(const gfx::Point& point) const { |
733 return delegate_->GetNonClientComponent(point); | 730 return delegate_->GetNonClientComponent(point); |
734 } | 731 } |
735 | 732 |
736 bool NativeWidgetAura::ShouldDescendIntoChildForEventHandling( | 733 bool NativeWidgetAura::ShouldDescendIntoChildForEventHandling( |
737 aura::Window* child, | 734 aura::Window* child, |
738 const gfx::Point& location) { | 735 const gfx::Point& location) { |
739 views::WidgetDelegate* widget_delegate = GetWidget()->widget_delegate(); | 736 views::WidgetDelegate* widget_delegate = GetWidget()->widget_delegate(); |
740 if (widget_delegate && | 737 if (widget_delegate && |
741 !widget_delegate->ShouldDescendIntoChildForEventHandling(child, location)) | 738 !widget_delegate->ShouldDescendIntoChildForEventHandling(child, location)) |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
941 drop_helper_->OnDragExit(); | 938 drop_helper_->OnDragExit(); |
942 } | 939 } |
943 | 940 |
944 int NativeWidgetAura::OnPerformDrop(const ui::DropTargetEvent& event) { | 941 int NativeWidgetAura::OnPerformDrop(const ui::DropTargetEvent& event) { |
945 DCHECK(drop_helper_.get() != NULL); | 942 DCHECK(drop_helper_.get() != NULL); |
946 return drop_helper_->OnDrop(event.data(), event.location(), | 943 return drop_helper_->OnDrop(event.data(), event.location(), |
947 last_drop_operation_); | 944 last_drop_operation_); |
948 } | 945 } |
949 | 946 |
950 //////////////////////////////////////////////////////////////////////////////// | 947 //////////////////////////////////////////////////////////////////////////////// |
| 948 // NativeWidgetAura, wm::CursorDelegate implementation: |
| 949 |
| 950 gfx::NativeCursor NativeWidgetAura::GetCursorForPoint(const gfx::Point& point) { |
| 951 return cursor_; |
| 952 } |
| 953 |
| 954 //////////////////////////////////////////////////////////////////////////////// |
951 // NativeWidgetAura, NativeWidget implementation: | 955 // NativeWidgetAura, NativeWidget implementation: |
952 | 956 |
953 ui::EventHandler* NativeWidgetAura::GetEventHandler() { | 957 ui::EventHandler* NativeWidgetAura::GetEventHandler() { |
954 return this; | 958 return this; |
955 } | 959 } |
956 | 960 |
957 //////////////////////////////////////////////////////////////////////////////// | 961 //////////////////////////////////////////////////////////////////////////////// |
958 // NativeWidgetAura, protected: | 962 // NativeWidgetAura, protected: |
959 | 963 |
960 NativeWidgetAura::~NativeWidgetAura() { | 964 NativeWidgetAura::~NativeWidgetAura() { |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1144 return aura::Env::GetInstance()->IsMouseButtonDown(); | 1148 return aura::Env::GetInstance()->IsMouseButtonDown(); |
1145 } | 1149 } |
1146 | 1150 |
1147 // static | 1151 // static |
1148 bool NativeWidgetPrivate::IsTouchDown() { | 1152 bool NativeWidgetPrivate::IsTouchDown() { |
1149 return aura::Env::GetInstance()->is_touch_down(); | 1153 return aura::Env::GetInstance()->is_touch_down(); |
1150 } | 1154 } |
1151 | 1155 |
1152 } // namespace internal | 1156 } // namespace internal |
1153 } // namespace views | 1157 } // namespace views |
OLD | NEW |