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

Unified Diff: ash/desktop_background/desktop_background_view.cc

Issue 435023003: Add pretargethandler to exit overview mode on touch/click. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 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: 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..64381685ef1e2d1a53b9a96ba3c1f93540875abc 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,55 @@ class LayerControlView : public views::View {
} // namespace
+namespace internal {
+
+// 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 {
+ CHECK_EQ(ui::EP_PRETARGET, event->phase());
+ if (event->handled())
tdanderson 2014/08/01 20:09:27 Is there a particular reason you added this check
rsadam 2014/08/05 14:52:55 I went back and looked at root_view.cc and this ch
+ return;
+ WindowSelectorController* controller =
+ Shell::GetInstance()->window_selector_controller();
+ if (event->type() == ui::ET_MOUSE_RELEASED && controller->IsSelecting()) {
+ controller->ToggleOverview();
+ event->StopPropagation();
+ }
+ }
+
+ virtual void OnTouchEvent(ui::TouchEvent* event) OVERRIDE {
tdanderson 2014/08/01 20:09:27 Since you've changed to listening for gestures, th
rsadam 2014/08/05 14:52:54 Done.
+ CHECK_EQ(ui::EP_PRETARGET, event->phase());
+ if (event->handled())
+ return;
+ WindowSelectorController* controller =
+ Shell::GetInstance()->window_selector_controller();
+ if (event->type() == ui::ET_GESTURE_TAP && controller->IsSelecting()) {
+ controller->ToggleOverview();
+ event->StopPropagation();
+ }
+ }
+
+ DISALLOW_COPY_AND_ASSIGN(PreEventDispatchHandler);
+};
+
+} // 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() {
bshe 2014/08/05 11:38:28 nit: do you need to remove the handler here?
rsadam 2014/08/05 14:52:55 Done.

Powered by Google App Engine
This is Rietveld 408576698