Commit Graph

111 Commits

Author SHA1 Message Date
Isaac Freund 34219b0334 touch: make cancel functions take a wlr_seat_client
The surface argument is only used to obtain a wlr_seat_client and
semantically makes no sense. The wl_touch.cancel event applies to all
touch points and all surfaces of a client.

I decided to make the functions accept a wlr_seat_client rather than a
wl_client as it is directly available in the wlr_touch_point struct and
simplifies the implementation.
2024-03-28 09:33:54 +00:00
Simon Ser 488a23c169 pointer: drop enum wlr_axis_orientation
Instead, use enum wl_pointer_axis from the Wayland protocol.
2024-02-28 16:39:18 +00:00
Simon Ser ec5263e6b7 pointer: drop enum wlr_axis_relative_direction
Instead, use enum wl_pointer_axis_relative_direction from the
Wayland protocol.
2024-02-28 16:39:18 +00:00
Simon Ser 812451cd8f pointer: use enum wl_pointer_button_state 2024-02-28 16:39:18 +00:00
Simon Ser 9f4cf242d9 pointer: drop enum wlr_axis_source
Instead, use enum wl_pointer_axis_source from the Wayland protocol.
2024-02-28 16:39:18 +00:00
Simon Ser 842093bb84 Define _POSIX_C_SOURCE globally
Stop trying to maintain a per-file _POSIX_C_SOURCE. Instead,
require POSIX.1-2008 globally. A lot of core source files depend
on that already.

Some care must be taken on a few select files where we need a bit
more than POSIX. Some files need XSI extensions (_XOPEN_SOURCE) and
some files need BSD extensions (_DEFAULT_SOURCE). In both cases,
these feature test macros imply _POSIX_C_SOURCE. Make sure to not
define both these macros and _POSIX_C_SOURCE explicitly to avoid
POSIX requirement conflicts (e.g. _POSIX_C_SOURCE says POSIX.1-2001
but _XOPEN_SOURCE says POSIX.1-2008).

Additionally, there is one special case in render/vulkan/vulkan.c.
That file needs major()/minor(), and these are system-specific.
On FreeBSD, _POSIX_C_SOURCE hides system-specific symbols so we need
to make sure it's not defined for this file. On Linux, we can
explicitly include <sys/sysmacros.h> and ensure that apart from
symbols defined there the file only uses POSIX toys.
2024-02-15 15:41:12 +01:00
Simon Ser 00bb1b0f84 seat/pointer: add support for axis_relative_direction event 2024-01-23 08:37:29 +00:00
Kirill Primak 0de3659698 Drop wl_client and user data assertions in bind handlers
A client can never be NULL and user data assertions aren't really
useful there.
2023-10-10 20:10:00 +03:00
Kirill Primak 86c30b8715 seat: remove wlr_seat_validate_grab_serial()
It makes little sense to have a catch-all grab vaildation function,
considering that e.g. tablet tool implicit grabs are possible as well.
Besides, the function has always returned true anyway.
2023-10-06 08:51:47 +00:00
Alexander Orzechowski 1b0694b794 treewide: Migrate from sizeof(struct) to sizeof(*pointer) where practical 2023-10-03 01:51:07 -04:00
Kirill Primak 0f67580aab compositor: introduce wlr_surface_set_role_object() 2023-06-23 11:54:05 +00:00
Simon Ser 1e68e1f661 seat: fix keyboard/pointer/touch resource destroy
We need to always unlink the resource, even if it's already inert.
seat_client_destroy_*() may be called multiple times on the same
resource.

Closes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3638
2023-06-20 20:14:49 +00:00
Kirill Primak 753f3cc4fa compositor: add wlr_surface_role.no_object
This commit allows to make a role as not represented by an object,
which fixes calling role commit handlers for roles like cursor
surfaces.

