Repository navigation
feat: Add event_number attribute to XEvent classes - #208
Conversation
89b8376 to
b07bf81
Compare
|
|
||
| assert isinstance(event, xcffib.xinput.BarrierHitEvent) | ||
| assert event.response_type == 35 | ||
| assert event.event_type == 25 |
There was a problem hiding this comment.
Oh, I see, viz. your discussion above...
I think we should use the same name for xproto and extension events, otherwise you have to keep track of a list of which events are in core to figure out how to decode things. The wire format will have the types as Of course, that means your code here will need to change, since the extension's offset is determined at runtime by the x server.
Sounds reasonable. |
It's already using the same name (
In theory this sounds nice, but if I understood correctly, the
Technically when people receive a message, the library already do the decoding and put the message into the correct Python type. So they shouldn't need to “figure out how to decode things”. These constants are only needed when people want to access the raw underlying value for whatever reason, such as the |
It depends on which extensions the server has enabled, so it should be stable for connections to the same server.
Right, but don't you have to pass the offset + event_number to FakeEvent? Or is it just event_number? |
|
(Could probably use a test explicitly for your use case.) |
|
Apparently this specific function only takes 5 distinct possibilities, all of them are fixed. This pull request adds |
|
Yeah, so if you want to export those hard coded values that's fine too. But I do think a round-trip test would be good to include. |
b07bf81 to
18083b2
Compare
|
Added a test. Hope this is what you mean. |
|
This is good enough, I was really thinking of one where you send an event through the X server as you're going to do in your code, to make sure our encoding matches what they expect. But assuming you've tested that in your work, I can land this. |
|
This new feature doesn't really have anything to do with the X server. It literally just define constants The code change is just replacing magic constants with slightly-less-magic constants. https://github.com/opensteno/plover/compare/d7a1dd1cdc3faa7cf5ec03047fc703f2c3b7f19c..525110a6a0c7270adc58200f3021d7fe204af774 (But yes, I tested this one by hand.) |
|
Cool. Can you make a new release as well? |
|
Yeah, let me land this memory leak fix and then I'll do one. Hopefully tomorrow night. |
|
Sure, no rush. Just in case you forget it. |
|
Just tagged v1.13.0 with both of your patches in it. |
Fix #206 .
Diff of generated code looks like this. (Though it also kind of show up in
test/generator/.)The name
event_numberinstead of sayevent_codewas chosen to match XMLnumber="..."attribute. Its caller call itopcodethough.Possible tech debts created/bad design choices made:
mkXClassandmkXEventClasssound like the former is a more general case of the latter, but this is in fact false, since the former does not supportevent_numberattribute.mkXClasstomkXNonEventClass? This name sounds clumsy though.mkXClasspassxge = Falsenow.event_numberdoes not clash with anything preexisting, so no backward compatibility concern, but it means different things:xcffib.xproto.KeyPressEvent:response_type = event_number. Add0x80if received an event from the X server generated from aSendEventrequest.xcffib.xfixes.SelectionNotifyEvent:response_type = first_event + event_number. May add0x80as above.xcffib.xinput.KeyPressEvent:response_type = 35,event_type = event_number.Need discussion on the above.
Point 1 and 2 are easy (but leads to slightly more diff to review).
For point 3, if we don't want one homogeneous name, a possible solution is
xproto):base_response_type(contrast withresponse_typewhich may have the0x80)response_type_offset(offset fromfirst_event)event_type(reuse, no concern of clash)