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

Unified Diff: ash/system/tray/tray_event_filter.cc

Issue 1918183003: mash: Close the system tray bubble on click outside its bounds (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@pointerwatcher
Patch Set: rebase Created 4 years, 8 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/system/tray/tray_event_filter.h ('k') | ash/system/web_notification/web_notification_tray.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/system/tray/tray_event_filter.cc
diff --git a/ash/system/tray/tray_event_filter.cc b/ash/system/tray/tray_event_filter.cc
index b7a6d617ba471134484a54fea154a5b65018bda2..dd18b803aa23d155cc8721824b96c01477a0cfe7 100644
--- a/ash/system/tray/tray_event_filter.cc
+++ b/ash/system/tray/tray_event_filter.cc
@@ -30,44 +30,40 @@ void TrayEventFilter::AddWrapper(TrayBubbleWrapper* wrapper) {
bool was_empty = wrappers_.empty();
wrappers_.insert(wrapper);
if (was_empty && !wrappers_.empty())
- ash::Shell::GetInstance()->AddPreTargetHandler(this);
+ Shell::GetInstance()->AddPointerWatcher(this);
}
void TrayEventFilter::RemoveWrapper(TrayBubbleWrapper* wrapper) {
wrappers_.erase(wrapper);
if (wrappers_.empty())
- ash::Shell::GetInstance()->RemovePreTargetHandler(this);
+ Shell::GetInstance()->RemovePointerWatcher(this);
}
-void TrayEventFilter::OnMouseEvent(ui::MouseEvent* event) {
- if (event->type() == ui::ET_MOUSE_PRESSED &&
- ProcessLocatedEvent(event)) {
- event->StopPropagation();
- }
+void TrayEventFilter::OnMousePressed(const ui::MouseEvent& event) {
+ ProcessLocatedEvent(event);
}
-void TrayEventFilter::OnTouchEvent(ui::TouchEvent* event) {
- if (event->type() == ui::ET_TOUCH_PRESSED && ProcessLocatedEvent(event))
- event->StopPropagation();
+void TrayEventFilter::OnTouchPressed(const ui::TouchEvent& event) {
+ ProcessLocatedEvent(event);
}
-bool TrayEventFilter::ProcessLocatedEvent(ui::LocatedEvent* event) {
- if (event->target()) {
- aura::Window* target = static_cast<aura::Window*>(event->target());
+void TrayEventFilter::ProcessLocatedEvent(const ui::LocatedEvent& event) {
+ if (event.target()) {
+ aura::Window* target = static_cast<aura::Window*>(event.target());
// Don't process events that occurred inside an embedded menu.
RootWindowController* root_controller =
GetRootWindowController(target->GetRootWindow());
if (root_controller &&
root_controller->GetContainer(kShellWindowId_MenuContainer)
->Contains(target)) {
- return false;
+ return;
}
// Don't process events that occurred inside the status area widget and
// a popup notification from message center.
if (root_controller &&
root_controller->GetContainer(kShellWindowId_StatusContainer)
->Contains(target)) {
- return false;
+ return;
}
}
@@ -85,22 +81,21 @@ bool TrayEventFilter::ProcessLocatedEvent(ui::LocatedEvent* event) {
aura::Window* root = bubble_widget->GetNativeView()->GetRootWindow();
aura::client::ScreenPositionClient* screen_position_client =
aura::client::GetScreenPositionClient(root);
- gfx::Point screen_point(event->root_location());
+ gfx::Point screen_point(event.root_location());
screen_position_client->ConvertPointToScreen(root, &screen_point);
if (bounds.Contains(screen_point))
- return false;
+ return;
if (wrapper->tray()) {
// If the user clicks on the parent tray, don't process the event here,
// let the tray logic handle the event and determine show/hide behavior.
bounds = wrapper->tray()->GetBoundsInScreen();
if (bounds.Contains(screen_point))
- return false;
+ return;
}
}
- // Handle clicking outside the bubble and tray and return true if the
- // event was handled.
+ // Handle clicking outside the bubble and tray.
// Cannot iterate |wrappers_| directly, because clicking outside will remove
// the wrapper, which shrinks |wrappers_| unsafely.
std::set<TrayBackgroundView*> trays;
@@ -108,12 +103,10 @@ bool TrayEventFilter::ProcessLocatedEvent(ui::LocatedEvent* event) {
iter != wrappers_.end(); ++iter) {
trays.insert((*iter)->tray());
}
- bool handled = false;
for (std::set<TrayBackgroundView*>::iterator iter = trays.begin();
iter != trays.end(); ++iter) {
- handled |= (*iter)->ClickedOutsideBubble();
+ (*iter)->ClickedOutsideBubble();
}
- return handled;
}
} // namespace ash
« no previous file with comments | « ash/system/tray/tray_event_filter.h ('k') | ash/system/web_notification/web_notification_tray.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698