Commit Graph

2500 Commits

Author SHA1 Message Date
Fergus Dall
4f53613e70 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>
2021-06-22 20:15:32 +10:00
Simon Ser
3e897faa29 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
2021-06-11 14:05:27 +00:00
Simon Ser
ba0c63dee8 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>
2021-06-10 14:33:32 +00:00
Tobias Stoeckmann
abcf1048e2 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>
2021-06-02 13:46:33 +00:00
Simon Ser
f8bea2450d 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>
2021-05-27 10:48:40 +02:00
Simon Ser
f452e41264 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>
2021-05-10 22:08:45 +00:00
Marius Vlad
e475decf1d src: Add missing new lines to log messages
Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2021-05-07 11:07:54 +03:00
Nick Diego Yamane
208fc99e66 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>
2021-05-04 15:26:48 +00:00
Tobias Stoeckmann
ed55438366 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>
2021-05-02 21:35:23 +02:00
Alexander Dunaev
0aebb5b94d 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>
2021-04-27 11:16:17 +00:00
James Hilliard
88f1605a82 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>
2021-04-16 03:45:06 -06:00
James Hilliard
4c21053123 meson: only require cpp for tests
Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
2021-04-16 03:04:56 -06:00
Alex Richardson
34306efeb2 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>
2021-04-15 07:34:53 +00:00
Alex Richardson
e881934927 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>
2021-04-15 07:34:53 +00:00
Michael Weiss
e4659ffbf5
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>
2021-04-02 20:55:15 +02:00
Jonas Ådahl
d224e6ccf3 ci: Use ci-fairy to check for Signed-off-by
Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
2021-03-26 17:24:47 +01:00
Alex Richardson
1349d3d15b 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>
2021-03-22 14:05:11 +00:00
Simon Ser
3bda3d1b47 build: drop autotools
Meson now replaces autotools.

Signed-off-by: Simon Ser <contact@emersion.fr>
2021-03-05 09:15:04 +00:00
Vlad Zahorodnii
2b22160fb6 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>
2021-03-05 09:12:33 +00:00
Simon Ser
727c7903b2 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>
2021-02-25 23:49:00 +01:00
sheepwall
70f1c83fd9 server: remove duplicate include
Signed-off-by: August Svensson <a.sve@live.se>
2021-02-22 19:09:08 +01:00
Tadeo Kondrak
ddf21afa6e 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>
2021-01-27 17:49:10 +00:00
Tadeo Kondrak
efab39642e 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>
2021-01-27 17:49:10 +00:00
Simon Ser
f1cc5d0c37 build: re-open master for regular development 2021-01-27 18:45:57 +01:00
Simon Ser
e60398b175 build: bump to version 1.19.0 for the official release 2021-01-27 17:48:01 +01:00
Simon Ser
0344e08ce0 build: bump to 1.18.93 for the RC1 release 2021-01-20 22:35:34 +01:00
Simon Ser
db8b64ca5e 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>
2021-01-19 17:16:54 +01:00
Loïc Yhuel
d32e77692c 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>
2021-01-13 17:01:15 +01:00
Simon Ser
69b8eaf385
build: bump to version 1.18.92 for the beta release 2021-01-06 20:18:58 +01:00
Simon Ser
d01dee9784 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>
2020-12-28 10:15:28 +00:00
Loïc Yhuel
74182eb605 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>
2020-12-23 15:37:58 +01:00
Simon Ser
ea09c2fde7
build: bump to version 1.18.91 for the alpha release 2020-12-21 11:16:05 +01:00
Maxime Roussin-Bélanger
dad8575a4b server: fix typos 2020-12-17 16:03:14 -05:00
Maxime Roussin-Bélanger
4c086a8ce2 egl: fix typo "Backards" 2020-12-17 16:03:14 -05:00
Maxime Roussin-Bélanger
0f0951d5c4 cursor: fix typo "insufficent" 2020-12-17 16:03:14 -05:00
Maxime Roussin-Bélanger
b52e71c8ec CONTRIBUTING: fix typo "excercising" 2020-12-17 16:03:14 -05:00
Maxime Roussin-Bélanger
efa5e3c8c6 tests: fix typos 2020-12-17 16:03:14 -05:00
Maxime Roussin-Bélanger
0f5cc8b71b doc: fix typos 2020-12-17 16:03:14 -05:00
Simon Ser
6741dafbf7 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
2020-10-29 13:07:20 +00:00
Simon Ser
d42b39ccab 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>
2020-10-29 13:02:50 +00:00
ganjing
1ea08d748c cursor/convert_font.c: malloc cannot guarantee that the memory allocated is always successful 2020-10-29 13:00:20 +00:00
Alyssa Ross
e53e0edf0f 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>
2020-10-29 12:56:15 +00:00
Nick Diego Yamane
53dd99793d 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>
2020-10-29 12:17:28 +00:00
Valentin
1ab6a81816 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>
2020-09-04 12:27:33 +02:00
Valentin
fc3beac71f 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>
2020-09-04 12:27:23 +02:00
Peter Hutterer
9b7171f955 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>
2020-08-18 07:57:26 +00:00
Christopher James Halse Rogers
4e16ef0aed
protocol: Minor gramatical fix.
Signed-off-by: Christopher James Halse Rogers <christopher.halse.rogers@canonical.com>
2020-08-14 10:30:22 +10:00
Simon Ser
1dfd2169da
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>
2020-06-16 11:35:14 +02:00
Kirill Chibisov
57b7c7d946 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>
2020-06-12 21:15:11 +00:00
Kirill Chibisov
4aa6eb868a 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>
2020-06-12 21:15:11 +00:00