summaryrefslogtreecommitdiff
path: root/chromium/ash/wm/gestures/shelf_gesture_handler.cc
diff options
context:
space:
mode:
authorZeno Albisser <zeno.albisser@digia.com>2013-08-15 21:46:11 +0200
committerZeno Albisser <zeno.albisser@digia.com>2013-08-15 21:46:11 +0200
commit679147eead574d186ebf3069647b4c23e8ccace6 (patch)
treefc247a0ac8ff119f7c8550879ebb6d3dd8d1ff69 /chromium/ash/wm/gestures/shelf_gesture_handler.cc
downloadqtwebengine-chromium-679147eead574d186ebf3069647b4c23e8ccace6.tar.gz
Initial import.
Diffstat (limited to 'chromium/ash/wm/gestures/shelf_gesture_handler.cc')
-rw-r--r--chromium/ash/wm/gestures/shelf_gesture_handler.cc92
1 files changed, 92 insertions, 0 deletions
diff --git a/chromium/ash/wm/gestures/shelf_gesture_handler.cc b/chromium/ash/wm/gestures/shelf_gesture_handler.cc
new file mode 100644
index 00000000000..5b99363eb63
--- /dev/null
+++ b/chromium/ash/wm/gestures/shelf_gesture_handler.cc
@@ -0,0 +1,92 @@
+// Copyright (c) 2012 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/wm/gestures/shelf_gesture_handler.h"
+
+#include "ash/root_window_controller.h"
+#include "ash/session_state_delegate.h"
+#include "ash/shelf/shelf_layout_manager.h"
+#include "ash/shelf/shelf_types.h"
+#include "ash/shelf/shelf_widget.h"
+#include "ash/shell.h"
+#include "ash/system/status_area_widget.h"
+#include "ash/wm/gestures/tray_gesture_handler.h"
+#include "ash/wm/window_properties.h"
+#include "ash/wm/window_util.h"
+#include "ui/aura/window.h"
+#include "ui/compositor/layer.h"
+#include "ui/compositor/scoped_layer_animation_settings.h"
+#include "ui/gfx/transform.h"
+#include "ui/views/widget/widget.h"
+
+namespace ash {
+namespace internal {
+
+ShelfGestureHandler::ShelfGestureHandler()
+ : drag_in_progress_(false) {
+}
+
+ShelfGestureHandler::~ShelfGestureHandler() {
+}
+
+bool ShelfGestureHandler::ProcessGestureEvent(const ui::GestureEvent& event) {
+ Shell* shell = Shell::GetInstance();
+ if (!shell->session_state_delegate()->NumberOfLoggedInUsers() ||
+ shell->session_state_delegate()->IsScreenLocked()) {
+ // The gestures are disabled in the lock/login screen.
+ return false;
+ }
+
+ // TODO(oshima): Find the root window controller from event's location.
+ RootWindowController* controller = Shell::GetPrimaryRootWindowController();
+
+ ShelfLayoutManager* shelf = controller->GetShelfLayoutManager();
+
+ // The gesture are disabled for fullscreen windows that are not in immersive
+ // mode.
+ const aura::Window* fullscreen = controller->GetFullscreenWindow();
+ if (fullscreen && !shelf->FullscreenWithMinimalChrome())
+ return false;
+
+ if (event.type() == ui::ET_GESTURE_SCROLL_BEGIN) {
+ drag_in_progress_ = true;
+ shelf->StartGestureDrag(event);
+ return true;
+ }
+
+ if (!drag_in_progress_)
+ return false;
+
+ if (event.type() == ui::ET_GESTURE_SCROLL_UPDATE) {
+ if (tray_handler_) {
+ if (!tray_handler_->UpdateGestureDrag(event))
+ tray_handler_.reset();
+ } else if (shelf->UpdateGestureDrag(event) ==
+ ShelfLayoutManager::DRAG_TRAY) {
+ tray_handler_.reset(new TrayGestureHandler());
+ }
+
+ return true;
+ }
+
+ drag_in_progress_ = false;
+
+ if (event.type() == ui::ET_GESTURE_SCROLL_END ||
+ event.type() == ui::ET_SCROLL_FLING_START) {
+ if (tray_handler_) {
+ tray_handler_->CompleteGestureDrag(event);
+ tray_handler_.reset();
+ }
+
+ shelf->CompleteGestureDrag(event);
+ return true;
+ }
+
+ // Unexpected event. Reset the state and let the event fall through.
+ shelf->CancelGestureDrag();
+ return false;
+}
+
+} // namespace internal
+} // namespace ash