platform/upstream/wayland.git
2 years agogitlab-ci: update ci-templates to the latest commit
Alex Richardson [Tue, 27 Jul 2021 13:00:38 +0000 (14:00 +0100)]
gitlab-ci: update ci-templates to the latest commit

This is in preparation for adding FreeBSD CI support.

Signed-off-by: Alex Richardson <Alexander.Richardson@cl.cam.ac.uk>
2 years agoUse epoll-shim to emulate epoll(7) on FreeBSD
Alex Richardson [Mon, 15 Mar 2021 22:18:14 +0000 (22:18 +0000)]
Use epoll-shim to emulate epoll(7) on FreeBSD

FreeBSD does not provide epoll(7) and instead requires an external library,
epoll-shim, that implements epoll() using kqueue(2)

Co-authored-by: Jan Beich <jbeich@FreeBSD.org>
Signed-off-by: Alex Richardson <Alexander.Richardson@cl.cam.ac.uk>
2 years agoos-wrappers-test: Handle fcntl() being declared as a macro
Alex Richardson [Mon, 7 Jun 2021 10:12:18 +0000 (11:12 +0100)]
os-wrappers-test: Handle fcntl() being declared as a macro

On some systems (e.g. FreeBSD with the latest epoll-shim), fcntl is
declared as a macro instead of a function. Wrap the definition here in
parantheses to avoid function-macro expansion.

Signed-off-by: Alex Richardson <Alexander.Richardson@cl.cam.ac.uk>
2 years agotests: Destroy custom global object
Derek Foreman [Thu, 26 Aug 2021 19:50:59 +0000 (14:50 -0500)]
tests: Destroy custom global object

Destroy our custom global object at end of run so we no longer "leak"
it.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2 years agoconnection: Rename wl_buffer
Derek Foreman [Fri, 6 Aug 2021 18:16:55 +0000 (13:16 -0500)]
connection: Rename wl_buffer

struct wl_buffer has other meaning in wayland, thus making this a pretty
confusing structure name. Function names like wl_buffer_put() just
compound the confusion.

Rename the struct and the associated functions (none of which are called
from outside this file anyway). The struct retains a wl_ prefix, as is
the custom for wayland internal data structures. The function names
have not retained this prefix, as we have many static function that
aren't prefixed.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2 years agoscanner: Use the new atomic marshal/destroy function
Derek Foreman [Wed, 21 Jul 2021 21:32:36 +0000 (16:32 -0500)]
scanner: Use the new atomic marshal/destroy function

Use the new flagged marshal+destroy function in generated code.

It's intended as a replacement for all existing wl_proxy_marshal_*
functions, so I've used it to replace them all. This results in a large
update to the scanner test files as well.

We now pass the new WL_MARSHAL_FLAG_DESTROY flag when appropriate, so
the race condition in #86 caused by releasing the display mutex between
marshalling the proxy and destroying the proxy is now gone.

Fixes #86

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2 years agoclient: Add new proxy marshalling functions with flags
Derek Foreman [Wed, 21 Jul 2021 21:26:00 +0000 (16:26 -0500)]
client: Add new proxy marshalling functions with flags

There's a race when destroying wayland objects in a multi-threaded client.
This occurs because we call:
wl_proxy_marshal(foo);
wl_proxy_destroy(foo);

And each of these functions takes, and releases, the display mutex.
Between the two calls, the display is not locked.

In order to allow atomically marshalling the proxy and destroying the
proxy without releasing the lock, add yet more wl_proxy_marshal_*
functions.  This time add flags and jam in all existing warts with the
hope that we can make it future proof this time.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2 years agoclient: Refactor wl_proxy_destroy critical section
Derek Foreman [Wed, 21 Jul 2021 21:03:12 +0000 (16:03 -0500)]
client: Refactor wl_proxy_destroy critical section

Split wl_proxy_destroy into two pieces, wl_proxy_destroy_unlocked which
performs the critical section code with no locking, and wl_proxy_destroy
which locks before calling that.

We'll use the new unlocked variant later in code that already holds the
lock.

There is a slight functional change - an aborting check is now called
with the lock held. This should be harmless as wl_abort() performs
no locking.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2 years agocursor: remove unused wl_cursor_theme.name
Simon Ser [Thu, 5 Aug 2021 16:09:53 +0000 (18:09 +0200)]
cursor: remove unused wl_cursor_theme.name

Let's just delete this field since it's not used anywhere and not
exposed in our public API.

Signed-off-by: Simon Ser <contact@emersion.fr>
2 years agocursor: rename load_default_theme to load_fallback_theme
Simon Ser [Thu, 5 Aug 2021 15:24:02 +0000 (17:24 +0200)]
cursor: rename load_default_theme to load_fallback_theme

The theme getting loaded by this function is not to be confused
with the theme named "default" located on the filesystem. Instead,
it's a minimal theme directly bundled into libwayland-cursor.

Make this clearer by naming this theme "fallback".

Signed-off-by: Simon Ser <contact@emersion.fr>
2 years agocursor: Try to fall back to a default xcursor theme first
Olivier Tilloy [Wed, 5 May 2021 15:15:33 +0000 (17:15 +0200)]
cursor: Try to fall back to a default xcursor theme first

The use case is systems where for some reason the current xcursor theme
cannot be accessed (an application packaged as a strictly confined snap,
for example).

Before falling back to wayland's default cursor theme, it is worth
trying the xcursor theme called "default", which hopefully looks better
than the former.

Fixes: https://gitlab.gnome.org/Community/Ubuntu/gnome-sdk/-/issues/6

Signed-off-by: Olivier Tilloy <olivier.tilloy@canonical.com>
2 years agoci: Sanitise build and install paths
Daniel Stone [Tue, 3 Aug 2021 20:53:12 +0000 (21:53 +0100)]
ci: Sanitise build and install paths

