Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(336)

Side by Side Diff: mash/wm/frame/frame_border_hit_test_controller.cc

Issue 2029883002: Moves mash/wm into ash/mus (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@remove_static_assert
Patch Set: move comment Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « mash/wm/frame/frame_border_hit_test_controller.h ('k') | mash/wm/frame/header_painter.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2015 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 "mash/wm/frame/frame_border_hit_test_controller.h"
6
7 #include "mash/wm/frame/caption_buttons/frame_caption_button_container_view.h"
8 #include "ui/aura/env.h"
9 #include "ui/aura/window.h"
10 #include "ui/base/hit_test.h"
11 #include "ui/gfx/geometry/insets.h"
12 #include "ui/views/widget/widget.h"
13 #include "ui/views/widget/widget_delegate.h"
14 #include "ui/views/window/non_client_view.h"
15
16 namespace mash {
17 namespace wm {
18
19 // In the window corners, the resize areas don't actually expand bigger, but the
20 // 16 px at the end of each edge triggers diagonal resizing.
21 const int kResizeAreaCornerSize = 16;
22
23 // Windows do not have a traditional visible window frame. Window content
24 // extends to the edge of the window. We consider a small region outside the
25 // window bounds and an even smaller region overlapping the window to be the
26 // "non-client" area and use it for resizing.
27 const int kResizeOutsideBoundsSize = 6;
28 const int kResizeOutsideBoundsScaleForTouch = 5;
29 const int kResizeInsideBoundsSize = 1;
30
31 // static
32 gfx::Insets FrameBorderHitTestController::GetResizeOutsideBoundsSize() {
33 return gfx::Insets(kResizeOutsideBoundsSize, kResizeOutsideBoundsSize,
34 kResizeOutsideBoundsSize, kResizeOutsideBoundsSize);
35 }
36
37 // static
38 int FrameBorderHitTestController::NonClientHitTest(
39 views::NonClientFrameView* view,
40 FrameCaptionButtonContainerView* caption_button_container,
41 const gfx::Point& point_in_widget) {
42 gfx::Rect expanded_bounds = view->bounds();
43 int outside_bounds = kResizeOutsideBoundsSize;
44
45 if (aura::Env::GetInstance()->is_touch_down())
46 outside_bounds *= kResizeOutsideBoundsScaleForTouch;
47 expanded_bounds.Inset(-outside_bounds, -outside_bounds);
48
49 if (!expanded_bounds.Contains(point_in_widget))
50 return HTNOWHERE;
51
52 // Check the frame first, as we allow a small area overlapping the contents
53 // to be used for resize handles.
54 views::Widget* frame = view->GetWidget();
55 bool can_ever_resize = frame->widget_delegate()->CanResize();
56 // Don't allow overlapping resize handles when the window is maximized or
57 // fullscreen, as it can't be resized in those states.
58 int resize_border = kResizeInsideBoundsSize;
59 if (frame->IsMaximized() || frame->IsFullscreen()) {
60 resize_border = 0;
61 can_ever_resize = false;
62 }
63 int frame_component = view->GetHTComponentForFrame(
64 point_in_widget, resize_border, resize_border, kResizeAreaCornerSize,
65 kResizeAreaCornerSize, can_ever_resize);
66 if (frame_component != HTNOWHERE)
67 return frame_component;
68
69 int client_component =
70 frame->client_view()->NonClientHitTest(point_in_widget);
71 if (client_component != HTNOWHERE)
72 return client_component;
73
74 if (caption_button_container->visible()) {
75 gfx::Point point_in_caption_button_container(point_in_widget);
76 views::View::ConvertPointFromWidget(caption_button_container,
77 &point_in_caption_button_container);
78 int caption_button_component = caption_button_container->NonClientHitTest(
79 point_in_caption_button_container);
80 if (caption_button_component != HTNOWHERE)
81 return caption_button_component;
82 }
83
84 // Caption is a safe default.
85 return HTCAPTION;
86 }
87
88 } // namespace wm
89 } // namespace mash
OLDNEW
« no previous file with comments | « mash/wm/frame/frame_border_hit_test_controller.h ('k') | mash/wm/frame/header_painter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698