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

Side by Side Diff: ash/pointer_watcher_delegate_aura.cc

Issue 1934123004: mash: Fix shelf overflow bubble not closing on click outside its bounds (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2openoverflow
Patch Set: rebase Created 4 years, 7 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 unified diff | Download patch
« no previous file with comments | « ash/pointer_watcher_delegate_aura.h ('k') | ash/shelf/overflow_bubble.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ash/pointer_watcher_delegate_aura.h" 5 #include "ash/pointer_watcher_delegate_aura.h"
6 6
7 #include "ash/shell.h" 7 #include "ash/shell.h"
8 #include "ui/aura/client/screen_position_client.h"
9 #include "ui/aura/window.h"
8 #include "ui/events/event.h" 10 #include "ui/events/event.h"
9 #include "ui/events/event_constants.h" 11 #include "ui/events/event_constants.h"
12 #include "ui/gfx/geometry/point.h"
10 #include "ui/views/pointer_watcher.h" 13 #include "ui/views/pointer_watcher.h"
11 14
12 namespace ash { 15 namespace ash {
13 16
14 PointerWatcherDelegateAura::PointerWatcherDelegateAura() { 17 PointerWatcherDelegateAura::PointerWatcherDelegateAura() {
15 Shell::GetInstance()->AddPreTargetHandler(this); 18 Shell::GetInstance()->AddPreTargetHandler(this);
16 } 19 }
17 20
18 PointerWatcherDelegateAura::~PointerWatcherDelegateAura() { 21 PointerWatcherDelegateAura::~PointerWatcherDelegateAura() {
19 Shell::GetInstance()->RemovePreTargetHandler(this); 22 Shell::GetInstance()->RemovePreTargetHandler(this);
20 } 23 }
21 24
22 void PointerWatcherDelegateAura::AddPointerWatcher( 25 void PointerWatcherDelegateAura::AddPointerWatcher(
23 views::PointerWatcher* watcher) { 26 views::PointerWatcher* watcher) {
24 pointer_watchers_.AddObserver(watcher); 27 pointer_watchers_.AddObserver(watcher);
25 } 28 }
26 29
27 void PointerWatcherDelegateAura::RemovePointerWatcher( 30 void PointerWatcherDelegateAura::RemovePointerWatcher(
28 views::PointerWatcher* watcher) { 31 views::PointerWatcher* watcher) {
29 pointer_watchers_.RemoveObserver(watcher); 32 pointer_watchers_.RemoveObserver(watcher);
30 } 33 }
31 34
32 void PointerWatcherDelegateAura::OnMouseEvent(ui::MouseEvent* event) { 35 void PointerWatcherDelegateAura::OnMouseEvent(ui::MouseEvent* event) {
33 if (event->type() == ui::ET_MOUSE_PRESSED) 36 if (event->type() == ui::ET_MOUSE_PRESSED)
34 FOR_EACH_OBSERVER(views::PointerWatcher, pointer_watchers_, 37 FOR_EACH_OBSERVER(views::PointerWatcher, pointer_watchers_,
35 OnMousePressed(*event)); 38 OnMousePressed(*event, GetLocationInScreen(*event)));
36 } 39 }
37 40
38 void PointerWatcherDelegateAura::OnTouchEvent(ui::TouchEvent* event) { 41 void PointerWatcherDelegateAura::OnTouchEvent(ui::TouchEvent* event) {
39 if (event->type() == ui::ET_TOUCH_PRESSED) 42 if (event->type() == ui::ET_TOUCH_PRESSED)
40 FOR_EACH_OBSERVER(views::PointerWatcher, pointer_watchers_, 43 FOR_EACH_OBSERVER(views::PointerWatcher, pointer_watchers_,
41 OnTouchPressed(*event)); 44 OnTouchPressed(*event, GetLocationInScreen(*event)));
45 }
46
47 gfx::Point PointerWatcherDelegateAura::GetLocationInScreen(
48 const ui::LocatedEvent& event) const {
49 aura::Window* target = static_cast<aura::Window*>(event.target());
50 gfx::Point location_in_screen = event.location();
51 aura::client::GetScreenPositionClient(target->GetRootWindow())
52 ->ConvertPointToScreen(target, &location_in_screen);
53 return location_in_screen;
42 } 54 }
43 55
44 } // namespace ash 56 } // namespace ash
OLDNEW
« no previous file with comments | « ash/pointer_watcher_delegate_aura.h ('k') | ash/shelf/overflow_bubble.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698