Commit 2c2fa8c6 authored by Tom Anderson's avatar Tom Anderson Committed by Commit Bot

[XProto] Fix startup crash on systems missing XInput

This CL includes 2 event fixes that were originally part of
CL [1] to fix similar event-related issues.

* event.h
    - "As() const" always called back into itself, causing an
      infinite loop.  The intention was to call the non-const
      As() function.
* event.cc
    - Xlib modifies the event data when parsing some events,
      but we never do, so let us parse the event before Xlib.
* gen_xproto.py
    - Ensure the extension is present before creating extension
      events.

[1] https://chromium-review.googlesource.com/c/chromium/src/+/2253223/

BUG=1098194, 1098204
R=thestig

Change-Id: I414acd9c138a92fbddd09da705127f1d7f60b552
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2261177
Commit-Queue: Thomas Anderson <thomasanderson@chromium.org>
Reviewed-by: default avatarLei Zhang <thestig@chromium.org>
Cr-Commit-Position: refs/heads/master@{#781615}
parent 7eabddd8
......@@ -46,6 +46,10 @@ Event::Event(xcb_generic_event_t* xcb_event,
}
}
// Xlib sometimes modifies |xcb_event|, so let it handle the event after
// we parse it with ReadEvent().
ReadEvent(this, connection, reinterpret_cast<uint8_t*>(xcb_event));
_XEnq(display, reinterpret_cast<xEvent*>(xcb_event));
if (!XEventsQueued(display, QueuedAlready)) {
// If Xlib gets an event it doesn't recognize (eg. from an
......@@ -60,8 +64,6 @@ Event::Event(xcb_generic_event_t* xcb_event,
XNextEvent(display, &xlib_event_);
if (xlib_event_.type == x11::GeGenericEvent::opcode)
XGetEventData(display, &xlib_event_.xcookie);
ReadEvent(this, connection, reinterpret_cast<uint8_t*>(xcb_event));
}
Event::Event(Event&& event) {
......
......@@ -57,7 +57,7 @@ class COMPONENT_EXPORT(X11) Event {
template <typename T>
const T* As() const {
return const_cast<const Event*>(this)->As<T>();
return const_cast<Event*>(this)->As<T>();
}
bool sequence_valid() const { return sequence_valid_; }
......
......@@ -1460,12 +1460,14 @@ class GenReadEvent(FileWriter):
# GenericEvent extension event
conds.extend([
'evtype == GeGenericEvent::opcode',
'%s.present()' % ext,
'ge->extension == %s.major_opcode()' % ext,
])
opcode = 'ge->event_type'
else:
# Extension event
opcode = 'evtype - %s.first_event()' % ext
conds.append('%s.present()' % ext)
if len(event.opcodes) == 1:
conds.append('%s == %s::opcode' % (opcode, typename))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment