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