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

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

Issue 27458002: Allow setting different hit test bounds overrides for mouse and touch (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 2 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 | Annotate | Revision Log
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/wm/frame_border_hit_test_controller.h" 5 #include "ash/wm/frame_border_hit_test_controller.h"
6 6
7 #include "ash/ash_constants.h" 7 #include "ash/ash_constants.h"
8 #include "ash/wm/header_painter.h" 8 #include "ash/wm/header_painter.h"
9 #include "ash/wm/window_state.h" 9 #include "ash/wm/window_state.h"
10 #include "ui/aura/env.h" 10 #include "ui/aura/env.h"
11 #include "ui/aura/window.h" 11 #include "ui/aura/window.h"
12 #include "ui/base/hit_test.h" 12 #include "ui/base/hit_test.h"
13 #include "ui/views/widget/widget.h" 13 #include "ui/views/widget/widget.h"
14 #include "ui/views/widget/widget_delegate.h" 14 #include "ui/views/widget/widget_delegate.h"
15 #include "ui/views/window/non_client_view.h" 15 #include "ui/views/window/non_client_view.h"
16 16
17 namespace {
18
19 // The height of the region in |frame_window_| where |frame_window_| should grab
20 // touches while in immersive fullscreen. (Even if a child window overlaps this
21 // region.) This region is used to allow us to intercept edge gestures to
22 // reveal the top-of-window views even if |frame_window_|'s web page conumes all
23 // touch events.
24 const int kImmersiveFullscreenTopInnerInsetTouch = 8;
James Cook 2013/10/17 16:56:24 OK, sounds good to me.
25
26 } // namespace
27
17 namespace ash { 28 namespace ash {
18 29
19 FrameBorderHitTestController::FrameBorderHitTestController(views::Widget* frame) 30 FrameBorderHitTestController::FrameBorderHitTestController(views::Widget* frame)
20 : frame_window_(frame->GetNativeWindow()) { 31 : frame_window_(frame->GetNativeWindow()) {
21 gfx::Insets mouse_outer_insets(-kResizeOutsideBoundsSize, 32 gfx::Insets mouse_outer_insets(-kResizeOutsideBoundsSize,
22 -kResizeOutsideBoundsSize, 33 -kResizeOutsideBoundsSize,
23 -kResizeOutsideBoundsSize, 34 -kResizeOutsideBoundsSize,
24 -kResizeOutsideBoundsSize); 35 -kResizeOutsideBoundsSize);
25 gfx::Insets touch_outer_insets = mouse_outer_insets.Scale( 36 gfx::Insets touch_outer_insets = mouse_outer_insets.Scale(
26 kResizeOutsideBoundsScaleForTouch); 37 kResizeOutsideBoundsScaleForTouch);
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 return frame_component; 86 return frame_component;
76 87
77 int client_component = frame->client_view()->NonClientHitTest(point); 88 int client_component = frame->client_view()->NonClientHitTest(point);
78 if (client_component != HTNOWHERE) 89 if (client_component != HTNOWHERE)
79 return client_component; 90 return client_component;
80 91
81 return header_painter->NonClientHitTest(point); 92 return header_painter->NonClientHitTest(point);
82 } 93 }
83 94
84 void FrameBorderHitTestController::UpdateHitTestBoundsOverrideInner() { 95 void FrameBorderHitTestController::UpdateHitTestBoundsOverrideInner() {
85 // Maximized and fullscreen windows don't want resize handles overlapping the 96 wm::WindowState* window_state(wm::GetWindowState(frame_window_));
86 // content area, because when the user moves the cursor to the right screen 97 if (window_state->IsFullscreen()) {
87 // edge we want them to be able to hit the scroll bar. 98 // Fullscreen windows don't want resize handles when the mouse is on top of
88 if (wm::GetWindowState(frame_window_)->IsMaximizedOrFullscreen()) { 99 // the content area, so it is unnecessary to steal events from the web
89 frame_window_->set_hit_test_bounds_override_inner(gfx::Insets()); 100 // contents along |frame_window_|'s edges. While in immersive fullscreen, we
101 // grab touch events along the top edge of |frame_window_| so that we can
102 // intercept edge gestures to reveal the top-of-window views even if the
103 // web contents consumes all touch events.
James Cook 2013/10/17 16:56:24 This is a helpful comment, thanks for expanding on
104 if (window_state->IsImmersiveFullscreen()) {
105 frame_window_->SetHitTestBoundsOverrideInner(gfx::Insets(),
106 gfx::Insets(kImmersiveFullscreenTopInnerInsetTouch, 0, 0, 0));
107 } else {
108 frame_window_->SetHitTestBoundsOverrideInner(gfx::Insets(),
109 gfx::Insets());
110 }
111 } else if (window_state->IsMaximized()) {
112 // We do not want resize handles for maximized windows either.
113 frame_window_->SetHitTestBoundsOverrideInner(gfx::Insets(),
114 gfx::Insets());
90 } else { 115 } else {
91 frame_window_->set_hit_test_bounds_override_inner( 116 gfx::Insets insets(kResizeInsideBoundsSize, kResizeInsideBoundsSize,
92 gfx::Insets(kResizeInsideBoundsSize, kResizeInsideBoundsSize, 117 kResizeInsideBoundsSize, kResizeInsideBoundsSize);
93 kResizeInsideBoundsSize, kResizeInsideBoundsSize)); 118 frame_window_->SetHitTestBoundsOverrideInner(insets, insets);
94 } 119 }
95 } 120 }
96 121
97 void FrameBorderHitTestController::OnWindowShowTypeChanged( 122 void FrameBorderHitTestController::OnWindowShowTypeChanged(
98 wm::WindowState* window_state, 123 wm::WindowState* window_state,
99 wm::WindowShowType old_type) { 124 wm::WindowShowType old_type) {
100 UpdateHitTestBoundsOverrideInner(); 125 UpdateHitTestBoundsOverrideInner();
101 } 126 }
102 127
128 void FrameBorderHitTestController::OnWindowFullscreenTypeChanged(
129 wm::WindowState* window_state,
130 wm::FullscreenType old_type) {
131 UpdateHitTestBoundsOverrideInner();
132 }
133
103 void FrameBorderHitTestController::OnWindowDestroying(aura::Window* window) { 134 void FrameBorderHitTestController::OnWindowDestroying(aura::Window* window) {
104 frame_window_->RemoveObserver(this); 135 frame_window_->RemoveObserver(this);
105 ash::wm::GetWindowState(frame_window_)->RemoveObserver(this); 136 ash::wm::GetWindowState(frame_window_)->RemoveObserver(this);
106 frame_window_ = NULL; 137 frame_window_ = NULL;
107 } 138 }
108 139
109 } // namespace ash 140 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698