Commit Graph

2397 Commits

Author SHA1 Message Date
Sigrid Solveig Haflínudóttir
2bcc27ff36 connection: change clen type in build_cmsg to size_t
To avoid implicit conversion since msg_control's type is size_t.

Signed-off-by: Sigrid Solveig Haflínudóttir <ftrvxmtrx@gmail.com>
2022-04-03 16:17:40 +00:00
Sigrid Solveig Haflínudóttir
d066c4bd4e connection: fix asan report on sendmsg call
Initialiaze the entire msghdr struct to 0 before use.

Example of the report fixed with this change:

AddressSanitizer:DEADLYSIGNAL
=================================================================
==20035==ERROR: AddressSanitizer: SEGV on unknown address 0x2dad4dbffffa0d (pc 0x0055555c7488 bp 0x007fffffc760 sp 0x007fffffc760 T0)
==20035==The signal is caused by a READ memory access.
    #0 0x55555c7488 in read_msghdr(void*, __sanitizer::__sanitizer_msghdr*, long) (/home/ftrvx/w/_/uxn/bin/uxnemu+0x77488)
    #1 0x55555c810c in sendmsg (/home/ftrvx/w/_/uxn/bin/uxnemu+0x7810c)
    #2 0x7ff7f2db20 in wl_connection_flush /home/ftrvx/q/wayland/build/../src/connection.c:315:10
    #3 0x7ff7f2d014 in wl_display_flush /home/ftrvx/q/wayland/build/../src/wayland-client.c:2154:9
    #4 0x7ff7e80bc0  (/lib/libSDL2-2.0.so.0+0x104bc0)
    #5 0x7ff7e523b0  (/lib/libSDL2-2.0.so.0+0xd63b0)
    #6 0x7ff7e534e4  (/lib/libSDL2-2.0.so.0+0xd74e4)
    #7 0x7ff7e535e8  (/lib/libSDL2-2.0.so.0+0xd75e8)
    #8 0x7ff7daad54  (/lib/libSDL2-2.0.so.0+0x2ed54)
    #9 0x7ff7dab130  (/lib/libSDL2-2.0.so.0+0x2f130)
    #10 0x555565bb40 in main /home/ftrvx/w/_/uxn/src/uxnemu.c:519:2
    #11 0x7ff7f62484 in libc_start_main_stage2 /builddir/musl-1.1.24/src/env/__libc_start_main.c:94:2

AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV (/home/ftrvx/w/_/uxn/bin/uxnemu+0x77488) in read_msghdr(void*, __sanitizer::__sanitizer_msghdr*, long)
==20035==ABORTING

Signed-off-by: Sigrid Solveig Haflínudóttir <ftrvxmtrx@gmail.com>
2022-04-03 16:17:40 +00:00
illiliti
de57106c94 meson: Use proper type for bools
Fix invalid usage of bools which violates official meson specification and thus
breaks muon, an implementation of meson written in C.

Signed-off-by: illiliti <illiliti@protonmail.com>
2022-04-02 17:04:08 +03:00
Simon Ser
962aefda42 server: introduce wl_signal_emit_mutable
wl_signal_emit doesn't handle well situations where a listener removes
another listener. This can happen in practice: wlroots and Weston [1]
both have private helpers to workaround this defect.

wl_signal_emit can't be fixed without breaking the API. Instead,
introduce a new function. Callers need to make sure to always remove
listeners when they are free'd.

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

Signed-off-by: Simon Ser <contact@emersion.fr>
Signed-off-by: Alexandros Frantzis <alexandros.frantzis@collabora.com>
2022-03-28 19:06:16 +00:00
Peter Hutterer
868eb99eb0 protocol: add the wl_pointer.axis_value120 events
These events are for high-resolution wheels. Each logical wheel click
represents an axis value120 value of 120, fractions of a wheel click an
integer fraction thereof. The new event replaces
wl_pointer.axis_discrete for wl_pointer versions 8 and above.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2022-03-28 17:31:27 +00:00
Aleksandr Mezin
79c84ed3f1 client, server: handle wl_map_insert_new() failures
Signed-off-by: Aleksandr Mezin <mezin.alexander@gmail.com>
2022-03-25 09:43:53 +00:00
Aleksandr Mezin
884d5fe3ab util: set errno in wl_map_insert_at()
And add errno checks in callers, where it seems to be necessary.

