Commit Graph

193 Commits

Author SHA1 Message Date
Alexander Orzechowski 1b0694b794 treewide: Migrate from sizeof(struct) to sizeof(*pointer) where practical 2023-10-03 01:51:07 -04:00
Kirill Primak a09d649439 docs: replace the less commonly used "::" with "." 2023-10-02 22:10:16 +03:00
Simon Ser fe06e5f49a Use wl_container_of() instead of casts
This slightly improves type safety.

The culprits were found with:

    git grep -E '\([a-z0-9_ ]+ \*\)\W?[a-z]'
2023-07-11 20:16:17 +02:00
Simon Ser 2d9659d765 backend/libinput: use struct initializers for events
This is more readable and consistent with the rest of wlroots.
2023-06-14 15:20:41 +02:00
Simon Ser e1c6801b65 backend/libinput: ignore multiple events for same pointer button
If the same button is pressed on two devices on the same seat,
ignore the second event.

This is also what Mutter does.

Closes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3665
2023-06-14 10:48:44 +00:00
Simon Ser 86fc2199f8 build: unify naming for HAVE_* defines
We sometimes used HAS_, sometimes polluted the LIBINPUT_ namespace,
etc.
2022-12-06 22:39:45 +00:00
Simon Ser a4a40618ad backend/libinput: use internal_config
Removes project arguments.
2022-12-06 22:39:45 +00:00
Simon Ser f0375eed24 backend/session: make optional
Some compositors are not interested in wlr_session, for instance
nested compositors.

Disabling wlr_session removes the udev dependency.
2022-11-25 16:15:29 +00:00
John Lindgren 2b767fe743 backend/libinput: Fix SIGSEGV found in low-memory fuzzing
Stack trace:

    #0  0x00007f17081f5b99 in wl_list_insert (list=list@entry=0x2d8, elm=elm@entry=0x7ffe7f7e85d0)
        at ../wayland-1.21.0/src/wayland-util.c:48
    #1  0x00007f17081f5f2e in wl_signal_emit_mutable (signal=signal@entry=0x2d8, data=data@entry=0x7ffe7f7e8660)
        at ../wayland-1.21.0/src/wayland-server.c:2167
    #2  0x00007f170815a971 in handle_switch_toggle (wlr_switch=0x2a0, event=0x55d5ba13dc00)
        at ../backend/libinput/switch.c:50
    #3  handle_libinput_event (event=0x55d5ba13dc00, backend=0x55d5b975d740) at ../backend/libinput/events.c:234
    #4  handle_libinput_readable (fd=<optimized out>, mask=<optimized out>, _backend=<optimized out>)
        at ../backend/libinput/backend.c:58
    #5  handle_libinput_readable (fd=fd@entry=34, mask=mask@entry=1, _backend=_backend@entry=0x55d5b975d740)
        at ../backend/libinput/backend.c:48
    #6  0x00007f170815c110 in backend_start (wlr_backend=0x55d5b975d740) at ../backend/libinput/backend.c:109
    #7  0x00007f1708160996 in multi_backend_start (wlr_backend=0x55d5b97583d0) at ../backend/multi/backend.c:32
2022-09-22 13:37:32 -04:00
Alexander Orzechowski 8bd7170fd9 Use env helpers 2022-08-22 10:18:52 -04:00
Alexander Orzechowski ef4baea0e2 Use wl_signal_emit_mutable 2022-08-18 07:16:16 -04:00
José Expósito e00f042f80 backend/libinput: code style consistency
Reduce a level of identation in "handle_pointer_axis" to keep the
consistency with "handle_pointer_axis_value120".
2022-07-11 11:01:35 +02:00
José Expósito c6032d6b1c backend/libinput: handle high-res scroll events
On newer versions of libinput, the event LIBINPUT_EVENT_POINTER_AXIS
has been deprecated in favour of LIBINPUT_EVENT_POINTER_SCROLL_WHEEL,
LIBINPUT_EVENT_POINTER_SCROLL_FINGER and
LIBINPUT_EVENT_POINTER_SCROLL_CONTINUOUS.

Where new events are provided by the backend, ignore
LIBINPUT_EVENT_POINTER_AXIS, receive high-resolution scroll events from
libinput and emit the appropiate wlr_pointer signal.
2022-07-11 11:01:35 +02:00
José Expósito 65c436407f pointer: transform low-res to high-res axis events
Currently, the "wlr_event_pointer_axis" event stores low-resolution
values in its "delta_discrete" field. Low-resolution values are always
multiples of one, i.e., 1 for one wheel detent, 2 for two wheel
detents, etc.

In order to simplify internal handling of events, always transform in
the backend from the low-resolution value into the high-resolution
value.

The transformation is performed by multiplying by 120. The 120 magic
number is used by the kernel and it is exposed to clients in the
"WLR_POINTER_AXIS_DISCRETE_STEP" constant.
2022-07-11 11:01:35 +02:00
José Expósito c84cc660f0 build: check if libinput supports high-res scroll
Starting with Linux Kernel v5.0 two new axes are available for
mice that support high-resolution wheel scrolling: REL_WHEEL_HI_RES and
REL_HWHEEL_HI_RES.