No sense in generating enormously long paths. This also happens to fix
artifacts not actually recording anything because we had a mismatch in
artifact paths vs. actual paths.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2 years agoci: Use Werror
Daniel Stone [Tue, 3 Aug 2021 20:32:02 +0000 (21:32 +0100)]
ci: Use Werror

No point warning on stuff if we don't make it fail.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2 years agoci: Use appropriate concurrency level
Daniel Stone [Tue, 3 Aug 2021 20:33:03 +0000 (21:33 +0100)]
ci: Use appropriate concurrency level

The appropriate concurrency level is not necessarily the number of
available CPUs; limit it to what the runners tell us we should be using.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2 years agoci: Add release builds
Daniel Stone [Tue, 3 Aug 2021 20:31:36 +0000 (21:31 +0100)]
ci: Add release builds

Signed-off-by: Daniel Stone <daniels@collabora.com>
2 years agoci: Use consistent YAML indendation
Daniel Stone [Tue, 3 Aug 2021 20:14:04 +0000 (21:14 +0100)]
ci: Use consistent YAML indendation

Signed-off-by: Daniel Stone <daniels@collabora.com>
2 years agoci: Only run ci-fairy on MRs
Daniel Stone [Tue, 3 Aug 2021 20:13:25 +0000 (21:13 +0100)]
ci: Only run ci-fairy on MRs

This requires adding rules to all the jobs, as it's all or nothing.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2 years agoci: Add ARMv7 build
Daniel Stone [Tue, 3 Aug 2021 20:09:50 +0000 (21:09 +0100)]
ci: Add ARMv7 build

Signed-off-by: Daniel Stone <daniels@collabora.com>
2 years agoci: Add AArch64 build
Daniel Stone [Tue, 3 Aug 2021 20:08:01 +0000 (21:08 +0100)]
ci: Add AArch64 build

Signed-off-by: Daniel Stone <daniels@collabora.com>
2 years agoci: Parameterise and template build
Daniel Stone [Tue, 3 Aug 2021 20:06:11 +0000 (21:06 +0100)]
ci: Parameterise and template build

This will make it a lot easier to add other variants later.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2 years agoci: Add comments, rename build stages
Daniel Stone [Tue, 3 Aug 2021 19:56:51 +0000 (20:56 +0100)]
ci: Add comments, rename build stages

No non-cosmetic changes, just making things more accessible.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2 years agoconnection: print array size
Simon Ser [Thu, 28 May 2020 21:47:29 +0000 (23:47 +0200)]
connection: print array size

This makes it easier to understand how an xdg_toplevel is configured for
instance.

Signed-off-by: Simon Ser <contact@emersion.fr>
2 years agoconnection, client: Avoid locale-dependent float printing
Manuel Stoeckl [Sun, 17 Jan 2021 23:02:50 +0000 (18:02 -0500)]
connection, client: Avoid locale-dependent float printing

Specifically, in the log formed when WAYLAND_DEBUG is set, this commit
ensures that floating point numbers are formatted using '.' instead of
the locale-specific decimal separator. As the debug logs are not
otherwise localized for end-users, and may be parsed by scripts, it is
better to have consistent output here.

The 24.8 fixed point numbers are now represented with 8 digits after
the decimal, since this is both exact and simpler to compute.

Signed-off-by: Manuel Stoeckl <code@mstoeckl.com>
3 years agoos-wrappers-test: Make syscall intercepts work with sanitizers
Fergus Dall [Fri, 9 Jul 2021 14:13:35 +0000 (00:13 +1000)]
os-wrappers-test: Make syscall intercepts work with sanitizers

Sanitizers need to intercept syscalls in the compiler run-time library, as
do these tests. We try to make this work by using dlsym(RTLD_NEXT) to find
the next definition in the chain, but here this approach won't work because
the compiler run-time library is linked into the same elf object as the test
interceptors are.

The sanitizer library supports this by giving the intercept functions a
prefix and making them only weakly alias the real names, so our interceptors
can call the sanitizers interceptors explicitly, which will then use dlsym
to call the real function.

By making our declarations of the sanitizer interceptor function weak we can
handle any combination of intercepts (including none, if there is no
sanitizer). If our declaration is resolves to a NULL pointer, we just use
dlsym.

Signed-off-by: Fergus Dall <sidereal@google.com>
3 years agoconnection-test: Pad out strings with null bytes
Fergus Dall [Fri, 9 Jul 2021 14:09:59 +0000 (00:09 +1000)]
connection-test: Pad out strings with null bytes

The connection_demarshal test writes a 10 byte string into a wayland message,
but doesn't pad it out to a four byte boundary. This leads to the last 32-bit
word of the message being partially uninitialized, which triggers an msan
violation when the message is written to the socket.

Signed-off-by: Fergus Dall <sidereal@google.com>
3 years agoserver: Fix undefined behavior in wl_socket_init_for_display_name
Fergus Dall [Fri, 9 Jul 2021 08:04:27 +0000 (18:04 +1000)]
server: Fix undefined behavior in wl_socket_init_for_display_name

This function constructs a socket path in sun_path using snprintf, which
returns the amount of space that would have been used if the buffer was
large enough. It then checks if this is larger then the actual buffer size
and, if so, returns ENAMETOOLONG. This is correct.

However, after calling snprintf and before checking that the length isn't too
long, it tries to compute a pointer to the part of the path that matches the
input name. It does this by adding the computed path length to the pointer to
the start of the path buffer, which will take it to one-past the null
terminator, and then walking backwards. If the path fits in the buffer, this
will take it at most one-past-the-end of the allocation, which is allowed, but
if the path is longer then the buffer then the pointer addition is undefined behavior.

Fix this by moving the display name computation past the check that the path
length is not too long.

This is detected by the test socket_path_overflow_server_create under ubsan.