Signed-off-by: Aleksandr Mezin <mezin.alexander@gmail.com>
2022-03-25 09:43:53 +00:00
Aleksandr Mezin
03e8a1f84b util: set errno in wl_map_reserve_new()
And also fix wl_connection_demarshal() to pass through that errno.

Signed-off-by: Aleksandr Mezin <mezin.alexander@gmail.com>
2022-03-25 09:43:53 +00:00
Aleksandr Mezin
ae263cca3e util: always check result of wl_array_add()
Not checking the result of wl_array_add() can cause writes past the end of the
allocated buffer if realloc fails.

Signed-off-by: Aleksandr Mezin <mezin.alexander@gmail.com>
2022-03-25 09:43:53 +00:00
Simon Ser
b6bbc0c44d build: use get_variable(pkgconfig) instead of get_pkgconfig_variable()
We don't get a warning for it yet, but get_pkgconfig_variable() is
deprecated.

Signed-off-by: Simon Ser <contact@emersion.fr>
2022-03-25 09:14:08 +00:00
Simon Ser
24e0a7b622 build: specify native arg in add_languages()
Fixes the following warning:

    WARNING: add_languages is missing native:, assuming languages are wanted for
    both host and build.

Signed-off-by: Simon Ser <contact@emersion.fr>
2022-03-25 09:14:08 +00:00
Simon Ser
02661fde24 build: use full_path() instead of path()
Fixes the following warning:

    WARNING: Project targeting '>= 0.56.0' but tried to use feature deprecated
    since '0.55.0': ExternalProgram.path. use ExternalProgram.full_path() instead

Signed-off-by: Simon Ser <contact@emersion.fr>
2022-03-25 09:14:08 +00:00
Alexander Irion
ca4678354c connection: Make wl_closure_print output atomic
When multiple threads are used, output from different threads was intermixed in one line. That what breaking parsing of the log messages. Now, intermixing is prevented by using a memstream.

Signed-off-by: Alexander Irion <alexander_irion@mentor.com>
2022-03-08 14:48:53 +01:00
Mikhail Gusarov
af8b5c0782 protocol: wl_shm.format events are actually sent after bind
Protocol documentation mistakenly specified that wl_shm.format
events are sent at connection setup time, but that's impossible
(clients do not yet know ID of wl_shm object at the time) and
contradicts implementation in libwayland.

Signed-off-by: Mikhail Gusarov <dottedmag@dottedmag.net>
2022-02-21 11:13:45 +01:00
Simon Ser
d690712b7b meson: use absolute paths for doxygen stamp files
The relative paths are incorrect when running as a subproject.

Signed-off-by: Simon Ser <contact@emersion.fr>
2022-02-05 15:39:23 +01:00
Simon Ser
7816f0b842 meson: use project build root for doxygen output
meson.build_root() returns the parent's build directory if Wayland is
a subproject. This fails with:

    error: tag OUTPUT_DIRECTORY: Output directory '<parent-build-dir>/doc/doxygen' does not exist and cannot be created

Instead, use meson.project_build_root(), which returns the subproject's
build directory.

Signed-off-by: Simon Ser <contact@emersion.fr>
2022-02-05 15:39:23 +01:00
Simon Ser
c78807520f meson: build requirement to 0.56.0
meson.project_build_root() is only available with 0.56.0.

Signed-off-by: Simon Ser <contact@emersion.fr>
2022-02-05 15:39:21 +01:00
Vlad Zahorodnii
4ebd997de2 cursor: Remove unused XcursorLibraryLoadImages() function
XcursorLibraryLoadImages() function is unused and not exported according to
objdump, so its removal should be an ABI compatible change.

Signed-off-by: Vlad Zahorodnii <vlad.zahorodnii@kde.org>
2022-02-05 14:33:32 +00:00
Fergus Dall
e949b3bfbb display-test: Fix a race condition in test suite
Several tests in this suite use setting and checking client.display_stopped (in
test-compositor.h) to synchronise between threads. This is a data race because
display_stopped is a non-atomic int. Fix this by making it an atomic_bool
instead. We don't need to change the access code because reads and writes are
sequentially consistent by default.

This can be reproduced (with both clang and gcc) by running
```
meson -Db_sanitize=thread build
cd build
ninja
meson test
```

