OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include "ash/common/frame/frame_border_hit_test.h" | |
6 | |
7 #include "ash/common/ash_constants.h" | |
8 #include "ash/common/frame/caption_buttons/frame_caption_button_container_view.h
" | |
9 #include "ash/common/wm_shell.h" | |
10 #include "ui/base/hit_test.h" | |
11 #include "ui/views/widget/widget.h" | |
12 #include "ui/views/widget/widget_delegate.h" | |
13 #include "ui/views/window/non_client_view.h" | |
14 | |
15 namespace ash { | |
16 | |
17 int FrameBorderNonClientHitTest( | |
18 views::NonClientFrameView* view, | |
19 FrameCaptionButtonContainerView* caption_button_container, | |
20 const gfx::Point& point_in_widget) { | |
21 gfx::Rect expanded_bounds = view->bounds(); | |
22 int outside_bounds = kResizeOutsideBoundsSize; | |
23 | |
24 if (WmShell::Get()->IsTouchDown()) | |
25 outside_bounds *= kResizeOutsideBoundsScaleForTouch; | |
26 expanded_bounds.Inset(-outside_bounds, -outside_bounds); | |
27 | |
28 if (!expanded_bounds.Contains(point_in_widget)) | |
29 return HTNOWHERE; | |
30 | |
31 // Check the frame first, as we allow a small area overlapping the contents | |
32 // to be used for resize handles. | |
33 views::Widget* frame = view->GetWidget(); | |
34 bool can_ever_resize = frame->widget_delegate()->CanResize(); | |
35 // Don't allow overlapping resize handles when the window is maximized or | |
36 // fullscreen, as it can't be resized in those states. | |
37 int resize_border = kResizeInsideBoundsSize; | |
38 if (frame->IsMaximized() || frame->IsFullscreen()) { | |
39 resize_border = 0; | |
40 can_ever_resize = false; | |
41 } | |
42 int frame_component = view->GetHTComponentForFrame( | |
43 point_in_widget, resize_border, resize_border, kResizeAreaCornerSize, | |
44 kResizeAreaCornerSize, can_ever_resize); | |
45 if (frame_component != HTNOWHERE) | |
46 return frame_component; | |
47 | |
48 int client_component = | |
49 frame->client_view()->NonClientHitTest(point_in_widget); | |
50 if (client_component != HTNOWHERE) | |
51 return client_component; | |
52 | |
53 if (caption_button_container->visible()) { | |
54 gfx::Point point_in_caption_button_container(point_in_widget); | |
55 views::View::ConvertPointFromWidget(caption_button_container, | |
56 &point_in_caption_button_container); | |
57 int caption_button_component = caption_button_container->NonClientHitTest( | |
58 point_in_caption_button_container); | |
59 if (caption_button_component != HTNOWHERE) | |
60 return caption_button_component; | |
61 } | |
62 | |
63 // Caption is a safe default. | |
64 return HTCAPTION; | |
65 } | |
66 | |
67 } // namespace ash | |
OLD | NEW |