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/window/non_client_view.h" | 5 #include "ui/views/window/non_client_view.h" |
6 | 6 |
7 #include "ui/accessibility/ax_view_state.h" | 7 #include "ui/accessibility/ax_view_state.h" |
8 #include "ui/base/hit_test.h" | 8 #include "ui/base/hit_test.h" |
9 #include "ui/gfx/rect_conversions.h" | 9 #include "ui/gfx/rect_conversions.h" |
10 #include "ui/views/rect_based_targeting_utils.h" | 10 #include "ui/views/rect_based_targeting_utils.h" |
(...skipping 18 matching lines...) Expand all Loading... |
29 static const int kFrameViewIndex = 0; | 29 static const int kFrameViewIndex = 0; |
30 static const int kClientViewIndex = 1; | 30 static const int kClientViewIndex = 1; |
31 // The overlay view is always on top (index == child_count() - 1). | 31 // The overlay view is always on top (index == child_count() - 1). |
32 | 32 |
33 //////////////////////////////////////////////////////////////////////////////// | 33 //////////////////////////////////////////////////////////////////////////////// |
34 // NonClientView, public: | 34 // NonClientView, public: |
35 | 35 |
36 NonClientView::NonClientView() | 36 NonClientView::NonClientView() |
37 : client_view_(NULL), | 37 : client_view_(NULL), |
38 overlay_view_(NULL) { | 38 overlay_view_(NULL) { |
| 39 SetEventTargeter( |
| 40 scoped_ptr<views::ViewTargeter>(new views::ViewTargeter(this))); |
39 } | 41 } |
40 | 42 |
41 NonClientView::~NonClientView() { | 43 NonClientView::~NonClientView() { |
42 // This value may have been reset before the window hierarchy shuts down, | 44 // This value may have been reset before the window hierarchy shuts down, |
43 // so we need to manually remove it. | 45 // so we need to manually remove it. |
44 RemoveChildView(frame_view_.get()); | 46 RemoveChildView(frame_view_.get()); |
45 } | 47 } |
46 | 48 |
47 void NonClientView::SetFrameView(NonClientFrameView* frame_view) { | 49 void NonClientView::SetFrameView(NonClientFrameView* frame_view) { |
48 // See comment in header about ownership. | 50 // See comment in header about ownership. |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 | 182 |
181 void NonClientView::GetAccessibleState(ui::AXViewState* state) { | 183 void NonClientView::GetAccessibleState(ui::AXViewState* state) { |
182 state->role = ui::AX_ROLE_CLIENT; | 184 state->role = ui::AX_ROLE_CLIENT; |
183 state->name = accessible_name_; | 185 state->name = accessible_name_; |
184 } | 186 } |
185 | 187 |
186 const char* NonClientView::GetClassName() const { | 188 const char* NonClientView::GetClassName() const { |
187 return kViewClassName; | 189 return kViewClassName; |
188 } | 190 } |
189 | 191 |
190 View* NonClientView::GetEventHandlerForRect(const gfx::Rect& rect) { | 192 // Terry - move to right place in file |
| 193 View* NonClientView::TargetForRect(View* root, |
| 194 const gfx::Rect& rect) { |
| 195 CHECK_EQ(root, this); |
| 196 |
191 if (!UsePointBasedTargeting(rect)) | 197 if (!UsePointBasedTargeting(rect)) |
192 return View::GetEventHandlerForRect(rect); | 198 return ViewTargeterDelegate::TargetForRect(root, rect); |
193 | 199 |
194 // Because of the z-ordering of our child views (the client view is positioned | 200 // Because of the z-ordering of our child views (the client view is positioned |
195 // over the non-client frame view, if the client view ever overlaps the frame | 201 // over the non-client frame view, if the client view ever overlaps the frame |
196 // view visually (as it does for the browser window), then it will eat | 202 // view visually (as it does for the browser window), then it will eat |
197 // events for the window controls. We override this method here so that we can | 203 // events for the window controls. We override this method here so that we can |
198 // detect this condition and re-route the events to the non-client frame view. | 204 // detect this condition and re-route the events to the non-client frame view. |
199 // The assumption is that the frame view's implementation of HitTest will only | 205 // The assumption is that the frame view's implementation of HitTest will only |
200 // return true for area not occupied by the client view. | 206 // return true for area not occupied by the client view. |
201 if (frame_view_->parent() == this) { | 207 if (frame_view_->parent() == this) { |
202 // During the reset of the frame_view_ it's possible to be in this code | 208 // During the reset of the frame_view_ it's possible to be in this code |
203 // after it's been removed from the view hierarchy but before it's been | 209 // after it's been removed from the view hierarchy but before it's been |
204 // removed from the NonClientView. | 210 // removed from the NonClientView. |
205 gfx::RectF rect_in_child_coords_f(rect); | 211 gfx::RectF rect_in_child_coords_f(rect); |
206 View::ConvertRectToTarget(this, frame_view_.get(), &rect_in_child_coords_f); | 212 View::ConvertRectToTarget(this, frame_view_.get(), &rect_in_child_coords_f); |
207 gfx::Rect rect_in_child_coords = gfx::ToEnclosingRect( | 213 gfx::Rect rect_in_child_coords = gfx::ToEnclosingRect( |
208 rect_in_child_coords_f); | 214 rect_in_child_coords_f); |
209 if (frame_view_->HitTestRect(rect_in_child_coords)) | 215 if (frame_view_->HitTestRect(rect_in_child_coords)) |
210 return frame_view_->GetEventHandlerForRect(rect_in_child_coords); | 216 return frame_view_->GetEventHandlerForRect(rect_in_child_coords); |
211 } | 217 } |
212 | 218 |
213 return View::GetEventHandlerForRect(rect); | 219 return ViewTargeterDelegate::TargetForRect(root, rect); |
214 } | 220 } |
215 | 221 |
216 View* NonClientView::GetTooltipHandlerForPoint(const gfx::Point& point) { | 222 View* NonClientView::GetTooltipHandlerForPoint(const gfx::Point& point) { |
217 // The same logic as for |GetEventHandlerForRect()| applies here. | 223 // The same logic as for |GetEventHandlerForRect()| applies here. |
218 if (frame_view_->parent() == this) { | 224 if (frame_view_->parent() == this) { |
219 // During the reset of the frame_view_ it's possible to be in this code | 225 // During the reset of the frame_view_ it's possible to be in this code |
220 // after it's been removed from the view hierarchy but before it's been | 226 // after it's been removed from the view hierarchy but before it's been |
221 // removed from the NonClientView. | 227 // removed from the NonClientView. |
222 gfx::Point point_in_child_coords(point); | 228 gfx::Point point_in_child_coords(point); |
223 View::ConvertPointToTarget(this, frame_view_.get(), &point_in_child_coords); | 229 View::ConvertPointToTarget(this, frame_view_.get(), &point_in_child_coords); |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
326 bool NonClientFrameView::DoesIntersectRect(const View* target, | 332 bool NonClientFrameView::DoesIntersectRect(const View* target, |
327 const gfx::Rect& rect) const { | 333 const gfx::Rect& rect) const { |
328 CHECK_EQ(target, this); | 334 CHECK_EQ(target, this); |
329 | 335 |
330 // For the default case, we assume the non-client frame view never overlaps | 336 // For the default case, we assume the non-client frame view never overlaps |
331 // the client view. | 337 // the client view. |
332 return !GetWidget()->client_view()->bounds().Intersects(rect); | 338 return !GetWidget()->client_view()->bounds().Intersects(rect); |
333 } | 339 } |
334 | 340 |
335 } // namespace views | 341 } // namespace views |
OLD | NEW |