This repository was archived by the owner on Jul 21, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 13
This repository was archived by the owner on Jul 21, 2024. It is now read-only.
Interface comments #4
Copy link
Copy link
Open
Description
I had a read through the docs in regards to the API and I'll summarise the various comments here, easier than filing a million separate issues :)
The main issue is that, right now, the Python API is a C API in the Python language. That's not the same as a real Python API and there's lot for improvement. Implementation-wise what I did in libevdev-python was have an internal class that matches the C API (like you already have) but have the public API be a hand-written one that wraps the C wrapper.
Anyway, here's a list of comments regarding the current API:
- The libinput context should be one of udev or path, see Split libinput contexts into udev/path classes #2
-
BaseEventshouldn't be visible if it's not to be used, but .... -
Eventshould be the equiv to whatBaseEventis right now -
Event.get_device()should be a read-onlydeviceproperty. This applies to almost allget_...functions in the events, they should be properties. -
Event.get_pointer_event()shouldn't exist. The C API does that because we don't have classes and have to work around it this way, but for Python,LibInput.get_event()should just return the right type of object, e.g.PointerEvent. - Logical pairs like
dx/dymaybe better returned as tuple? -
get_absolute_x_transformedcould be ax, y = event.transform_absolute(width, height)or something -
get_timevsget_time_usec()- just dropget_time()[edit: makeget_timereturn us]. the only reason it exists in the libinput API is because we realised too late ms isn't enough and we have to be backwards-compatible. -
DeviceConfig.config_*is redundant, drop theconfig_prefix -
config_status_to_str()should just be a__repr__ - The config may be worth subclassing, e.g.
DeviceConfig.Tap.finger_countor so -
libinput.constant.Event->EventType? - for the event codes, it may be better relying on evdev directly, but I understand that the python evdev situation isn't great right now
Metadata
Metadata
Assignees
Labels
No labels