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

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: Fix diamond inheritance. Created 6 years, 4 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
« no previous file with comments | « ash/desktop_background/desktop_background_view.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..ed3733b7672031679a34884e9d2946349e8e53d0 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,14 +73,51 @@ class LayerControlView : public views::View {
} // namespace
+// 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());
+ WindowSelectorController* controller =
+ Shell::GetInstance()->window_selector_controller();
+ if (event->type() == ui::ET_MOUSE_RELEASED && controller->IsSelecting()) {
+ controller->ToggleOverview();
+ event->StopPropagation();
+ }
+ }
+
+ virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE {
+ CHECK_EQ(ui::EP_PRETARGET, event->phase());
+ 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);
+};
+
////////////////////////////////////////////////////////////////////////////////
// DesktopBackgroundView, public:
-DesktopBackgroundView::DesktopBackgroundView() {
+DesktopBackgroundView::DesktopBackgroundView()
+ : pre_dispatch_handler_(new PreEventDispatchHandler()) {
set_context_menu_controller(this);
+ AddPreTargetHandler(pre_dispatch_handler_.get());
}
DesktopBackgroundView::~DesktopBackgroundView() {
+ RemovePreTargetHandler(pre_dispatch_handler_.get());
}
////////////////////////////////////////////////////////////////////////////////
« no previous file with comments | « ash/desktop_background/desktop_background_view.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698