Both axes send data in fractions of 120 where each multiple of 120
amounts to one logical scroll event. Fractions of 120 indicate a wheel
movement less than one detent.

Three new events are now available on libinput:
LIBINPUT_EVENT_POINTER_SCROLL_WHEEL,
LIBINPUT_EVENT_POINTER_SCROLL_FINGER, and
LIBINPUT_EVENT_POINTER_SCROLL_CONTINUOUS.
These events replace the LIBINPUT_EVENT_POINTER_AXIS event, so new
clients should simply ignore that event.

Also, two new APIs are available to access the high-resolution data:
libinput_event_pointer_get_scroll_value() and
libinput_event_pointer_get_scroll_value_v120().

Add a project argument (LIBINPUT_HAS_SCROLL_VALUE120) to allow
building against old versions of libinput or, where high-resolution
scroll is available, support it.
2022-07-11 11:01:35 +02:00
Isaac Freund 91943a68a6 wlr_input_device: remove anon union field
This union is unnecessary since the recent input device refactor and can
now be replaced by wlr_*_from_input_device() functions.
2022-06-21 18:42:07 +00:00
Simon Zeni aaf787ee56 types/wlr_touch: uniformize events name 2022-03-17 18:16:14 +00:00
Simon Zeni e732c5c895 types/wlr_tablet_tool: uniformize events name 2022-03-17 18:16:14 +00:00
Simon Zeni d1f543a9d8 types/wlr_tablet_pad: uniformize events name 2022-03-17 18:16:14 +00:00
Simon Zeni 13d7fa2f03 types/wlr_switch: uniformize events name 2022-03-17 18:16:14 +00:00
Simon Zeni 9a17200446 types/wlr_keyboard: uniformize events name 2022-03-17 18:16:14 +00:00
Simon Zeni bd6c000d14 types/wlr_pointer: uniformize events name 2022-03-17 18:16:14 +00:00
Simon Zeni 96ccc50c57 types/wlr_input_device: move width_mm and height_mm fields to wlr_tablet and wlr_touch 2022-03-17 13:44:19 -04:00
Simon Zeni 10cbb9fbe1 interface/wlr_touch: rework destroy sequence
The destroy callback in wlr_touch_impl has been removed. The function
`wlr_touch_finish` has been introduced to clean up the resources owned by a
wlr_touch.

`wlr_input_device_destroy` no longer destroys the wlr_touch, attempting to
destroy a wlr_touch will result in a no-op.

The field `name` has been added to the wlr_touch_impl to be able to identify
a given wlr_touch device.
2022-03-07 16:37:41 +00:00
Simon Zeni 8d3cb94b41 interface/wlr_tablet_tool: rework destroy sequence
The destroy callback in wlr_tablet_tool_impl has been removed. The function
`wlr_tablet_tool_finish` has been introduced to clean up the resources owned by
a wlr_tablet_tool.

`wlr_input_device_destroy` no longer destroys the wlr_tablet_tool, attempting to
destroy a wlr_tablet_tool will result in a no-op.

The field `name` has been added to the wlr_tablet_tool_impl to be able to
identify a given wlr_tablet_tool device.
2022-03-07 16:37:41 +00:00
Simon Zeni a5b032cb1e interface/wlr_tablet_pad: rework destroy sequence
The destroy callback in wlr_tablet_pad_impl has been removed. The function
`wlr_tablet_pad_finish` has been introduced to clean up the resources owned by a
wlr_tablet_pad.

`wlr_input_device_destroy` no longer destroys the wlr_tablet_pad, attempting to
destroy a wlr_tablet_pad will result in a no-op.

The field `name` has been added to the wlr_tablet_pad_impl to be able to identify
a given wlr_tablet_pad device.
2022-03-07 16:37:41 +00:00
Simon Zeni 0d2be496a8 interface/wlr_switch: rework destroy sequence
The destroy callback in wlr_switch_impl has been removed. The function
`wlr_switch_finish` has been introduced to clean up the resources owned by a
wlr_switch.

`wlr_input_device_destroy` no longer destroys the wlr_switch, attempting to
destroy a wlr_switch will result in a no-op.

The field `name` has been added to the wlr_switch_impl to be able to identify
a given wlr_switch device.
2022-03-07 16:37:41 +00:00
Simon Zeni 51cd3c0726 interface/wlr_pointer: rework destroy sequence
The destroy callback in wlr_pointer_impl has been removed. The function
`wlr_pointer_finish` has been introduced to clean up the resources owned by a
wlr_pointer.

`wlr_input_device_destroy` no longer destroys the wlr_pointer, attempting to
destroy a wlr_pointer will result in a no-op.

The field `name` has been added to the wlr_pointer_impl to be able to identify
a given wlr_pointer device.
2022-03-07 16:37:41 +00:00
Simon Zeni 7dc4a3ecd7 interface/wlr_keyboard: rework destroy sequence
The destroy member in wlr_keyboard_impl has been removed. The function
`wlr_keyboard_finish` has been introduce to clean up the resources owned by a
wlr_keyboard.

