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

Side by Side Diff: ash/wm/frame_border_hittest_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_hittest_controller.h" 5 #include "ash/wm/frame_border_hittest_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_properties.h"
9 #include "ash/wm/window_state.h" 10 #include "ash/wm/window_state.h"
11 #include "ash/wm/wm_types.h"
10 #include "ui/aura/env.h" 12 #include "ui/aura/env.h"
11 #include "ui/aura/window.h" 13 #include "ui/aura/window.h"
12 #include "ui/base/hit_test.h" 14 #include "ui/base/hit_test.h"
13 #include "ui/views/widget/widget.h" 15 #include "ui/views/widget/widget.h"
14 #include "ui/views/widget/widget_delegate.h" 16 #include "ui/views/widget/widget_delegate.h"
15 #include "ui/views/window/non_client_view.h" 17 #include "ui/views/window/non_client_view.h"
16 18
19 namespace {
20
21 // The height of the region in |frame_window_| where |frame_window_| should grab
22 // touches while in immersive fullscreen. (Even if a child window overlaps this
23 // region.) This region is used to allow us to intercept edge gestures to
24 // reveal the top-of-window views even if |frame_window_|'s web page conumes all
25 // touch events.
26 const int kImmersiveFullscreenTopInnerInsetTouch = 8;
James Cook 2013/10/16 16:38:35 Are you sure you want to do it this way? We're OK
pkotwicz 2013/10/17 04:45:08 This is not a change. This is just moving what we
27
28 } // namespace
29
17 namespace ash { 30 namespace ash {
18 31
19 FrameBorderHittestController::FrameBorderHittestController(views::Widget* frame) 32 FrameBorderHittestController::FrameBorderHittestController(views::Widget* frame)
20 : frame_window_(frame->GetNativeWindow()) { 33 : frame_window_(frame->GetNativeWindow()) {
21 gfx::Insets mouse_outer_insets(-kResizeOutsideBoundsSize, 34 gfx::Insets mouse_outer_insets(-kResizeOutsideBoundsSize,
22 -kResizeOutsideBoundsSize, 35 -kResizeOutsideBoundsSize,
23 -kResizeOutsideBoundsSize, 36 -kResizeOutsideBoundsSize,
24 -kResizeOutsideBoundsSize); 37 -kResizeOutsideBoundsSize);
25 gfx::Insets touch_outer_insets = mouse_outer_insets.Scale( 38 gfx::Insets touch_outer_insets = mouse_outer_insets.Scale(
26 kResizeOutsideBoundsScaleForTouch); 39 kResizeOutsideBoundsScaleForTouch);
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 return frame_component; 88 return frame_component;
76 89
77 int client_component = frame->client_view()->NonClientHitTest(point); 90 int client_component = frame->client_view()->NonClientHitTest(point);
78 if (client_component != HTNOWHERE) 91 if (client_component != HTNOWHERE)
79 return client_component; 92 return client_component;
80 93
81 return header_painter->NonClientHitTest(point); 94 return header_painter->NonClientHitTest(point);
82 } 95 }
83 96
84 void FrameBorderHittestController::UpdateHitTestBoundsOverrideInner() { 97 void FrameBorderHittestController::UpdateHitTestBoundsOverrideInner() {
85 // Maximized and fullscreen windows don't want resize handles overlapping the 98 if (wm::GetWindowState(frame_window_)->IsFullscreen()) {
86 // content area, because when the user moves the cursor to the right screen 99 // Fullscreen windows don't want resize handles when the mouse is on top of
87 // edge we want them to be able to hit the scroll bar. 100 // the content area, so it is unnecessary to steal events from the web
88 if (wm::GetWindowState(frame_window_)->IsMaximizedOrFullscreen()) { 101 // contents along |frame_window_|'s edges. While in immersive fullscreen, we
89 frame_window_->set_hit_test_bounds_override_inner(gfx::Insets()); 102 // grab touch events along the top edge of |frame_window_| so that we can
103 // intercept edge gestures to reveal the top-of-window views even if the
104 // web contents consumes all touch events.
105 wm::FullscreenType fullscreen_type =
106 frame_window_->GetProperty(internal::kFullscreenTypeKey);
107 if (wm::IsImmersiveFullscreenType(fullscreen_type)) {
108 frame_window_->SetHitTestBoundsOverrideInner(gfx::Insets(),
109 gfx::Insets(kImmersiveFullscreenTopInnerInsetTouch, 0, 0, 0));
110 } else {
111 frame_window_->SetHitTestBoundsOverrideInner(gfx::Insets(),
112 gfx::Insets());
113 }
114 } else if (wm::GetWindowState(frame_window_)->IsMaximized()) {
115 // We do not want resize handles for maximized windows either.
116 frame_window_->SetHitTestBoundsOverrideInner(gfx::Insets(),
117 gfx::Insets());
90 } else { 118 } else {
91 frame_window_->set_hit_test_bounds_override_inner( 119 gfx::Insets insets(kResizeInsideBoundsSize, kResizeInsideBoundsSize,
92 gfx::Insets(kResizeInsideBoundsSize, kResizeInsideBoundsSize, 120 kResizeInsideBoundsSize, kResizeInsideBoundsSize);
93 kResizeInsideBoundsSize, kResizeInsideBoundsSize)); 121 frame_window_->SetHitTestBoundsOverrideInner(insets, insets);
94 } 122 }
95 } 123 }
96 124
97 void FrameBorderHittestController::OnWindowShowTypeChanged( 125 void FrameBorderHittestController::OnWindowShowTypeChanged(
98 wm::WindowState* window_state, 126 wm::WindowState* window_state,
99 wm::WindowShowType old_type) { 127 wm::WindowShowType old_type) {
100 UpdateHitTestBoundsOverrideInner(); 128 UpdateHitTestBoundsOverrideInner();
101 } 129 }
102 130
131 void FrameBorderHittestController::OnWindowPropertyChanged(aura::Window* window,
132 const void* key,
133 intptr_t old) {
134 if (key == ash::internal::kFullscreenTypeKey)
135 UpdateHitTestBoundsOverrideInner();
136 }
137
103 void FrameBorderHittestController::OnWindowDestroying(aura::Window* window) { 138 void FrameBorderHittestController::OnWindowDestroying(aura::Window* window) {
104 frame_window_->RemoveObserver(this); 139 frame_window_->RemoveObserver(this);
105 ash::wm::GetWindowState(frame_window_)->RemoveObserver(this); 140 ash::wm::GetWindowState(frame_window_)->RemoveObserver(this);
106 frame_window_ = NULL; 141 frame_window_ = NULL;
107 } 142 }
108 143
109 } // namespace ash 144 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698