Fixes: 099b9de752
2023-06-14 14:06:28 +00:00
Kirill Primak 2acc74a3db Clear input regions if they're ignored 2023-06-06 13:33:31 +03:00
Alexander Orzechowski d700bd2d7c wlr_seat_pointer: cursor surfaces are always mapped 2023-06-06 06:00:21 -04:00
Väinö Mäkelä 0e5f76186e seat: Allow binding to inert seats
If a seat is destroyed while a client is trying to bind it, wlroots
needs to create an inert seat resource instead of crashing.
2023-06-03 10:43:12 +00:00
Simon Ser 69aeccddb7 seat/keyboard: allow no keymap 2023-05-17 22:08:34 +00:00
Andri Yngvason 00489b11a0 seat: Provide dummy resources for inert seats 2023-04-18 08:29:30 +00:00
Andri Yngvason 3898bb482d seat: Let client manage its own resources
This makes seat_client resources inert when seats and/or input devices are
destroyed, rather than destroying the resources.

When the client calls e.g. wl_keyboard_release(), it's not expecting the
keyboard global to be already destroyed, so this results in an error such
as this:

    wl_display@1: error 0: invalid object 22
2023-04-18 08:29:30 +00:00
Andri Yngvason 1689a3503b wlr_seat: Extract seat_client_create() function 2023-04-18 08:29:30 +00:00
Simon Ser 0e54b861e9 seat/keyboard: constify wlr_seat_keyboard_notify_enter() 2023-01-26 15:06:45 +00:00
Simon Ser 695d28c250 seat/keyboard: constify wlr_seat_keyboard_notify_modifiers() 2023-01-26 15:06:45 +00:00
Simon Ser e44834595d seat/keyboard: constify args in wlr_seat_keyboard_enter() 2023-01-26 15:06:45 +00:00
Simon Ser 12e04d8f83 seat/keyboard: constify wlr_seat_keyboard_send_modifiers() 2023-01-26 15:06:45 +00:00
Simon Ser f41dcb3a97 seat/keyboard: skip wl_array allocation
We can just create a wl_array from the array passed by the user.
Here, wl_array is only necessary to make libwayland happy.
2023-01-26 15:06:45 +00:00
Simon Zeni 0611c10909 types/wlr_seat: finish keyboard_state during wlr_seat_destroy 2022-11-29 15:21:18 -05:00
Guido Günther 8a56490229 seat/pointer: Initialize low_res_value
Fixes

    In file included from /usr/include/wayland-server-core.h:32,
                     from ../types/seat/wlr_seat_pointer.c:6:
    In function 'wl_fixed_from_double',
        inlined from 'wlr_seat_pointer_send_axis' at ../types/seat/wlr_seat_pointer.c:367:6:
    /usr/include/wayland-util.h:641:17: error: 'low_res_value' may be used uninitialized [-Werror=maybe-uninitialized]
      641 |         u.d = d + (3LL << (51 - 8));
          |               ~~^~~~~~~~~~~~~~~~~~~
    ../types/seat/wlr_seat_pointer.c: In function 'wlr_seat_pointer_send_axis':
    ../types/seat/wlr_seat_pointer.c:329:16: note: 'low_res_value' was declared here
      329 |         double low_res_value;
          |                ^~~~~~~~~~~~~
2022-11-24 22:37:52 +01:00
bi4k8 8b12037cad wlr_seat: clear `drag->seat_client` when destroyed
This was previously a use-after-free in `wlr_drag.c`.
2022-11-16 01:56:18 +00:00
Kirill Primak 20c208d46a util/array: unclutter 2022-08-29 13:48:42 +00:00
Alexander Orzechowski ef4baea0e2 Use wl_signal_emit_mutable 2022-08-18 07:16:16 -04:00
Quantum 30bf8a4303 seat/pointer: fix uninitialized variable warning
This results in the following warning, which in release mode causes an
error due to -Werror:

