Commit Graph

8637 Commits

Author SHA1 Message Date
Philipp Zabel
746a03068e libweston, backends: store backend pointer in struct weston_head
Compositor code can use opaque pointer comparison to determine whether
a head belongs to a given backend. Store a backend pointer in struct
weston_head to enable the compositor to select the correct backend
specific output configuration code.

This also allows to use the backend pointer instead of the opaque
backend_id pointer to check whether a head belongs to a backend, so
replace the checks in all to_xyz_head() functions and drop backend_id.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2022-12-12 15:21:16 +01:00
Philipp Zabel
1e901fa2b7 backend-vnc: drop unnecessary output release
No output is created at this point. Even if an output existed,
it should be relased when the head ist destroyed.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2022-12-12 13:55:20 +01:00
Philipp Zabel
635aa225c6 backend-vnc: set flags of current mode instead of template
vnc_ensure_matching_mode() does not transfer flags from init_mode.
Set flags on the returned mode instead.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2022-12-12 13:55:20 +01:00
Philipp Zabel
853eb7327f backend-vnc: set head properties in vnc_head_create
Set static monitor strings and physical size once, on head creation.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2022-12-12 13:55:20 +01:00
Philipp Zabel
233e056b50 backend-vnc: allocate mode with xzalloc
Let xzalloc warn and abort when running out of memory.
With this, vnc_insert_new_mode() and vnc_ensure_matching_mode() can not
return NULL anymore. Remove the now unnecessary error handling.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2022-12-12 13:55:20 +01:00
Philipp Zabel
1e6e885e36 backend-vnc: allocate head with xzalloc
Let xzalloc warn and abort when running out of memory.
With this, vnc_head_create() doesn't need an error return value anymore.
Remove the now unnecessary error handling.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2022-12-12 13:55:20 +01:00
Philipp Zabel
2b3f5f7821 backend-vnc: allocate seat with xzalloc
Let xzalloc warn and abort when running out of memory and remove the
now unnecessary error handling.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2022-12-12 13:55:09 +01:00
Philipp Zabel
dfa845b1dd libweston: add missing struct weston_renderer forward declaration
struct weston_renderer is defined in libweston-internal.h, which is not
included from libweston.h. Add the missing forward declaration for the
renderer pointer stored in struct weston_compositor.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2022-12-09 17:04:01 +01:00
Philipp Zabel
84c10124cd compositor: support loading backend via shortened name
While the --backend parameter looks like it takes a file name, it really
is selected from a list of supported strings that are then funneled
through a translation to enum weston_compositor_backend [1].

Because all backend parameters are of the form "...-backend.so", and
writing "--backend=...-backend.so" is boring, allow the --backend option
to match the backend name without "-backend.so" suffix instead.

For example, this allows to use "--backend=headless" instead of
"--backend=headless-backend.so".

Update help text and documentation. Keep the old way working for
backwards compatibility.

[1] 50dbf38514 ("libweston: use enum to choose the backend")

Signed-off-by: Philipp Zabel <philipp.zabel@gmail.com>
2022-12-08 17:39:12 +01:00
Philipp Zabel
06eb28ba62 backend-x11: drop use_pixman from x11_backend
Now that the renderer type is stored in struct weston_renderer,
use that instead of use_pixman to determine the renderer type.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2022-12-08 09:44:20 +00:00
Philipp Zabel
e752c8737f backend-wayland: drop use_pixman from wayland_backend
Now that the renderer type is stored in struct weston_renderer,
use that instead of use_pixman to determine the renderer type.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2022-12-08 09:44:20 +00:00
Philipp Zabel
a9c1b41f3f backend-drm: drop use_pixman from drm_backend
Now that the renderer type is stored in struct weston_renderer,
use that instead of use_pixman to determine the renderer type.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2022-12-08 09:44:20 +00:00
Philipp Zabel
51c8882991 libweston: move headless_backend::renderer_type to weston_renderer::type
Move the renderer type from struct headless_backend into struct
weston_renderer to store the chosen renderer type in a unified manner.
This will later allow secondary backends to determine the renderer type
chosen by the primary backend.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2022-12-08 09:44:20 +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
Derek Foreman
1d36f7655d xwm: Assert if we try to fetch our own selection
Now that we don't accidentally delay our selection ownership changes,
let's assert() if we somehow find ourselves downloading our own selection,
as the assertion is simpler to understand than the mess that ensues if
we hit this.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2022-12-07 10:03:37 +02:00
Derek Foreman
11bcad116f xwm: Propagate selection ownership immediately
If we don't xcb_flush() when we set the selection owner, we end up with
a ridiculous corner case where we can run use a command line X client
like 'xclip -i -selection clipboard' to crash weston.

Start weston, ensure Xwayland is running (set a selection with xclip), set
the clipboard from a wayland client, then set the clipboard with xclip
again.

Since xclip doesn't do anything xwm notices except set the clipboard, it
won't provoke a flush on our selection ownership change. xclip will take
ownership, then we call xcb_convert_selection(), and THEN we flush, sending
out our pending ownership change and the xcb_convert_selection() request.

The ownership change takes place first, we attempt to get our own selection
and weston explodes in a mess.

Stop this from happening with a flush when changing selection ownership.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2022-12-07 10:03:37 +02:00
Derek Foreman
bb993df236 xwm: Don't crash when setting selection with no seat
It's possible to set the clipboard with no seat present - one way is to
use the RDP backend and then run 'xclip -i -selection clipboard' locally
without making an RDP connection.

Check if seat is NULL to prevent this from crashing.

Fixes #698

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2022-12-07 10:03:37 +02:00
Derek Foreman
a04fd99212 xwm: Fix selection if no seat present at startup
It's possible that there are no seats present at startup (especially with
the RDP backend, which creates and removes seats for connections), and
previously we'd just fail to set up XWayland cut and paste properly.

We should set up a listener and find a seat when one becomes available -
but we also need to switch seats if ours is removed.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
Co-authored-by: Hideyuki Nagase <hideyukn@microsoft.com>
2022-12-07 10:03:37 +02:00
Leandro Ribeiro
7344970552 libweston/input: update view transforms when pointer is constrained
When the pointer is constrained and the surface in which it is
constrained gets committed, we may warp the pointer in some
circumstances. In order to do that, we need the associated view
transforms up-to-date. So update view transforms when this surface gets
committed.

This fixes an issue in which we'd hit an assert when trying to warp the
pointer, as we were trying to transform views with dirty transforms.

This is a leftover of d611ab24fd
"libweston: Update view transforms more often".

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2022-12-06 13:52:09 -03:00
Derek Foreman
ef4d2955f0 libweston-desktop: Prevent spurious focus change signals
This should prevent extra focus signal emission the similarly to
how default_grab_pointer_focus() does, though we don't have the
surface jumping logic here.

This stops xdg pings from being sent every output repaint during
a grab when the pointer isn't in any windows belonging to the
grab parent.

An example would be running weston-terminal, bringing up the
right click pop-up, and moving the mouse onto the desktop while
another client causes repaints.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2022-12-02 16:07:25 +00:00
Derek Foreman
58de1aac5c libweston-desktop: Set grab client before calling grab functions
This prevents a spurious pointer focus clear at the start of a grab.
This would, for example, cause an extra pointer leave when bringing
up a right-click pop-up in a ttk app like weston-terminal.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2022-12-02 16:07:25 +00:00
Pekka Paalanen
142ec0f477 tests: add output_icc_decorations
Here are more tests for output decorations drawing, this time through
the color-lcms plugin. This is the only practical way to exercise the
input-to-output category of color transformations.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-12-02 13:36:25 +00:00
Pekka Paalanen
2cf85ab637 tests: add output-decorations
This adds a new test checking that output decorations (used in the
wayland-backend, here tested with headless-backend) are drawn correctly.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-12-02 13:36:25 +00:00
Pekka Paalanen
9b7084cfca tests: change shot argument type in verify_image()
Only the 'image' field of struct buffer is ever used here, so just
pass pixman_image_t instead of struct buffer.

This allows a future test to mangle a screenshot (e.g. convert pixel
format) before feeding it in.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-12-02 13:36:25 +00:00
Pekka Paalanen
e11a51709d compositor: add output-decorations option for headless
This will be used by a new test.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-12-02 13:36:25 +00:00
Pekka Paalanen
3746e163ab backend-headless: add option for output decorations
When the new option is enabled, headless backend will draw decorations
around its outputs. This makes the actual "framebuffer" larger by the
thickness of the decorations to keep the video mode area free for
clients.

This will be needed for a future test, that will ensure that GL-renderer
will paint the output decorations correctly.

