| Index: ui/app_list/views/app_list_view.cc
|
| diff --git a/ui/app_list/views/app_list_view.cc b/ui/app_list/views/app_list_view.cc
|
| index 48a26d9691f3574d9d65d1e07384ba03e8c7dac8..2db73ddfe8ada1982962a4cf4f0a279c6ca27a0d 100644
|
| --- a/ui/app_list/views/app_list_view.cc
|
| +++ b/ui/app_list/views/app_list_view.cc
|
| @@ -35,6 +35,7 @@
|
| #include "ui/display/screen.h"
|
| #include "ui/gfx/canvas.h"
|
| #include "ui/gfx/geometry/insets.h"
|
| +#include "ui/gfx/geometry/vector2d_conversions.h"
|
| #include "ui/gfx/image/image_skia.h"
|
| #include "ui/gfx/path.h"
|
| #include "ui/gfx/skia_util.h"
|
| @@ -72,6 +73,9 @@ constexpr int kAppListThresholdDenominator = 3;
|
| // state, measured in DIPs/event.
|
| constexpr int kAppListDragVelocityThreshold = 25;
|
|
|
| +// The scroll offset in order to transition from PEEKING to FULLSCREEN
|
| +constexpr int kAppListMinScrollToSwitchStates = 20;
|
| +
|
| // The DIP distance from the bezel that a drag event must end within to transfer
|
| // the |app_list_state_|.
|
| constexpr int kAppListBezelMargin = 50;
|
| @@ -664,6 +668,30 @@ void AppListView::OnMaximizeModeChanged(bool started) {
|
| }
|
| }
|
|
|
| +bool AppListView::HandleScroll(const ui::Event* event) {
|
| + if (app_list_state_ != PEEKING)
|
| + return false;
|
| +
|
| + switch (event->type()) {
|
| + case ui::ET_MOUSEWHEEL:
|
| + SetState(event->AsMouseWheelEvent()->y_offset() < 0 ? FULLSCREEN_ALL_APPS
|
| + : CLOSED);
|
| + return true;
|
| + case ui::ET_SCROLL:
|
| + case ui::ET_SCROLL_FLING_START: {
|
| + int offset = event->AsScrollEvent()->y_offset();
|
| + if (abs(offset) > kAppListMinScrollToSwitchStates) {
|
| + SetState(offset < 0 ? FULLSCREEN_ALL_APPS : CLOSED);
|
| + return true;
|
| + }
|
| + break;
|
| + }
|
| + default:
|
| + break;
|
| + }
|
| + return false;
|
| +}
|
| +
|
| void AppListView::OnBeforeBubbleWidgetInit(views::Widget::InitParams* params,
|
| views::Widget* widget) const {
|
| if (!params->native_widget) {
|
| @@ -697,6 +725,19 @@ void AppListView::GetWidgetHitTestMask(gfx::Path* mask) const {
|
| mask->addRect(gfx::RectToSkRect(GetBubbleFrameView()->GetContentsBounds()));
|
| }
|
|
|
| +void AppListView::OnScrollEvent(ui::ScrollEvent* event) {
|
| + if (!is_fullscreen_app_list_enabled_)
|
| + return;
|
| +
|
| + if (event->type() == ui::ET_SCROLL_FLING_CANCEL)
|
| + return;
|
| +
|
| + if (HandleScroll(event)) {
|
| + event->SetHandled();
|
| + event->StopPropagation();
|
| + }
|
| +}
|
| +
|
| void AppListView::OnMouseEvent(ui::MouseEvent* event) {
|
| if (!is_fullscreen_app_list_enabled_)
|
| return;
|
| @@ -714,6 +755,11 @@ void AppListView::OnMouseEvent(ui::MouseEvent* event) {
|
| EndDrag(event->location());
|
| event->SetHandled();
|
| break;
|
| + case ui::ET_MOUSEWHEEL: {
|
| + if (HandleScroll(event))
|
| + event->SetHandled();
|
| + break;
|
| + }
|
| default:
|
| break;
|
| }
|
| @@ -765,8 +811,8 @@ bool AppListView::AcceleratorPressed(const ui::Accelerator& accelerator) {
|
| void AppListView::Layout() {
|
| const gfx::Rect contents_bounds = GetContentsBounds();
|
|
|
| - // Make sure to layout |app_list_main_view_| and |speech_view_| at the center
|
| - // of the widget.
|
| + // Make sure to layout |app_list_main_view_| and |speech_view_| at the
|
| + // center of the widget.
|
| gfx::Rect centered_bounds = contents_bounds;
|
| centered_bounds.ClampToCenteredSize(gfx::Size(
|
| app_list_main_view_->contents_view()->GetDefaultContentsBounds().width(),
|
| @@ -948,8 +994,9 @@ void AppListView::OnSpeechRecognitionStateChanged(
|
| } else {
|
| app_list_main_view_->SetVisible(true);
|
| // Refocus the search box. However, if the app list widget does not have
|
| - // focus, it means another window has already taken focus, and we *must not*
|
| - // focus the search box (or we would steal focus back into the app list).
|
| + // focus, it means another window has already taken focus, and we *must
|
| + // not* focus the search box (or we would steal focus back into the app
|
| + // list).
|
| if (GetWidget()->IsActive())
|
| search_box_view_->search_box()->RequestFocus();
|
| }
|
|
|