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

Side by Side Diff: ash/pointer_watcher_delegate_aura.cc

Issue 2256343003: Update ui::PointerEvent to support mouse wheel and capture change events. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . 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 | « no previous file | ash/pointer_watcher_delegate_aura_unittest.cc » ('j') | ui/events/event.h » ('J')
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/display/screen.h"
10 #include "ui/events/event.h" 11 #include "ui/events/event.h"
11 #include "ui/events/event_constants.h" 12 #include "ui/events/event_constants.h"
12 #include "ui/gfx/geometry/point.h" 13 #include "ui/gfx/geometry/point.h"
13 #include "ui/views/pointer_watcher.h" 14 #include "ui/views/pointer_watcher.h"
14 #include "ui/views/widget/widget.h" 15 #include "ui/views/widget/widget.h"
15 16
16 namespace ash { 17 namespace ash {
17 18
18 PointerWatcherDelegateAura::PointerWatcherDelegateAura() { 19 PointerWatcherDelegateAura::PointerWatcherDelegateAura() {
19 Shell::GetInstance()->AddPreTargetHandler(this); 20 Shell::GetInstance()->AddPreTargetHandler(this);
(...skipping 17 matching lines...) Expand all
37 } 38 }
38 } 39 }
39 40
40 void PointerWatcherDelegateAura::RemovePointerWatcher( 41 void PointerWatcherDelegateAura::RemovePointerWatcher(
41 views::PointerWatcher* watcher) { 42 views::PointerWatcher* watcher) {
42 non_move_watchers_.RemoveObserver(watcher); 43 non_move_watchers_.RemoveObserver(watcher);
43 move_watchers_.RemoveObserver(watcher); 44 move_watchers_.RemoveObserver(watcher);
44 } 45 }
45 46
46 void PointerWatcherDelegateAura::OnMouseEvent(ui::MouseEvent* event) { 47 void PointerWatcherDelegateAura::OnMouseEvent(ui::MouseEvent* event) {
47 if (event->type() == ui::ET_MOUSE_CAPTURE_CHANGED) {
48 FOR_EACH_OBSERVER(views::PointerWatcher, non_move_watchers_,
49 OnMouseCaptureChanged());
50 FOR_EACH_OBSERVER(views::PointerWatcher, move_watchers_,
51 OnMouseCaptureChanged());
52 return;
53 }
54
55 // For compatibility with the mus version, don't send drags. 48 // For compatibility with the mus version, don't send drags.
56 if (event->type() != ui::ET_MOUSE_PRESSED && 49 if (event->type() != ui::ET_MOUSE_PRESSED &&
57 event->type() != ui::ET_MOUSE_RELEASED && 50 event->type() != ui::ET_MOUSE_RELEASED &&
58 event->type() != ui::ET_MOUSE_MOVED) 51 event->type() != ui::ET_MOUSE_MOVED &&
52 event->type() != ui::ET_MOUSEWHEEL &&
53 event->type() != ui::ET_MOUSE_CAPTURE_CHANGED)
59 return; 54 return;
60 55
61 DCHECK(ui::PointerEvent::CanConvertFrom(*event)); 56 DCHECK(ui::PointerEvent::CanConvertFrom(*event));
62 NotifyWatchers(ui::PointerEvent(*event), *event); 57 NotifyWatchers(ui::PointerEvent(*event), *event);
63 } 58 }
64 59
65 void PointerWatcherDelegateAura::OnTouchEvent(ui::TouchEvent* event) { 60 void PointerWatcherDelegateAura::OnTouchEvent(ui::TouchEvent* event) {
66 // For compatibility with the mus version, don't send drags. 61 // For compatibility with the mus version, don't send drags.
67 if (event->type() != ui::ET_TOUCH_PRESSED && 62 if (event->type() != ui::ET_TOUCH_PRESSED &&
68 event->type() != ui::ET_TOUCH_RELEASED) 63 event->type() != ui::ET_TOUCH_RELEASED)
(...skipping 14 matching lines...) Expand all
83 78
84 views::Widget* PointerWatcherDelegateAura::GetTargetWidget( 79 views::Widget* PointerWatcherDelegateAura::GetTargetWidget(
85 const ui::LocatedEvent& event) const { 80 const ui::LocatedEvent& event) const {
86 aura::Window* window = static_cast<aura::Window*>(event.target()); 81 aura::Window* window = static_cast<aura::Window*>(event.target());
87 return views::Widget::GetTopLevelWidgetForNativeView(window); 82 return views::Widget::GetTopLevelWidgetForNativeView(window);
88 } 83 }
89 84
90 void PointerWatcherDelegateAura::NotifyWatchers( 85 void PointerWatcherDelegateAura::NotifyWatchers(
91 const ui::PointerEvent& event, 86 const ui::PointerEvent& event,
92 const ui::LocatedEvent& original_event) { 87 const ui::LocatedEvent& original_event) {
93 const gfx::Point screen_location(GetLocationInScreen(original_event)); 88 const gfx::Point screen_location =
94 views::Widget* target_widget = GetTargetWidget(original_event); 89 event.type() == ui::ET_POINTER_CAPTURE_CHANGED
90 ? display::Screen::GetScreen()->GetCursorScreenPoint()
91 : GetLocationInScreen(original_event);
sadrul 2016/08/19 16:38:58 Why do you need a valid location for CAPTURE_CHANG
riajiang 2016/08/19 17:23:42 https://cs.chromium.org/chromium/src/ash/wm/immers
sadrul 2016/08/22 14:55:19 Nope. Good catch. I am beginning to think if we sh
riajiang 2016/08/22 16:03:05 Done.
92 views::Widget* target_widget = event.type() == ui::ET_POINTER_CAPTURE_CHANGED
93 ? nullptr
94 : GetTargetWidget(original_event);
sadrul 2016/08/19 16:38:58 Why special case for CAPTURE_CHANGED? Can we fix G
riajiang 2016/08/22 16:03:05 Apparently GetTargetWidget already does the right
95 FOR_EACH_OBSERVER( 95 FOR_EACH_OBSERVER(
96 views::PointerWatcher, move_watchers_, 96 views::PointerWatcher, move_watchers_,
97 OnPointerEventObserved(event, screen_location, target_widget)); 97 OnPointerEventObserved(event, screen_location, target_widget));
98 if (event.type() != ui::ET_POINTER_MOVED) { 98 if (event.type() != ui::ET_POINTER_MOVED) {
99 FOR_EACH_OBSERVER( 99 FOR_EACH_OBSERVER(
100 views::PointerWatcher, non_move_watchers_, 100 views::PointerWatcher, non_move_watchers_,
101 OnPointerEventObserved(event, screen_location, target_widget)); 101 OnPointerEventObserved(event, screen_location, target_widget));
102 } 102 }
103 } 103 }
104 104
105 } // namespace ash 105 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | ash/pointer_watcher_delegate_aura_unittest.cc » ('j') | ui/events/event.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698