Commit Graph

1579 Commits

Author SHA1 Message Date
Marius Vlad eeef6be8e2 doc/sphinx: Include weston-config and shell-utils in docs
libweston contains weston_config and weston_shell_utils utilities
functions so include these in the sphinx documentation as well.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2023-01-09 22:13:07 +00:00
Marius Vlad 6293ab1f90 libweston, shared: Move out weston_shell_get_binding_modifier
This doesn't really belong into shell-utils,  so better move it out to
shared/config-parser. Renamed to weston_config_get_binding_modifier
to maintain the same namespace.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2023-01-09 22:13:07 +00:00
Marius Vlad 19d32da742 shell-utils: Integrate shell-utils into libweston
These shell utils functions are potentially useful to other shells as
well, so make them widely available.

Renamed all functions to weston_shell_utils namespace.

No functional change, copied ad litteram.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2023-01-09 22:13:07 +00:00
Derek Foreman 68cad4db42 drm: Use cached matrix in drm_paint_node_transform_supported
We've passed the paint node deeply enough that we can now use the cached
matrix in it to save some calculations.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2023-01-09 21:58:19 +00:00
Derek Foreman 05eee6eaef drm: Pass paint node to drm_view_transform_supported
Rename it as well.

By passing the paint node we'll have access to the cached buffer to output
matrix later.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2023-01-09 21:58:19 +00:00
Derek Foreman 2a1a8994c4 drm: Cache buffer to output matrix in paint node
We use this a few times for plane tests, so we can cache it here to avoid
recalculating it.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2023-01-09 21:58:19 +00:00
Derek Foreman 7c7489fe79 drm: Pass paint node to drm_plane_state_coords_for_view
Rename the function as well, as it no longer takes a view.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2023-01-09 21:58:19 +00:00
Derek Foreman a65ba82232 drm: Pass paint node to drm_output_try_view_on_plane
Rename the function as it no longer tests views, but paint nodes.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2023-01-09 21:58:19 +00:00
Derek Foreman 263e78d0fc drm: Pass paint node to cursor view prep function
Rename this as well, since it no longer takes a view.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2023-01-09 21:58:19 +00:00
Derek Foreman 567ed2706a drm: pass paint node to drm_fb_get_from_view
This is a preamble to saving a bit of matrix maths.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2023-01-09 21:58:19 +00:00
Marius Vlad ab1a3c8164 libweston/input: update view transforms when handling touch_down
Another leftover from d611ab24 "libweston: Update view transforms more
often".

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2022-12-30 14:02:59 +00:00
Leandro Ribeiro 04cc477afa libweston/input: update view transforms when handling confined pointer motion
When the pointer is confined and we are handling motion, we need
up-to-date view transforms in order to respect the confinement. So
update view transforms in such case.

This fixes an issue in which we'd try to transform views with dirty
transforms in weston_pointer_clamp_event_to_region(), hitting an assert.

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

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2022-12-19 17:05:37 -03:00
Philipp Zabel ce4cf2d060 backend-vnc: move accumulated damage with output
When the output is moved, move its per-framebuffer accumulated damage
with it. The alternative would be to track accumulated damage in the
local output coordinate system, but that would require translating back
into global coordinates for repaint_output.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2022-12-16 15:51:27 +02:00
Philipp Zabel 0706569ac9 linux-dmabuf: add missing includes and declarations
Currently linux-dmabuf.h implicitly depends on libweston.h being
included before it. Instead of adding missing includes for bool,
dev_t, struct timespec, struct weston_compositor,
struct weston_drm_format_array, struct wl_array, and struct wl_list,
just include libweston.h.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2022-12-16 15:05:10 +02:00
Michael Olbrich a943e5e70e compositor: commit subsurfaces before the main surface
The main surface commit includes the xdg surface commit. Here, the
accumulated surface size is validated. All subsurfaces must be comitted
first to ensure that the corrent current values are used.

Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
2022-12-16 08:32:29 +00:00
Pekka Paalanen 212c666ab5 backend-wayland: use gl-borders
Use the gl-renderer border code shared with headless-backend. We can
drop all this open-coded stuff.

In the output disable path, make sure to call this only when gl-renderer
is used. It will also reset the border state in gl-renderer, which is
harmless here, and it's necessary in the resize path.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-12-14 11:57:24 +00:00
Pekka Paalanen e619a65b09 libweston: move gl-borders code into helper lib
Move this code from headless-backend to a helper library, so it can be
shared with wayland-backend.

gl-renderer.h was missing #pragma once, which made the build fail.

Unfortunately gl-borders needs gl-renderer.h which will attempt to
include EGL headers if gl-renderer is enabled in the build, so we must
get the EGL build flags too, just for the headers.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-12-14 11:57:24 +00:00
Pekka Paalanen c57112a40a backend-headless: refactor into weston_gl_borders
Refactor this code into two backend-agnostic functions, that in the next
step can be moved into code shared between backends.

Pure refactoring, no changes.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-12-14 11:57:24 +00:00
Pekka Paalanen 5522f73559 backend-headless: clean up gl border data pointer
GL-renderer keeps the pointer for the border image data for later use.
When we destroy our cairo_surface, that data gets freed. Therefore,
reset the pointer stored by GL-renderer too, to ensure use-after-free
cannot happen.

This is not really necessary in this particular case, because the
renderer output is destroyed immediately after, so there is no chance of
UAF.

However, this is needed for code sharing purposes. Wayland-backend will
do exactly this when an output is resized. To share this code with
wayland-backend, we also need to reset the pointers. It's harmless and
more correct in the output disable path.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-12-14 11:57:24 +00:00
Pekka Paalanen f47ed7894c backend-headless: use a loop in update_gl_border
Replace a bunch of copied code with a loop over a simple array. This
makes the code easier to read, and allows further refactoring.

This is pure refactoring, no changes to results or behavior.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-12-14 11:57:24 +00:00
Pekka Paalanen 915d8e8cdf build: simplify dep_egl a bit
Make sure dep_egl is always a valid dependency object, even if not
found. Ensure it is not found when not wanted, to avoid linking when
found but not wanted.

Using a not-found dependency in Meson is defined to be a safe no-op, so
use that to simplify the backend dependencies.

libweston/meson.build already errors out if renderer-gl is enabled and
EGL is not found, so the same checks can be removed from the backends.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-12-14 11:57:24 +00:00
Philipp Zabel 2667829746 libweston: call correct weston_backend::create_output depending on head
Now that struct weston_head contains a pointer to the backend owning
the head, choose to call the same backend's create_output callback.

This will be necessary to support loading multiple backends
simultaneously.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2022-12-12 17:24:45 +01:00
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 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
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 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
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 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 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
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
Philipp Zabel 133417b016 backend-vnc: Add user authentication
Let VNC clients authenticate using the local username and password of
the user weston is running as. To avoid transmitting the password in
cleartext, make TLS security mandatory.

Signed-off-by: Philipp Zabel <philipp.zabel@gmail.com>
2022-11-23 16:58:48 +01:00
Philipp Zabel 0733c8f571 libweston: Add user authentication support via PAM
Add user authentication support for remote backends via PAM.
This requires a configuration file /etc/pam.d/weston.

Signed-off-by: Philipp Zabel <philipp.zabel@gmail.com>
2022-11-23 16:58:48 +01:00
Philipp Zabel 1a027e63cb backend-vnc: enable TLS support
Add TLS key and certificate parameters to enable encryption support.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2022-11-23 11:04:19 +01:00