Commit Graph

1674 Commits

Author SHA1 Message Date
Robert Mader 68e2a606c0 clients/simple-dmabuf-v4l: Add pointer support
To make the app a little bit more pleasant to work with and, crucially,
makes the cursor hide in fullscreen mode. This is useful when testing
hardware planes on devices with no cursor plane / a single primary plane.

Also add an option to keep the cursor around in fullscreen mode.

Signed-off-by: Robert Mader <robert.mader@collabora.com>
2023-08-31 21:32:36 +00:00
Robert Mader 6cee95af37 client/simple-dmabuf-v4l: Add fullscreen support
Effectively making the app behave very similar to a simple video player.
It was useful to me for testing hardware plane YUV support, so it's
likely worth upstreaming.

If available, wp_viewporter is used to scale up the image. The width to
height ratio is kept, allowing to further test black bars in fullscreen
mode.

For now scaling is only applied if xdg-shell is used.

Signed-off-by: Robert Mader <robert.mader@collabora.com>
2023-08-31 21:32:36 +00:00
Robert Mader bf209e3985 clients/simple-dmabuf-v4l: Use interface name variables
It's good practice nowadays, so let's be a good example.

Signed-off-by: Robert Mader <robert.mader@collabora.com>
2023-08-31 21:32:36 +00:00
Robert Mader d5753805b7 clients/simple-egl: Use interface name variables
It's good practice nowadays, so let's be a good example.

Signed-off-by: Robert Mader <robert.mader@collabora.com>
2023-08-31 21:32:36 +00:00
Tomohito Esaki d31ab9163d clients/simple-dmabuf-egl: Drop support libgbm older than 21.1.1
Since clients using dmabuf require libgbm 21.1.1, there is no need to
support the old libgbm which does not support modifiers.

Signed-off-by: Tomohito Esaki <etom@igel.co.jp>
2023-08-09 21:45:42 +03:00
Tomohito Esaki fef8410866 clients/meson.build: Require libgbm 21.1.1 for clients using dmabuf
Since drm-backend requires libgbm 21.1.1, client samples using dmabuf
should be similar to drm-backend.

Signed-off-by: Tomohito Esaki <etom@igel.co.jp>
2023-08-09 21:45:42 +03:00
Tomohito Esaki 1ffd387d0e clients/simple-dmabuf-feedback: Drop support libgbm older than 21.1.1
Since simple-dmabuf-feedback requires libgbm 21.1.1, there is no need to
support the old libgbm which does not support modifiers.

Signed-off-by: Tomohito Esaki <etom@igel.co.jp>
2023-08-09 21:45:42 +03:00
Marius Vlad 5b1207a425 Revert "clients/window: Update min_allocation for smaller widths/heights"
This seems to break interactive resize, giving invalid/0/negative values
to pending allocations.

This reverts commit 9555118095.

Fixes: #780
Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2023-07-19 14:40:03 +03:00
Simon Ser 8c4128df5d clients/simple-dmabuf-feedback: do not block until rendering completes
glFinish() blocks until all commands have finished. This is
unnecessary: we can use glFlush() and rely on implicit sync
instead.

Signed-off-by: Simon Ser <contact@emersion.fr>
2023-07-14 10:49:44 +00:00
Simon Ser 0349f15269 clients/simple-dmabuf-egl: do not block until rendering completes
glFinish() blocks until all commands have finished. This is
unnecessary: we can use glFlush() and rely on implicit sync
instead.

Signed-off-by: Simon Ser <contact@emersion.fr>
2023-07-14 10:49:44 +00:00
Marius Vlad 9555118095 clients/window: Update min_allocation for smaller widths/heights
This makes sure we update min_allocation in situations where the
width and height passed is smaller than the one set previously
(obviously except for the first time). This has the side effect of
not overwriting pending_allocations such that we correctly resize when
passed a width/height smaller the ones set-up in the past.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2023-07-05 21:28:16 +03:00
Derek Foreman f0196739ae toy-toolkit: Fix rotations
Ever since commit 3012934 some rotations have been broken. This is because
I transposed xy and yx in the cairo_matrix_init() call.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2023-06-27 11:41:35 +00:00
Sergio Gómez 03aeb4bd83 clients: Replace 'confine' client to showcase pointer constraints in general
The 'confine' client is used to showcase the behavior of pointer confinement
through the interface zwp_confined_pointer_v1.

Since zwp_confined_pointer_v1 is part of pointer constraints in general, which
includes pointer locking, it makes sense to augment the scope of the client so
it can serve as a showcase for this category of interfaces through
zwp_pointer_constraints_v1.

Currently 'confine' relies on, and is designed around the limitations of, the
toytoolkit. Adapting the toytoolkit for the new requirements proved
unproductive, especially since we wish to add support for pointer constraints in
sub-surfaces. Hence the solution adopted was to write a new client that would
replace the previous one.

This patch introduces the new client, 'constraints.c', replacing 'confine.c'.

Signed-off-by: Sergio Gómez <sergio.g.delreal@gmail.com>
2023-06-14 16:26:34 -05:00
Loïc Molinari fff8dbd9b8 gl-renderer: Move clip_quad() to clipper
clip_quad() is a dedicated clipping function for quads that doesn't
depend on any GL renderer internal structures. It can be moved out to
the clipper to be called by both the renderer and the clipping test
client without having to duplicate code.

Signed-off-by: Loïc Molinari <loic.molinari@gmail.com>
2023-06-12 11:15:51 +00:00
Loïc Molinari 3d94f943a6 gl-renderer: Update HTTP links to vertex clipping resources
Signed-off-by: Loïc Molinari <loic.molinari@gmail.com>
2023-06-12 11:15:51 +00:00
Loïc Molinari 39fee794b5 gl-renderer: Get rid of axis-aligned bbox check in simple clipper
Since both the surface rect and the transformed quad are axis-aligned
in the simple clipping path, non-zero area detection can more
efficiently be checked post-clipping by comparing opposite edges.

Signed-off-by: Loïc Molinari <loic.molinari@gmail.com>
2023-06-12 11:15:51 +00:00
Loïc Molinari d34f35c904 gl-renderer: Use simple clipper on translated and/or scaled nodes
Add a basic check to let the clipper take the simple axis-aligned path
when nodes are solely transformed with a translation and/or a scaling.
That makes some nodes like sub-surfaces (which always have their
transform enabled) take the fast path in the common case.

Signed-off-by: Loïc Molinari <loic.molinari@gmail.com>
2023-06-12 11:15:51 +00:00
Loïc Molinari 49053a2aa2 gl-renderer: Store clipped vertices directly into the vertex buffer
Move vertex clipper back to single-precision floating point
intermediates. Since positions are sent down the graphics hardware as
single-precision values, this prevents useless conversions between
single and double precision values and lets compilers fit twice as
much data into vector registers. It also removes a copy by letting the
clipper store vertices directly into the vertex buffer.

This is mostly reverting the conversion to double-precision that
happened along with the switch to the weston_coord struct for vertex
coordinates (commit 10e70bf23c).

Signed-off-by: Loïc Molinari <loic.molinari@gmail.com>
2023-06-12 11:15:51 +00:00
Loïc Molinari a4d31fa8bd gl-renderer: Decouple coord space transformation from clipper
The clipper transforms dirty rects to surface space before clipping.
Each dirty rect is transformed by the same matrix for each surface
rect. This change decouples the transformation and the clipping code
to transform and compute the bounding box of dirty rects just once.

Signed-off-by: Loïc Molinari <loic.molinari@gmail.com>
2023-06-12 11:15:51 +00:00
Loïc Molinari 54bce80c73 gl-renderer: Clip and dispatch vertices in surface coord space
Clip dirty rects to surface rects in surface coordinate space.
Dispatch vertices in surface coordinates and let the graphics hardware
handle the transformations. Clipping in global coordinate space
implies a useless roundtrip on the CPU to get the clipped polygons
back in surface coordinates for the buffer transformation. Clipping in
surface coordinate space prevents that.

This might seem counter-intuitive at first because in surface space
it's the dirty rects that are clipped to axis-aligned surface rects,
while it's the opposite in global space.

The projection matrix now combines the view and the output transforms.

Signed-off-by: Loïc Molinari <loic.molinari@gmail.com>
2023-06-12 11:15:51 +00:00
Simon Ser fe49534488 clients/scaler: check viewporter availability
I just got bitten by this: I thought my compositor was dropping
the viewport somehow, but it just didn't expose the viewporter
global.

Signed-off-by: Simon Ser <contact@emersion.fr>
2023-05-02 18:02:33 +03:00
Sebastian Wick 34400d7d16 clients/simple-dmabuf-feedback: get buffer size from configure events
instead of the output mode. The mode doesn't say anything about the
actual output geometry which could lead to buffers extending the output
region on rotated monitors. This now also works with moving the window
to different monitors.

Signed-off-by: Sebastian Wick <sebastian.wick@redhat.com>
2023-04-20 11:42:15 +00:00
Sebastian Wick 6c27f0b87c clients/simple-dmabuf-feedback: create buffers on demand
Signed-off-by: Sebastian Wick <sebastian.wick@redhat.com>
2023-04-20 11:42:15 +00:00
Sebastian Wick 62d7a46ba2 clients/simple-dmabuf-feedback: fullscreen surface from the start
Signed-off-by: Sebastian Wick <sebastian.wick@redhat.com>
2023-04-20 11:42:15 +00:00
Sebastian Wick 57cba6afb4 clients/simple-dmabuf-feedback: fix dangling pointers
to presentation feedback objects.

Signed-off-by: Sebastian Wick <sebastian.wick@redhat.com>
2023-04-20 11:42:15 +00:00
Bram Stolk 26de6e35a9 simple-dmabuf-v4l: Add support to NV12 devices that combine planes
There are V4L2 devices that will output NV12 but will do so using one dma
buffer. To support this, we need to add the same dma buffer twice but with
a different offset for the chrominance plane.
Also supports situations of 3 planes (e.g. YU12) inside a single dma buffer.

Fixes: #712
Signed-off-by: Bram Stolk (b.stolk@gmail.com)
2023-04-18 10:57:55 +00:00
marius vlad 1446d9cb3c client-shm: Add basic keyboard support
And use it to exit with using the KEY_ESC, similar to simple-egl.
This was ripped from simple-egl ad litteram.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2023-04-12 14:40:38 +03:00
marius vlad 2e0b67e5be simple-shm: Add maximized/fullscreen support
Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2023-04-12 14:40:38 +03:00
marius vlad cd634c34ed simple-shm: Use buffers as a list
Rather than having them as an array. This would simplify handling of
maximized and fullscreen and make things easier to reason with.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2023-04-12 14:40:38 +03:00
Marius Vlad 76f689e370 simple-touch: Add maximized/fullscreen states
Helpful to have other states like maximized or fullscreen for
the simple-touch client.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2023-04-12 14:40:38 +03:00
Michael Olbrich 14fc87cc42 clients/window: dismiss window on tablet tool up events
Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
2023-03-31 12:10:26 +00:00
Lyude Paul 0b0c6e7ad7 clients: Add demo application for tablets
Note that this application does not follow best practices for handling tablet
events. The events are grouped by frame, all processing should be done in the
frame instead of the respective handler.

A good toolkit would accumulate the data in the events and provide them as one
event to the actual client once the frame is received. toytoolkit just hooks
up the handler one-by-one, so we're doing this here as well.

Co-authored-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Lyude Paul <thatslyude@gmail.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Bastian Farkas <bfarkas@de.adit-jv.com>
Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
2023-03-31 12:10:26 +00:00
Lyude Paul 017eac1a6b clients/desktop-shell: Add tablet support to the top panel of the desktop shell
Co-authored-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Lyude Paul <thatslyude@gmail.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Bastian Farkas <bfarkas@de.adit-jv.com>
Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
2023-03-31 12:10:26 +00:00
Lyude Paul 6a06669b58 clients: Add support for tablet cursor motion to window frames in libtoytoolkit
When it comes to a window frame, a tablet tool and cursor act almost
identical; they click things, drag things, etc. The tool type and extra
axes don't serve any use in the context of a window frame, so tablet
pointers share the frame_pointer structures used for the mouse pointer.

Co-authored-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Lyude Paul <thatslyude@gmail.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Jonas Ådahl <jadahl@gmail.com>
Signed-off-by: Bastian Farkas <bfarkas@de.adit-jv.com>
Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
2023-03-31 12:10:26 +00:00
Lyude Paul 0ced0c62ee clients/window: Add tablet cursor support into libtoytoolkit
Again, a lot of this is code that has been reused from the cursor code
for pointers.

Co-authored-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Lyude Paul <thatslyude@gmail.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Jonas Ådahl <jadahl@gmail.com>
Signed-off-by: Bastian Farkas <bfarkas@de.adit-jv.com>
Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
2023-03-31 12:10:26 +00:00
Michael Olbrich 76ada6fe04 clients/window: add support for handling tablets
Based on a patch from:
Peter Hutterer <peter.hutterer@who-t.net>
Lyude Paul <thatslyude@gmail.com>

Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
2023-03-31 12:10:26 +00:00
Robert Mader 9337d42741 clients/simple-egl: Implement fractional-scale protocol support
Fractional scale is increasingly common in the Wayland ecosystem. Thus,
given simple-egl's role as egl example client, implement support for
the new protocol - even though Weston itself does not support it yet.

Together with buffer_scale and buffer_transform this ensures
simple-egl provides optimally sized and oriented buffers.

Signed-off-by: Robert Mader <robert.mader@collabora.com>
2023-03-31 10:08:36 +00:00
Leandro Ribeiro 190770e31c clients/simple-dmabuf-feedback: drop outdated comment
There's a comment explaining how to hack the DRM-backend in order to
fake that a certain format is not supported by the KMS device. This is
useful in order to test dma-buf feedback implementations using the
simple-dmabuf-feedback client. But with recent changes on the
DRM-backend, this got outdated.

Drop this comment, as everyone interested in this client is probably
familiar enough with the DRM-backend in order to do that.

Also made some adjustments to other comments explaining how this client
works.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2023-03-28 16:23:44 -03:00
Daniel van Vugt 183d92e291 clients/simple-dmabuf-feedback: Remove unsupported f suffixes
NVIDIA is more pedantic than Mesa and correctly complains that `1.0f`
is not valid syntax in the OpenGL ES Shading Language version 1.00.
And we are indeed using SL version 1.00 by virtue of using an ES 2.0
context.

So use the syntax compatible with the context we've created.

Signed-off-by: Daniel van Vugt <daniel.van.vugt@canonical.com>
2023-03-17 15:40:22 +08:00
Derek Foreman 10e70bf23c clipping: Use struct weston_coord in vertex clipping code
Remove the independent x, y floats from the clipping code and replace them
with struct weston_cord. This includes the polygon8 structure as well.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2023-02-09 12:12:40 +00:00
Derek Foreman 030edb5c48 clients/simple-egl: Add a vertical bar mode
Add an animation that moves a vertical bar from left to right. This is
nice for testing the tearing extension.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2023-02-01 10:12:55 -06:00
Derek Foreman 5191113638 clients/simple-egl: Refactor out drawing code
Pull the triangle draw code into its own function so we can more readily
add other animations later.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2023-02-01 10:12:55 -06:00
Derek Foreman ab897491df clients: Add tearing control to simple-egl
Add a new command line option to test the tearing-control protocol.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2023-02-01 10:12:53 -06:00
Derek Foreman 3012934a6d ttk: Use weston_matrix_init_transform in toy toolkit
Setup the cairo matrix with our new transform function.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2023-01-16 17:01:54 +00:00
Marco Felsch a8e93ed90f ivi-shell: add screenshot capability
Various shells provide the functionality to take screenshots using the
weston-screenshooter or a key combination. This is useful on the ivi-shell, too.

Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
2022-12-07 10:17:45 +02:00
Michael Tretter 6bcfc43a88 clients/screenshot: build screenshooter with kiosk-shell and fullscreen-shell
The output capture protocol is also provided by the kiosk shell and the
fullscreen shell. Therefore, the weston-screenshooter to take screenshots should
be built if the desktop shell is disabled, too.

Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
2022-12-07 10:17:45 +02:00
Pekka Paalanen 949b2eb751 clients: rewrite screenshot.c for new protocol
The functionality of this screenshooting helper client is kept exactly
the same as before: if you have multiple outputs, some transformed, some
scale, in any layout, this will create a "multi-image" where the
framebuffer (the physical image) of each output is pasted into a row of
images in the order the outputs were advertised thrugh wl_registry.
Output transform or scale are not accounted for. If you have a monitor
rotated sideways, the screenshot will have the image of that monitor
reverse-sideways.

Otherwise the client is almost completely re-written, so trying to read
the diff is not that useful.

The old screenshooting protocol is replaced with the new
weston-output-capture protocol. This makes it unnecessary to listen for
wl_output information (since we do not handle output transform or scale
anyway).

The buffer sizes and formats are dictated by the compositor, which also
means we cannot hardcode the format. Hence, use Pixman for the blitting,
in case it needs to do format conversion. It is good to get rid of
hand-crafted pixel data manipulation code too.

For that reason we also need a pixel format database to convert between
DRM fourcc, wl_shm and Pixman codes. We link to libweston to borrow its
database instead of inventing another partial copy of it. It's weird to
use compositor library private API in a client, but better than the
alternative.

The original code had no tear-down code at all. Now, if everything
succeeds, the program ends with no unfreed memory according to ASan. If
something fails, it still YOLO's it (doesn't free stuff). That's how far
my pedantry carried.

I also did not bother taking output transform or scale into account,
since the old code did not either. It would be nice to create a seamless
image of the desktop with shots rotated and scaled to align, in the max
scale over all outputs. Meh.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-11-29 11:12:32 +02:00
Marius Vlad 75b6758fd2 simple-dmabuf-feedback: Correct the rectangle orientation
Similar to changes in simple-dmabuf-egl, this perform a x-axis
reflection as it has the same NDC values as simple-dmabuf-egl and we get
an inverted image. We do it straight in the shader this time.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2022-11-07 11:54:15 +02:00
Simon Ser 9b455e24a2 clients/simple-dmabuf-egl: drop Y_INVERT flag
The motivations for this are:

- Y_INVERT is not used by most real-world clients.
  weston-simple-dmabuf-egl and weston-simple-dmabuf-v4l are one only
  known users. Thus this creates a special case just for these demo
  clients.
- Some compositors (wlroots) have dropped support for DMA-BUF flags,
  so the client no longer runs there.
- Dropping the flag allows compositors to use a KMS hardware plane to
  display the buffer.

It keeps the same axis orientation we had in place where we had the
y-invert flag enabled by default, by doing a reflection about x-axis.

Signed-off-by: Simon Ser <contact@emersion.fr>
Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
Closes: https://gitlab.freedesktop.org/wayland/weston/-/issues/675
2022-11-07 11:28:29 +02:00
Derek Foreman 5079f0b2f9 helpers: Add a u64 from 2 u32 helper
We do this enough that having a single implementation for it is probably
a win.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2022-10-27 08:13:30 +00:00
Robert Mader ff459f0273 simple-egl: Add option for fixed width/height fullscreen ratio
As a realistic scenario used by clients.

The motivation is to have an easy way to test correct fullscreen
behavior of compositors, as they have to compensate for the smaller
buffer size by adding black bars.

Signed-off-by: Robert Mader <robert.mader@collabora.com>
2022-10-05 15:42:35 +03:00
Marius Vlad b87418e4c4 clients/eventdemo: Remove duplicated param entries
Removes doxygen warning.

Fixes #664

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2022-09-14 16:46:24 +03:00
Derek Foreman 11ba13d717 clients: Fix cursors when compositor gives wl_seat before wl_compositor
We have no guarantee that we can create a surface for the pointer at the
instant we receive a seat that will (probably eventually) need one.

Hold off until we receive an enter event before creating this - at that
point we know with certainty that wl_compositor is available, since we've
used it to create the surface that was entered.

Fixes #659

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2022-09-12 11:53:41 -05:00
Marius Vlad 32791eae1f simple-egl: Update buffer_size dimensions when starting as maximized
With commit 62ab6891db, 'clients/simple-egl: Handle buffer
scale and transform' we changed the way we resized the client, by
encapsulating the resize in update_buffer_geometry() function.

we didn't correct that when creating the EGL window, which might be
problematic if you attempt to start the window with different a
different state, like maximized.

Fixes 62ab6891db

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2022-08-22 18:22:57 +03:00
Erik Kurzinger 8f1ca8204a clients/simple-egl: call eglSwapInterval after eglMakeCurrent
If weston-simple-egl is run with the "-b" flag, it will attempt to set
the swap interval to 0 during create_surface. However, at that point, it
will not have made its EGLContext current yet, causing the
eglSwapInterval call to have no effect. To fix this, wait until the
EGLContext has been made current in init_gl before updating the swap
interval.

Signed-off-by: Erik Kurzinger <ekurzinger@nvidia.com>
2022-08-12 08:22:26 -07:00
Derek Foreman 646cc1b389 clients: Set the hotspot with attach if we already have a valid cursor
We want atomic hotspot updates - this can't happen with
wl_pointer_set_cursor. So if we have a surface that already has a cursor
role, just update the hotspot when attaching new content.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2022-08-10 13:05:09 -05:00
Derek Foreman ebbe30df3c Revert "clients/window: atomically update pointer cursor"
This reverts commit 992ee045f1.

Recreating the surface for every cursor change causes flickering
cursors on some compositors, and is not the best way to achieve
atomic cursor updates

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2022-08-10 13:05:07 -05:00
Derek Foreman 8b0125d601 Revert "clients/window: Fix animated cursors"
This reverts commit f079f43658.

This only partially fixed a problem introduced in
992ee045f1

I'm reverting that commit in favor of a different fix, so this
broken fix needs to go first.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2022-08-10 13:04:27 -05:00
Marius Vlad 6744a6278e clients/window: Bump xdg-shell version to latest
It seems we've missed an update from 3 to 4 (bounds events). With it,
this updates to version 5 which sends the capabilities event. Stubs, as
we're not using them.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2022-07-26 16:17:43 +03:00
Pekka Paalanen c95feefbc0 clients/simple-touch: use xzalloc() for buffer
This file relied on shared/xalloc.h to include <libweston/zalloc.h>.
That would be a problem if xalloc.h stopped doing that.

Just use xzalloc().

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-07-20 12:45:04 +03:00
Pekka Paalanen 9229a45116 shared: rewrite fail_on_null() as abort_oom_if_null()
Recently I learnt that fprintf() is not async-signal-safe. Maybe it also
attempts to allocate memory sometimes. Hence, using it when we
presumably are out of memory is wishful thinking.

Therefore replace that with async-signal-safe code. If you have to check
pointers from traditional signal handlers, now you could do that too!

While doing this, we also lose the string formatting for line number. I
would argue that printing file and line number is not that useful, if
the system really is out of memory. If not out of memory, a core dump
would give us much more detailed information about what went wrong.

clients/window.c had some calls to fail_on_null() and these are simply
replaced. They were used for checking that creating new wl_proxy by
issuing a protocol request worked, and IIRC that only fails on
out-of-memory, so the same rationale applies here.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-07-20 12:44:12 +03:00
Daniel Stone 965d90cbaa desktop-shell: Use custom_env to launch panel clients
Rather than open-coding our own implementation of parsing a string to
construct an envp and an argp, just use custom_env's implementation.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-07-19 14:12:37 +00:00
Michel Dänzer 77fb2f56af clients/presentation-shm: Bind to xdg_wm_base version 1
It was binding to any advertised version, but it can't actually work
with version 4 (because it doesn't handle the new configure_bounds
event).

Other sample clients in the tree are hard-coding version 1, so do the
same here.

Fixes: 6d9fda7156 ("clients/presentation-shm: use xdg_shell instead of wl_shell")
Signed-off-by: Michel Dänzer <mdaenzer@redhat.com>
2022-06-30 15:16:46 +02:00
Daniel Stone c55a14206d cairo-util: Clean up more Cairo detritus; almost all of it
Pango, Cairo, and fontconfig, all want to leave thread-global data
hanging around in order to maintain a cache. Try to clean up as much of
it as we possibly can on exit, apart from the Pango language string
which appears to be unfreeable, so has been added to LSan suppressions.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-06-29 14:33:21 +01:00
Daniel Stone d43931080e weston-terminal: Don't leak Cairo fonts
The docs say they're ours to unref.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-06-29 14:33:21 +01:00
Daniel Stone fc4fb9fb92 weston-terminal: Make exit path a little more obvious
Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-06-29 14:33:21 +01:00
Daniel Stone f9e54ab2f8 weston-terminal: Fix some egregious memory leaks
Some of the Pango bits still leak, but this takes care of a lot of the
worst.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-06-29 14:33:21 +01:00
Daniel Stone 6bfbfb2e10 toytoolkit: Delete remnants of EGL support
This code was all dead, since neither cairo-glesv2 nor the sample nested
compositor ever made it to the Meson build.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-06-29 14:33:21 +01:00
Marius Vlad cc69dc447e clients/window: Defer closing of window
Instead of closing the window directly by calling close_handler() use a
deferred task to do that instead.

That way we avoid a potential invalid access on a link which was
previously removed, due to the fact both window_destroy() and
touch_handle_up() traverse the same list.

This is an alternative to 841.

Fixes: #607.

Suggested-by: Pekka Paalanen <pekka.paalanen@collabora.com>
Reported-by: He Yong <hyyoxhk@163.com>
Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2022-06-22 15:29:05 +03:00
Robert Mader f7541d9e42 clients/simple-egl: Fix angle reset on benchmark interval
Commit 62ab6891db intended to change the angle calculation
so that the a time delta since the first frame would be used
instead of the absolute time. That was done in order to ensure
the angle would always start with the same value, allowing users
to differentiate left and right, which again is needed when
testing flipped transforms.

However, the `benchmark_time` variable is unsuitable for that
purpose as it gets reset on each benchmark interval, abruptly
changing the angle.

Thus introduce a dedicated variable.

Fixes 62ab6891db

Signed-off-by: Robert Mader <robert.mader@collabora.com>
2022-06-14 13:11:59 +02:00
Robert Mader 62ab6891db clients/simple-egl: Handle buffer scale and transform
Buffer scale is common enough in the modern desktop space to
expect average GL clients to handle it. Thus lets include it into
our main example client.

While on it, also handle buffer transforms. It's essentially free
for GL clients in terms of computing power but may increase the
chance that Wayland compositors are able to hit scanout fast paths.
Thus having an example client for it is likely valueabel for client
and compositor developers.

Signed-off-by: Robert Mader <robert.mader@collabora.com>
2022-05-31 12:08:06 +00:00
Robert Mader 0b2369bb4a clients/simple-egl: Rename geometry to buffer_size
To reflect more clearly that we use it for `wl_buffer` coordinates.

Signed-off-by: Robert Mader <robert.mader@collabora.com>
2022-05-31 12:08:06 +00:00
Robert Mader 009625c297 clients/simple-egl: Rename buffer_size to buffer_bpp
`buffer_size` usually refers to `wl_buffer` size in the Wayland world.

Signed-off-by: Robert Mader <robert.mader@collabora.com>
2022-05-31 12:08:06 +00:00
Robert Mader 4090f0eb6f clients/simple-egl: Use INT32_MAX for opaque region
Setting the opaque region correctly is common source of error for
clients that simply want to express that a whole surface is opaque.
This is especially true once buffer_scale and buffer_transform come
into play, as unlike for damage, where buffer_damage is the
encouraged and user friendly way today, opaque regions are always
in logical coordinates.

As faulty opaque regions don't have a visual impact in these cases
but only increase resource consumption, these errors often remain
for long times. See
1e2bc68171
for one of many examples.

Give an easy example how to set the opaque region in a conformant
and reliable way.

Signed-off-by: Robert Mader <robert.mader@collabora.com>
2022-05-31 12:08:06 +00:00
Robert Mader 572ad2d8a9 clients/simple-dmabuf-*: Use gbm_bo_create_with_modifiers2
It is used in Mesa. Lets switch to it as well in order to provide
good examples and encourage proper API usage.

Signed-off-by: Robert Mader <robert.mader@collabora.com>
2022-05-23 13:25:34 +00:00
Robert Mader 46a6b5b448 clients/simple-dmabuf-feedback: Support multi-tranche feedbacks
Compositors may choose to send multiple scanout or non-scanout
tranches. So instead of assuming that the first respective tranche
contains the format/modifier we're looking for, check all tranches.

While on it, make sure that in case a compositor sends scanout
tranches on the initial feedback, `pick_format_from_scanout_tranche()`
does not unintentionally pick `INITIAL_BUFFER_FORMAT`.

Signed-off-by: Robert Mader <robert.mader@collabora.com>
2022-05-23 13:21:38 +00:00
Daniel Stone a55bd6798e clients: Delete gears
It doesn't and can't build, because it depends on cairo-gl. We already
have simple-egl which shows how to use EGL/GLESv2 on Wayland.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-05-23 13:45:57 +01:00
Robert Mader 34f7e01c2b clients/simple-dmabuf-feedback: use time instead of redraws
Weston uses a timeout of 2 seconds before it sends scanout
tranches to clients in order to not trigger excessive buffer
reallocations in clients.
`simple-dmabuf-feedback` in turn counts redraws (200) before
exiting. That doesn't work on e.g. 144Hz screens, thus use a
timer here as well.

Signed-off-by: Robert Mader <robert.mader@collabora.com>
2022-05-12 11:53:04 +00:00
Erik Faye-Lund fed2ee51f2 simple-egl: clean up unused callback
Unused since 45ee1f9ef7, which itself
removes code that was unused since
1e65840b61.

Signed-off-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
2022-05-10 08:03:27 +00:00
Simon Ser 6122765203 clients/simple-dmabuf-feedback: prettify output
- Use more consistent style, e.g. the tree structure uses
  the same indentation level throughout
- Swap format name and code for consistency with modifiers
- Use constants for ASCII art (taken from drm_info)

Signed-off-by: Simon Ser <contact@emersion.fr>
2022-05-02 19:36:07 +02:00
Marius Vlad 054aaa5a8b simple-egl: Move set_fullscreen/set_maximized before initial commit
Rather than setting the fullscreen/maximized before initial
wl_surface.commit, make it part of the initial window state.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
Suggested-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-04-29 12:42:46 +03:00
Marius Vlad 0277046a1d simple-egl: Defer EGL surface/window creation
Rather than creating the wl_egl_window at the same time as wl_surface,
do it after we get the first configure event.

With it, we also defer eglMakeCurrent() as according to the spec, the
first time a OpenGL or OpenGL ES context is made current, the viewport
and scissor dimensions are set to the size of the draw surface.

This is particulary important when attempting to start simple-egl either
as fullscreen or as maximized, as not doing so will either incorrectly
commit a buffer with the original dimensions, and later on to resize to
the correct dimensions (which is the case for fullscreen), or it will
terminate the wayland connection abruptly due to xdg-shell protocol
violation, with a mismatch for the client's geometry (the case for
maximized).

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
Suggested-by: Daniel Stone <daniel.stone@collabora.com>
2022-04-29 12:34:51 +03:00
Marius Vlad c15699b7f8 simple-egl: Remove uneeded check
display->wm_base is checked right after handling registry object, and
with it the globals, so there's no to perform and additional check for
xwm_base.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2022-04-29 12:34:36 +03:00
Marius Vlad 01ef3746a2 simple-egl: Add start as maximized
Just like start as fullscreen, let us add a start as maximized as well.
It tests out the maximized state and with clients geometry checks.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2022-04-29 12:34:36 +03:00
Simon Ser 778c0683c0 clients/simple-dmabuf-feedback: use presentation-time
Print a message when presentation switches to/from zero-copy mode.
This makes it easier to understand whether the compositor DMA-BUF
feedback was effective.

Signed-off-by: Simon Ser <contact@emersion.fr>
2022-04-27 14:21:55 +02:00
Leandro Ribeiro 7724c5ea38 clients/simple-dmabuf-feedback: do not use buffer before compositor's response
This fixes an issue when running simple-dmabuf-feedback:
"wl_display@1: error 1: invalid arguments for wl_surface@3.attach".

As we are not using create_immed request from zwp_linux_dmabuf_v1, we
can't start to use a dma-buf buffer before we process compositor's event
telling us that the creation succeeded.

This was causing problems in the following scenario:

1. buffer is marked to be recreated (because of dma-buf feedback);
2. in buffer_release() event, we destroy the buffer and recreate it;
3. after we recreate it, roundtrip is not called, as we don't want to
   block during the drawing loop;
4. buffer status is not being properly tracked, so we are trying to
   use a buffer before receiving the event from the compositor telling
   us that the creation succeeded.

To fix this, this patch improves buffer status tracking. Now we only
pick a buffer in the drawing loop when it is available. Also, if we have
no buffers available we perform a roundtrip and try again, as we may
have recreated all of them but still didn't have the chance to process
compositor's events telling us that creation succeeded.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2022-04-27 11:52:00 +00:00
Robert Mader 2669853562 clients/simple-dmabuf-feedback: Add fallback print method for unknown formats
Using `pixel_format_get_info()` can result in formats being
reported as `UNKNOWN` when used on compositors other than Weston.

