Chromium Code Reviews| Index: chrome/browser/ui/ash/app_list/app_list_presenter_delegate_mus.cc |
| diff --git a/chrome/browser/ui/ash/app_list/app_list_presenter_delegate_mus.cc b/chrome/browser/ui/ash/app_list/app_list_presenter_delegate_mus.cc |
| index 979835f6d280510c829273f5b88028e2293c454f..c31aec9bedc50297a1958005384872e7c4b8ee59 100644 |
| --- a/chrome/browser/ui/ash/app_list/app_list_presenter_delegate_mus.cc |
| +++ b/chrome/browser/ui/ash/app_list/app_list_presenter_delegate_mus.cc |
| @@ -3,11 +3,11 @@ |
| // found in the LICENSE file. |
| #include "chrome/browser/ui/ash/app_list/app_list_presenter_delegate_mus.h" |
| - |
| #include "ui/app_list/presenter/app_list_view_delegate_factory.h" |
| #include "ui/app_list/views/app_list_view.h" |
| #include "ui/display/display.h" |
| #include "ui/display/screen.h" |
| +#include "ui/views/mus/window_manager_connection.h" |
| namespace { |
| @@ -36,10 +36,15 @@ gfx::Point GetCenterOfDisplay(int64_t display_id, int minimum_height) { |
| } // namespace |
| AppListPresenterDelegateMus::AppListPresenterDelegateMus( |
| + app_list::AppListPresenter* presenter, |
| app_list::AppListViewDelegateFactory* view_delegate_factory) |
| - : view_delegate_factory_(view_delegate_factory) {} |
| + : view_delegate_factory_(view_delegate_factory), presenter_(presenter) {} |
| -AppListPresenterDelegateMus::~AppListPresenterDelegateMus() {} |
| +AppListPresenterDelegateMus::~AppListPresenterDelegateMus() { |
| + views::WindowManagerConnection::Get() |
| + ->pointer_watcher_event_router() |
| + ->RemovePointerWatcher(this); |
| +} |
| app_list::AppListViewDelegate* AppListPresenterDelegateMus::GetViewDelegate() { |
| return view_delegate_factory_->GetDelegate(); |
| @@ -65,9 +70,11 @@ void AppListPresenterDelegateMus::Init(app_list::AppListView* view, |
| view->SetAnchorPoint( |
| GetCenterOfDisplay(display_id, GetMinimumBoundsHeightForAppList(view))); |
| + views::WindowManagerConnection::Get() |
| + ->pointer_watcher_event_router() |
| + ->AddPointerWatcher(this, true); |
| + |
| // TODO(mfomitchev): Setup updating bounds on keyboard bounds change. |
| - // TODO(mfomitchev): Setup dismissing on mouse/touch gesture anywhere outside |
| - // the bounds of the app list. |
| // TODO(mfomitchev): Setup dismissing on maximize (touch-view) mode start/end. |
| // TODO(mfomitchev): Setup DnD. |
| // TODO(mfomitchev): UpdateAutoHideState for shelf |
| @@ -78,8 +85,6 @@ void AppListPresenterDelegateMus::OnShown(int64_t display_id) { |
| } |
| void AppListPresenterDelegateMus::OnDismissed() { |
| - DCHECK(is_visible_); |
| - is_visible_ = false; |
| } |
| void AppListPresenterDelegateMus::UpdateBounds() { |
| @@ -89,6 +94,22 @@ void AppListPresenterDelegateMus::UpdateBounds() { |
| view_->UpdateBounds(); |
| } |
| +void AppListPresenterDelegateMus::OnPointerEventObserved( |
| + const ui::PointerEvent& event, |
| + const gfx::Point& location_in_screen, |
| + views::Widget* target) { |
| + // dismiss app list on a mouse click or touch outside of the app list window. |
|
mfomitchev
2016/09/29 20:00:36
Nit: Capital D
thanhph
2016/09/29 20:42:51
done!
|
| + if (event.type() == ui::ET_TOUCH_PRESSED || |
| + event.type() == ui::ET_POINTER_DOWN) { |
| + if (!target) { |
| + presenter_->Dismiss(); |
| + } else if (target != view_->GetWidget()) { |
|
mfomitchev
2016/09/29 20:00:36
Unify the two conditions to turn this into a simpl
thanhph
2016/09/29 20:42:51
done. thanks!
|
| + // else close the app list widget if clicks elsewhere |
|
mfomitchev
2016/09/29 20:00:36
Nit: Don't think you need this anymore.
thanhph
2016/09/29 20:42:51
removed this comment!
|
| + presenter_->Dismiss(); |
| + } |
| + } |
| +} |
| + |
| gfx::Vector2d AppListPresenterDelegateMus::GetVisibilityAnimationOffset( |
| aura::Window* root_window) { |
| // TODO(mfomitchev): Classic ash does different animation here depending on |