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

Unified Diff: ui/wm/core/easy_resize_window_targeter.cc

Issue 118553004: aura: Add an EasyResizeWindowTargeter. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: tot-merge-r243131 Created 6 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/wm/DEPS ('k') | ui/wm/public/easy_resize_window_targeter.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/wm/core/easy_resize_window_targeter.cc
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 0000000000000000000000000000000000000000..f3a2b0a77ebcdb09506581d4daa95ca4b2d2c4de
--- /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
« no previous file with comments | « ui/wm/DEPS ('k') | ui/wm/public/easy_resize_window_targeter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698