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/base/accessibility/accessible_view_state.h" | 7 #include "ui/base/accessibility/accessible_view_state.h" |
8 #include "ui/base/hit_test.h" | 8 #include "ui/base/hit_test.h" |
| 9 #include "ui/gfx/rect_conversions.h" |
| 10 #include "ui/views/rect_based_targeting_utils.h" |
9 #include "ui/views/widget/root_view.h" | 11 #include "ui/views/widget/root_view.h" |
10 #include "ui/views/widget/widget.h" | 12 #include "ui/views/widget/widget.h" |
11 #include "ui/views/window/client_view.h" | 13 #include "ui/views/window/client_view.h" |
12 | 14 |
13 namespace views { | 15 namespace views { |
14 | 16 |
15 // static | 17 // static |
16 const int NonClientFrameView::kFrameShadowThickness = 1; | 18 const int NonClientFrameView::kFrameShadowThickness = 1; |
17 const int NonClientFrameView::kClientEdgeThickness = 1; | 19 const int NonClientFrameView::kClientEdgeThickness = 1; |
18 const char NonClientFrameView::kViewClassName[] = | 20 const char NonClientFrameView::kViewClassName[] = |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 | 183 |
182 void NonClientView::GetAccessibleState(ui::AccessibleViewState* state) { | 184 void NonClientView::GetAccessibleState(ui::AccessibleViewState* state) { |
183 state->role = ui::AccessibilityTypes::ROLE_CLIENT; | 185 state->role = ui::AccessibilityTypes::ROLE_CLIENT; |
184 state->name = accessible_name_; | 186 state->name = accessible_name_; |
185 } | 187 } |
186 | 188 |
187 const char* NonClientView::GetClassName() const { | 189 const char* NonClientView::GetClassName() const { |
188 return kViewClassName; | 190 return kViewClassName; |
189 } | 191 } |
190 | 192 |
191 views::View* NonClientView::GetEventHandlerForPoint(const gfx::Point& point) { | 193 views::View* NonClientView::GetEventHandlerForRect(const gfx::Rect& rect) { |
| 194 if (!views::UsePointBasedTargeting(rect)) |
| 195 return View::GetEventHandlerForRect(rect); |
| 196 |
192 // Because of the z-ordering of our child views (the client view is positioned | 197 // Because of the z-ordering of our child views (the client view is positioned |
193 // over the non-client frame view, if the client view ever overlaps the frame | 198 // over the non-client frame view, if the client view ever overlaps the frame |
194 // view visually (as it does for the browser window), then it will eat mouse | 199 // view visually (as it does for the browser window), then it will eat |
195 // events for the window controls. We override this method here so that we can | 200 // events for the window controls. We override this method here so that we can |
196 // detect this condition and re-route the events to the non-client frame view. | 201 // detect this condition and re-route the events to the non-client frame view. |
197 // The assumption is that the frame view's implementation of HitTest will only | 202 // The assumption is that the frame view's implementation of HitTest will only |
198 // return true for area not occupied by the client view. | 203 // return true for area not occupied by the client view. |
199 if (frame_view_->parent() == this) { | 204 if (frame_view_->parent() == this) { |
200 // During the reset of the frame_view_ it's possible to be in this code | 205 // During the reset of the frame_view_ it's possible to be in this code |
201 // after it's been removed from the view hierarchy but before it's been | 206 // after it's been removed from the view hierarchy but before it's been |
202 // removed from the NonClientView. | 207 // removed from the NonClientView. |
203 gfx::Point point_in_child_coords(point); | 208 gfx::RectF rect_in_child_coords_f(rect); |
204 View::ConvertPointToTarget(this, frame_view_.get(), &point_in_child_coords); | 209 View::ConvertRectToTarget(this, frame_view_.get(), &rect_in_child_coords_f); |
205 if (frame_view_->HitTestPoint(point_in_child_coords)) | 210 gfx::Rect rect_in_child_coords = gfx::ToEnclosingRect( |
206 return frame_view_->GetEventHandlerForPoint(point_in_child_coords); | 211 rect_in_child_coords_f); |
| 212 if (frame_view_->HitTestRect(rect_in_child_coords)) |
| 213 return frame_view_->GetEventHandlerForRect(rect_in_child_coords); |
207 } | 214 } |
208 | 215 |
209 return View::GetEventHandlerForPoint(point); | 216 return View::GetEventHandlerForRect(rect); |
210 } | 217 } |
211 | 218 |
212 views::View* NonClientView::GetTooltipHandlerForPoint(const gfx::Point& point) { | 219 views::View* NonClientView::GetTooltipHandlerForPoint(const gfx::Point& point) { |
213 // The same logic as for |GetEventHandlerForPoint()| applies here. | 220 // The same logic as for |GetEventHandlerForRect()| applies here. |
214 if (frame_view_->parent() == this) { | 221 if (frame_view_->parent() == this) { |
215 // During the reset of the frame_view_ it's possible to be in this code | 222 // During the reset of the frame_view_ it's possible to be in this code |
216 // after it's been removed from the view hierarchy but before it's been | 223 // after it's been removed from the view hierarchy but before it's been |
217 // removed from the NonClientView. | 224 // removed from the NonClientView. |
218 gfx::Point point_in_child_coords(point); | 225 gfx::Point point_in_child_coords(point); |
219 View::ConvertPointToTarget(this, frame_view_.get(), &point_in_child_coords); | 226 View::ConvertPointToTarget(this, frame_view_.get(), &point_in_child_coords); |
220 views::View* handler = | 227 views::View* handler = |
221 frame_view_->GetTooltipHandlerForPoint(point_in_child_coords); | 228 frame_view_->GetTooltipHandlerForPoint(point_in_child_coords); |
222 if (handler) | 229 if (handler) |
223 return handler; | 230 return handler; |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
313 const char* NonClientFrameView::GetClassName() const { | 320 const char* NonClientFrameView::GetClassName() const { |
314 return kViewClassName; | 321 return kViewClassName; |
315 } | 322 } |
316 | 323 |
317 void NonClientFrameView::OnBoundsChanged(const gfx::Rect& previous_bounds) { | 324 void NonClientFrameView::OnBoundsChanged(const gfx::Rect& previous_bounds) { |
318 // Overridden to do nothing. The NonClientView manually calls Layout on the | 325 // Overridden to do nothing. The NonClientView manually calls Layout on the |
319 // FrameView when it is itself laid out, see comment in NonClientView::Layout. | 326 // FrameView when it is itself laid out, see comment in NonClientView::Layout. |
320 } | 327 } |
321 | 328 |
322 } // namespace views | 329 } // namespace views |
OLD | NEW |