Signed-off-by: Fergus Dall <sidereal@google.com>
3 years agoutil: Avoid undefined behaviour in for_each_helper
Fergus Dall [Fri, 9 Jul 2021 07:52:01 +0000 (17:52 +1000)]
util: Avoid undefined behaviour in for_each_helper

for_each_helper tries to calculate a one-past-the-end pointer for its
wl_array input. This is fine when the array has one or more entries, but we
initialize arrays by setting wl_array.data to NULL. Pointer arithmetic is
only defined when both the pointer operand and the result point to the same
allocation, or one-past-the-end of that allocation. As NULL points to no
allocation, no pointer arithmetic can be performed on it, not even adding 0,
even if the result is never dereferenced.

This is caught by clang's ubsan from version 10.

Many tests already hit this case, but I added an explicit test for iterating
over an empty wl_map.

Signed-off-by: Fergus Dall <sidereal@google.com>
3 years agoclient: print discarded events in debug log
Manuel Stoeckl [Sun, 27 Sep 2020 01:14:16 +0000 (21:14 -0400)]
client: print discarded events in debug log

Before this patch, setting WAYLAND_DEBUG=1 or WAYLAND_DEBUG=client made
a program log all requests sent and events that it processes. However,
some events received are not processed. This can happen when a Wayland
server sends an event to an object that does not exist, or was recently
destroyed by the client program (either before the event was decoded,
or after being decoded but before being dispatched.)

This commit prints all discarded messages in the debug log, producing
lines like:

[1234567.890] discarded [unknown]@42.[event 0](0 fd, 12 byte)
[1234567.890] discarded wl_callback@3.done(34567)
[1234567.890] discarded [zombie]@13.[event 1](3 fd, 8 byte)

The first indicates an event to an object that does not exist; the
second, an event to an object that was deleted after decoding, but
before dispatch; the third, an event to an object that left a
'zombie' marker behind to indicate which events have associated
file descriptors.

Signed-off-by: Manuel Stoeckl <code@mstoeckl.com>
3 years agowayland-util: avoid memcpy(NULL) in wl_array_copy()
Pekka Paalanen [Tue, 13 Jul 2021 10:19:48 +0000 (13:19 +0300)]
wayland-util: avoid memcpy(NULL) in wl_array_copy()

The problem was found running Weston, with both Weston and Wayland built
with ASan:

../../git/wayland/src/wayland-util.c:150:2: runtime error: null pointer passed as argument 1, which is declared to never be null
../../git/wayland/src/wayland-util.c:150:2: runtime error: null pointer passed as argument 2, which is declared to never be null

This turns out to be caused by copying an empty array into an empty
array.

That seems to be completely valid thing to do, and wl_array_init()
initializes the pointers to NULL and size to zero. Copying initialized
arrays must always be valid.

The error are caused by calling memcpy() with NULL pointers. It doesn't
explode, because also the size is zero.

Fix the problem by calling memcpy() only if size is not zero. This
should keep things like copying an empty array into a non-empty array
work.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
3 years agoshm: document wl_shm_buffer
Simon Ser [Tue, 13 Jul 2021 13:52:31 +0000 (15:52 +0200)]
shm: document wl_shm_buffer

The main motivation is to make it clear when a wl_shm_buffer is
destroyed.

Signed-off-by: Simon Ser <contact@emersion.fr>
3 years agotests: Test wayland-scanner with a description in an entry
James Legg [Wed, 2 Jun 2021 23:10:22 +0000 (00:10 +0100)]
tests: Test wayland-scanner with a description in an entry

This previously would have caused a memory leak and incorrect
comments.

Signed-off-by: James Legg <lankyleggy@gmail.com>
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
3 years agoscanner: Use descriptions in entries
James Legg [Wed, 2 Jun 2021 23:10:21 +0000 (00:10 +0100)]
scanner: Use descriptions in entries

entry may have a description according to the DTD. This is used in
some protocols including xdg-shell.

Fixes the code comment on an enum declaration using the description of
the last enum that had one, adds the descriptions to the comments on
enumerators, and avoids leaking the previously missing descriptions.

Fixes #208

Signed-off-by: James Legg <lankyleggy@gmail.com>
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
3 years agoprotocol: clarify wl_seat.name description
Simon Ser [Tue, 29 Jun 2021 10:47:04 +0000 (12:47 +0200)]
protocol: clarify wl_seat.name description

Define the expected properties of the seat name.

Signed-off-by: Simon Ser <contact@emersion.fr>
3 years agoCI: turn on ASan and UBSan
Pekka Paalanen [Fri, 14 May 2021 13:25:07 +0000 (16:25 +0300)]
CI: turn on ASan and UBSan

I just noticed that libwayland test suite is ASan and UBSan clean, so
let's turn that on in CI to avoid regressing.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
3 years agoshm: add safety assertions
Simon Ser [Wed, 2 Jun 2021 14:35:30 +0000 (16:35 +0200)]
shm: add safety assertions

Catch any API mis-use with an assert. This should abort when the
user calls unreferences the pool more times than it's referenced.

Also change the refcount check to explicitly check for positive
counts. That makes the condition more readable.

Signed-off-by: Simon Ser <contact@emersion.fr>
3 years agoconnection: Handle non-nullable strings in wl_connection_demarshal
Fergus Dall [Tue, 22 Jun 2021 09:31:26 +0000 (19:31 +1000)]
connection: Handle non-nullable strings in wl_connection_demarshal

Currently a null string passed into a non-nullable argument of a message
will decode succesfully, probably resulting in the handler function
crashing. Instead treat it the same way we do non-nullable objects and ids.

Signed-off-by: Fergus Dall <sidereal@google.com>
3 years agoconnection-test: Encode size in message headers correctly
Fergus Dall [Tue, 22 Jun 2021 10:05:47 +0000 (20:05 +1000)]
connection-test: Encode size in message headers correctly

