blob: a4e8737468c556e7a6128b384807c0545418353e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
// 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/shelf/shelf_layout_manager.h"
#include "ash/shelf/shelf_types.h"
#include "ash/shelf/shelf_widget.h"
#include "ash/shell.h"
#include "ash/shell_delegate.h"
#include "ash/system/status_area_widget.h"
#include "ash/wm/gestures/tray_gesture_handler.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->delegate()->IsUserLoggedIn() ||
shell->delegate()->IsScreenLocked()) {
// The gestures are disabled in the lock/login screen.
return false;
}
// The gesture are disabled for fullscreen windows.
aura::Window* active = wm::GetActiveWindow();
if (active && wm::IsWindowFullscreen(active))
return false;
// TODO(oshima): Find the root window controller from event's location.
ShelfLayoutManager* shelf =
Shell::GetPrimaryRootWindowController()->GetShelfLayoutManager();
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_.get()) {
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_.get()) {
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
|