overview_gesture_handler.cc revision 4e180b6a0b4720a9b8e9e959a882386f690f08ff
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 3// found in the LICENSE file. 4 5#include "ash/wm/gestures/overview_gesture_handler.h" 6 7#include "ash/shell.h" 8#include "ash/shell_delegate.h" 9#include "ash/wm/overview/window_selector_controller.h" 10#include "ui/events/event.h" 11#include "ui/events/event_constants.h" 12#include "ui/gfx/rect.h" 13#include "ui/gfx/screen.h" 14 15namespace ash { 16namespace internal { 17 18namespace { 19 20// The number of pixels from the top of the screen (a virtual bezel) to allow 21// the overview swipe down gesture to begin within. Note this does not actually 22// prevent handling of the touches so a fullscreen page which consumes these can 23// prevent entering overview with a swipe down. 24const int kTopBezelExtraPixels = 5; 25 26} // namespace; 27 28OverviewGestureHandler::OverviewGestureHandler() 29 : in_top_bezel_gesture_(false) { 30} 31 32OverviewGestureHandler::~OverviewGestureHandler() { 33} 34 35bool OverviewGestureHandler::ProcessGestureEvent( 36 const ui::GestureEvent& event) { 37 // Detect at the beginning of any gesture whether it begins on the top bezel. 38 if (event.type() == ui::ET_GESTURE_BEGIN && 39 event.details().touch_points() == 1) { 40 in_top_bezel_gesture_ = !Shell::GetScreen()->GetDisplayNearestPoint( 41 event.location()).bounds().y() + kTopBezelExtraPixels > 42 event.location().y(); 43 return false; 44 } 45 46 if (!in_top_bezel_gesture_ || 47 event.type() != ui::ET_GESTURE_MULTIFINGER_SWIPE || 48 !event.details().swipe_down() || 49 event.details().touch_points() != 3) { 50 return false; 51 } 52 53 Shell* shell = Shell::GetInstance(); 54 shell->delegate()->RecordUserMetricsAction(UMA_GESTURE_OVERVIEW); 55 shell->window_selector_controller()->ToggleOverview(); 56 return true; 57} 58 59} // namespace internal 60} // namespace ash 61