Commit graph

2590 commits

Author SHA1 Message Date
Simon Ser
fd42f70baf shm: implement version 2
This version adds a release request.

Signed-off-by: Simon Ser <contact@emersion.fr>
2024-01-19 15:12:29 +00:00
Simon Ser
f06736a8a0 protocol: add wl_shm.release request
Allows clients to cleanly release wl_shm objects. Useful for clients
using multiple wl_registry objects (e.g. via libraries).

Signed-off-by: Simon Ser <contact@emersion.fr>
2024-01-19 15:12:29 +00:00
Simon Ser
9e233e31a2 shm: fix resource versions
This was hardcoded to 1 regardless of the version passed to the
callback or the version of the parent resource.

Signed-off-by: Simon Ser <contact@emersion.fr>
2024-01-19 15:12:29 +00:00
Ben Widawsky
8072ab0a50 protocol: clarify scale expecations
Since the positivity of zero is debatable, and, in some cases scale was simply
underspecified, clarify the situation.

Signed-off-by: Ben Widawsky <ben@bwidawsk.net>
2024-01-19 14:35:06 +00:00
Simon Ser
647398ead4 util: use C23 deprecated attribute
Signed-off-by: Simon Ser <contact@emersion.fr>
2024-01-19 14:21:59 +00:00
Simon Ser
56b9c92b98 util: use C23 typeof if available
Instead of using the non-standard __typeof__, prefer the standard
typeof operator introduced in C23.

Signed-off-by: Simon Ser <contact@emersion.fr>
2024-01-19 14:21:59 +00:00
Simon Ser
dc1da181db protocol: document wl_surface.offset for sub-surfaces
Document that the request is ignored, since this is the behavior
of most compositors.

Signed-off-by: Simon Ser <contact@emersion.fr>
2024-01-19 14:14:15 +00:00
Consolatis
6daa1b8713 cursor: add aliases for cursor name spec
The cursor name spec [1] describes how cursors should be named,
and is widely used. Add aliases so that users can pass these
names to libwayland-cursor without having to add fallbacks for
X11 cursor names.

[1]: https://www.freedesktop.org/wiki/Specifications/cursor-spec/

Signed-off-by: Simon Ser <contact@emersion.fr>
2024-01-19 14:08:16 +00:00
Simon Ser
0e139cfbc7 build: add a gen-scanner-test target
This adds a command to re-generate the test data. This needs to be
done when either an XML source file or the scanner's output is
changed.

Signed-off-by: Simon Ser <contact@emersion.fr>
2024-01-15 14:29:10 +01:00
Julian Orth
6626d4d98c protocol: wl_subsurface will never be focused
The spec does not describe which actions cause the compositor to assign
keyboard focus to a surface, leaving this up to the compositor.
Compositors differ in their behavior when the user clicks on a
sub-surface. Some will move the keyboard focus to the subsurface whereas
others will only ever assign the keyboard focus to toplevel surfaces.
Some applications (e.g. firefox) seem to require the second behavior.

This patch specifies that sub-surfaces never get the keyboard focus.

Signed-off-by: Julian Orth <ju.orth@gmail.com>
2023-12-27 18:02:07 +00:00
Francesco Guastella
86588fbdeb build: define tests in egl/meson.build when the 'tests' option is enabled
Signed-off-by: Francesco Guastella <guastella.francesco@gmail.com>
2023-12-10 14:58:04 +00:00
Kirill Primak
82d8b21827 protocol: improve wl_subsurface.{set_position,place_above} description
Don't mention when the parent surface state is applied; the parent
surface isn't necessarily a sub-surface.

Signed-off-by: Kirill Primak <vyivel@eclair.cafe>
2023-11-21 15:54:58 +00:00
Kirill Chibisov
8a19dc19a1 protocol: clarify defaults with wl_compositor@v6
This should be sufficient for clients to not decide to fallback to
output based logic to determine scaling/transform when compositor
doesn't send any of the v6 events.

Signed-off-by: Kirill Chibisov <contact@kchibisov.com>
2023-11-21 15:50:11 +00:00
Simon Ser
2a91f01d6c util: simplify wl_fixed_from_double()
Same as 0e0ae7e290 ("util: simplify wl_fixed_to_double()"), but
for the reverse function.

Signed-off-by: Simon Ser <contact@emersion.fr>
2023-11-21 15:47:13 +00:00
Simon Ser
3007718b0c gitlab: make issue template the default
The issue template is hard to notice because it's not the default.
Users have to explicitly select it from the easy-to-miss dropdown
to get the warning.

Make the template the default one, so that new users are less likely
to miss it.

Signed-off-by: Simon Ser <contact@emersion.fr>
2023-11-21 15:44:31 +00:00
Simon Ser
e4eb42d073 protocol: refer to wl_surface.offset in wl_data_device.start_drag
Passing an offset to wl_surface.attach is not supported in the
latest version of the interface.

Signed-off-by: Simon Ser <contact@emersion.fr>
2023-11-21 15:36:00 +00:00
David Benjamin
50ea9c5b1c connection: avoid calling memcpy on NULL, 0
Due to what is arguably a mistake in the C language specification,
passing NULL to memcpy and friends is undefined behavior (UB) even when
the count is 0. C additionally mistakenly leaves NULL + 0 and NULL -
NULL undefined. (C++ fixes this mistake.) These are very problematic
because (NULL, 0) is a natural representation of the empty slice.

Some details:
https://github.com/llvm/llvm-project/issues/49459
https://www.imperialviolet.org/2016/06/26/nonnull.html

Unfortunately, despite how clearly this is a mistake, glibc headers and
GCC now try to exploit this specification mistake and will miscompile
code, so C projects need to workaround this. In particular, UBSan from
Clang will flag this as a bug (although Clang itself has the good sense
to never lean on this bug). We've run into a few UBSan errors in
Chromium stemming from Wayland's memcpy calls. Add runtime guards as
needed to avoid these cases.

Note: Chromium's copy of wayland has
https://gitlab.freedesktop.org/wayland/wayland/-/merge_requests/188
applied. It is possible the ring_buffer_copy UB cases are only reachable
with that MR applied, I'm not sure. But it seemed simplest to just add
the fix to wayland as-is. Then when/if that MR lands, it will pick this
up.

Signed-off-by: David Benjamin <davidben@google.com>
2023-11-08 08:41:16 -05:00
David Edmundson
edb943dc64 client: Add method to get display for a given proxy
This can be useful for additional validation purposes when handling
proxies. This is similar to existing server side API
wl_global_get_display.

Signed-off-by: David Edmundson <david@davidedmundson.co.uk>
2023-08-07 13:38:01 +00:00
Simon Ser
379a6f6759 ci: upgrade FreeBSD to 13.2
Signed-off-by: Simon Ser <contact@emersion.fr>
2023-08-02 16:47:07 +02:00
Simon Ser
63b0050561 ci: upgrade Debian to bookworm
This is the current Debian stable release.

Signed-off-by: Simon Ser <contact@emersion.fr>
2023-08-02 16:47:07 +02:00
Simon Ser
a81f947aff ci: upgrade ci-templates
Newer ci-templates contains bugfixes.

While at it, stop using a GitLab YAML reference, because we only
use this value in one spot.

Signed-off-by: Simon Ser <contact@emersion.fr>
2023-08-02 16:47:07 +02:00
Simon Ser
7b27881cd1 cursor: check return value of snprintf()
Fixes a new warning in GCC 7:

    FAILED: cursor/libwayland-cursor.so.0.22.90.p/xcursor.c.o
    cc -Icursor/libwayland-cursor.so.0.22.90.p -Icursor -I../cursor -I. -I.. -Isrc -I../src -fdiagnostics-color=always -pipe -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wextra -Werror -std=c99 -O3 -D_POSIX_C_SOURCE=200809L -Wno-unused-parameter -Wstrict-prototypes -Wmissing-prototypes -fvisibility=hidden -fPIC '-DICONDIR="/usr/share/X11/icons"' -MD -MQ cursor/libwayland-cursor.so.0.22.90.p/xcursor.c.o -MF cursor/libwayland-cursor.so.0.22.90.p/xcursor.c.o.d -o cursor/libwayland-cursor.so.0.22.90.p/xcursor.c.o -c ../cursor/xcursor.c
    ../cursor/xcursor.c: In function 'xcursor_load_theme':
    ../cursor/xcursor.c:596:39: error: '%s' directive output between 7 and 7 bytes may cause result to exceed 'INT_MAX' [-Werror=format-truncation=]
      596 |         snprintf(full, full_size, "%s/%s/%s", dir, subdir, file);
          |                                       ^~
    ......
      764 |                 full = xcursor_build_fullname(dir, "cursors", "");
          |                                                    ~~~~~~~~~
    ../cursor/xcursor.c:596:41: error: '/' directive output between 1 and 1 bytes may cause result to exceed 'INT_MAX' [-Werror=format-truncation=]
      596 |         snprintf(full, full_size, "%s/%s/%s", dir, subdir, file);
          |                                         ^
    cc1: all warnings being treated as errors

Signed-off-by: Simon Ser <contact@emersion.fr>
2023-08-02 16:47:07 +02:00
Simon Ser
72da004b3e protocol: fix whitespace
This file uses tabs instead of 8 spaces.

Signed-off-by: Simon Ser <contact@emersion.fr>
2023-07-19 11:01:17 +00:00
Peter Hutterer
e3908eb360 Add a triage-policies file for bugbot
With a default template for the common case of "this is not a protocol bug".

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2023-07-07 21:18:08 +10:00
Alex Yang
6d33346571 debug: Replace "@<id>" with "#<id>" in logs
Wayland debug logs resemble email addresses. This is a problem when
anonymizing logs from users. For example:

[2512874.343] xdg_surface@700.configure(333)

In the above log line, the substring "surface@700.config" can be
mistaken for an email address and redacted during anonymization.

Signed-off-by: Alex Yang <aycyang@google.com>
2023-06-27 14:08:25 -07:00
Simon Ser
4ec379ebcc tests: manually wrap libc functions
The way we're wrapping libc functions via dlsym() is pretty fragile
and breaks on FreeBSD. The failures happen in our CI and are pretty
random, see e.g. [1].

Use a more manual way to wrap via a function pointer.

[1]: https://gitlab.freedesktop.org/wayland/wayland/-/jobs/44204010

Signed-off-by: Simon Ser <contact@emersion.fr>
2023-06-27 13:31:50 +02:00
Simon Ser
4a7348e48c egl: add missing ABI check test
We were building the executable for the test, but not declaring
the test.

Signed-off-by: Simon Ser <contact@emersion.fr>
2023-06-20 09:20:49 +02:00
Simon Ser
f181de1bcf tests: add missing proxy-test
This was probably lost during a rebase.

Signed-off-by: Simon Ser <contact@emersion.fr>
2023-06-20 09:20:49 +02:00
Simon Ser
56dfdb7614 server: use bool in struct fields
Use bool instead of int for boolean values, to make it more
explicit what the field contains. For instance "error" is not to
be confused with an error code.

This is all private API.

Signed-off-by: Simon Ser <contact@emersion.fr>
2023-05-30 09:18:34 +00:00
Simon Ser
a3c499493b protocol: refer to wl_surface.offset in set_cursor
The offset in wl_surface.attach has been superseded by
wl_surface.offset. Refer to the new request instead of using the
deprecated one.

Signed-off-by: Simon Ser <contact@emersion.fr>
2023-05-23 09:33:43 +00:00
Sebastian Wick
f3026c916e protocol: specify the exact form of premultiplication
There are two ways to do pre-multiplication of the alpha channel into
the color channels: on optical values or on electrical values. While
pre-multiplication with optical values is arguably more correct, because
operations like blending or scaling require pre-multiplied, optical
color channels, wayland and compositors by default work with
pre-multiplied electrical values. This is most likely a convention that
Wayland took from Cairo.

This commit makes sure that the expectation of pre-multiplied electrical
values is properly documented.

Signed-off-by: Sebastian Wick <sebastian.wick@redhat.com>
2023-05-09 14:52:58 +02:00
Simon Ser
2aec19ce41 build: override wayland-scanner dep
This allows a parent project to find wayland-scanner.

Signed-off-by: Simon Ser <contact@emersion.fr>
2023-05-09 09:56:18 +00:00
Simon Ser
8f2a33cffc server: stop wl_display_run() on dispatch error
If wl_event_loop_dispatch() fails, we could enter an infinite loop,
repeatedly calling a failing wl_event_loop_dispatch() forever.

Signed-off-by: Simon Ser <contact@emersion.fr>
2023-05-09 09:50:53 +00:00
Simon Ser
0e0ae7e290 util: simplify wl_fixed_to_double()
We can just use a simple division instead of bit operations with
magic numbers. Readability matters more than performance here.

References: https://gitlab.freedesktop.org/wayland/wayland/-/merge_requests/296
Signed-off-by: Simon Ser <contact@emersion.fr>
2023-05-09 09:33:06 +00:00
Yang Wang
11b17c1286 event-loop: optimize timer check logic
the 'has_timers' flag can be returned directly without having to track all the ready events
when a timer is found ready.

Signed-off-by: Yang Wang <KevinYang.Wang@amd.com>
2023-05-03 19:21:17 +00:00
Manuel Stoeckl
b1b97e8d34 tests: drop misleading fixed-benchmark
Because this benchmark performed wl_fixed_to_double conversions
on a long sequence of consecutive integers, the compiler could
optimize away the addition performed in wl_fixed_to_double, merging
it with the loop iteration code. This made tests/fixed-benchmark.c
significantly underestimate the actual cost of the current
wl_fixed_to_double implementation.

