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

Side by Side Diff: ui/events/platform/x11/x11_event_source_libevent.cc

Issue 2786693002: Add PointerDetails to ui::MouseEvent's constructors (Closed)
Patch Set: mouse event constructor Created 3 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "ui/events/platform/x11/x11_event_source_libevent.h" 5 #include "ui/events/platform/x11/x11_event_source_libevent.h"
6 6
7 #include <X11/Xlib.h> 7 #include <X11/Xlib.h>
8 #include <X11/extensions/XInput2.h> 8 #include <X11/extensions/XInput2.h>
9 9
10 #include <memory> 10 #include <memory>
(...skipping 19 matching lines...) Expand all
30 return base::MakeUnique<KeyEvent>(event_type, 30 return base::MakeUnique<KeyEvent>(event_type,
31 KeyboardCodeFromXKeyEvent(&xev), 31 KeyboardCodeFromXKeyEvent(&xev),
32 EventFlagsFromXEvent(xev)); 32 EventFlagsFromXEvent(xev));
33 case ET_MOUSE_PRESSED: 33 case ET_MOUSE_PRESSED:
34 case ET_MOUSE_MOVED: 34 case ET_MOUSE_MOVED:
35 case ET_MOUSE_DRAGGED: 35 case ET_MOUSE_DRAGGED:
36 case ET_MOUSE_RELEASED: 36 case ET_MOUSE_RELEASED:
37 return base::MakeUnique<MouseEvent>( 37 return base::MakeUnique<MouseEvent>(
38 event_type, EventLocationFromXEvent(xev), 38 event_type, EventLocationFromXEvent(xev),
39 EventSystemLocationFromXEvent(xev), EventTimeFromXEvent(xev), 39 EventSystemLocationFromXEvent(xev), EventTimeFromXEvent(xev),
40 EventFlagsFromXEvent(xev), GetChangedMouseButtonFlagsFromXEvent(xev)); 40 EventFlagsFromXEvent(xev), GetChangedMouseButtonFlagsFromXEvent(xev),
41 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE,
42 ui::PointerEvent::kMousePointerId));
41 case ET_MOUSEWHEEL: 43 case ET_MOUSEWHEEL:
42 return base::MakeUnique<MouseWheelEvent>( 44 return base::MakeUnique<MouseWheelEvent>(
43 GetMouseWheelOffsetFromXEvent(xev), EventLocationFromXEvent(xev), 45 GetMouseWheelOffsetFromXEvent(xev), EventLocationFromXEvent(xev),
44 EventSystemLocationFromXEvent(xev), EventTimeFromXEvent(xev), 46 EventSystemLocationFromXEvent(xev), EventTimeFromXEvent(xev),
45 EventFlagsFromXEvent(xev), GetChangedMouseButtonFlagsFromXEvent(xev)); 47 EventFlagsFromXEvent(xev), GetChangedMouseButtonFlagsFromXEvent(xev));
46 case ET_SCROLL_FLING_START: 48 case ET_SCROLL_FLING_START:
47 case ET_SCROLL_FLING_CANCEL: { 49 case ET_SCROLL_FLING_CANCEL: {
48 float x_offset, y_offset, x_offset_ordinal, y_offset_ordinal; 50 float x_offset, y_offset, x_offset_ordinal, y_offset_ordinal;
49 GetFlingDataFromXEvent(xev, &x_offset, &y_offset, &x_offset_ordinal, 51 GetFlingDataFromXEvent(xev, &x_offset, &y_offset, &x_offset_ordinal,
50 &y_offset_ordinal, nullptr); 52 &y_offset_ordinal, nullptr);
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 // Translates a XEvent into a ui::Event. 86 // Translates a XEvent into a ui::Event.
85 std::unique_ptr<ui::Event> TranslateXEventToEvent(const XEvent& xev) { 87 std::unique_ptr<ui::Event> TranslateXEventToEvent(const XEvent& xev) {
86 int flags = EventFlagsFromXEvent(xev); 88 int flags = EventFlagsFromXEvent(xev);
87 switch (xev.type) { 89 switch (xev.type) {
88 case LeaveNotify: 90 case LeaveNotify:
89 case EnterNotify: 91 case EnterNotify:
90 // EnterNotify creates ET_MOUSE_MOVED. Mark as synthesized as this is 92 // EnterNotify creates ET_MOUSE_MOVED. Mark as synthesized as this is
91 // not real mouse move event. 93 // not real mouse move event.
92 if (xev.type == EnterNotify) 94 if (xev.type == EnterNotify)
93 flags |= EF_IS_SYNTHESIZED; 95 flags |= EF_IS_SYNTHESIZED;
94 return base::MakeUnique<MouseEvent>(ET_MOUSE_MOVED, 96 return base::MakeUnique<MouseEvent>(
95 EventLocationFromXEvent(xev), 97 ET_MOUSE_MOVED, EventLocationFromXEvent(xev),
96 EventSystemLocationFromXEvent(xev), 98 EventSystemLocationFromXEvent(xev), EventTimeFromXEvent(xev), flags,
97 EventTimeFromXEvent(xev), flags, 0); 99 0,
100 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE,
101 ui::PointerEvent::kMousePointerId));
98 102
99 case KeyPress: 103 case KeyPress:
100 case KeyRelease: 104 case KeyRelease:
101 return base::MakeUnique<KeyEvent>(EventTypeFromXEvent(xev), 105 return base::MakeUnique<KeyEvent>(EventTypeFromXEvent(xev),
102 KeyboardCodeFromXKeyEvent(&xev), flags); 106 KeyboardCodeFromXKeyEvent(&xev), flags);
103 107
104 case ButtonPress: 108 case ButtonPress:
105 case ButtonRelease: { 109 case ButtonRelease: {
106 switch (EventTypeFromXEvent(xev)) { 110 switch (EventTypeFromXEvent(xev)) {
107 case ET_MOUSEWHEEL: 111 case ET_MOUSEWHEEL:
108 return base::MakeUnique<MouseWheelEvent>( 112 return base::MakeUnique<MouseWheelEvent>(
109 GetMouseWheelOffsetFromXEvent(xev), EventLocationFromXEvent(xev), 113 GetMouseWheelOffsetFromXEvent(xev), EventLocationFromXEvent(xev),
110 EventSystemLocationFromXEvent(xev), EventTimeFromXEvent(xev), 114 EventSystemLocationFromXEvent(xev), EventTimeFromXEvent(xev),
111 flags, 0); 115 flags, 0);
112 case ET_MOUSE_PRESSED: 116 case ET_MOUSE_PRESSED:
113 case ET_MOUSE_RELEASED: 117 case ET_MOUSE_RELEASED:
114 return base::MakeUnique<MouseEvent>( 118 return base::MakeUnique<MouseEvent>(
115 EventTypeFromXEvent(xev), EventLocationFromXEvent(xev), 119 EventTypeFromXEvent(xev), EventLocationFromXEvent(xev),
116 EventSystemLocationFromXEvent(xev), EventTimeFromXEvent(xev), 120 EventSystemLocationFromXEvent(xev), EventTimeFromXEvent(xev),
117 flags, GetChangedMouseButtonFlagsFromXEvent(xev)); 121 flags, GetChangedMouseButtonFlagsFromXEvent(xev),
122 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE,
123 ui::PointerEvent::kMousePointerId));
118 case ET_UNKNOWN: 124 case ET_UNKNOWN:
119 // No event is created for X11-release events for mouse-wheel 125 // No event is created for X11-release events for mouse-wheel
120 // buttons. 126 // buttons.
121 break; 127 break;
122 default: 128 default:
123 NOTREACHED(); 129 NOTREACHED();
124 } 130 }
125 break; 131 break;
126 } 132 }
127 133
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 203
198 void X11EventSourceLibevent::OnFileCanReadWithoutBlocking(int fd) { 204 void X11EventSourceLibevent::OnFileCanReadWithoutBlocking(int fd) {
199 event_source_.DispatchXEvents(); 205 event_source_.DispatchXEvents();
200 } 206 }
201 207
202 void X11EventSourceLibevent::OnFileCanWriteWithoutBlocking(int fd) { 208 void X11EventSourceLibevent::OnFileCanWriteWithoutBlocking(int fd) {
203 NOTREACHED(); 209 NOTREACHED();
204 } 210 }
205 211
206 } // namespace ui 212 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698