../types/seat/wlr_seat_pointer.c: In function ‘wlr_seat_pointer_send_axis’:
../types/seat/wlr_seat_pointer.c:344:25: error: ‘low_res_value_discrete’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
  343 |   if (version < WL_POINTER_AXIS_VALUE120_SINCE_VERSION &&
      |       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  344 |     value_discrete != 0 && low_res_value_discrete == 0) {
      |     ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
2022-07-28 02:25:31 -04:00
Kirill Primak 7298c42139 seat/pointer: rework sending axis events
This commit fixes:
- sending discrete scrolling events to multiple pointer resources
- sending events to clients which don't support wl_pointer.axis_discrete
2022-07-27 14:26:56 +00:00
José Expósito add44b3e2e seat: support low-resolution clients
When the client doesn't support high-resolution scroll, accumulate
deltas until we can notify a discrete event.

Some mice have a free spinning wheel, making possible to lock the wheel
when the accumulator value is not 0. To avoid synchronization issues
between the mouse wheel and the accumulators, store the last delta and
when the scroll direction changes, reset the accumulator.
2022-07-11 11:01:35 +02:00
José Expósito 40dc5121aa seat: support high-resolution clients
Upgrade the seat protocol to version 8 and handle clients that support
high-resolution scroll wheel events.

Since the backend already sends discrete values in the 120 range,
forwarding them is enough.
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
Guido Günther 17b2b06633 seat: Allow to cancel touches
After cancelation we destroy the touch points associated with this
surface as the Wayland spec says:

No further events are sent to the clients from that particular gesture.
Touch cancellation applies to all touch points currently active on this
client's surface. The client is responsible for finalizing the touch
points, future touch points on this surface may re-use the touch point
ID.

Closes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/2999
2022-05-22 09:43:33 +00:00
Ferdinand Bachmann d3a2ea33e5 types/seat/wlr_seat.c: fix focused_client being null after seat_client recreation 2022-04-16 20:56:30 +02:00
Leonardo Hernández Hernández 4519117a68 seat: take wlr_keyboard in wlr_seat_set_keyboard()
Signed-off-by: Leonardo Hernández Hernández <leohdz172@protonmail.com>
2022-03-23 13:08:41 +00:00
Simon Zeni cfed039c9a types/wlr_input_device: move init and finish function to private API 2022-03-07 16:37:41 +00:00
Kirill Primak 617eb4fb93 surface: deprecate wlr_surface.h 2022-01-13 10:06:41 +00:00
Simon Ser 4377b55292 util/global: remove wl_display arg from wlr_global_destroy_safe
Since [1], we can get the wl_display directly from the wl_global.

[1]: 2b22160fb6
2021-12-14 13:13:50 +00:00
David Rosca 31914928d2
seat: Only resend keyboard/pointer enter to focused clients
Otherwise it will send enter events to clients that already
have keyboard/pointer focus.
Notably Qt applications warns about this.
2021-12-14 08:23:53 +01:00
Simon Ser d290b13871 seat: avoid copying the keymap for each client
We can just send a read-only file descriptor instead.
2021-09-05 22:06:25 +02:00
Tudor Brindus 033c9cab74 input/pointer: try harder to not send duplicate motion events
wl_fixed_t is a 32-bit data type, but our doubles are 64-bit. This meant
that two doubles that would map to the same wl_fixed_t could compare
unequal, and send a duplicate motion event.

Refs swaywm/sway#4632.
2021-08-07 09:04:12 +02:00
Simon Ser c27263c105 seat: allow compositors to not load a keymap
The protocol allows compositors to not send any keymap to Wayland
clients. Handle a keymap-less keyboard correctly by sending
WL_KEYBOARD_KEYMAP_FORMAT_NO_KEYMAP instead of erroring out in the
mmap call.
2021-08-06 23:06:29 +02:00
Vyivel a93b18dbd5 input/pointer: send axis source once per frame
Only one wl_pointer.axis_source event is permitted per frame, according
to the Wayland specification.

Fixes https://github.com/swaywm/wlroots/issues/2973
2021-07-19 12:00:31 +02:00
Simon Ser b934fbaf04 seat: add wlr_seat_touch_{send,notify}_frame
The wl_touch.frame event is used to group multiple touch events
together. Instead of sending it immediately after each touch event,
rely on the backend to send it (and on the compositor to relay it).

This is a breaking change because compositors now need to manually
send touch frame events instead of relying on wlr_seat to do it.
2021-07-08 09:12:17 +02:00
Isaac Freund 78befa59f9 gtk-primary-selection: drop support
The standard primary-selection protocol is now widely supported.
2021-04-08 09:50:18 +02:00
Kenny Levinsen 46d2f80c38 wlr_seat_pointer: Remove log on notify_button 2021-03-07 11:01:38 +01:00
Simon Ser 8d76d3263d seat: use WL_SEAT_ERROR_CAPABILITY
Depends on [1].

[1]: https://gitlab.freedesktop.org/wayland/wayland/-/merge_requests/79
2021-02-08 13:30:21 +01:00