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..540ed1ca7ecab48f68096524d9b0fdb9dee25c4c 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 |
@@ -9,6 +9,15 @@ |
#include "ui/display/display.h" |
#include "ui/display/screen.h" |
+#include "ui/views/mus/window_manager_connection.h" |
+#include "ui/views/pointer_watcher.h" |
+#include "ash/common/shelf/wm_shelf.h" |
mfomitchev
2016/09/23 19:47:15
We shouldn't depend on any of the ash classes. Wit
thanhph
2016/09/29 18:12:08
Good point. I forget to remove these ash includes.
|
+#include "ash/common/wm_lookup.h" |
+#include "ash/common/wm_window.h" |
+#include "ash/common/shelf/app_list_button.h" |
+#include "ash/common/shelf/shelf_layout_manager.h" |
+#include "ash/common/shelf/shelf_types.h" |
+ |
namespace { |
// Gets the point at the center of the display. The calculation should exclude |
@@ -36,10 +45,18 @@ 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) {} |
- |
-AppListPresenterDelegateMus::~AppListPresenterDelegateMus() {} |
+ : view_delegate_factory_(view_delegate_factory), |
+ presenter_(presenter){ |
+ // ash::WmShell::Get()->AddShellObserver(this); |
+ }; |
+ |
+AppListPresenterDelegateMus::~AppListPresenterDelegateMus() { |
+ // views::WindowManagerConnection::Get() |
mfomitchev
2016/09/23 19:47:15
I think we do want this?
thanhph
2016/09/29 18:12:08
Yes..I'll add this back.
|
+ // ->pointer_watcher_event_router() |
+ // ->RemovePointerWatcher(this); |
+} |
app_list::AppListViewDelegate* AppListPresenterDelegateMus::GetViewDelegate() { |
return view_delegate_factory_->GetDelegate(); |
@@ -48,6 +65,7 @@ app_list::AppListViewDelegate* AppListPresenterDelegateMus::GetViewDelegate() { |
void AppListPresenterDelegateMus::Init(app_list::AppListView* view, |
int64_t display_id, |
int current_apps_page) { |
+ LOG(ERROR) << "\n\n!!!!!. Initializing AppListPresenterDelegateMus\n\n\n"; |
view_ = view; |
// Note: This would place the app list into the USER_WINDOWS container, unlike |
@@ -65,6 +83,10 @@ void AppListPresenterDelegateMus::Init(app_list::AppListView* view, |
view->SetAnchorPoint( |
GetCenterOfDisplay(display_id, GetMinimumBoundsHeightForAppList(view))); |
+ views::WindowManagerConnection::Get() |
+ ->pointer_watcher_event_router() |
+ ->AddPointerWatcher(this, true); |
mfomitchev
2016/09/23 19:47:15
Any reason we passing true for |wants_moves|? I th
thanhph
2016/09/29 18:12:08
That makes sense, will make the code faster by set
|
+ |
// 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. |
@@ -78,17 +100,47 @@ void AppListPresenterDelegateMus::OnShown(int64_t display_id) { |
} |
void AppListPresenterDelegateMus::OnDismissed() { |
- DCHECK(is_visible_); |
- is_visible_ = false; |
+ presenter_->Dismiss(); |
mfomitchev
2016/09/23 19:47:15
This will cause an infinite loop, since Dismiss()
thanhph
2016/09/29 18:12:08
my function is OnDismissed not OnDismiss so it'll
|
} |
void AppListPresenterDelegateMus::UpdateBounds() { |
if (!view_ || !is_visible_) |
+ |
return; |
view_->UpdateBounds(); |
} |
+void AppListPresenterDelegateMus::OnPointerEventObserved( |
+ const ui::PointerEvent& event, |
+ const gfx::Point& location_in_screen, |
+ views::Widget* target) { |
+ LOG(ERROR) << "\n\n!!!!!. Closing ?\n\n\n"; |
+ |
+ if (event.type() == ui::ET_TOUCH_PRESSED || |
+ event.type() == ui::ET_POINTER_DOWN) { |
+ if (!target) { |
+ // |
+ LOG(ERROR) << "\n\n!!!!!. Closing OnPointerEventObserved\n\n\n"; |
+ // view_->app_list_main_view_->close(); |
+ // view_->CloseAppList(); |
+ // target->Hide(); |
+ this->OnDismissed(); |
mfomitchev
2016/09/23 19:47:15
presenter_->Dismiss()
thanhph
2016/09/29 18:12:08
Thanks.. This is cleaner.
|
+ // OnDismissed(); |
+ // target->CloseNow(); |
+ // target->GetTopLevelWidget()->CloseNow(); |
+ } else { |
+ LOG(ERROR) << "\n\n!!!!! target->GetWindowBoundsInScreen().ToString():" |
+ << target->GetWindowBoundsInScreen().ToString() << "\n\n\n"; |
+ |
+ // LOG(ERROR) << "x:" << target->bounds.x() |
+ // << "x:" << target->bounds.y() |
+ // << "width:" << target->bounds.width() |
+ // << "height:" << target->bounds.height() ; |
+ } |
+ } |
+} |
+ |
gfx::Vector2d AppListPresenterDelegateMus::GetVisibilityAnimationOffset( |
aura::Window* root_window) { |
// TODO(mfomitchev): Classic ash does different animation here depending on |