| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "ash/frame/frame_border_hit_test_controller.h" | 5 #include "ash/common/frame/frame_border_hit_test.h" |
| 6 | |
| 7 #include <memory> | |
| 8 | 6 |
| 9 #include "ash/common/ash_constants.h" | 7 #include "ash/common/ash_constants.h" |
| 10 #include "ash/common/wm/window_state_observer.h" | 8 #include "ash/common/frame/caption_buttons/frame_caption_button_container_view.h
" |
| 11 #include "ash/frame/caption_buttons/frame_caption_button_container_view.h" | 9 #include "ash/common/wm_shell.h" |
| 12 #include "ash/wm/resize_handle_window_targeter.h" | |
| 13 #include "ui/aura/env.h" | |
| 14 #include "ui/aura/window.h" | |
| 15 #include "ui/aura/window_observer.h" | |
| 16 #include "ui/aura/window_targeter.h" | |
| 17 #include "ui/base/hit_test.h" | 10 #include "ui/base/hit_test.h" |
| 18 #include "ui/views/widget/widget.h" | 11 #include "ui/views/widget/widget.h" |
| 19 #include "ui/views/widget/widget_delegate.h" | 12 #include "ui/views/widget/widget_delegate.h" |
| 20 #include "ui/views/window/non_client_view.h" | 13 #include "ui/views/window/non_client_view.h" |
| 21 | 14 |
| 22 namespace ash { | 15 namespace ash { |
| 23 | 16 |
| 24 FrameBorderHitTestController::FrameBorderHitTestController(views::Widget* frame) | 17 int FrameBorderNonClientHitTest( |
| 25 : frame_window_(frame->GetNativeWindow()) { | |
| 26 frame_window_->SetEventTargeter(std::unique_ptr<ui::EventTargeter>( | |
| 27 new ResizeHandleWindowTargeter(frame_window_, NULL))); | |
| 28 } | |
| 29 | |
| 30 FrameBorderHitTestController::~FrameBorderHitTestController() {} | |
| 31 | |
| 32 // static | |
| 33 int FrameBorderHitTestController::NonClientHitTest( | |
| 34 views::NonClientFrameView* view, | 18 views::NonClientFrameView* view, |
| 35 FrameCaptionButtonContainerView* caption_button_container, | 19 FrameCaptionButtonContainerView* caption_button_container, |
| 36 const gfx::Point& point_in_widget) { | 20 const gfx::Point& point_in_widget) { |
| 37 gfx::Rect expanded_bounds = view->bounds(); | 21 gfx::Rect expanded_bounds = view->bounds(); |
| 38 int outside_bounds = kResizeOutsideBoundsSize; | 22 int outside_bounds = kResizeOutsideBoundsSize; |
| 39 | 23 |
| 40 if (aura::Env::GetInstance()->is_touch_down()) | 24 if (WmShell::Get()->IsTouchDown()) |
| 41 outside_bounds *= kResizeOutsideBoundsScaleForTouch; | 25 outside_bounds *= kResizeOutsideBoundsScaleForTouch; |
| 42 expanded_bounds.Inset(-outside_bounds, -outside_bounds); | 26 expanded_bounds.Inset(-outside_bounds, -outside_bounds); |
| 43 | 27 |
| 44 if (!expanded_bounds.Contains(point_in_widget)) | 28 if (!expanded_bounds.Contains(point_in_widget)) |
| 45 return HTNOWHERE; | 29 return HTNOWHERE; |
| 46 | 30 |
| 47 // Check the frame first, as we allow a small area overlapping the contents | 31 // Check the frame first, as we allow a small area overlapping the contents |
| 48 // to be used for resize handles. | 32 // to be used for resize handles. |
| 49 views::Widget* frame = view->GetWidget(); | 33 views::Widget* frame = view->GetWidget(); |
| 50 bool can_ever_resize = frame->widget_delegate()->CanResize(); | 34 bool can_ever_resize = frame->widget_delegate()->CanResize(); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 74 point_in_caption_button_container); | 58 point_in_caption_button_container); |
| 75 if (caption_button_component != HTNOWHERE) | 59 if (caption_button_component != HTNOWHERE) |
| 76 return caption_button_component; | 60 return caption_button_component; |
| 77 } | 61 } |
| 78 | 62 |
| 79 // Caption is a safe default. | 63 // Caption is a safe default. |
| 80 return HTCAPTION; | 64 return HTCAPTION; |
| 81 } | 65 } |
| 82 | 66 |
| 83 } // namespace ash | 67 } // namespace ash |
| OLD | NEW |