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

Side by Side Diff: ash/frame/frame_border_hit_test_controller.cc

Issue 2215223003: Moves most frame related classes to ash/common/frame (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comment Created 4 years, 4 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 | « ash/frame/frame_border_hit_test_controller.h ('k') | ash/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
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/frame/frame_border_hit_test_controller.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "ash/common/ash_constants.h"
10 #include "ash/common/wm/window_state_observer.h"
11 #include "ash/frame/caption_buttons/frame_caption_button_container_view.h"
12 #include "ash/wm/resize_handle_window_targeter.h" 9 #include "ash/wm/resize_handle_window_targeter.h"
13 #include "ui/aura/env.h"
14 #include "ui/aura/window.h" 10 #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"
18 #include "ui/views/widget/widget.h" 11 #include "ui/views/widget/widget.h"
19 #include "ui/views/widget/widget_delegate.h"
20 #include "ui/views/window/non_client_view.h"
21 12
22 namespace ash { 13 namespace ash {
23 14
24 FrameBorderHitTestController::FrameBorderHitTestController(views::Widget* frame) 15 FrameBorderHitTestController::FrameBorderHitTestController(views::Widget* frame)
25 : frame_window_(frame->GetNativeWindow()) { 16 : frame_window_(frame->GetNativeWindow()) {
26 frame_window_->SetEventTargeter(std::unique_ptr<ui::EventTargeter>( 17 frame_window_->SetEventTargeter(std::unique_ptr<ui::EventTargeter>(
27 new ResizeHandleWindowTargeter(frame_window_, NULL))); 18 new ResizeHandleWindowTargeter(frame_window_, NULL)));
28 } 19 }
29 20
30 FrameBorderHitTestController::~FrameBorderHitTestController() {} 21 FrameBorderHitTestController::~FrameBorderHitTestController() {}
31 22
32 // static
33 int FrameBorderHitTestController::NonClientHitTest(
34 views::NonClientFrameView* view,
35 FrameCaptionButtonContainerView* caption_button_container,
36 const gfx::Point& point_in_widget) {
37 gfx::Rect expanded_bounds = view->bounds();
38 int outside_bounds = kResizeOutsideBoundsSize;
39
40 if (aura::Env::GetInstance()->is_touch_down())
41 outside_bounds *= kResizeOutsideBoundsScaleForTouch;
42 expanded_bounds.Inset(-outside_bounds, -outside_bounds);
43
44 if (!expanded_bounds.Contains(point_in_widget))
45 return HTNOWHERE;
46
47 // Check the frame first, as we allow a small area overlapping the contents
48 // to be used for resize handles.
49 views::Widget* frame = view->GetWidget();
50 bool can_ever_resize = frame->widget_delegate()->CanResize();
51 // Don't allow overlapping resize handles when the window is maximized or
52 // fullscreen, as it can't be resized in those states.
53 int resize_border = kResizeInsideBoundsSize;
54 if (frame->IsMaximized() || frame->IsFullscreen()) {
55 resize_border = 0;
56 can_ever_resize = false;
57 }
58 int frame_component = view->GetHTComponentForFrame(
59 point_in_widget, resize_border, resize_border, kResizeAreaCornerSize,
60 kResizeAreaCornerSize, can_ever_resize);
61 if (frame_component != HTNOWHERE)
62 return frame_component;
63
64 int client_component =
65 frame->client_view()->NonClientHitTest(point_in_widget);
66 if (client_component != HTNOWHERE)
67 return client_component;
68
69 if (caption_button_container->visible()) {
70 gfx::Point point_in_caption_button_container(point_in_widget);
71 views::View::ConvertPointFromWidget(caption_button_container,
72 &point_in_caption_button_container);
73 int caption_button_component = caption_button_container->NonClientHitTest(
74 point_in_caption_button_container);
75 if (caption_button_component != HTNOWHERE)
76 return caption_button_component;
77 }
78
79 // Caption is a safe default.
80 return HTCAPTION;
81 }
82
83 } // namespace ash 23 } // namespace ash
OLDNEW
« no previous file with comments | « ash/frame/frame_border_hit_test_controller.h ('k') | ash/frame/header_painter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698