In these tests, message sizes are inconsistently encoded in either the upper
or lower 16 bits of the second word of the message. Resolve this in favour
of using the upper 16 bits, as this is how messages are supposed to be
encoded, even though that aspect of message decoding isn't being tested
here.

Signed-off-by: Fergus Dall <sidereal@google.com>
3 years agoprotocol: allow immediate wl_buffer.destroy if not re-used
Simon Ser [Wed, 26 May 2021 10:07:17 +0000 (12:07 +0200)]
protocol: allow immediate wl_buffer.destroy if not re-used

Allow wl_buffer objects to be destroyed without having to wait for
wl_buffer.release if the underlying storage isn't going to be
re-used.

The main motivation for this is to avoid glitches when a client is
torn down. When a client disconnects, all of its objects are destroyed
in arbitrary order. However some compositors will still need to
access the destroyed buffer's underlying storage afterwards, e.g. for
visual effects (fade-out) or for atomic layout updates (wait for other
clients to commit a new buffer before hiding the buffer).

It's still incorrect for clients to destroy a wl_buffer and mutate
the underlying storage without waiting for wl_buffer.release.

Signed-off-by: Simon Ser <contact@emersion.fr>
Closes: https://gitlab.freedesktop.org/wayland/wayland/-/issues/185

3 years agoshm: remove wl_shm_buffer.pool NULL checks
Simon Ser [Wed, 2 Jun 2021 14:22:54 +0000 (16:22 +0200)]
shm: remove wl_shm_buffer.pool NULL checks

wl_shm_buffer.pool is never set to NULL. The only time it's set is
in shm_pool_create_buffer, and the pool is guaranteed to be non-NULL
there.

Signed-off-by: Simon Ser <contact@emersion.fr>
3 years agocursor: fix crash with weird input files
Tobias Stoeckmann [Fri, 14 May 2021 11:06:15 +0000 (13:06 +0200)]
cursor: fix crash with weird input files

If a cursor file contains multiple images for the same size, this
typically indicates an animation. The compositor weston uses
wl_cursor_frame_and_duration to figure out at which time a specific image
should be shown.

The total delay is the sum of all image delays. But if all images have a
delay of 0, the total delay is 0 as well. The code does not check for this
special condition and triggers a floating point exception by eventually
performing a modulo operation with 0.

This, of course, could also happen if the sum of all image delays
triggers an unsigned int overflow. But since a comment in the code
already indicates that it does not try to "fix" handling of weird files,
I would argue that it's "okay" if that happens. At least the program
won't crash.

Proof of Concept:

install -D ~/.icons/poc/cursors
base64 -d > ~/.icons/poc/cursors/left_ptr << EOF
WGN1chAAAAAAAAEAAgAAAAIA/f8BAAAAKAAAAAIA/f8BAAAAKAAAACQAAAACAP3/AQAAAAEAAAAB
AAAAAQAAAAEAAAABAAAAAAAAAAAAAAA=
EOF
cat > /tmp/weston.ini << EOF
[shell]
cursor-theme=poc
EOF
weston -c /tmp/weston.ini

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
3 years agoprotocol: drop reference to wl_drm
Simon Ser [Wed, 26 May 2021 10:00:17 +0000 (12:00 +0200)]
protocol: drop reference to wl_drm

Change the wl_drm reference to linux-dmabuf. wl_drm is a legacy,
private Mesa protocol that shouldn't be used by regular clients.

Signed-off-by: Simon Ser <contact@emersion.fr>
3 years agobuild: replace assembly embedding with Python script
Simon Ser [Tue, 15 Dec 2020 19:35:25 +0000 (20:35 +0100)]
build: replace assembly embedding with Python script

This allows Meson to properly track dependencies and re-build the scanner when
editing the dtd. We also stop depending on GNU as' .incbin and make the
embedding less obscure.

Signed-off-by: Simon Ser <contact@emersion.fr>
3 years agosrc: Add missing new lines to log messages
Marius Vlad [Fri, 7 May 2021 08:00:43 +0000 (11:00 +0300)]
src: Add missing new lines to log messages

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
3 years agoDocument serial param usage in wl_pointer.set_cursor
Nick Diego Yamane [Wed, 28 Apr 2021 15:34:05 +0000 (11:34 -0400)]
Document serial param usage in wl_pointer.set_cursor

Serial is supposed to contain the latest wl_pointer.enter value received
by clients but it was not even mentioned in the docs, so add it to avoid
misinterpretations.

Signed-off-by: Nick Diego Yamane <nickdiego@igalia.com>
3 years agocursor: fix CVE-2013-2003
Tobias Stoeckmann [Sun, 2 May 2021 19:35:23 +0000 (21:35 +0200)]
cursor: fix CVE-2013-2003

The libXcursor fix for CVE-2013-2003 has never been imported into
wayland, leaving it vulnerable to it.

Changing the argument type to an unsigned type is an effective merge of
Ilja Van Sprundel's commit in libXcursor.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
3 years agocursor: add one more directory to XCURSORPATH
Alexander Dunaev [Wed, 17 Feb 2021 08:44:00 +0000 (15:44 +0700)]
cursor: add one more directory to XCURSORPATH

The user may install cursor themes manually, and the desktop environment
may provide a special directory for storing them.  For instance, GTK puts
those themes into ~/.local/share/icons, and many Linux distributions suggest
using that directory for user-specific themes.  However, users of
libwayland-cursor cannot load these themes using the API provided by the
library because the latter does not look into that directory.

This patch adds ~/.local/share/icons to the search path, so user-specific
themes can be loaded through the API provided by libwayland-cursor.

