Commit 968bd873 authored by rsadam@chromium.org's avatar rsadam@chromium.org

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
parent d48437d1
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include "ash/session/session_state_delegate.h" #include "ash/session/session_state_delegate.h"
#include "ash/shell.h" #include "ash/shell.h"
#include "ash/shell_window_ids.h" #include "ash/shell_window_ids.h"
#include "ash/wm/overview/window_selector_controller.h"
#include "ash/wm/window_animations.h" #include "ash/wm/window_animations.h"
#include "base/message_loop/message_loop.h" #include "base/message_loop/message_loop.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
...@@ -72,14 +73,51 @@ class LayerControlView : public views::View { ...@@ -72,14 +73,51 @@ class LayerControlView : public views::View {
} // namespace } // 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, public:
DesktopBackgroundView::DesktopBackgroundView() { DesktopBackgroundView::DesktopBackgroundView()
: pre_dispatch_handler_(new PreEventDispatchHandler()) {
set_context_menu_controller(this); set_context_menu_controller(this);
AddPreTargetHandler(pre_dispatch_handler_.get());
} }
DesktopBackgroundView::~DesktopBackgroundView() { DesktopBackgroundView::~DesktopBackgroundView() {
RemovePreTargetHandler(pre_dispatch_handler_.get());
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
......
...@@ -5,12 +5,15 @@ ...@@ -5,12 +5,15 @@
#ifndef ASH_DESKTOP_BACKGROUND_DESKTOP_BACKGROUND_VIEW_H_ #ifndef ASH_DESKTOP_BACKGROUND_DESKTOP_BACKGROUND_VIEW_H_
#define ASH_DESKTOP_BACKGROUND_DESKTOP_BACKGROUND_VIEW_H_ #define ASH_DESKTOP_BACKGROUND_DESKTOP_BACKGROUND_VIEW_H_
#include "ui/events/event.h"
#include "ui/gfx/image/image_skia.h" #include "ui/gfx/image/image_skia.h"
#include "ui/views/context_menu_controller.h" #include "ui/views/context_menu_controller.h"
#include "ui/views/view.h" #include "ui/views/view.h"
namespace ash { namespace ash {
class PreEventDispatchHandler;
class DesktopBackgroundView : public views::View, class DesktopBackgroundView : public views::View,
public views::ContextMenuController { public views::ContextMenuController {
public: public:
...@@ -26,6 +29,7 @@ class DesktopBackgroundView : public views::View, ...@@ -26,6 +29,7 @@ class DesktopBackgroundView : public views::View,
virtual void ShowContextMenuForView(views::View* source, virtual void ShowContextMenuForView(views::View* source,
const gfx::Point& point, const gfx::Point& point,
ui::MenuSourceType source_type) OVERRIDE; ui::MenuSourceType source_type) OVERRIDE;
scoped_ptr<PreEventDispatchHandler> pre_dispatch_handler_;
DISALLOW_COPY_AND_ASSIGN(DesktopBackgroundView); DISALLOW_COPY_AND_ASSIGN(DesktopBackgroundView);
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment