Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1929)

Unified Diff: chrome/browser/ui/ash/app_list/app_list_presenter_delegate_mus.cc

Issue 2434573004: Close app list widget when users click outside of the widget (Closed)
Patch Set: Combine 2 if statements and add DCHECK(!is_visible_) before its use. Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..67346177bf79a99485e50572c8c1393fbf022000 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
@@ -4,10 +4,13 @@
#include "chrome/browser/ui/ash/app_list/app_list_presenter_delegate_mus.h"
+#include "ui/app_list/presenter/app_list_presenter.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/pointer_watcher_event_router.h"
+#include "ui/views/mus/window_manager_connection.h"
namespace {
@@ -36,10 +39,13 @@ 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) {}
+ : presenter_(presenter), view_delegate_factory_(view_delegate_factory) {}
-AppListPresenterDelegateMus::~AppListPresenterDelegateMus() {}
+AppListPresenterDelegateMus::~AppListPresenterDelegateMus() {
+ DCHECK(!is_visible_);
+}
app_list::AppListViewDelegate* AppListPresenterDelegateMus::GetViewDelegate() {
return view_delegate_factory_->GetDelegate();
@@ -66,18 +72,23 @@ void AppListPresenterDelegateMus::Init(app_list::AppListView* view,
GetCenterOfDisplay(display_id, GetMinimumBoundsHeightForAppList(view)));
// 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
}
void AppListPresenterDelegateMus::OnShown(int64_t display_id) {
+ views::WindowManagerConnection::Get()
+ ->pointer_watcher_event_router()
+ ->AddPointerWatcher(this, false);
+ DCHECK(!is_visible_);
is_visible_ = true;
}
void AppListPresenterDelegateMus::OnDismissed() {
+ views::WindowManagerConnection::Get()
+ ->pointer_watcher_event_router()
+ ->RemovePointerWatcher(this);
DCHECK(is_visible_);
is_visible_ = false;
}
@@ -95,3 +106,14 @@ gfx::Vector2d AppListPresenterDelegateMus::GetVisibilityAnimationOffset(
// shelf alignment. We should probably do that too.
return gfx::Vector2d(0, kAnimationOffset);
}
+
+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.
+ if ((event.type() == ui::ET_TOUCH_PRESSED ||
+ event.type() == ui::ET_POINTER_DOWN) &&
+ (!target || (view_ && (target != view_->GetWidget()))))
+ presenter_->Dismiss();
+}

Powered by Google App Engine
This is Rietveld 408576698