`wlr_input_device_destroy` no longer destroys the wlr_keyboard, attempting to
destroy a wlr_keyboard will result in a no-op.

The field `name` has been added to the wlr_keyboard_impl to be able to identify
a given wlr_keyboard device.
2022-03-07 16:37:41 +00:00
Simon Zeni d0718a9b32 backend/libinput: public API cleanup 2022-03-02 18:18:05 +00:00
Simon Zeni 0d21496e53 backend/libinput: rework tablet_pad interface
The wlr_libinput_input_device now owns its wlr_tablet_pad, instead of creating
a new wlr_libinput_input_device for it.
2022-03-02 18:18:05 +00:00
Simon Zeni c8456086a1 backend/libinput: rework tablet interface
The wlr_libinput_device owns its wlr_tablet and its associated wlr_tablet_tools
2022-03-02 18:18:05 +00:00
Simon Zeni 4f4dd95223 backend/libinput: rework touch interface
The wlr_libinput_input_device now owns its wlr_touch, instead of creating
a new wlr_libinput_input_device for it.
2022-03-02 18:18:05 +00:00
Simon Zeni d750c5ac67 backend/libinput: rework switch interface
The wlr_libinput_input_device now owns its wlr_switch, instead of creating
a new wlr_libinput_input_device for it.
2022-03-02 18:18:05 +00:00
Simon Zeni d60cdad3ea backend/libinput: rework pointer interface
The wlr_libinput_input_device now owns its wlr_pointer, instead of creating
a new wlr_libinput_input_device for it
2022-03-02 18:18:05 +00:00
Simon Zeni 5eefda1ffe backend/libinput: rework keyboard interface
The wlr_libinput_input_device now owns its wlr_keyboard, instead of creating
a new wlr_libinput_input_device for it.
2022-03-02 18:18:05 +00:00
Simon Zeni 9dd6e2b905 backend/libinput: add devices wl_list
This commit prepares the ground for a wlr_libinput_input_device refactoring.
2022-03-02 18:18:05 +00:00
Simon Zeni e279266f71 interfaces: remove wlr_input_device_impl 2022-02-22 14:23:46 -05:00
Simon Zeni 91ba28e020 backend/libinput: remove wlr_input_device_impl 2022-02-21 16:48:43 -05:00
Simon Zeni edfb332b24 types/wlr_touch: add base wlr_input_device
wlr_touch now owns its wlr_input_device. It will be initialized when the
tablet tool is initialized, and finished when the touch is destroyed.
2022-02-21 17:11:32 +00:00
Simon Zeni 7dfee50350 types/wlr_tablet_tool: add base wlr_input_device
wlr_tablet_tool owns its wlr_input_device. It will be initialized when the
tablet tool is initialized, and finished when the tablet tool is destroyed.
2022-02-21 17:11:32 +00:00
Simon Zeni a662743610 types/wlr_tablet_pad: add base wlr_input_device
wlr_tablet_pad owns its wlr_input_device. It will be initialized when the
tablet pad is initialized, and finished when the tablet pad is destroyed.
2022-02-21 17:11:32 +00:00
Simon Zeni 0f3b38365d types/wlr_switch: add base wlr_input_device
wlr_switch owns its wlr_input_device. It will be initialized when the
switch is initialized, and finished when the switch is destroyed.
2022-02-21 17:11:32 +00:00
Simon Zeni d5480efc7a types/wlr_pointer: add base wlr_input_device
wlr_pointer owns its wlr_input_device. It will be initialized when the
pointer is initialized, and finished when the pointer is destroyed.
2022-02-21 17:11:32 +00:00
Simon Zeni a1978b1299 types/wlr_keyboard: add base wlr_input_device
wlr_keyboard owns its base wlr_input_device. It will be initialized when the
keyboard is initialized, and finished when the keyboard is destroyed.
2022-02-21 17:11:32 +00:00
Simon Zeni 71577e351e types/wlr_input_device: default vendor and product id to 0
vendor and product id are set when needed by the libinput backend
2022-02-21 17:11:32 +00:00
Simon Ser 1d9c1bcea6 input-device: remove wlr_input_device.link
This field's ownership is unclear: it's in wlr_input_device, but
it's not managed by the common code, it's up to each individual
backend to use it and clean it up.

Since this is a backend implementation detail, move it to the
backend-specific structs.
2021-11-23 14:14:18 +00:00
José Expósito 52d2491931 backend/libinput: send hold gesture events
Receive hold gesture events from libinput and emit the appropiate
wlr_pointer signal.
2021-09-27 15:30:31 +02:00
José Expósito 95970b3619 build: check if libinput supports hold gestures
Add a project argument (LIBINPUT_HAS_HOLD_GESTURES) to allow building
against old versions of libinput.
2021-09-27 15:30:31 +02:00
Simon Ser 18c2dce65e backend: unify startup messages 2021-08-19 20:47:36 +02:00