| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2012 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/shelf_gesture_handler.h" | |
| 6 | |
| 7 #include "ash/common/session/session_state_delegate.h" | |
| 8 #include "ash/common/shelf/shelf_types.h" | |
| 9 #include "ash/common/system/status_area_widget.h" | |
| 10 #include "ash/common/wm/window_state.h" | |
| 11 #include "ash/common/wm_shell.h" | |
| 12 #include "ash/root_window_controller.h" | |
| 13 #include "ash/shelf/shelf_layout_manager.h" | |
| 14 #include "ash/shelf/shelf_widget.h" | |
| 15 #include "ash/wm/window_state_aura.h" | |
| 16 #include "ash/wm/window_util.h" | |
| 17 #include "ui/aura/window.h" | |
| 18 #include "ui/compositor/layer.h" | |
| 19 #include "ui/compositor/scoped_layer_animation_settings.h" | |
| 20 #include "ui/gfx/transform.h" | |
| 21 #include "ui/views/widget/widget.h" | |
| 22 | |
| 23 namespace ash { | |
| 24 | |
| 25 ShelfGestureHandler::ShelfGestureHandler() : drag_in_progress_(false) {} | |
| 26 | |
| 27 ShelfGestureHandler::~ShelfGestureHandler() {} | |
| 28 | |
| 29 bool ShelfGestureHandler::ProcessGestureEvent( | |
| 30 const ui::GestureEvent& event, | |
| 31 const aura::Window* event_target_window) { | |
| 32 // The gestures are disabled in the lock/login screen. | |
| 33 SessionStateDelegate* delegate = WmShell::Get()->GetSessionStateDelegate(); | |
| 34 if (!delegate->NumberOfLoggedInUsers() || delegate->IsScreenLocked()) | |
| 35 return false; | |
| 36 | |
| 37 RootWindowController* controller = | |
| 38 RootWindowController::ForWindow(event_target_window); | |
| 39 ShelfLayoutManager* shelf = controller->GetShelfLayoutManager(); | |
| 40 | |
| 41 if (event.type() == ui::ET_GESTURE_WIN8_EDGE_SWIPE) { | |
| 42 shelf->OnGestureEdgeSwipe(event); | |
| 43 return true; | |
| 44 } | |
| 45 | |
| 46 const aura::Window* fullscreen = controller->GetWindowForFullscreenMode(); | |
| 47 if (fullscreen && | |
| 48 wm::GetWindowState(fullscreen)->hide_shelf_when_fullscreen()) { | |
| 49 return false; | |
| 50 } | |
| 51 | |
| 52 if (event.type() == ui::ET_GESTURE_SCROLL_BEGIN) { | |
| 53 drag_in_progress_ = true; | |
| 54 shelf->StartGestureDrag(event); | |
| 55 return true; | |
| 56 } | |
| 57 | |
| 58 if (!drag_in_progress_) | |
| 59 return false; | |
| 60 | |
| 61 if (event.type() == ui::ET_GESTURE_SCROLL_UPDATE) { | |
| 62 shelf->UpdateGestureDrag(event); | |
| 63 return true; | |
| 64 } | |
| 65 | |
| 66 drag_in_progress_ = false; | |
| 67 | |
| 68 if (event.type() == ui::ET_GESTURE_SCROLL_END || | |
| 69 event.type() == ui::ET_SCROLL_FLING_START) { | |
| 70 shelf->CompleteGestureDrag(event); | |
| 71 return true; | |
| 72 } | |
| 73 | |
| 74 // Unexpected event. Reset the state and let the event fall through. | |
| 75 shelf->CancelGestureDrag(); | |
| 76 return false; | |
| 77 } | |
| 78 | |
| 79 } // namespace ash | |
| OLD | NEW |