Signed-off-by: Fergus Dall <sidereal@google.com>
2022-02-05 14:29:39 +00:00
Simon Ser
5eb5620cbd Use zalloc for structs
When allocating memory for structs, use zalloc instead of malloc.
This ensures the memory is zero-initialized, and reduces the risk
of forgetting to initialize all struct fields.

Signed-off-by: Simon Ser <contact@emersion.fr>
2022-02-05 14:25:19 +00:00
Simon Ser
4b05ecb8f7 build: explicitly set check arg in run_command()
Fixes the following warning:

    WARNING: You should add the boolean check kwarg to the run_command call.
             It currently defaults to false,
             but it will default to true in future releases of meson.
             See also: https://github.com/mesonbuild/meson/issues/9300

Signed-off-by: Simon Ser <contact@emersion.fr>
2022-02-02 15:04:42 +01:00
Julian Orth
ee92898cb5 protocol: xkb_v1 is null-terminated
Closes #270

Signed-off-by: Julian Orth <ju.orth@gmail.com>
2022-01-31 21:31:07 +00:00
Simon Ser
40c275f642 build: set c_std=c99
Set explicitly the C standard to use to make sure we don't use
features not available on our target platforms.

Signed-off-by: Simon Ser <contact@emersion.fr>
2022-01-10 15:08:46 +01:00
Simon Ser
0d314c4a04 build: don't rely on implicit GNU extensions
Currently libwayland assumes GNU extensions will be available, but
doesn't define the C standard to use. Instead, let's unconditionally
enable POSIX extensions, and enable GNU extensions on a case-by-case
basis as needed.

Signed-off-by: Simon Ser <contact@emersion.fr>
2022-01-10 15:08:46 +01:00
Simon Ser
65616e946b tests: use __typeof__ instead of typeof
typeof is a GNU extension. Compiler extensions should be prefixed
with __ per the C standard.

Signed-off-by: Simon Ser <contact@emersion.fr>
2022-01-10 14:51:09 +01:00
Simon Ser
31b17e3d85 build: re-open main branch for regular development 2022-01-10 11:13:16 +01:00
shierote
aa6a07c2fe doc: fix typo in wl_data_device.data_offer
Signed-off-by: Taishi Eguchi <taishi2060@gmail.com>
2022-01-10 10:07:22 +00:00
Derek Foreman
ea237db7f6 tests: Fix tc_client_fd_leaks_exec test
tc_client_fd_leaks and tc_client_fd_leaks_exec are currently the exact
same test. It seems clear from the name that the latter was intended to
spawn sanity_fd_leak_exec instead of sanity_fd_leak.

Fixes #121

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2022-01-10 09:52:00 +00:00
Max Ihlenfeldt
8893573651 protocol: clarify wl_shm_pool.resize
Add a note that the request only changes the size of the memory mapping
and does not touch the mapped file.

Signed-off-by: Max Ihlenfeldt <mihlenfeldt@igalia.com>
2022-01-07 13:30:29 +00:00
Mikhail Gusarov
eca836add5 doc: Clarify that null terminator is included in string length
Signed-off-by: Mikhail Gusarov <dottedmag@dottedmag.net>
2021-12-18 15:01:21 +01:00
Mikhail Gusarov
971a0a8b84 doc: Clarify position of file descriptors in the stream
The specification left the position and order of file
descriptors unspecified. Specify that

- order of file descriptors is maintained
- position of file descriptors is bounded, but loose

Signed-off-by: Mikhail Gusarov <dottedmag@dottedmag.net>
2021-12-12 15:09:00 +01:00
Simon Ser
75c1a93e20 build: bump to version 1.20.0 for the official release 2021-12-09 17:20:36 +01:00
Simon Ser
ba82e0d806 meson: override dependencies to ease use as subproject
Make it easier to use Wayland as a Meson subproject by overriding
dependencies we define. This allows to easily build Wayland as a
subproject like so:

    subproject('wayland', required: false, default_options: ['documentation=false'])

After this statement, the wayland-* dependencies will use the subproject
instead of the system if available.

