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

Side by Side Diff: ash/pointer_watcher_delegate_aura.cc

Issue 2183163002: mus: Change PointerWatcher to observe all pointer events, with moves optional. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 4 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/mus/window_manager_unittest.cc ('k') | ash/sysui/pointer_watcher_delegate_mus.cc » ('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" 8 #include "ui/aura/client/screen_position_client.h"
9 #include "ui/aura/window.h" 9 #include "ui/aura/window.h"
10 #include "ui/events/event.h" 10 #include "ui/events/event.h"
(...skipping 16 matching lines...) Expand all
27 views::PointerWatcher* watcher) { 27 views::PointerWatcher* watcher) {
28 pointer_watchers_.AddObserver(watcher); 28 pointer_watchers_.AddObserver(watcher);
29 } 29 }
30 30
31 void PointerWatcherDelegateAura::RemovePointerWatcher( 31 void PointerWatcherDelegateAura::RemovePointerWatcher(
32 views::PointerWatcher* watcher) { 32 views::PointerWatcher* watcher) {
33 pointer_watchers_.RemoveObserver(watcher); 33 pointer_watchers_.RemoveObserver(watcher);
34 } 34 }
35 35
36 void PointerWatcherDelegateAura::OnMouseEvent(ui::MouseEvent* event) { 36 void PointerWatcherDelegateAura::OnMouseEvent(ui::MouseEvent* event) {
37 if (event->type() == ui::ET_MOUSE_PRESSED) 37 // For compatibility with the mus version, don't send moves.
38 FOR_EACH_OBSERVER(views::PointerWatcher, pointer_watchers_, 38 if (event->type() != ui::ET_MOUSE_PRESSED &&
39 OnMousePressed(*event, GetLocationInScreen(*event), 39 event->type() != ui::ET_MOUSE_RELEASED)
40 GetTargetWidget(*event))); 40 return;
41 ui::PointerEvent mouse_pointer_event(*event);
42 FOR_EACH_OBSERVER(
43 views::PointerWatcher, pointer_watchers_,
44 OnPointerEventObserved(mouse_pointer_event, GetLocationInScreen(*event),
45 GetTargetWidget(*event)));
41 } 46 }
42 47
43 void PointerWatcherDelegateAura::OnTouchEvent(ui::TouchEvent* event) { 48 void PointerWatcherDelegateAura::OnTouchEvent(ui::TouchEvent* event) {
44 if (event->type() == ui::ET_TOUCH_PRESSED) 49 // For compatibility with the mus version, don't send moves.
45 FOR_EACH_OBSERVER(views::PointerWatcher, pointer_watchers_, 50 if (event->type() != ui::ET_TOUCH_PRESSED &&
46 OnTouchPressed(*event, GetLocationInScreen(*event), 51 event->type() != ui::ET_TOUCH_RELEASED)
47 GetTargetWidget(*event))); 52 return;
53 ui::PointerEvent touch_pointer_event(*event);
54 FOR_EACH_OBSERVER(
55 views::PointerWatcher, pointer_watchers_,
56 OnPointerEventObserved(touch_pointer_event, GetLocationInScreen(*event),
57 GetTargetWidget(*event)));
48 } 58 }
49 59
50 gfx::Point PointerWatcherDelegateAura::GetLocationInScreen( 60 gfx::Point PointerWatcherDelegateAura::GetLocationInScreen(
51 const ui::LocatedEvent& event) const { 61 const ui::LocatedEvent& event) const {
52 aura::Window* target = static_cast<aura::Window*>(event.target()); 62 aura::Window* target = static_cast<aura::Window*>(event.target());
53 gfx::Point location_in_screen = event.location(); 63 gfx::Point location_in_screen = event.location();
54 aura::client::GetScreenPositionClient(target->GetRootWindow()) 64 aura::client::GetScreenPositionClient(target->GetRootWindow())
55 ->ConvertPointToScreen(target, &location_in_screen); 65 ->ConvertPointToScreen(target, &location_in_screen);
56 return location_in_screen; 66 return location_in_screen;
57 } 67 }
58 68
59 views::Widget* PointerWatcherDelegateAura::GetTargetWidget( 69 views::Widget* PointerWatcherDelegateAura::GetTargetWidget(
60 const ui::LocatedEvent& event) const { 70 const ui::LocatedEvent& event) const {
61 aura::Window* window = static_cast<aura::Window*>(event.target()); 71 aura::Window* window = static_cast<aura::Window*>(event.target());
62 return views::Widget::GetTopLevelWidgetForNativeView(window); 72 return views::Widget::GetTopLevelWidgetForNativeView(window);
63 } 73 }
64 74
65 } // namespace ash 75 } // namespace ash
OLDNEW
« no previous file with comments | « ash/mus/window_manager_unittest.cc ('k') | ash/sysui/pointer_watcher_delegate_mus.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698