Index: ash/desktop_background/desktop_background_view.cc |
diff --git a/ash/desktop_background/desktop_background_view.cc b/ash/desktop_background/desktop_background_view.cc |
index d0e850c8889d714d825bb80ed3a1ef940299566d..de6e656e3f81622d2a8af474998c276b5e4349a7 100644 |
--- a/ash/desktop_background/desktop_background_view.cc |
+++ b/ash/desktop_background/desktop_background_view.cc |
@@ -15,6 +15,7 @@ |
#include "ash/session/session_state_delegate.h" |
#include "ash/shell.h" |
#include "ash/shell_window_ids.h" |
+#include "ash/wm/overview/window_selector_controller.h" |
#include "ash/wm/window_animations.h" |
#include "base/message_loop/message_loop.h" |
#include "base/strings/utf_string_conversions.h" |
@@ -72,11 +73,45 @@ class LayerControlView : public views::View { |
} // namespace |
+namespace internal { |
tdanderson
2014/08/01 19:32:14
newline after line 76
rsadam
2014/08/01 19:57:10
Done.
|
+// This event handler receives events in the pre-target phase and takes care of |
+// the following: |
+// - Disabling overview mode on touch release. |
+// - Disabling overview mode on mouse release. |
+class PreEventDispatchHandler : public ui::EventHandler { |
+ public: |
+ PreEventDispatchHandler() {} |
+ virtual ~PreEventDispatchHandler() {} |
+ |
+ private: |
+ // ui::EventHandler: |
+ virtual void OnMouseEvent(ui::MouseEvent* event) OVERRIDE { |
tdanderson
2014/08/01 19:32:14
I'd add a CHECK_EQ to verify that the phase is act
rsadam
2014/08/01 19:57:10
Done.
|
+ WindowSelectorController* controller = |
+ Shell::GetInstance()->window_selector_controller(); |
+ if (event->type() == ui::ET_MOUSE_RELEASED && controller->IsSelecting()) { |
tdanderson
2014/08/01 19:32:14
Since conditional is only one line, omit {} around
rsadam
2014/08/01 19:57:10
Acknowledged! Readded the braces since I moved the
|
+ controller->ToggleOverview(); |
+ } |
tdanderson
2014/08/01 19:32:14
Mark the event as handled (here and also in the ot
rsadam
2014/08/01 19:57:09
Based on my understanding we should only do this i
tdanderson
2014/08/01 20:09:27
Yep, that's correct.
|
+ } |
+ |
+ virtual void OnTouchEvent(ui::TouchEvent* event) OVERRIDE { |
tdanderson
2014/08/01 19:32:14
We should instead listen for ET_GESTURE_TAP instea
rsadam
2014/08/01 19:57:09
Done.
|
+ WindowSelectorController* controller = |
+ Shell::GetInstance()->window_selector_controller(); |
+ if (event->type() == ui::ET_TOUCH_RELEASED && controller->IsSelecting()) { |
tdanderson
2014/08/01 19:32:14
Same as above, no {}
rsadam
2014/08/01 19:57:10
Acknowledged.
|
+ controller->ToggleOverview(); |
+ } |
+ } |
+ |
+ DISALLOW_COPY_AND_ASSIGN(PreEventDispatchHandler); |
+}; |
tdanderson
2014/08/01 19:32:14
newline after line 105
rsadam
2014/08/01 19:57:10
Done.
|
+} // namespace internal |
+ |
//////////////////////////////////////////////////////////////////////////////// |
// DesktopBackgroundView, public: |
-DesktopBackgroundView::DesktopBackgroundView() { |
+DesktopBackgroundView::DesktopBackgroundView() |
+ : pre_dispatch_handler_(new internal::PreEventDispatchHandler()) { |
set_context_menu_controller(this); |
+ AddPreTargetHandler(pre_dispatch_handler_.get()); |
} |
DesktopBackgroundView::~DesktopBackgroundView() { |