diff options
author | rsadam@chromium.org <rsadam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-08-05 21:18:24 +0000 |
---|---|---|
committer | rsadam@chromium.org <rsadam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-08-05 21:18:24 +0000 |
commit | 968bd8737c82e6a50ad856d8ae332bd80a2f948f (patch) | |
tree | 3557443736920dc1d97af51a2f2c0086e9400e99 /ash/desktop_background/desktop_background_view.cc | |
parent | d48437d138cb309e2d2893ba9ce6797830b45f19 (diff) | |
download | chromium_src-968bd8737c82e6a50ad856d8ae332bd80a2f948f.zip chromium_src-968bd8737c82e6a50ad856d8ae332bd80a2f948f.tar.gz chromium_src-968bd8737c82e6a50ad856d8ae332bd80a2f948f.tar.bz2 |
Add pretargethandler to exit overview mode on touch/click.
Touching or clicking on the background page while in overview mode will now
dismiss it.
BUG=364507
TEST=TBA
Review URL: https://codereview.chromium.org/435023003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@287601 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash/desktop_background/desktop_background_view.cc')
-rw-r--r-- | ash/desktop_background/desktop_background_view.cc | 40 |
1 files changed, 39 insertions, 1 deletions
diff --git a/ash/desktop_background/desktop_background_view.cc b/ash/desktop_background/desktop_background_view.cc index d0e850c..ed3733b 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()); } //////////////////////////////////////////////////////////////////////////////// |