The output title is deliberately NULL, because text rendering is
unpredictable and depends on e.g. what fonts are installed in the
system. Therefore screenshot testing of any text would be really
painful, so let's avoid that.

The decorations setup code is mostly copied from wayland-backend.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-12-02 13:36:25 +00:00
Derek Foreman
71cf2783d6 desktop-shell: Fix stuck panel
Ever since d611ab24 the panel surface's frame callback gets lost and the
panel stops updating after its first draw.

Fix this by dirtying the geometry in configure_static_view() after it
changes the layer list, since the layer list is considered part of
geometry.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2022-12-01 09:34:17 +00:00
Philipp Zabel
c448819b37 backend-wayland: do not try to release uninitialized seat
Do not call weston_seat_release() if Weston aborts before
weston_seat_init() could be called. This fixes a possible
segfault due to uninitialized list traversal in the error
path.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2022-11-30 14:11:22 +01:00
Pekka Paalanen
fdaf4cf320 libweston: deprecate weston_screenshooter_shoot()
Nothing in-tree uses this function, and its functionality has been
replaced with the weston-output-capture protocol extension which is
implemented in libweston core.

Users of this function should migrate to
weston_compositor_add_screenshot_authority() and replace custom
screenshooting protocols with weston-output-capture.xml installed by
libweston.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-11-29 11:12:32 +02:00
Pekka Paalanen
17df553bf3 compositor: remove weston-screenshooter protocol
There are no internal users left for this protocol, they have been
migrated to the new weston-output-capture protocol. There are no
external users, because this protocol was private and never installed.

Remove this dead code.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-11-29 11:12:32 +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
Pekka Paalanen
93a94e767b compositor: authorize new screenshooter protocol
This is necessary in order to convert clients/screenshot.c into the
protocol.

We authorize a client the same way as before: if the wl_client is the
one we spawned, it's allowed.

Allowing screenshots on --debug was authorized by an earlier patch in
compositor/main.c.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-11-29 11:10:33 +02:00
Pekka Paalanen
849b87e285 tests: rewrite screenshooting to use new protocol
Migrate the tst suite to using the new screenshooting protocol. This
ensures the new protocol and implementation work, and removes a user of
the old protocol so that the old protocol can be removed in the future.

Now that the compositor chooses the pixel format,
capture_screenshot_of_output() needs to convert to the expected format
in the tests when necessary.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-11-29 11:10:33 +02:00
Pekka Paalanen
e3046b129c tests: add output-capture-protocol test
For exercising various code paths in the server side protocol
implementation.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-11-29 11:10:30 +02:00
Pekka Paalanen
c93b18ea54 tests: use pixel-formats.h in create_shm_buffer()
Instead of starting yet another hand-crafted pixel format mapping table,
use the one we have.

Following patches want to be able to create XRGB8888 buffers, and later
even other formats.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-11-29 11:00:52 +02:00
Pekka Paalanen
e40a7eae67 compositor: make new screenhots free for all on --debug
Replicating the policy of the old screenshooting interface, allow all
screenshot to anyone with the new interface as well when --debug is
used.

Looks like there was one stray trailing space in unrelated code that my
editor deleted. Better this way.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-11-29 11:00:52 +02:00
Pekka Paalanen
f60c9cc1e9 gl-renderer: implement output capture
This services output capture tasks for the 'framebuffer' and 'full
framebuffer' pixel sources.

Both pixel sources come from the same source: the EGLSurface. The only
difference is the area. The EGLSurface contains the borders used for
output decorations, hence 'full framebuffer' is possible to capture.

We use GL_ANGLE_pack_reverse_row_order extension to make glReadPixels
return the image data in the layout we need for wl_shm buffers directly.
Without the extension we have to flip manually.

Another extension to the same effect is MESA_pack_invert, but this is
not specified for GL ES. It also uses a different token value, so it
cannot be directly substituted even if supported.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-11-29 11:00:52 +02:00
Pekka Paalanen
0c8c2c4016 pixman-renderer: implement output capture
This services output capture tasks for the 'framebuffer' and 'blending'
pixel sources.

Just like the old screenshooting path, the 'framebuffer' pixel source is
the hardware buffer, whether a shadow is used or not. This may not be
the best for performance, but you do get the real framebuffer contents.
Maybe it's rgb565, or even less.

When the shadow buffer is used, I realized it is effectively the same as
the intermediate blending buffer in GL-renderer when color management is
used. Pixman-renderer does non-linear blending only, so the shadow
buffer is in the blending space. The shadow buffer is also always 8 bpc
regardless of the hardware framebuffer, so the read-back may be
different from the hardware framebuffer. Read-back from the shadow is
optimal for performance, but not what the hardware gets.

'full-framebuffer' source cannot yet be implemented, because backends do
not tell Pixman-renderer about the margins where the wayland-backend
blits the output decorations. The target "hardware" buffer handed to
pixman-renderer does not allow accessing the decorations area.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-11-29 11:00:52 +02:00
Pekka Paalanen
c7f5de6d63 libweston: add pixel_format_get_shm_format()
This will be useful for client code that wants to create a wl_shm buffer
with a DRM format code.

The test suite will be using this.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-11-29 11:00:52 +02:00
Pekka Paalanen
3700c78131 libweston: implement new screenshooting protocol base
This implements the basics of the new screenshooting protocol. The
actual pixel operations will be implemented separately in the renderers
and DRM-backend.

See the previous commit "protocol: new screenshooter protocol" for why.

If DRM-backend needs more from weston_capture_task when it implements
writeback screenshooting, it will be easy to add user_data or expose
weston_capture_task::link for the backend to use. Those were not added
yet because it is uncertain what is actually needed.

The DRM-backend no-damage optimization requires special handling here as
well. See also 7f1a113c89 .

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-11-29 11:00:52 +02:00
Pekka Paalanen
d0eca43b9b protocol: new screenshooter protocol
This is a completely new screenshooting protocol designed to support:
- color management testing by adding the "blending" source
- KMS testing by adding the "writeback" source
- output decorations testing by adding the "full_framebuffer" source
- proper buffer size negotiation instead of guessing from wl_output
- compositor chosen pixel format, primarily for "blending" source
- proper indication of screenshot failure
- dmabuf target buffers, linear only

This new protocol should be good enough to publish as a Weston public
extension. Hence install it.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-11-29 11:00:52 +02:00
Derek Foreman
ca6f30d5de libweston: Fix comment
We now depend on the matrices in weston_view being correct even when the
transform isn't enabled.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2022-11-28 10:32:44 +00:00
Derek Foreman
2952ea6379 matrix-transform-test: Add additional tests
Add tests to validate that weston_matrix_to_transform() works properly
on the matrices generated by weston_surface_build_buffer_matrix() and
weston_output_update_matrix()

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2022-11-25 08:29:05 -06:00
Derek Foreman
fb20fe9b03 compositor: Cache filtering decision in paint node
Instead of basing this on simple checks, we can test the matrix. This
should result in more opportunistically picking fast nearest neighbour
filtering when it won't result in visible distortion.

For now we only use this in the gl renderer, as paint nodes aren't
plumbed into the pixman renderer yet.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2022-11-25 08:29:05 -06:00
Derek Foreman
021fdf4244 backend-drm: Analyze transformation chain to check if it's supported
Instead of bailing based on our loosely tracked matrix "type" (that won't
recognize when an operation is reversed by its inverse) use the new
weston_matrix_to_transform to determine if the matrix reasonably matches.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2022-11-25 08:29:05 -06:00
Derek Foreman
d14753e80c libweston: Add function to create a view's buffer to output matrix
This can be helpful in testing if a paint node needs linear vs nearest
neighbour filtering, or if a view can be placed on a plane.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2022-11-25 08:29:05 -06:00
Derek Foreman
92a9860e1d libweston: Add function to find the output transform of a matrix
When we build up a matrix from a series of operations, it's very useful
to know if the combined operations still result in something that matches
a wl_output_transform.

This adds a function to test if a matrix leads to a standard output
transform, and returns the transform if it does.

Tests are provided that check if complex series of operations return
expected results - the weston_matrix_needs_filtering function is tested
at the same time.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2022-11-25 08:29:05 -06:00
Derek Foreman
0e2136df7b libweston: Add a function to test if transformed images need filters
If a transformation matrix causes a scale, a rotation not a multiple of 90
degrees or a non-integral translation then textures rendered with
it would benefit from bilinear filtering.

This test is done in a lazy fashion by examining elements of the matrix
to check for a simple pattern that indicates these conditions are met.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2022-11-25 08:25:53 -06:00
Derek Foreman
061c2b7382 desktop-shell: Update view transform when resizing windows
After commit 2dc8680d71 this started crashing. We need to update the
view transform here too.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2022-11-24 15:59:26 -06:00