Signed-off-by: Manuel Stoeckl <code@mstoeckl.com>
2023-05-03 19:15:12 +00:00
Manuel Stoeckl
d40052e083 protocol: add new shm formats
This brings the format list up to date with libdrm 2.4.115.

Signed-off-by: Manuel Stoeckl <code@mstoeckl.com>
2023-05-03 19:10:32 +00:00
Joshua Ashton
3bac2e5fb8 event-loop: Handle EINTR and EAGAIN in wl_event_loop_dispatch
This fixes an issue where it was not possible to start Gamescope under GDB on some setups.
https://github.com/ValveSoftware/gamescope/issues/743

Any signals would cause epoll_wait to return -1 and set errno to EINTR.

This also handles the EAGAIN case like the other polling loops in libwayland.

Signed-off-by: Joshua Ashton <joshua@froggi.es>
2023-05-02 12:36:35 +01:00
Xaver Hugl
1e259a255a protocol: improve wl_keyboard focus documentation
The compositor must not send any key events while a surface is not focused,
but in order to allow for common actions like ctrl+scroll for zooming to work
with unfocused surfaces it may do so with modifiers.

Signed-off-by: Xaver Hugl <xaver.hugl@gmail.com>
2023-04-12 13:37:51 +00:00
Simon Ser
307b23626d protocol: disallow re-using wl_data_source
As pointed out in [1], re-using a wl_data_source for multiple start_drag or
set_selection requests has bad consequences, because this object has events
that allo tracking the state of a selection/drag-and-drop operation. Tracking
two operations at the same time isn't possible with this interface.

[1]: https://lists.freedesktop.org/archives/wayland-devel/2019-January/039936.html

Signed-off-by: Simon Ser <contact@emersion.fr>
Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-04-04 11:39:08 +00:00
Simon Ser
cdd890a6f8 build: re-open main branch for regular development 2023-04-04 13:38:18 +02:00
Simon Ser
b2649cb3ee build: bump to version 1.22.0 for the official release 2023-04-04 09:58:31 +02:00
Simon Ser
cd036bb7b8 build: bump to version 1.21.93 for the RC1 release 2023-03-28 20:03:14 +02:00
Faith Ekstrand
eb19f99a5b Add a .mailmap file
This will let command-line Git tools re-map my name and e-mail address properly.
I'm using my personal e-mail address and not my Collabora address because I'm
not actively contributing to Wayland anymore and this is mostly for letting
people find me should they dig me up in the project history.

Signed-off-by: Faith Ekstrand <faith@gfxstrand.net>
2023-03-25 11:17:32 -05:00
Simon Ser
002e1f1d3a build: bump version to 1.21.92 for the beta release 2023-03-16 01:08:44 +01:00
Simon Ser
3956948fac client: fix wl_display_disconnect() documentation
Signed-off-by: Simon Ser <contact@emersion.fr>
Closes: https://gitlab.freedesktop.org/wayland/wayland/-/issues/361
2023-03-07 13:22:43 +00:00
Alexandros Frantzis
b01a85dfd5 client: Do not warn about attached proxies on default queue destruction.
If the default queue is being destroyed, the client is disconnecting
from the wl_display, so there is no possibility of subsequent events
being queued to the destroyed default queue, which is what this warning
is about.

Note that interacting with (e.g., destroying) a wl_proxy after its
wl_display is destroyed is a certain memory error, and this warning will
indirectly warn about this issue. However, this memory error should be
detected and warned about through a more deliberate mechanism.

Signed-off-by: Alexandros Frantzis <alexandros.frantzis@collabora.com>
2023-03-01 15:50:02 +02:00
Simon Ser
344d31f871 build: bump version to 1.21.91 for the alpha release 2023-02-28 17:15:31 +01:00
Alexandros Frantzis
d72f9007c3 client: Abort when trying to add an event to a destroyed queue
Detect when we are trying to add an event to a destroyed queue,
and abort instead of causing a use-after-free memory error.

This situation can occur when an wl_event_queue is destroyed before
its attached wl_proxy objects.

Signed-off-by: Alexandros Frantzis <alexandros.frantzis@collabora.com>
2023-02-28 11:22:04 +00:00
Alexandros Frantzis
e09010f470 tests: Support tests that check for client failure
Add the display_destroy_expect_signal() function to check that test
clients exit due to a particular signal. This is useful for checking
that clients fail in an expected way.

Signed-off-by: Alexandros Frantzis <alexandros.frantzis@collabora.com>
2023-02-28 11:22:04 +00:00