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

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

Issue 1892483005: SelectionOwner: add support for TIMESTAMP target (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nogncheck 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 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.h" 5 #include "ui/events/platform/x11/x11_event_source.h"
6 6
7 #include <X11/XKBlib.h> 7 #include <X11/XKBlib.h>
8 #include <X11/Xlib.h> 8 #include <X11/Xlib.h>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 28 matching lines...) Expand all
39 39
40 return true; 40 return true;
41 } 41 }
42 42
43 } // namespace 43 } // namespace
44 44
45 X11EventSource* X11EventSource::instance_ = nullptr; 45 X11EventSource* X11EventSource::instance_ = nullptr;
46 46
47 X11EventSource::X11EventSource(X11EventSourceDelegate* delegate, 47 X11EventSource::X11EventSource(X11EventSourceDelegate* delegate,
48 XDisplay* display) 48 XDisplay* display)
49 : delegate_(delegate), display_(display), continue_stream_(true) { 49 : delegate_(delegate),
50 display_(display),
51 last_seen_server_time_(CurrentTime),
52 continue_stream_(true) {
50 DCHECK(!instance_); 53 DCHECK(!instance_);
51 instance_ = this; 54 instance_ = this;
52 55
53 DCHECK(delegate_); 56 DCHECK(delegate_);
54 DCHECK(display_); 57 DCHECK(display_);
55 DeviceDataManagerX11::CreateInstance(); 58 DeviceDataManagerX11::CreateInstance();
56 InitializeXkb(display_); 59 InitializeXkb(display_);
57 } 60 }
58 61
59 X11EventSource::~X11EventSource() { 62 X11EventSource::~X11EventSource() {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 98
96 //////////////////////////////////////////////////////////////////////////////// 99 ////////////////////////////////////////////////////////////////////////////////
97 // X11EventSource, protected 100 // X11EventSource, protected
98 101
99 void X11EventSource::ExtractCookieDataDispatchEvent(XEvent* xevent) { 102 void X11EventSource::ExtractCookieDataDispatchEvent(XEvent* xevent) {
100 bool have_cookie = false; 103 bool have_cookie = false;
101 if (xevent->type == GenericEvent && 104 if (xevent->type == GenericEvent &&
102 XGetEventData(xevent->xgeneric.display, &xevent->xcookie)) { 105 XGetEventData(xevent->xgeneric.display, &xevent->xcookie)) {
103 have_cookie = true; 106 have_cookie = true;
104 } 107 }
108 Time event_time = ExtractTimeFromXEvent(*xevent);
109 if (event_time != CurrentTime)
110 last_seen_server_time_ = event_time;
105 delegate_->ProcessXEvent(xevent); 111 delegate_->ProcessXEvent(xevent);
106 PostDispatchEvent(xevent); 112 PostDispatchEvent(xevent);
107 if (have_cookie) 113 if (have_cookie)
108 XFreeEventData(xevent->xgeneric.display, &xevent->xcookie); 114 XFreeEventData(xevent->xgeneric.display, &xevent->xcookie);
109 } 115 }
110 116
111 void X11EventSource::PostDispatchEvent(XEvent* xevent) { 117 void X11EventSource::PostDispatchEvent(XEvent* xevent) {
112 if (xevent->type == GenericEvent && 118 if (xevent->type == GenericEvent &&
113 (xevent->xgeneric.evtype == XI_HierarchyChanged || 119 (xevent->xgeneric.evtype == XI_HierarchyChanged ||
114 (xevent->xgeneric.evtype == XI_DeviceChanged && 120 (xevent->xgeneric.evtype == XI_DeviceChanged &&
115 static_cast<XIDeviceChangedEvent*>(xevent->xcookie.data)->reason == 121 static_cast<XIDeviceChangedEvent*>(xevent->xcookie.data)->reason ==
116 XIDeviceChange))) { 122 XIDeviceChange))) {
117 ui::UpdateDeviceList(); 123 ui::UpdateDeviceList();
118 hotplug_event_handler_->OnHotplugEvent(); 124 hotplug_event_handler_->OnHotplugEvent();
119 } 125 }
120 126
121 if (xevent->type == EnterNotify && 127 if (xevent->type == EnterNotify &&
122 xevent->xcrossing.detail != NotifyInferior && 128 xevent->xcrossing.detail != NotifyInferior &&
123 xevent->xcrossing.mode != NotifyUngrab) { 129 xevent->xcrossing.mode != NotifyUngrab) {
124 // Clear stored scroll data 130 // Clear stored scroll data
125 ui::DeviceDataManagerX11::GetInstance()->InvalidateScrollClasses(); 131 ui::DeviceDataManagerX11::GetInstance()->InvalidateScrollClasses();
126 } 132 }
127 } 133 }
128 134
135 Time X11EventSource::ExtractTimeFromXEvent(const XEvent& xevent) {
sadrul 2016/04/20 17:58:43 This can go in a standalone function in anon names
dcheng 2016/04/20 18:55:43 Done.
136 switch (xevent.type) {
137 case KeyPress:
138 case KeyRelease:
139 return xevent.xkey.time;
140 case ButtonPress:
141 case ButtonRelease:
142 return xevent.xbutton.time;
143 case MotionNotify:
144 return xevent.xmotion.time;
145 case EnterNotify:
146 case LeaveNotify:
147 return xevent.xcrossing.time;
148 case PropertyNotify:
149 return xevent.xproperty.time;
150 case SelectionClear:
151 return xevent.xselectionclear.time;
152 case SelectionRequest:
153 return xevent.xselectionrequest.time;
154 case SelectionNotify:
155 return xevent.xselection.time;
156 case GenericEvent:
157 return static_cast<XIDeviceEvent*>(xevent.xcookie.data)->time;
sadrul 2016/04/20 18:01:08 Also, you should check DeviceDataManagerX11::IsXID
dcheng 2016/04/20 18:55:43 Done. But as mentioned earlier, other code often d
158 }
159 return CurrentTime;
160 }
161
129 void X11EventSource::StopCurrentEventStream() { 162 void X11EventSource::StopCurrentEventStream() {
130 continue_stream_ = false; 163 continue_stream_ = false;
131 } 164 }
132 165
133 void X11EventSource::OnDispatcherListChanged() { 166 void X11EventSource::OnDispatcherListChanged() {
134 if (!hotplug_event_handler_) { 167 if (!hotplug_event_handler_) {
135 hotplug_event_handler_.reset(new X11HotplugEventHandler()); 168 hotplug_event_handler_.reset(new X11HotplugEventHandler());
136 // Force the initial device query to have an update list of active devices. 169 // Force the initial device query to have an update list of active devices.
137 hotplug_event_handler_->OnHotplugEvent(); 170 hotplug_event_handler_->OnHotplugEvent();
138 } 171 }
139 } 172 }
140 173
141 } // namespace ui 174 } // namespace ui
OLDNEW
« ui/base/x/selection_owner.cc ('K') | « ui/events/platform/x11/x11_event_source.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698