Signed-off-by: Alexander Dunaev <adunaev@igalia.com>
Reviewed-by: Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
Reviewed-by: Simon Ser <contact@emersion.fr>
3 years agobuild: add option to disable tests
James Hilliard [Tue, 3 Mar 2020 22:27:51 +0000 (15:27 -0700)]
build: add option to disable tests

When building for a product, tests are not needed.

Besides, one test requires a C++ compiler, which is not always
available.

So, add an option to configure to disable building tests altogether.

Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Signed-off-by: Alexey Brodkin <abrodkin@synopsys.com>
Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
3 years agomeson: only require cpp for tests
James Hilliard [Fri, 16 Apr 2021 08:32:38 +0000 (02:32 -0600)]
meson: only require cpp for tests

Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
3 years agoChange wl_os_dupfd_cloexec minfd to be int
Alex Richardson [Thu, 18 Mar 2021 10:46:55 +0000 (10:46 +0000)]
Change wl_os_dupfd_cloexec minfd to be int

The fcntl() argument is defined to be an int and not a long. This does not
matter on most architectures since the value is passed in registers, but
it causes issues on big-endian architectures that pass variadic arguments
on the stack.

Signed-off-by: Alex Richardson <Alexander.Richardson@cl.cam.ac.uk>
Reviewed-by: Simon Ser <contact@emersion.fr>
3 years agoos-wrappers-test.c: Correctly forward arguments to fcntl
Alex Richardson [Thu, 18 Mar 2021 10:45:50 +0000 (10:45 +0000)]
os-wrappers-test.c: Correctly forward arguments to fcntl

We can't just unconditionally read the optional arguments (and also read
it as a void* despite actually being an int).
While this happens to work on most architectures because the first few
variadic arguments are passed in registers, this is non-portable and
causes a crash on architectures that set bounds on variadic function
arguments (for example CHERI-enabled architectures). It could also cause
problems on big-endian architectures that pass variadic arguments on the
stack rather than in registers.

For CHERI-MIPS, reading sizeof(void*) causes a read of 16 bytes from the
bounded varargs capability. This always crashes since even calls with the
optional argument only have 4 bytes available.

Signed-off-by: Alex Richardson <Alexander.Richardson@cl.cam.ac.uk>
Reviewed-by: Simon Ser <contact@emersion.fr>
3 years agomeson: Only require expat when building wayland-scanner
Michael Weiss [Fri, 2 Apr 2021 17:26:57 +0000 (19:26 +0200)]
meson: Only require expat when building wayland-scanner

This code is only required for building wayland-scanner so it should be
scoped accordingly. libxml-2.0 will only be required if both "scanner"
and "dtd_validation" are set to true.

Signed-off-by: Michael Weiss <dev.primeos@gmail.com>
3 years agoci: Use ci-fairy to check for Signed-off-by
Jonas Ådahl [Fri, 26 Mar 2021 16:21:07 +0000 (17:21 +0100)]
ci: Use ci-fairy to check for Signed-off-by

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
3 years agoUse MAP_FAILED instead of (void *) -1
Alex Richardson [Fri, 19 Mar 2021 11:24:05 +0000 (11:24 +0000)]
Use MAP_FAILED instead of (void *) -1

While MAP_FAILED is generally defined to that value, we should not be
relying on implementation details of system headers.

Signed-off-by: Alex Richardson <Alexander.Richardson@cl.cam.ac.uk>
Reviewed-by: Simon Ser <contact@emersion.fr>
3 years agobuild: drop autotools
Simon Ser [Mon, 14 Dec 2020 13:46:46 +0000 (14:46 +0100)]
build: drop autotools

Meson now replaces autotools.

Signed-off-by: Simon Ser <contact@emersion.fr>
3 years agoserver: add wl_display getter for wl_global
Vlad Zahorodnii [Wed, 24 Feb 2021 14:02:54 +0000 (16:02 +0200)]
server: add wl_display getter for wl_global

This can be useful if the compositor wants to call wl_global_destroy() with some
delay but it doesn't have the wl_display object associated with the global,
which is needed to get access to the event loop.

Signed-off-by: Vlad Zahorodnii <vlad.zahorodnii@kde.org>
3 years agoclient: assert queue display matches proxy
Simon Ser [Thu, 25 Feb 2021 22:49:00 +0000 (23:49 +0100)]
client: assert queue display matches proxy

In wl_proxy_set_queue, passing a wl_event_queue from a completely
unrelated wl_display could lead to object IDs mismatches.

Add an assertion to catch this case. It's always a user bug if this
happens.

Signed-off-by: Simon Ser <contact@emersion.fr>
3 years agoserver: remove duplicate include
sheepwall [Mon, 22 Feb 2021 17:19:13 +0000 (18:19 +0100)]
server: remove duplicate include

Signed-off-by: August Svensson <a.sve@live.se>
3 years agoprotocol: Specify wl_callback::done to be a destructor event
Tadeo Kondrak [Thu, 11 Jun 2020 19:41:09 +0000 (13:41 -0600)]
protocol: Specify wl_callback::done to be a destructor event

It's the only destructor event in the core protocol, and destructor
events were previously unannotated.

Signed-off-by: Tadeo Kondrak <me@tadeo.ca>
3 years agoprotocol: Add type attribute to events
Tadeo Kondrak [Thu, 11 Jun 2020 19:39:56 +0000 (13:39 -0600)]
protocol: Add type attribute to events

This allows specifying events to be destructors, which is useful for
non-C language bindings. It is unused in wayland-scanner.

Signed-off-by: Tadeo Kondrak <me@tadeo.ca>
3 years agobuild: re-open master for regular development
Simon Ser [Wed, 27 Jan 2021 17:45:57 +0000 (18:45 +0100)]
build: re-open master for regular development

3 years agobuild: bump to version 1.19.0 for the official release 1.19.0
Simon Ser [Wed, 27 Jan 2021 16:48:01 +0000 (17:48 +0100)]
build: bump to version 1.19.0 for the official release

3 years agobuild: bump to 1.18.93 for the RC1 release 1.18.93
Simon Ser [Wed, 20 Jan 2021 21:35:34 +0000 (22:35 +0100)]
build: bump to 1.18.93 for the RC1 release

3 years agoprotocol: sync wl_shm.format with libdrm 2.4.104
Simon Ser [Sun, 17 Jan 2021 10:51:39 +0000 (11:51 +0100)]
protocol: sync wl_shm.format with libdrm 2.4.104

This adds 4 new formats.

Signed-off-by: Simon Ser <contact@emersion.fr>
Reviewed-by: Jonas Ådahl <jadahl@gmail.com>
Acked-by: Daniel Stone <daniels@collabora.com>
3 years agoserver: Allow absolute paths in WAYLAND_DISPLAY
Loïc Yhuel [Thu, 14 Nov 2019 13:13:17 +0000 (14:13 +0100)]
server: Allow absolute paths in WAYLAND_DISPLAY

The compositor should handle absolute paths in WAYLAND_DISPLAY like the clients, ie not
adding the XDG_RUNTIME_DIR prefix if it's an absolute path.

This allows to create the wayland socket in a separate directory for system compositors if
desired. Clients could then directly inherit the environment variable.

Signed-off-by: Loïc Yhuel <loic.yhuel@softathome.com>
3 years agobuild: bump to version 1.18.92 for the beta release upstream_bkup_20220121 upstream_bkup_20220124 upstream_bkup_20220208 1.18.92 upstream/1.18.92
Simon Ser [Wed, 6 Jan 2021 19:18:58 +0000 (20:18 +0100)]
build: bump to version 1.18.92 for the beta release

3 years agoRemove TODO
Simon Ser [Mon, 14 Dec 2020 16:27:45 +0000 (17:27 +0100)]
Remove TODO

These TODO items are outdated (either done or not applicable anymore). Let's
migrate items that we want to keep to GitLab issues.

Signed-off-by: Simon Ser <contact@emersion.fr>
3 years agomeson: link with -lrt if needed for clock_gettime
Loïc Yhuel [Thu, 2 Apr 2020 16:25:54 +0000 (18:25 +0200)]
meson: link with -lrt if needed for clock_gettime

This is already done in autotools, and fixes the build with glibc < 2.17.

Signed-off-by: Loïc Yhuel <loic.yhuel@softathome.com>
3 years agobuild: bump to version 1.18.91 for the alpha release 1.18.91
Simon Ser [Mon, 21 Dec 2020 10:16:05 +0000 (11:16 +0100)]
build: bump to version 1.18.91 for the alpha release

3 years agoserver: fix typos
Maxime Roussin-Bélanger [Thu, 17 Dec 2020 20:42:10 +0000 (15:42 -0500)]
server: fix typos

3 years agoegl: fix typo "Backards"
Maxime Roussin-Bélanger [Thu, 17 Dec 2020 20:41:13 +0000 (15:41 -0500)]
egl: fix typo "Backards"

3 years agocursor: fix typo "insufficent"
Maxime Roussin-Bélanger [Thu, 17 Dec 2020 20:40:58 +0000 (15:40 -0500)]
cursor: fix typo "insufficent"

3 years agoCONTRIBUTING: fix typo "excercising"
Maxime Roussin-Bélanger [Thu, 17 Dec 2020 20:40:38 +0000 (15:40 -0500)]
CONTRIBUTING: fix typo "excercising"

3 years agotests: fix typos
Maxime Roussin-Bélanger [Thu, 17 Dec 2020 20:40:04 +0000 (15:40 -0500)]
tests: fix typos

3 years agodoc: fix typos
Maxime Roussin-Bélanger [Thu, 17 Dec 2020 20:39:46 +0000 (15:39 -0500)]
doc: fix typos

3 years agoprotocol: deprecate non-current wl_output.mode
Simon Ser [Thu, 16 Apr 2020 17:08:53 +0000 (19:08 +0200)]
protocol: deprecate non-current wl_output.mode

The current wl_output.mode event has several issues when used to advertise
modes that aren't current:

- It's not possible to remove some modes. This is an issue for virtual
  outputs and when the kernel prunes some modes because of link limitations.
- wl_output.mode fails to carry metadata such as aspect ratio, which results
  in duplicated or missing modes.
- It's not clear, given the current set of protocols, how non-current modes
  are useful to clients. Xwayland ignores non-current modes.

GNOME and wlroots already only advertise the current mode because of these
issues.

If a protocol needs the clients to know about all available modes, it should
advertise these modes itself instead of relying on wl_output.mode.

Signed-off-by: Simon Ser <contact@emersion.fr>
Closes: https://gitlab.freedesktop.org/wayland/wayland/-/issues/92

3 years agoprotocol: make it clear wl_surface.enter/leave are not for frame throttling
Simon Ser [Wed, 15 Jul 2020 07:39:25 +0000 (09:39 +0200)]
protocol: make it clear wl_surface.enter/leave are not for frame throttling

Some clients rely on wl_surface.enter/leave to start/stop their rendering
loop.

There are cases where this doesn't work:

