Commit Graph

2500 Commits

Author SHA1 Message Date
Peter Hutterer
68842b3403 protocol: minor clarification for axis_discrete events
Explicitly spell out that multiple axis_discrete events *for the same axis*
within the same wl_pointer.frame are not permitted.

References: https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/911#note_1438099

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2022-06-30 09:12:08 +00:00
Simon Ser
c7fc1e79ca util: set errno when hitting WL_MAP_MAX_OBJECTS
Callers may check errno when wl_map_insert_* functions return an
error (since [1]). Make sure it's always set to a meaningful value
when returning an error, otherwise callers might end up checking an
errno coming from a completely different function.

[1]: https://gitlab.freedesktop.org/wayland/wayland/-/merge_requests/205

Signed-off-by: Simon Ser <contact@emersion.fr>
Fixes: b19488c715 ("util: Limit size of wl_map")
2022-06-28 11:59:26 +02:00
Simon Ser
8e322a5a99 build: bump to version 1.20.93 for the RC1 release 2022-06-23 21:59:18 +02:00
Simon Ser
41b10c7458 server: warn about global filtering consistency
The filtering needs to be static given a client and a global,
otherwise libwayland will misbehave.

Signed-off-by: Simon Ser <contact@emersion.fr>
References: https://gitlab.freedesktop.org/wayland/wayland/-/merge_requests/241#note_1421888
2022-06-15 10:37:18 +02:00
Simon Ser
7eb00b070d server: add PID race condition disclaimer to wl_client_get_credentials
PIDs are re-used and cannot be used to reliably check the identity of
a Wayland client.

Signed-off-by: Simon Ser <contact@emersion.fr>
2022-06-15 07:57:12 +00:00
Simon Ser
2fb4cdebbe tests: add a test for dynamic filtered globals
Ensure dynamically created and destroyed globals which are filtered
don't trigger any global/global_remove event.

Signed-off-by: Simon Ser <contact@emersion.fr>
2022-06-15 07:53:19 +00:00
Simon Ser
1b00df864c server: check visibility before sending global/global_remove
See the previous discussion at [1]: libwayland incorrectly skips
the visibility checks when sending global/global_remove events.
The check is only performed when a client performs a
wl_display.get_registry request.

[1]: https://gitlab.freedesktop.org/wayland/wayland/-/merge_requests/148

Signed-off-by: Simon Ser <contact@emersion.fr>
2022-06-15 07:53:19 +00:00
Olivier Fourdan
dd00220b1e cursor/os-compatibility: handle EINTR gracefully
If os_resize_anonymous_file() called from os_create_anonymous_file()
fails with EINTR (Interrupted system call), then the buffer allocation
fails.

To avoid that, retry posix_fallocate() on EINTR.

However, in the presence of an alarm, the interrupt may trigger
repeatedly and prevent a large posix_fallocate() to ever complete
successfully, so we need to first block SIGALRM to prevent this.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
2022-06-09 19:18:47 +00:00
Simon Ser
07c8f41576 build: bump to version 1.20.92 for the beta release
Signed-off-by: Simon Ser <contact@emersion.fr>
2022-06-09 20:52:32 +02:00
Alexandros Frantzis
444d0ff338 client: Lock display when setting a proxy event queue
Assignments to a wl_proxy's queue member are currently not synchronized
with potential reads of that member during event reading/queuing.
Assuming atomic pointer value reads and writes (which is a reasonable
assumption), and using the documented best practices to handle event
queue changes, a queue change should still be safe to perform.

That being said, such implicitly atomic accesses are difficult to assess
for correctness, especially since they do not introduce memory barriers.

To make the code more obviously correct, and handle any potential races
we are not currently aware of, this commit updates wl_proxy_set_queue()
to set the proxy's event queue under the display lock (all other
proxy queue accesses are already done under the display lock).

Signed-off-by: Alexandros Frantzis <alexandros.frantzis@collabora.com>
Suggested-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-06-09 18:38:53 +00:00
Alexandros Frantzis
a8246a9f0f client: Document best practices for event queue changes
Document the proper way to deal with event queue changes, in order to
guarantee proper handing of all events which were queued before the
queue change takes effect, especially in multi-threaded setups.

Make a special note about queue changes of newly created proxies,
which require the use of a proxy wrapper for thread safety.

Signed-off-by: Alexandros Frantzis <alexandros.frantzis@collabora.com>
Suggested-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-06-09 18:38:53 +00:00
Antonin Décimo
9434e8d69f Check that XDG base directories paths are absolute
The [spec][1] reads:

> All paths set in these environment variables must be absolute. If an
> implementation encounters a relative path in any of these variables it should
> consider the path invalid and ignore it.

and

> If $XDG_DATA_HOME is either not set or empty, a default equal to
> $HOME/.local/share should be used.

Testing that the path is absolute also entails that is is non-empty.

[1]: https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html

