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

Unified Diff: ash/shelf/shelf_bezel_event_filter.cc

Issue 15931005: Move bezel event routing for the shelf into ShelfLayoutManager (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Removed failing test after discussing with sadrul Created 7 years, 6 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 | « ash/shelf/shelf_bezel_event_filter.h ('k') | ash/shelf/shelf_layout_manager.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/shelf/shelf_bezel_event_filter.cc
diff --git a/ash/shelf/shelf_bezel_event_filter.cc b/ash/shelf/shelf_bezel_event_filter.cc
new file mode 100644
index 0000000000000000000000000000000000000000..6f8eb1808b07df14f45c7d3fc1066c298a3bc8bf
--- /dev/null
+++ b/ash/shelf/shelf_bezel_event_filter.cc
@@ -0,0 +1,73 @@
+// Copyright (c) 2013 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 "ash/shelf/shelf_bezel_event_filter.h"
+
+#include "ash/shelf/shelf_layout_manager.h"
+#include "ash/shell.h"
+
+namespace ash {
+namespace internal {
+
+ShelfBezelEventFilter::ShelfBezelEventFilter(
+ ShelfLayoutManager* shelf)
+ : shelf_(shelf),
+ in_touch_drag_(false) {
+ Shell::GetInstance()->AddPreTargetHandler(this);
+}
+
+ShelfBezelEventFilter::~ShelfBezelEventFilter() {
+ Shell::GetInstance()->RemovePreTargetHandler(this);
+}
+
+void ShelfBezelEventFilter::OnGestureEvent(
+ ui::GestureEvent* event) {
+ gfx::Rect screen =
+ Shell::GetScreen()->GetDisplayNearestPoint(event->location()).bounds();
+ if ((!screen.Contains(event->location()) &&
+ IsShelfOnBezel(screen, event->location())) ||
+ in_touch_drag_) {
+ if (gesture_handler_.ProcessGestureEvent(*event)) {
+ switch (event->type()) {
+ case ui::ET_GESTURE_SCROLL_BEGIN:
+ in_touch_drag_ = true;
+ break;
+ case ui::ET_GESTURE_SCROLL_END:
+ case ui::ET_SCROLL_FLING_START:
+ in_touch_drag_ = false;
+ break;
+ default:
+ break;
+ }
+ event->StopPropagation();
+ }
+ }
+}
+
+bool ShelfBezelEventFilter::IsShelfOnBezel(
+ const gfx::Rect& screen,
+ const gfx::Point& point) const{
+ switch (shelf_->GetAlignment()) {
+ case SHELF_ALIGNMENT_BOTTOM:
+ if (point.y() >= screen.bottom())
+ return true;
+ break;
+ case SHELF_ALIGNMENT_LEFT:
+ if (point.x() <= screen.x())
+ return true;
+ break;
+ case SHELF_ALIGNMENT_TOP:
+ if (point.y() <= screen.y())
+ return true;
+ break;
+ case SHELF_ALIGNMENT_RIGHT:
+ if (point.x() >= screen.right())
+ return true;
+ break;
+ }
+ return false;
+}
+
+} // namespace internal
+} // namespace ash
« no previous file with comments | « ash/shelf/shelf_bezel_event_filter.h ('k') | ash/shelf/shelf_layout_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698