summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-08-09 19:42:39 +0000
committersadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-08-09 19:42:39 +0000
commita86445bd3d13de8f9845ee939856acbbc11a0a7c (patch)
tree82c575bc5e709a9a7213b9d39ef42eb04b8cae77
parent37e47023fb62c398f5d4a837f77a9835f5e3f265 (diff)
downloadchromium_src-a86445bd3d13de8f9845ee939856acbbc11a0a7c.zip
chromium_src-a86445bd3d13de8f9845ee939856acbbc11a0a7c.tar.gz
chromium_src-a86445bd3d13de8f9845ee939856acbbc11a0a7c.tar.bz2
ash: Use different hit-test outer-region for mouse and touch events.
The hit-region for windows need to be larger for touch events to allow resizing windows easily, while continuing to use a smaller hit-region for mouse-events. BUG=135187 Review URL: https://chromiumcodereview.appspot.com/10854060 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@150870 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--ash/ash_constants.cc2
-rw-r--r--ash/ash_constants.h2
-rw-r--r--ash/wm/frame_painter.cc12
-rw-r--r--ash/wm/shelf_layout_manager.cc9
-rw-r--r--chrome/browser/ui/views/extensions/shell_window_views.cc21
-rw-r--r--ui/aura/window.cc4
-rw-r--r--ui/aura/window.h18
-rw-r--r--ui/aura/window_unittest.cc13
-rw-r--r--ui/oak/oak_aura_window_display.cc2
9 files changed, 51 insertions, 32 deletions
diff --git a/ash/ash_constants.cc b/ash/ash_constants.cc
index 616bee4..e452d46 100644
--- a/ash/ash_constants.cc
+++ b/ash/ash_constants.cc
@@ -13,8 +13,8 @@ namespace ash {
DEFINE_WINDOW_PROPERTY_KEY(bool, kConstrainedWindowKey, false);
const int kResizeAreaCornerSize = 16;
-const int kResizeOutsideBoundsSizeTouch = 30;
const int kResizeOutsideBoundsSize = 6;
+const int kResizeOutsideBoundsScaleForTouch = 5;
const int kResizeInsideBoundsSize = 1;
} // namespace ash
diff --git a/ash/ash_constants.h b/ash/ash_constants.h
index 17082d8..ad12a6f 100644
--- a/ash/ash_constants.h
+++ b/ash/ash_constants.h
@@ -24,8 +24,8 @@ ASH_EXPORT extern const int kResizeAreaCornerSize;
// extends to the edge of the window. We consider a small region outside the
// window bounds and an even smaller region overlapping the window to be the
// "non-client" area and use it for resizing.
-ASH_EXPORT extern const int kResizeOutsideBoundsSizeTouch;
ASH_EXPORT extern const int kResizeOutsideBoundsSize;
+ASH_EXPORT extern const int kResizeOutsideBoundsScaleForTouch;
ASH_EXPORT extern const int kResizeInsideBoundsSize;
} // namespace ash
diff --git a/ash/wm/frame_painter.cc b/ash/wm/frame_painter.cc
index 10fbbc6..5050906 100644
--- a/ash/wm/frame_painter.cc
+++ b/ash/wm/frame_painter.cc
@@ -181,12 +181,10 @@ void FramePainter::Init(views::Widget* frame,
window_ = frame->GetNativeWindow();
// Ensure we get resize cursors for a few pixels outside our bounds.
- int outside_bounds = ui::GetDisplayLayout() == ui::LAYOUT_TOUCH ?
- kResizeOutsideBoundsSizeTouch :
- kResizeOutsideBoundsSize;
- window_->set_hit_test_bounds_override_outer(
- gfx::Insets(-outside_bounds, -outside_bounds,
- -outside_bounds, -outside_bounds));
+ window_->SetHitTestBoundsOverrideOuter(
+ gfx::Insets(-kResizeOutsideBoundsSize, -kResizeOutsideBoundsSize,
+ -kResizeOutsideBoundsSize, -kResizeOutsideBoundsSize),
+ kResizeOutsideBoundsScaleForTouch);
// Ensure we get resize cursors just inside our bounds as well.
window_->set_hit_test_bounds_override_inner(
gfx::Insets(kResizeInsideBoundsSize, kResizeInsideBoundsSize,
@@ -224,7 +222,7 @@ int FramePainter::NonClientHitTest(views::NonClientFrameView* view,
if (ui::GetDisplayLayout() == ui::LAYOUT_TOUCH &&
aura::Env::GetInstance()->is_touch_down()) {
- outside_bounds = kResizeOutsideBoundsSizeTouch;
+ outside_bounds *= kResizeOutsideBoundsScaleForTouch;
}
expanded_bounds.Inset(-outside_bounds, -outside_bounds);
diff --git a/ash/wm/shelf_layout_manager.cc b/ash/wm/shelf_layout_manager.cc
index fa758dc..e1da66e 100644
--- a/ash/wm/shelf_layout_manager.cc
+++ b/ash/wm/shelf_layout_manager.cc
@@ -585,10 +585,11 @@ void ShelfLayoutManager::UpdateHitTestBounds() {
break;
}
}
- if (launcher_widget() && launcher_widget()->GetNativeWindow())
- launcher_widget()->GetNativeWindow()->set_hit_test_bounds_override_outer(
- insets);
- status_->GetNativeWindow()->set_hit_test_bounds_override_outer(insets);
+ if (launcher_widget() && launcher_widget()->GetNativeWindow()) {
+ launcher_widget()->GetNativeWindow()->SetHitTestBoundsOverrideOuter(
+ insets, 1);
+ }
+ status_->GetNativeWindow()->SetHitTestBoundsOverrideOuter( insets, 1);
}
bool ShelfLayoutManager::IsShelfWindow(aura::Window* window) {
diff --git a/chrome/browser/ui/views/extensions/shell_window_views.cc b/chrome/browser/ui/views/extensions/shell_window_views.cc
index eaef516..08f6f51 100644
--- a/chrome/browser/ui/views/extensions/shell_window_views.cc
+++ b/chrome/browser/ui/views/extensions/shell_window_views.cc
@@ -37,6 +37,7 @@
#if defined(USE_ASH)
#include "ash/ash_constants.h"
#include "ash/wm/custom_frame_view_ash.h"
+#include "ui/aura/env.h"
#include "ui/aura/window.h"
#endif
@@ -121,12 +122,12 @@ void ShellWindowFrameView::Init(views::Widget* frame) {
#if defined(USE_ASH)
aura::Window* window = frame->GetNativeWindow();
// Ensure we get resize cursors for a few pixels outside our bounds.
- int outside_bounds = ui::GetDisplayLayout() == ui::LAYOUT_TOUCH ?
- ash::kResizeOutsideBoundsSizeTouch :
- ash::kResizeOutsideBoundsSize;
- window->set_hit_test_bounds_override_outer(
- gfx::Insets(-outside_bounds, -outside_bounds,
- -outside_bounds, -outside_bounds));
+ window->SetHitTestBoundsOverrideOuter(
+ gfx::Insets(-ash::kResizeOutsideBoundsSize,
+ -ash::kResizeOutsideBoundsSize,
+ -ash::kResizeOutsideBoundsSize,
+ -ash::kResizeOutsideBoundsSize),
+ ash::kResizeOutsideBoundsScaleForTouch);
// Ensure we get resize cursors just inside our bounds as well.
// TODO(jeremya): do we need to update these when in fullscreen/maximized?
window->set_hit_test_bounds_override_inner(
@@ -162,9 +163,11 @@ int ShellWindowFrameView::NonClientHitTest(const gfx::Point& point) {
#if defined(USE_ASH)
gfx::Rect expanded_bounds = bounds();
- int outside_bounds = ui::GetDisplayLayout() == ui::LAYOUT_TOUCH ?
- ash::kResizeOutsideBoundsSizeTouch :
- ash::kResizeOutsideBoundsSize;
+ int outside_bounds = ash::kResizeOutsideBoundsSize;
+ if (ui::GetDisplayLayout() == ui::LAYOUT_TOUCH &&
+ aura::Env::GetInstance()->is_touch_down()) {
+ outside_bounds *= ash::kResizeOutsideBoundsScaleForTouch;
+ }
expanded_bounds.Inset(-outside_bounds, -outside_bounds);
if (!expanded_bounds.Contains(point))
return HTNOWHERE;
diff --git a/ui/aura/window.cc b/ui/aura/window.cc
index 822723b..f54bb75 100644
--- a/ui/aura/window.cc
+++ b/ui/aura/window.cc
@@ -496,7 +496,9 @@ bool Window::HitTest(const gfx::Point& local_point) {
// Expand my bounds for hit testing (override is usually zero but it's
// probably cheaper to do the math every time than to branch).
gfx::Rect local_bounds(gfx::Point(), bounds().size());
- local_bounds.Inset(hit_test_bounds_override_outer_);
+ local_bounds.Inset(aura::Env::GetInstance()->is_touch_down() ?
+ hit_test_bounds_override_outer_touch_ :
+ hit_test_bounds_override_outer_mouse_);
if (!delegate_ || !delegate_->HasHitTestMask())
return local_bounds.Contains(local_point);
diff --git a/ui/aura/window.h b/ui/aura/window.h
index c49e073..1965a8d 100644
--- a/ui/aura/window.h
+++ b/ui/aura/window.h
@@ -241,14 +241,17 @@ class AURA_EXPORT Window : public ui::LayerDelegate,
void set_ignore_events(bool ignore_events) { ignore_events_ = ignore_events; }
// Sets the window to grab hits for an area extending -|insets| pixels outside
- // its bounds. This can be used to create an invisible non- client area, for
+ // its bounds. This can be used to create an invisible non-client area, for
// example if your windows have no visible frames but still need to have
- // resize edges.
- void set_hit_test_bounds_override_outer(const gfx::Insets& insets) {
- hit_test_bounds_override_outer_ = insets;
+ // resize edges. It is possible to set a larger hit-region for touch-events.
+ void SetHitTestBoundsOverrideOuter(const gfx::Insets& mouse_insets,
+ int touch_scale) {
+ hit_test_bounds_override_outer_mouse_ = mouse_insets;
+ hit_test_bounds_override_outer_touch_ = mouse_insets.Scale(touch_scale);
}
- gfx::Insets hit_test_bounds_override_outer() const {
- return hit_test_bounds_override_outer_;
+
+ gfx::Insets hit_test_bounds_override_outer_mouse() const {
+ return hit_test_bounds_override_outer_mouse_;
}
// Sets the window to grab hits for an area extending |insets| pixels inside
@@ -469,7 +472,8 @@ class AURA_EXPORT Window : public ui::LayerDelegate,
bool ignore_events_;
// See set_hit_test_outer_override().
- gfx::Insets hit_test_bounds_override_outer_;
+ gfx::Insets hit_test_bounds_override_outer_mouse_;
+ gfx::Insets hit_test_bounds_override_outer_touch_;
gfx::Insets hit_test_bounds_override_inner_;
ObserverList<WindowObserver> observers_;
diff --git a/ui/aura/window_unittest.cc b/ui/aura/window_unittest.cc
index af8a470..a26c0d5 100644
--- a/ui/aura/window_unittest.cc
+++ b/ui/aura/window_unittest.cc
@@ -429,10 +429,21 @@ TEST_F(WindowTest, HitTest) {
EXPECT_FALSE(w1.HitTest(gfx::Point(-1, -1)));
// We can expand the bounds slightly to track events outside our border.
- w1.set_hit_test_bounds_override_outer(gfx::Insets(-1, -1, -1, -1));
+ w1.SetHitTestBoundsOverrideOuter(gfx::Insets(-1, -1, -1, -1), 5);
EXPECT_TRUE(w1.HitTest(gfx::Point(-1, -1)));
EXPECT_FALSE(w1.HitTest(gfx::Point(-2, -2)));
+ ui::TouchEventImpl pressed(
+ ui::ET_TOUCH_PRESSED, gfx::Point(50, 50), 0, getTime());
+ root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&pressed);
+ EXPECT_TRUE(w1.HitTest(gfx::Point(-2, -2)));
+ EXPECT_TRUE(w1.HitTest(gfx::Point(-5, -5)));
+ EXPECT_FALSE(w1.HitTest(gfx::Point(-5, -6)));
+ ui::TouchEventImpl released(
+ ui::ET_TOUCH_RELEASED, gfx::Point(50, 50), 0, getTime());
+ root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&released);
+ EXPECT_FALSE(w1.HitTest(gfx::Point(-2, -2)));
+
// TODO(beng): clip Window to parent.
}
diff --git a/ui/oak/oak_aura_window_display.cc b/ui/oak/oak_aura_window_display.cc
index 68130091..70ad155 100644
--- a/ui/oak/oak_aura_window_display.cc
+++ b/ui/oak/oak_aura_window_display.cc
@@ -145,7 +145,7 @@ string16 OakAuraWindowDisplay::GetText(int row, int column_id) {
return PropertyWithBool("Can Focus: ", window_->CanFocus());
case ROW_HITTESTBOUNDSOVERRIDEOUTER:
return PropertyWithInsets("Hit test bounds override outer: ",
- window_->hit_test_bounds_override_outer());
+ window_->hit_test_bounds_override_outer_mouse());
case ROW_HITTESTBOUNDSOVERRIDEINNER:
return PropertyWithInsets("Hit test bounds override inner: ",
window_->hit_test_bounds_override_inner());