Signed-off-by: Antonin Décimo <antonin.decimo@gmail.com>
2022-06-09 18:34:17 +00:00
Simon Ser
f710d01663 cursor/os-compatibility: fix trailing space
Signed-off-by: Simon Ser <contact@emersion.fr>
2022-06-04 22:58:50 +02:00
Simon Ser
0297c2c47a cursor/os-compatibility: remove strcpy/strcat usage
These functions don't perform bounds checking, so they are easy to
misuse and complicate audits.

Signed-off-by: Simon Ser <contact@emersion.fr>
2022-06-04 22:58:47 +02:00
Simon Ser
355c8e885c cursor: move xcursor_theme_inherits declarations at the top
Per code style, declarations need to be at the start of the block.

And make l const while at it.

Signed-off-by: Simon Ser <contact@emersion.fr>
2022-05-27 22:41:12 +02:00
Simon Ser
dfe820efce cursor: drop xcursor_add_path_elt
Just use snprintf instead. It doesn't really matter if we have
some duplicate slashes in filenames.

Signed-off-by: Simon Ser <contact@emersion.fr>
2022-05-27 22:41:12 +02:00
Simon Ser
ccca002691 cursor: drop unused XCursor comment declarations
Signed-off-by: Simon Ser <contact@emersion.fr>
2022-05-27 22:41:12 +02:00
Simon Ser
1cb728246b cursor: fix indentation of xcursor_load_theme declaration
Signed-off-by: Simon Ser <contact@emersion.fr>
2022-05-27 22:41:12 +02:00
Simon Ser
7a399383fc cursor: simplify xcursor_library_path
- Use early returns
- De-duplicate XDG_DATA_HOME code-paths
- Don't crash on allocation failure
- Use size_t when appropriate
- Fix indentation

Signed-off-by: Simon Ser <contact@emersion.fr>
2022-05-27 22:41:11 +02:00
Simon Ser
f33356742e cursor: remove unnecessary ifs in xcursor_load_theme
load_all_cursors_from_dir and xcursor_theme_inherits already have
the NULL checks we want.

Signed-off-by: Simon Ser <contact@emersion.fr>
2022-05-27 22:41:11 +02:00
Simon Ser
6c49a8f7e5 cursor: drop xcursor_images_set_name
We don't ever need to set the name multiple times for a single
struct xcursor_images, so we can just set the field directly. Also
replace the hand-rolled logic with strdup.

Signed-off-by: Simon Ser <contact@emersion.fr>
2022-05-27 22:41:11 +02:00
Simon Ser
6cf5e8f932 cursor: use getline instead of fgets
This avoids storing 8KiB on the stack, and removes the line length
limit.

Signed-off-by: Simon Ser <contact@emersion.fr>
2022-05-27 22:41:11 +02:00
Simon Ser
0b8793ab0c cursor: remove unnecessary parentheses in load_all_cursors_from_dir
Signed-off-by: Simon Ser <contact@emersion.fr>
2022-05-27 22:41:10 +02:00
Simon Ser
c2a150f7c2 cursor: remove xcursor_file_load_images wrapper
It's just calling xcursor_xc_file_load_images.

Signed-off-by: Simon Ser <contact@emersion.fr>
2022-05-27 16:01:42 +02:00
Simon Ser
73d4d2410e build: bump to version 1.20.91 for the alpha release
Signed-off-by: Simon Ser <contact@emersion.fr>
2022-05-26 20:15:35 +02:00
Xavier Claessens
24244f26bf Meson: Override wayland-scanner if it can be run
This allows projects to use Wayland as a Meson subproject and get the
wayland-scanner executable when doing find_program('wayland-scanner').

Signed-off-by: Xavier Claessens <xavier.claessens@collabora.com>
2022-05-24 14:09:33 +00:00
Simon Ser
5e4253ed50 util: fix code block language in docs
Without {.xml}, Doxygen interprets the code as C. See [1] for
details.

[1]: https://www.doxygen.nl/manual/commands.html#cmdcode

Signed-off-by: Simon Ser <contact@emersion.fr>
2022-05-23 10:13:46 +00:00
Simon Ser
93b61fde1f cursor: rename local variables to snake case
Signed-off-by: Simon Ser <contact@emersion.fr>
2022-05-23 08:59:05 +00:00
Simon Ser
cf9065dfb8 cursor: drop xcursor_file abstraction
Just use FILE * directly instead.

Signed-off-by: Simon Ser <contact@emersion.fr>
2022-05-23 08:59:05 +00:00
Simon Ser
245d30ecb8 cursor: refactor xcursor_theme_inherits
Use early returns and breaks to avoid dealing with very long
indentation lines.

Signed-off-by: Simon Ser <contact@emersion.fr>
2022-05-23 08:59:05 +00:00
Simon Ser
963014459c cursor: convert macros to functions
Improves readability since there's no need for so many parentheses
anymore, adds type safety. The compiler will inline the function
automatically as necessary.

