Skip to content
This repository was archived by the owner on Jul 21, 2024. It is now read-only.
This repository was archived by the owner on Jul 21, 2024. It is now read-only.

Interface comments #4

@whot

Description

@whot

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
  • BaseEvent shouldn't be visible if it's not to be used, but ....
  • Event should be the equiv to what BaseEvent is right now
  • Event.get_device() should be a read-only device property. This applies to almost all get_... 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/dy maybe better returned as tuple?
  • get_absolute_x_transformed could be a x, y = event.transform_absolute(width, height) or something
  • get_time vs get_time_usec() - just drop get_time() [edit: make get_time return 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 the config_ prefix
  • config_status_to_str() should just be a __repr__
  • The config may be worth subclassing, e.g. DeviceConfig.Tap.finger_count or 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

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions