Commit 1723281f authored by James Cook's avatar James Cook Committed by Commit Bot

chromeos: Convert OverflowBubble to ui::EventHandler

Now that ash and the ui service are in the same process we don't need
to use PointerWatcher in ash anymore.

This is a partial manual revert of:
https://codereview.chromium.org/1934123004/

Bug: 595851, 872450
Test: ash_unittests
Change-Id: Ifbbb407210d0b3ec8d20993bff7a0f2cf44ba38e
Reviewed-on: https://chromium-review.googlesource.com/1186032
Commit-Queue: James Cook <jamescook@chromium.org>
Reviewed-by: default avatarMichael Wasserman <msw@chromium.org>
Cr-Commit-Position: refs/heads/master@{#585583}
parent 9fa94c6e
......@@ -11,6 +11,8 @@
#include "ash/shelf/shelf_view.h"
#include "ash/shell.h"
#include "ash/system/tray/tray_background_view.h"
#include "ui/aura/client/screen_position_client.h"
#include "ui/aura/window.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/views/widget/widget.h"
......@@ -19,12 +21,12 @@ namespace ash {
OverflowBubble::OverflowBubble(Shelf* shelf)
: shelf_(shelf), bubble_(nullptr), overflow_button_(nullptr) {
DCHECK(shelf_);
Shell::Get()->AddPointerWatcher(this, views::PointerWatcherEventTypes::BASIC);
Shell::Get()->AddPreTargetHandler(this);
}
OverflowBubble::~OverflowBubble() {
Hide();
Shell::Get()->RemovePointerWatcher(this);
Shell::Get()->RemovePreTargetHandler(this);
}
void OverflowBubble::Show(OverflowButton* overflow_button,
......@@ -61,10 +63,16 @@ void OverflowBubble::Hide() {
overflow_button->OnOverflowBubbleHidden();
}
void OverflowBubble::ProcessPressedEvent(
const gfx::Point& event_location_in_screen) {
if (!IsShowing() || bubble_->shelf_view()->IsShowingMenu() ||
bubble_->GetBoundsInScreen().Contains(event_location_in_screen) ||
void OverflowBubble::ProcessPressedEvent(ui::LocatedEvent* event) {
if (!IsShowing() || bubble_->shelf_view()->IsShowingMenu())
return;
aura::Window* target = static_cast<aura::Window*>(event->target());
gfx::Point event_location_in_screen = event->location();
aura::client::GetScreenPositionClient(target->GetRootWindow())
->ConvertPointToScreen(target, &event_location_in_screen);
if (bubble_->GetBoundsInScreen().Contains(event_location_in_screen) ||
overflow_button_->GetBoundsInScreen().Contains(
event_location_in_screen)) {
return;
......@@ -83,12 +91,14 @@ void OverflowBubble::ProcessPressedEvent(
Hide();
}
void OverflowBubble::OnPointerEventObserved(
const ui::PointerEvent& event,
const gfx::Point& location_in_screen,
gfx::NativeView target) {
if (event.type() == ui::ET_POINTER_DOWN)
ProcessPressedEvent(location_in_screen);
void OverflowBubble::OnMouseEvent(ui::MouseEvent* event) {
if (event->type() == ui::ET_MOUSE_PRESSED)
ProcessPressedEvent(event);
}
void OverflowBubble::OnTouchEvent(ui::TouchEvent* event) {
if (event->type() == ui::ET_TOUCH_PRESSED)
ProcessPressedEvent(event);
}
void OverflowBubble::OnWidgetDestroying(views::Widget* widget) {
......
......@@ -7,7 +7,7 @@
#include "ash/ash_export.h"
#include "base/macros.h"
#include "ui/views/pointer_watcher.h"
#include "ui/events/event_handler.h"
#include "ui/views/widget/widget_observer.h"
namespace views {
......@@ -15,7 +15,7 @@ class Widget;
}
namespace ui {
class PointerEvent;
class LocatedEvent;
}
namespace ash {
......@@ -26,7 +26,7 @@ class ShelfView;
// OverflowBubble shows shelf items that won't fit on the main shelf in a
// separate bubble.
class ASH_EXPORT OverflowBubble : public views::PointerWatcher,
class ASH_EXPORT OverflowBubble : public ui::EventHandler,
public views::WidgetObserver {
public:
// |shelf| is the shelf that spawns the bubble.
......@@ -44,14 +44,13 @@ class ASH_EXPORT OverflowBubble : public views::PointerWatcher,
OverflowBubbleView* bubble_view() { return bubble_; }
private:
void ProcessPressedEvent(const gfx::Point& event_location_in_screen);
void ProcessPressedEvent(ui::LocatedEvent* event);
// views::PointerWatcher:
void OnPointerEventObserved(const ui::PointerEvent& event,
const gfx::Point& location_in_screen,
gfx::NativeView target) override;
// ui::EventHandler:
void OnMouseEvent(ui::MouseEvent* event) override;
void OnTouchEvent(ui::TouchEvent* event) override;
// Overridden from views::WidgetObserver:
// views::WidgetObserver:
void OnWidgetDestroying(views::Widget* widget) override;
Shelf* shelf_;
......
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