Signed-off-by: Simon Ser <contact@emersion.fr>
2022-05-23 08:59:05 +00:00
Simon Ser
bcfcd49232 cursor: rename functions to snake case
Signed-off-by: Simon Ser <contact@emersion.fr>
2022-05-23 08:59:05 +00:00
Simon Ser
3c12a7a1be cursor: fix whitespace in function args definitions
Signed-off-by: Simon Ser <contact@emersion.fr>
2022-05-23 08:59:05 +00:00
Simon Ser
a46d8be4e1 cursor: remove struct typedefs, rename to snake case
Signed-off-by: Simon Ser <contact@emersion.fr>
2022-05-23 08:59:05 +00:00
Simon Ser
21394fd5f7 cursor: fix spacing around conditions and loops
Signed-off-by: Simon Ser <contact@emersion.fr>
2022-05-23 08:59:05 +00:00
Simon Ser
315126d3bd cursor: fix indentation
Use tabs.

Signed-off-by: Simon Ser <contact@emersion.fr>
2022-05-23 08:59:05 +00:00
Simon Ser
450bb7c145 cursor: remove unnecessary if before free
free(NULL) is valid and is a no-op.

Signed-off-by: Simon Ser <contact@emersion.fr>
2022-05-23 08:59:05 +00:00
Simon Ser
92e758834c cursor: fix variable declaration style
Use a single space between type and variable name.

Signed-off-by: Simon Ser <contact@emersion.fr>
2022-05-23 08:59:05 +00:00
Simon Ser
b0a4e63351 cursor: fix struct declaration style
Use tabs for indentation, don't use tabs to align field names.

Signed-off-by: Simon Ser <contact@emersion.fr>
2022-05-23 08:59:05 +00:00
Simon Ser
329be63d6b cursor: fix define style
Don't use tabs, don't align.

Signed-off-by: Simon Ser <contact@emersion.fr>
2022-05-23 08:59:05 +00:00
Simon Ser
5f5f1da691 cursor: drop whitespace before parens in function calls
This is in line with the rest of the Wayland code style.

Signed-off-by: Simon Ser <contact@emersion.fr>
2022-05-23 08:59:05 +00:00
Simon Ser
13d4ae01cb cursor: drop XCURSOR_LIB_* defines
These are unused.

Signed-off-by: Simon Ser <contact@emersion.fr>
2022-05-23 08:59:05 +00:00
Simon Ser
7658cff241 cursor: drop XcursorTrue and XcursorFalse
Just use <stdbool.h> instead.

Signed-off-by: Simon Ser <contact@emersion.fr>
2022-05-23 08:59:05 +00:00
Simon Ser
4ea5ad1d11 cursor: remove private Xcursor int typedefs
Just use the types directly instead.

Signed-off-by: Simon Ser <contact@emersion.fr>
2022-05-23 08:59:05 +00:00
Simon Ser
d01868413f server: add wl_global_get_version
Add a helper to check the advertised version of a global. This can
be handy when checking whether a compositor feature is supported,
instead of having to store the version passed to wl_global_create
separately.

Signed-off-by: Simon Ser <contact@emersion.fr>
2022-05-23 08:53:19 +00:00
Derek Foreman
b19488c715 util: Limit size of wl_map
Since server IDs are basically indistinguishable from really big client
IDs at many points in the source, it's theoretically possible to overflow
a map and either overflow server IDs into the client ID space, or grow
client IDs into the server ID space. This would currently take a massive
amount of RAM, but the definition of massive changes yearly.

Prevent this by placing a ridiculous but arbitrary upper bound on the
number of items we can put in a map: 0xF00000, somewhere over 15 million.
This should satisfy pathological clients without restriction, but stays
well clear of the 0xFF000000 transition point between server and client
IDs. It will still take an improbable amount of RAM to hit this, and a
client could still exhaust all RAM in this way, but our goal is to prevent
overflow and undefined behaviour.

Fixes #224

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2022-05-16 14:39:21 +00:00
Simon Ser
f7ca2c65f3 docs/publican: ensure output encoding is UTF-8
Without this, DocBook picks the output encoding and on some setups
we end up with ISO-8859-1. Tested by booting a fresh Alpine VM,
verifying that the generated HTML is using the incorrect charset,
applying the patch, and verifying that the generated HTML is fixed.

Signed-off-by: Simon Ser <contact@emersion.fr>
2022-05-11 07:21:14 +00:00
Simon Ser
9402afc353 build: sanity check options
Fail when tests/documentation is enabled without libraries. Fail
when neither scanner nor libraries is enabled, because we don't
build anything in that case.

Signed-off-by: Simon Ser <contact@emersion.fr>
2022-05-10 14:02:51 +00:00
Simon Ser
2dcc35af81 cursor: use MAP_FAILED instead of hardcoded constant
Signed-off-by: Simon Ser <contact@emersion.fr>
2022-05-06 21:57:24 +02:00
Simon Ser
04efea1727 Remove publish-doc
We don't use this script anymore.

Signed-off-by: Simon Ser <contact@emersion.fr>
2022-05-05 11:24:11 +02:00