Signed-off-by: Simon Ser <contact@emersion.fr>
2021-12-08 00:27:58 +01:00
Simon Ser
28c2d8321b build: bump to version 1.19.93 for the RC1 release 2021-12-02 20:51:39 +01:00
Simon Ser
dcd8a62b18 build: bump to version 1.19.92 for the beta release 2021-11-18 16:30:09 +01:00
Jan Grulich
78590b3aff protocol: clarify wl_data_offer::selection
Clearly specify that switching focus within the same client
doesn't mean a new selection will be send.

Signed-off-by: Jan Grulich <jgrulich@redhat.com>
2021-11-15 13:20:41 +00:00
Manuel Stoeckl
1638dad613 protocol: sync wl_shm.format with libdrm 2.4.108
The four new formats added (all 16 bpc, RGB colorspace) are very useful
for applications providing high bit depth content and rendering their
buffers on CPU, as computations with 16 bit unsigned integers are often
more efficient than with the (half float, 10 bit) alternative formats.

Signed-off-by: Manuel Stoeckl <code@mstoeckl.com>
2021-11-11 20:15:22 -05:00
Simon Ser
5420619f91 build: bump to version 1.19.91 for the alpha release 2021-11-04 20:39:22 +01:00
Duncan McIntosh
20fd3b3af9 wayland-shm: Check the size of sealed memory if ignoring SIGBUS handlers
In 11623e8f, SIGBUS handlers aren't set if F_SEAL_SHRINK is configured on
the memory. This helps avoid setting up handlers with cooperative clients;
however, if an application gives an incorrect size, the compositor would
access it anyways, figuring SIGBUS is impossible, and crash.

This can be fixed by simply removing the seal-checking logic and always
setting the signal handler. However, it seems that fstat can give the size
of the memfd, so we can check that the size we were told is within the
region. Since it's sealed to shrinking, it must never be shrunk in future,
so we can really (hopefully) ignore SIGBUS.

I was worried that fstat wasn't supported for this, but shm_overview(7) does
mention that it is a possible use.

The best solution would likely be avoiding SIGBUS entirely with
MAP_NOSIGBUS, but that hasn't been merged yet and wouldn't help systems
without it (e.g. with older kernels).

A proof-of-concept of this crash is attached with the merge request. Running
it with this patch gives an invalid-shm error, which is correct.

Signed-off-by: Duncan McIntosh <duncan82013@live.ca>
2021-11-04 09:02:19 +00:00
Simon Ser
ebfc70cdf7 protocol: wl_shm uses pre-multiplied alpha
Add a note about pre-multiplied alpha for all wl_shm formats.
Include an escape hatch in the spec to allow other protocol
extensions to override this.

Signed-off-by: Simon Ser <contact@emersion.fr>
Closes: https://gitlab.freedesktop.org/wayland/wayland/-/issues/61
2021-11-04 08:53:47 +00:00
Derek Foreman
ca893075ef debug: Fix printing of new ids
The client side closure traces have incorrect object ids for new server
generated objects. This is because create_proxies() overwrites the id in
'n' type arguments by storing a pointer to the actual object in the 'o'
field of the union.

Getting back to an id from this pointer requires accessing a structure
that isn't visible outside of wayland-client.c.

Add a function pointer to fish the correct value out of the argument and
pass it to wl_closure_print.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2021-11-02 11:27:51 +00:00
Simon Ser
9c05e6c475 protocol: add wl_output.{name,description}
This is inspired from xdg-output-unstable-v1. This allows clients to
get the name and description without having to use xdg_output. This
should eventually allow us to restrict xdg_output to clients like
Xwayland.

The name is a unique non-persistent user-friendly string that can be
used to refer to an output. This can be used by Wayland clients to
refer to a specific wl_output (e.g. across processes or in CLI
arguments).

The description is a non-unique user-friendly string that can be
displayed to the user.

Signed-off-by: Simon Ser <contact@emersion.fr>
References: https://gitlab.freedesktop.org/wayland/wayland-protocols/-/issues/7
2021-10-28 14:03:04 +00:00
Simon Ser
aa88321517 protocol: add note about wl_output.done in events
Mention that geometry, mode and scale wl_output events are followed
by a done event.

Signed-off-by: Simon Ser <contact@emersion.fr>
2021-10-28 14:03:04 +00:00
Simon McVittie
0cdd2a5c54 build: Include the Wayland minor version in libraries' ABI versions
The ABI of a shared library on Linux is given by a major version, which
is part of the SONAME and is incremented (rarely) on incompatible
changes, and a minor version, which is part of the basename of the
regular file to which the SONAME provides a symlink.

