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