/** * Generic XI2 event. All XI2 events have the same header. */ typedef struct { int type; /* GenericEvent */ unsigned long serial; /* # of last request processed by server */ Bool send_event; /* true if this came from a SendEvent request */ Display *display; /* Display the event was read from */ int extension; /* XI extension offset */ int evtype; Time time; } XIEvent;

cool, makes sense, shared event header… okay let’s look at the events…

typedef struct { int type; /* GenericEvent */ unsigned long serial; /* # of last request processed by server */ Bool send_event; /* true if this came from a SendEvent request */ Display *display; /* Display the event was read from */ int extension; /* XI extension offset */ int evtype; /* XI_DeviceChanged */ Time time; int deviceid; /* id of the device that changed */ int sourceid; /* Source for the new classes. */ int reason; /* Reason for the change */ int num_classes; XIAnyClassInfo **classes; /* same as in XIDeviceInfo */ } XIDeviceChangedEvent;

no no no no no not like that, why is XIEvent not embedded there?? the fuck

i bet the implementation of those event functions is a cast-fest and strict aliasing nightmare

@navi Yeah truly an X11 moment, so glad it's becoming more and more legacy
@lanodan i really don't like libwayland at all

but hell every time i have to interact with libX11 or libxcb i wish it was libwayland instead

insanity


CC: @[email protected]

how is libwayland even worse then libX11?
@mateusz6768 @lanodan

nop, not at all

libwayland sucks but libX11 sucks so, so, so much more


CC: @[email protected]

i mean aliasing of structs in libX11 could have decreased the header complexity since you are not redefining the base structs but likely was not yet present in compilers at that time

@mateusz6768 @lanodan

it’s not about complexity, it’s about correctness, you can’t cast those event types without UB (strict aliasing), but by the structure of the code, i’m pretty sure they do cast stuff

the correct way to do that would be this:

typedef struct { XIEvent event; int deviceid; /* id of the device that changed */ int sourceid; /* Source for the new classes. */ int reason; /* Reason for the change */ int num_classes; XIAnyClassInfo **classes; /* same as in XIDeviceInfo */ } XIDeviceChangedEvent;

and there’s no compiler that didn’t support this