- Some compositors don't send wl_surface.leave when a toplevel is hidden.
  For instance Sway doesn't send this event when a toplevel is on an inactive
  workspace (but doesn't send wl_surface.frame events).
- Some compositors might still want applications to continue to render even if
  away from outputs. For instance a compositor that allows to screen record
  individual toplevels might not send a wl_surface.enter event for hidden
  toplevels.

Signed-off-by: Simon Ser <contact@emersion.fr>
3 years agocursor/convert_font.c: malloc cannot guarantee that the memory allocated is always...
ganjing [Mon, 27 Jul 2020 03:22:40 +0000 (11:22 +0800)]
cursor/convert_font.c: malloc cannot guarantee that the memory allocated is always successful

3 years agodoc: make reproducible
Alyssa Ross [Thu, 29 Oct 2020 12:06:36 +0000 (12:06 +0000)]
doc: make reproducible

This setting makes Docbook section IDs consistent, and should allow
Wayland builds that include documentation to be fully reproducible.

Signed-off-by: Alyssa Ross <hi@alyssa.is>
3 years agoprotocol: Clarify how clients can cancel a drag operation
Nick Diego Yamane [Wed, 8 Jul 2020 14:48:19 +0000 (10:48 -0400)]
protocol: Clarify how clients can cancel a drag operation

Explicitly say that destroying a wl_data_source previously used in a
wl_data_device::start_drag request will cancel the DND session. This
is currently the only way to do it from client side (besides those
"indirect" ones already documented) and all compositors work like that
but it is not clear spec-wise it is the expected behaviour.

Signed-off-by: Nick Diego Yamane <nickdiego@igalia.com>
3 years agoFix undefined behavior
Valentin [Fri, 4 Sep 2020 10:15:03 +0000 (12:15 +0200)]
Fix undefined behavior

Without the casts the bytes accesses get converted to int. but int is
not guaranteed to be 4 bytes large. Even when it is 4 bytes large
`bytes[3] << 24` does not fit because int is signed.

Signed-off-by: Valentin Kettner <vakevk@gmail.com>
3 years agoUse fixed size integer type
Valentin [Fri, 4 Sep 2020 10:12:56 +0000 (12:12 +0200)]
Use fixed size integer type

This type is meant to be 4 bytes large as seen in _XcursorReadUInt which
always reads 4 bytes. An unsigned int is often 4 bytes large but this
isnt' guaranteed so it is cleaner to use the exact type we want.

Signed-off-by: Valentin Kettner <vakevk@gmail.com>
3 years agoAdd a basic gitlab issue template
Peter Hutterer [Thu, 9 Jul 2020 04:44:04 +0000 (14:44 +1000)]
Add a basic gitlab issue template

This makes the Bug template available in the new issues form. Ideally a majority
of users will select this template and then realize that they're in the wrong
repo.

Making this a default is a feature of the enterprise gitlab version only, see
https://docs.gitlab.com/ce/user/project/description_templates.html#overview

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
3 years agoprotocol: Minor gramatical fix.
Christopher James Halse Rogers [Fri, 14 Aug 2020 00:24:02 +0000 (10:24 +1000)]
protocol: Minor gramatical fix.

Signed-off-by: Christopher James Halse Rogers <christopher.halse.rogers@canonical.com>
4 years agoprotocol: disambiguate key codes in wl_keyboard.key
Simon Ser [Mon, 3 Feb 2020 14:45:58 +0000 (15:45 +0100)]
protocol: disambiguate key codes in wl_keyboard.key

Explain that wl_keyboard.key yields platform-specific key codes.
Some compositors use Linux key codes (defined in the
linux/input-event-codes.h header file, e.g. KEY_ESC), however
clients should not assume that this is always the case. The only
reliable way for clients to interpret key codes is to feed them
into a keyboard mapping.

Signed-off-by: Simon Ser <contact@emersion.fr>
4 years agoClarify clients behavior on wl_keyboard.leave
Kirill Chibisov [Sun, 24 May 2020 11:12:44 +0000 (14:12 +0300)]
Clarify clients behavior on wl_keyboard.leave

Clients must assume that every key, including modifiers, are lifted
after getting wl_keyboard.leave event, not doing so could lead to key repeat
keep going after the user changes focus, or stuck modifiers, when the user
interacts with client without keyboard focus.

Signed-off-by: Kirill Chibisov <contact@kchibisov.com>
4 years agoClarify the order of wl_keyboard.modifiers
Kirill Chibisov [Sat, 23 May 2020 23:28:31 +0000 (02:28 +0300)]
Clarify the order of wl_keyboard.modifiers

Consider that we set the modifier for the modifier key as well, and that
you have the option to change your layout when both shifts pressed. This
realized by making the shift keys produce 'Group_switch' when you press
the shift key and the shift modifier is already active. So sending modifier
before the key event will result in 'Group_switch' each time you press
shift.

That being said, the order of modifiers should be updated after the
key/enter event, so it'll only affect future keypresses, not the current one.

See: https://lists.x.org/archives/xorg-devel/2014-July/043110.html

Signed-off-by: Kirill Chibisov <contact@kchibisov.com>
4 years agodoc: Document libwayland-cursor with meson
Emmanuel Gil Peyrot [Wed, 22 Jan 2020 12:26:47 +0000 (13:26 +0100)]
doc: Document libwayland-cursor with meson

Signed-off-by: Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
4 years agodoc: Document libwayland-cursor with autotools
Emmanuel Gil Peyrot [Wed, 13 Nov 2019 21:53:49 +0000 (22:53 +0100)]
doc: Document libwayland-cursor with autotools

Signed-off-by: Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
4 years agocursor: Properly document wl_cursor_image and wl_cursor
Emmanuel Gil Peyrot [Wed, 13 Nov 2019 21:53:21 +0000 (22:53 +0100)]
cursor: Properly document wl_cursor_image and wl_cursor

Signed-off-by: Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
4 years agocursor: Use spaces for alignment in the header
Emmanuel Gil Peyrot [Wed, 13 Nov 2019 19:39:01 +0000 (20:39 +0100)]
cursor: Use spaces for alignment in the header

Signed-off-by: Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
4 years agoprotocol: add seat missing_capability error
Simon Ser [Thu, 28 May 2020 08:00:12 +0000 (10:00 +0200)]
protocol: add seat missing_capability error

The protocol says:

> It is a protocol violation to issue this request on a seat that
> has never had the pointer capability.

But never defines an error code.

Signed-off-by: Simon Ser <contact@emersion.fr>
Closes: https://gitlab.freedesktop.org/wayland/wayland/-/issues/165

4 years agogitlab CI: update to use the fdo ci templates
Peter Hutterer [Thu, 4 Jun 2020 05:40:49 +0000 (15:40 +1000)]
gitlab CI: update to use the fdo ci templates

Instead of building a new debian image every time we build the repo, let's build
it once and re-use it. This way we're more  likely to spot actual bugs vs issues
with the distribution (or mirrors). This is the same approach mesa, gstreamer,
libinput, etc. already use.

The pipeline consists of two parts: container-build and distribution-image. Both
use the FDO_DISTRIBUTION_... variables to do their thing, the former to build an
image, the latter to use that image. The container-build step is a noop if an
image with that tag already exists in the registry, the templates take care of
all that.

The .debian.buster section groups the variables needed to easily extend all jobs
requiring buster. Not all variables are used by all jobs but meh.

The grouping is slightly odd because some debian-specific variables are in
the global variables and others in the .debian.buster section. This grouping
will make things easier if we extend to build on other distributions - then we
have all packages and tags in one place.

Because buster doesn't have a recent-enough version of meson, we install that
from pip.

Fixes #79

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.com>
4 years agoeditorconfig: add settings for the .gitlab-ci.yml file
Peter Hutterer [Thu, 4 Jun 2020 05:40:08 +0000 (15:40 +1000)]
editorconfig: add settings for the .gitlab-ci.yml file

Different indentation and we don't want a fixed line length here, wrapping yaml
is prone to introduce bugs.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.com>
4 years agodoc: fix and clarify pointer image behaviour
Yann Dirson [Mon, 30 Mar 2020 16:29:08 +0000 (18:29 +0200)]
doc: fix and clarify pointer image behaviour

Signed-off-by: Yann Dirson <ydirson@free.fr>
4 years agoReplace initial 8 spaces with a tab for all xml files
Peter Hutterer [Thu, 16 Apr 2020 05:57:07 +0000 (15:57 +1000)]
Replace initial 8 spaces with a tab for all xml files

This is the style used in wayland.xml which is the only file we really
care about for git blame information. So let's adjust all others to that
style for consistency and fix editorconfig to avoid messing this up in
the future.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
4 years agoscanner: Guard interface declarations
Guido Günther [Tue, 21 Apr 2020 10:47:56 +0000 (12:47 +0200)]
scanner: Guard interface declarations

This allows to include client and server headers in the same file
fixing warnings like

In file included from ../subprojects/wlroots/include/wlr/types/wlr_layer_shell_v1.h:16,
                 from ../src/desktop.h:16,
                 from ../src/server.h:13,
                 from ../tests/testlib.c:8:
tests/59830eb@@footest@sta/wlr-layer-shell-unstable-v1-protocol.h:80:34: warning: redundant redeclaration of ‘zwlr_layer_shell_v1_interface’ [-Wredundant-decls]
   80 | extern const struct wl_interface zwlr_layer_shell_v1_interface;
      |                                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from ../tests/testlib.h:8,
                 from ../tests/testlib.c:7:
tests/59830eb@@footest@sta/wlr-layer-shell-unstable-v1-client-protocol.h:77:34: note: previous declaration of ‘zwlr_layer_shell_v1_interface’ was here
   77 | extern const struct wl_interface zwlr_layer_shell_v1_interface;
      |                                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from ../subprojects/wlroots/include/wlr/types/wlr_layer_shell_v1.h:16,
                 from ../src/desktop.h:16,
                 from ../src/server.h:13,
                 from ../tests/testlib.c:8:
tests/59830eb@@footest@sta/wlr-layer-shell-unstable-v1-protocol.h:106:34: warning: redundant redeclaration of ‘zwlr_layer_surface_v1_interface’ [-Wredundant-decls]
  106 | extern const struct wl_interface zwlr_layer_surface_v1_interface;
      |                                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from ../tests/testlib.h:8,
                 from ../tests/testlib.c:7:
tests/59830eb@@footest@sta/wlr-layer-shell-unstable-v1-client-protocol.h:103:34: note: previous declaration of ‘zwlr_layer_surface_v1_interface’ was here
  103 | extern const struct wl_interface zwlr_layer_surface_v1_interface;

Signed-off-by: Guido Günther <agx@sigxcpu.org>
Closes: #158

4 years agodoc/man: remove manually written man pages
Simon Ser [Thu, 16 Apr 2020 17:50:52 +0000 (19:50 +0200)]
doc/man: remove manually written man pages

There is only one page written. Having manually-written man pages duplicates
information with doc comments. Besides, man pages are already generated by
Doxygen.

Signed-off-by: Simon Ser <contact@emersion.fr>
Closes: https://gitlab.freedesktop.org/wayland/wayland/-/issues/156

4 years agoclient: improve wl_display_connect docs
Simon Ser [Thu, 16 Apr 2020 17:49:12 +0000 (19:49 +0200)]
client: improve wl_display_connect docs

Add a paragraph about WAYLAND_SOCKET and describe what happens when the display
name is a relative path.

Signed-off-by: Simon Ser <contact@emersion.fr>
4 years agoREADME with upadated compile instructions
Ricardo Quesada [Tue, 7 Apr 2020 17:06:19 +0000 (10:06 -0700)]
README with upadated compile instructions

This commit updates the README build & install instructions.
It replaces that obsolete "autogen && make" with "meson && ninja"

Signed-off-by: Ricardo Quesada <ricardoquesada@gmail.com>
4 years agomeson: Deduplicate generation of wayland-version.h
Matt Turner [Mon, 16 Mar 2020 23:47:05 +0000 (16:47 -0700)]
meson: Deduplicate generation of wayland-version.h

Signed-off-by: Matt Turner <mattst88@gmail.com>