summaryrefslogtreecommitdiffstats
path: root/ui/wm
diff options
context:
space:
mode:
authorsadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-01-06 22:00:30 +0000
committersadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-01-06 22:00:30 +0000
commit3b66a3cddaa01576269a60803b0d9313d21a78f4 (patch)
tree8512a6d52a652223ba39c14199c45bebda0c8c49 /ui/wm
parent4ef896f4f19ecf56add1b2ad9382cf106cd56f5b (diff)
downloadchromium_src-3b66a3cddaa01576269a60803b0d9313d21a78f4.zip
chromium_src-3b66a3cddaa01576269a60803b0d9313d21a78f4.tar.gz
chromium_src-3b66a3cddaa01576269a60803b0d9313d21a78f4.tar.bz2
aura: Add an EasyResizeWindowTargeter.
Add EasyResizeWindowTargeter to allow easily resizing windows with mouse/touch with the new event-dispatch code. This will eventually allow getting rid of Window::SetHitTestBoundsOverrideOuter() once the new event-dispatch code is used for all event types. This patch installs an EasyResizeWindowTargeter for the shelf and status-area widgets. Subsequent CLs will install such targeters for the toplevel windows too. Collateral change includes adding some dependencies on wm_public (in DEPS and gyp). BUG=318879 R=ben@chromium.org Review URL: https://codereview.chromium.org/118553004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@243177 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/wm')
-rw-r--r--ui/wm/DEPS4
-rw-r--r--ui/wm/core/easy_resize_window_targeter.cc48
-rw-r--r--ui/wm/public/easy_resize_window_targeter.h48
-rw-r--r--ui/wm/wm.gyp8
4 files changed, 107 insertions, 1 deletions
diff --git a/ui/wm/DEPS b/ui/wm/DEPS
new file mode 100644
index 0000000..98fe186
--- /dev/null
+++ b/ui/wm/DEPS
@@ -0,0 +1,4 @@
+include_rules = [
+ "+ui/aura",
+ "+ui/gfx",
+]
diff --git a/ui/wm/core/easy_resize_window_targeter.cc b/ui/wm/core/easy_resize_window_targeter.cc
new file mode 100644
index 0000000..f3a2b0a
--- /dev/null
+++ b/ui/wm/core/easy_resize_window_targeter.cc
@@ -0,0 +1,48 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ui/wm/public/easy_resize_window_targeter.h"
+
+#include "ui/aura/window.h"
+#include "ui/gfx/geometry/insets_f.h"
+#include "ui/gfx/geometry/rect.h"
+
+namespace wm {
+
+EasyResizeWindowTargeter::EasyResizeWindowTargeter(
+ aura::Window* container,
+ const gfx::Insets& mouse_extend,
+ const gfx::Insets& touch_extend)
+ : container_(container),
+ mouse_extend_(mouse_extend),
+ touch_extend_(touch_extend) {
+}
+
+EasyResizeWindowTargeter::~EasyResizeWindowTargeter() {
+}
+
+bool EasyResizeWindowTargeter::EventLocationInsideBounds(
+ aura::Window* window,
+ const ui::LocatedEvent& event) const {
+ // Use the extended bounds only for immediate child windows of |container_|.
+ // Use the default targetter otherwise.
+ if (window->parent() == container_ && (!window->transient_parent() ||
+ window->transient_parent() == container_)) {
+ gfx::RectF bounds(window->bounds());
+ gfx::Transform transform = window->layer()->transform();
+ transform.TransformRect(&bounds);
+ if (event.IsTouchEvent() || event.IsGestureEvent()) {
+ bounds.Inset(touch_extend_);
+ } else {
+ bounds.Inset(mouse_extend_);
+ }
+
+ // Note that |event|'s location is in the |container_|'s coordinate system,
+ // as is |bounds|.
+ return bounds.Contains(event.location());
+ }
+ return WindowTargeter::EventLocationInsideBounds(window, event);
+}
+
+} // namespace wm
diff --git a/ui/wm/public/easy_resize_window_targeter.h b/ui/wm/public/easy_resize_window_targeter.h
new file mode 100644
index 0000000..c4c7137
--- /dev/null
+++ b/ui/wm/public/easy_resize_window_targeter.h
@@ -0,0 +1,48 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef UI_WM_PUBLIC_EASY_RESIZE_WINDOW_TARGETER_H_
+#define UI_WM_PUBLIC_EASY_RESIZE_WINDOW_TARGETER_H_
+
+#include "ui/aura/window_targeter.h"
+#include "ui/gfx/geometry/insets.h"
+
+namespace wm {
+
+// An EventTargeter for a container window that uses a slightly larger
+// hit-target region for easier resize.
+class EasyResizeWindowTargeter : public aura::WindowTargeter {
+ public:
+ // |container| window is the owner of this targeter.
+ EasyResizeWindowTargeter(aura::Window* container,
+ const gfx::Insets& mouse_extend,
+ const gfx::Insets& touch_extend);
+
+ virtual ~EasyResizeWindowTargeter();
+
+ protected:
+ void set_mouse_extend(const gfx::Insets& mouse_extend) {
+ mouse_extend_ = mouse_extend;
+ }
+
+ void set_touch_extend(const gfx::Insets& touch_extend) {
+ touch_extend_ = touch_extend;
+ }
+
+ // aura::WindowTargeter:
+ virtual bool EventLocationInsideBounds(
+ aura::Window* window,
+ const ui::LocatedEvent& event) const OVERRIDE;
+
+ private:
+ aura::Window* container_;
+ gfx::Insets mouse_extend_;
+ gfx::Insets touch_extend_;
+
+ DISALLOW_COPY_AND_ASSIGN(EasyResizeWindowTargeter);
+};
+
+} // namespace wm
+
+#endif // UI_WM_PUBLIC_EASY_RESIZE_WINDOW_TARGETER_H_
diff --git a/ui/wm/wm.gyp b/ui/wm/wm.gyp
index 5063551..725d9ea 100644
--- a/ui/wm/wm.gyp
+++ b/ui/wm/wm.gyp
@@ -10,7 +10,14 @@
{
'target_name': 'wm_public',
'type': 'static_library',
+ 'dependencies': [
+ '../../skia/skia.gyp:skia',
+ '../aura/aura.gyp:aura',
+ '../gfx/gfx.gyp:gfx_geometry',
+ ],
'sources': [
+ 'core/easy_resize_window_targeter.cc',
+ 'public/easy_resize_window_targeter.h',
'public/window_types.h',
],
},
@@ -20,7 +27,6 @@
'dependencies': [
'../../skia/skia.gyp:skia',
'../aura/aura.gyp:aura',
- '../views/views.gyp:views',
],
'sources': [
'test/wm_test_helper.cc',