As `weston-simple-dmabuf-feedback` somewhat succeeds `wayland-info`
as tool for `zwp_linux_dmabuf_v1` debugging from version 4 on, copy
the approach from the later for these cases.

Signed-off-by: Robert Mader <robert.mader@collabora.com>
2022-03-11 13:56:17 +01:00
nerdopolis 8e2c67c317 clients/desktop-shell: Add a displayname= option for launchers
Signed-off-by: n3rdopolis <bluescreen_avenger@verizon.net>
2022-02-24 00:38:55 +02:00
Robert Mader 3e6ef529f8 clients/simple-dmabuf-*: Increase buffer limit to four
In certain situations these clients crash a lot due to the low
buffer limit. Four buffers is also what EGL allows without blocking
and what is arguably the upper limit of what a compositor should
demand.

Signed-off-by: Robert Mader <robert.mader@collabora.com>
2022-02-17 12:26:41 +01:00
Simon Ser 7e70f9016a clients: drop weston-info
Users should rely on wayland-info from wayland-utils [1] instead.
We've been printing a deprecation since 85382d394a ("clients:
deprecate weston-info"), so users should be aware already.

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

Signed-off-by: Simon Ser <contact@emersion.fr>
2022-02-03 16:19:27 +00:00
Simon Ser dfab60c6ee clients/simple-dmabuf-feedback: fix bound global versions
It's invalid for a client to pass the compositor's supported version
directly to wl_registry_bind. For instance, under wlroots the client
will bind to wl_output version 4 and crash because it doesn't handle
the new "name" event.

Signed-off-by: Simon Ser <contact@emersion.fr>
2022-01-26 14:42:08 +00:00
Marius Vlad 3151220a9b clients/simple-*: Add appids for other clients
Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2022-01-21 18:39:23 +00:00
Marius Vlad b3544c26ad clients/window: Add functions to set/retrieve app_id
Adds appid for all clients using the toolkit, flower, fullscreen, image,
resizor, scaler, smoke, stacking, subsurfaces, terminal,
touch-calibrator, transformed, etc.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2022-01-21 18:39:23 +00:00
Derek Foreman f079f43658 clients/window: Fix animated cursors
Since commit 992ee045f1 we create a new surface when we update the cursor
image. This broke animated cursors by discarding any existing frame
callback used for timing, and moving the setup for frame callbacks to
after the commit on the pointer surface.

To fix this we need another surface commit for the frame callbacks, but
this alone is not enough to fix the regression, as a lingering kludge
intended to fix problems when reusing the pointer surface is no longer
working as intended.

Since we no longer re-use the same surface, we can delete the old surface
on pointer exit, along with any callbacks set on it. Then a frame callback
will be recreated naturally. This lets us remove the now broken kludge
from the past and restore animated cursor functionality.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2022-01-20 10:23:59 +00:00
Marius Vlad 3c5e6c536f clients/meson:build: Conditionally build dmabuf-feedback client
As mesa includes gbm_bo_get_fd_for_plane() from 21.1.0 version onwards,
build the dma-buf feedback client only after that. This should provide
some sanity for package maintainers, as this would need pulling a
rather newer mesa version to build it (which might not be available).

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2022-01-12 13:39:04 +00:00
Marius Vlad 9b82be0792 simple-egl: Don't set-up alpha for opaque/fullscreen
When setting the window as opaque or fullscreen (which creates an opaque
region) make it so we don't have any alpha pixels set.
This was mistakenly dropped from a previous patch series update to
simple-egl.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2022-01-12 13:35:31 +02:00
Marius Vlad 6eabd93d59 clients/simple-damage,simple-shm: Use calloc instead of malloc
This avoids some unwarranted errors about conditional jumps or
invalid access from ASan as malloc doesn't set the memory to zero.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2021-12-09 18:06:03 +02:00
Leandro Ribeiro a272604c00 clients/simple-dmabuf-feedback: pretty print format/modifier pairs
As [1] has already landed, use it to pretty print format/modifier pairs
of each dma-buf feedback tranche.

[1] https://gitlab.freedesktop.org/mesa/drm/-/merge_requests/108

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2021-12-07 11:55:40 -03:00
Daniel Stone 78ba71191a simple-egl: Avoid 30bpc configs
[XA]RGB8888 is almost universally the thing people want to use.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2021-11-27 09:57:46 +00:00
Leandro Ribeiro 18d9ad98b1 clients: add client to test the dma-buf feedback implementation
Simple client to test the dma-buf feedback implementation. This does not
replace the need to implement a dma-buf feedback test that can be run in
the CI. But as we still don't know exactly how to do this, this client
can be helpful to run tests manually.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
2021-11-25 11:16:54 -03:00