Until now, the ABI minor version was hard-coded, which means we can't
tell which of a pair of Wayland libraries is newer (and therefore
likely to have more symbols and/or fewer bugs).

libwayland-egl already had ABI major version 1, so we can use the
"marketing" version number as the ABI major.minor version number
directly, so Wayland 1.19.90 would produce
libwayland-egl.so.1 -> libwayland-egl.so.1.19.90.

libwayland-cursor and libwayland-server have ABI major version 0,
and OS distributions don't like it when there's a SONAME bump for no
good reason, so use their existing ABI major version together with
the "marketing" minor version:
libwayland-cursor.so.0 -> libwayland-cursor.so.0.19.90.

If the Wayland major version number is incremented to 2, we'll have to
rethink this, so add some error() to break the build if/when that
happens. Assuming that Wayland 2.0 would involve breaking changes,
the best way would probably to bump all the SONAMEs to
libwayland-foo.so.2.

Resolves: https://gitlab.freedesktop.org/wayland/wayland/-/issues/175
Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-10-28 12:46:06 +00:00
Jonas Ådahl
fceabb7e9e protocol: Add wl_surface.offset
This is meant to address the issue where the call to 'wl_surface.attach'
is done by e.g. Vulkan, meaning applications cannot affect the values of
the offset passed as the x and y arguments.

The lack of ability to pass these is problematic when using the Vulkan
for e.g. drawing DND surfaces, as the buffer offset is used to implement
the drag icon hotspots.

Closes: https://gitlab.freedesktop.org/wayland/wayland/-/issues/148
Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
Reviewed-by: Simon Ser <contact@emersion.fr>
2021-10-28 12:39:39 +00:00
Manuel Stoeckl
f00cfda737 client: handle fcntl error on bad fd in wl_display_connect
This makes wl_display_connect fail immediately instead of
succeeding when the integer provided by WAYLAND_SOCKET does
not refer to a valid file descriptor.

Signed-off-by: Manuel Stoeckl <code@mstoeckl.com>
2021-10-28 12:30:43 +00:00
Damian Hobson-Garcia
d564823cfd server: stop wl_display event loop from any context
Calling wl_display_terminate() will exit the wl_display event loop
at the start of the next loop iteration.  This works fine when
wl_display_terminate() is called after the event loop wakes up
from polling on the added event sources.  If, however, it is
called before polling starts, the event loop will not exit until
one or more event sources trigger.  Depending on the types of event
sources, they may never trigger (or may not trigger for a long time),
so the event loop may never exit.

Add an extra event source to the wl_display event loop that will trigger
whenever wl_display_terminate() is called, so that the event loop will
always exit.

Fixes #201

Signed-off-by: Damian Hobson-Garcia <dhobsong@igel.co.jp>
2021-10-09 13:09:04 +00:00
Matt Hoosier
c6c1bbe4ab protocol: mention that buffers with alpha are assumed premultiplied
This turns out to be the default assumption by compositors, OpenGL, and the DRM
framework. Let's say it explicitly to avoid misinterpretation.

See https://lists.freedesktop.org/archives/wayland-devel/2021-September/041990.html.

Signed-off-by: Matt Hoosier <matt.hoosier@garmin.com>
2021-09-29 09:43:21 -05:00
Olivier Fourdan
616b4ae618 shm: Relax shm_pool_create_buffer() validity check
shm_pool_create_buffer() can raise a false WL_SHM_ERROR_INVALID_STRIDE
error under some circumstances because of integer division.

Fix this by using a strict comparison operator instead of lower or
equal.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Demi Marie Obenour <demi@invisiblethingslab.com>
Reviewed-by: Simon Ser <contact@emersion.fr>
Reviewed-by: Jonas Ådahl <jadahl@gmail.com>
Closes: https://gitlab.freedesktop.org/wayland/wayland/-/issues/235
2021-09-16 17:31:09 +02:00
Simon Ser
7ef305d073 protocol: mention that keymap mapping must be read-only
It may be obvious that the mapping must be established in read-only
mode, but it wasn't specified in the specification text.

Signed-off-by: Simon Ser <contact@emersion.fr>
2021-09-16 08:25:05 +00:00