Commit Graph

108 Commits

Author SHA1 Message Date
Benjamin Herrenschmidt 89f3a8a71e Add support for FreeRDP 3.x
With this, Weston can build against either FreeRDP 3.x or 2.x depending
on what has been detected by meson (3.x takes priority).

The main source of changes is the settings are now opaque and require the
use of accessors. That was pretty mechanical and seems to work on 2.x as
well.

There are a few changes around constants getting a WINPR_ prefix, the UTF
conversion functions we used are obsolete, so use the proper "new" ones,
and other fairly minor things.

The key & cert management changed rather completely, libfreerdp won't load
files for us, we have to use the helpers to do so, and I *think* the RDP RSA
key and SSL key use the same setting location. Seems to work with SSL at
least.

There was also a minor glitch with keyboard input, KBD_FLAGS_DOWN is basically
never set. It appears to be an upstream FreeRDP change in 3.x, it was being
set incorrectly (always on any key down) while it should only be set on
repeats. However the fastpath input code has no way to set it from what I
can tell, so it's just loss. We instead ignore it.

Note that the screen size is odd (and different between freerdp client and
remmina), it also won't adjust dynamically when the window is resized. I
don't think this relates to my port though, I observe the same behaviour
with the packaged FreeRDP 2 based Weston, but I can try to look into it
later

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
2024-08-14 12:29:28 +10:00
Marius Vlad 75280d2e40 frontend: Disable client resize for RDP remote outputs
Similar to the VNC backend do the same for the RDP backed, as this would
allow to get a matching output, in dimensions, to the one we are
mirroring.

This also re-works a bit the no-clients-resize to be more inline with
VNC one.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2024-08-12 15:50:13 +00:00
Loïc Molinari db66a64aab rdp: Fix invalid free and memory leak on error
Peer context creation's error handling labels must be swapped to avoid
an invalid free when nsc context creation fails and a leak of the rfx
context when encode stream creation fails.

Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
2024-07-24 08:54:45 +00:00
Derek Foreman 302a1b143f rdp: Align nsc_compose_message content
This function in FreeRDP expects to be able to read groups of bytes, so
move the left edge of our damage region so the wide reads never read
outside of our framebuffer.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2024-07-24 08:41:36 +00:00
Derek Foreman b56d887e34 rdp-backend: Fix more scale that should be current_scale
Commit c3321d5819 tried to fix this, but
I didn't thoroughly look for other uses of the wrong scale variable.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2024-07-11 12:37:25 -05:00
Derek Foreman 2abe4efcf7 libweston/backends: Move damage flush into backends
Currently we flush damage for the "primary plane" every repaint, but this
is folly.

The drm backend may skip rendering entirely if using an all-planes
composition. This could leave the renderer plane in a messy state if a
surface on an overlay plane disappears.

Instead, let the backends flush the primary plane damage when they know
they need to render.

Fixes #864

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2024-01-10 14:13:09 -06:00
Philipp Zabel f014009419 backend-rdp: Enable multi-backend support
Insert the backend into the weston_compositor::backend_list instead
of setting weston_compositor::backend. The compositor uses this to
determine whether the backend is capable of being loaded simultaneously
with other backends.

To stay backwards compatible, the RDP backend can be loaded as primary
backend. It also supports being loaded as secondary backend.

Signed-off-by: Philipp Zabel <philipp.zabel@gmail.com>
2023-09-28 14:02:04 +00:00
Philipp Zabel 8888777b26 backend-rdp: Use weston_output_finish_frame_from_timer()
Replace the finish frame handler logic with a call to the
weston_output_finish_frame_from_timer() helper function.

This makes finish_frame_handler() return more exact timestamps
calculated from the previous frame time if the timer callback
was not delayed too much.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2023-09-27 12:37:09 +03:00
Philipp Zabel b7400c614e backend-rdp: Use weston_output_arm_frame_timer()
Replace the finish frame timer arming logic with a call to the
weston_output_arm_frame_timer() helper function that does the same.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2023-09-27 12:37:09 +03:00
Philipp Zabel e541aea2d7 backend-rdp: make sure to finish frames with timestamps in the past
Round up the ms delay to make sure that the finish_frame_timer always
expires after the next frame_time. That way, finish_frame_handler()
never passes a timestamp in the future to weston_output_finish_frame().
Setting frame_time into the future risks hitting an assert in
weston_output_finish_frame(), when it is called from start_repaint_loop
within the frame interval.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2023-09-15 09:52:37 +03:00
Philipp Zabel 1d59530e4b libweston: Set the presentation clock in the compositor
Let backends declare the presentation clocks they can use with a
new bitfield weston_backend::supported_presentation_clocks and set
presentation clock after loading the backend in the compositor.

Make weston_compositor_set_presentation_clock() internal and replace
weston_compositor_set_presentation_clock_software() with an exported
weston_compositor_backends_loaded(), which is called by the compositor
after the backend is loaded.

In the future, this can be extended to determine the subset of clocks
supported by all backends.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2023-08-02 11:51:56 +03:00
Philipp Zabel e58452d6be backend-rdp: extract weston_output_set_single_mode()
The ensure_single_mode() helper replaces an output's single mode.
Extract it into libweston so it can be reused by the VNC backend,
and rename it to weston_output_set_single_mode().

At the same time, set the the previously missing
WL_OUTPUT_MODE_CURRENT flag on the new mode.

Fixes #758

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2023-07-11 15:43:29 +00:00
Derek Foreman f07af89f9c libweston: Move output damage subtraction out of backends
Right now every backend clears output damage from the primary plane when
it repaints. Instead of having this same operation spread across all
the backends, just do it in the core instead.

In the future, we want to remove damage tracking from the primary plane
entirely, and this is a small step in that direction.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2023-07-11 07:26:43 -05:00
Philipp Zabel 90c11cf40e libweston: move weston_compositor_shutdown call out of backends
If we want to support multiple backends, the compositor must take care
to call this once, at the appropriate moment, so stop letting the
backends handle compositor shutdown themselves.

Move the weston_compositor_shutdown() calls from the backend::destroy
callbacks into weston_compositor_destroy() and the calls in the backend
creation error paths into weston_compositor_load_backend().

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2023-06-27 12:09:47 +01:00
Philipp Zabel 6d699c3f54 libweston: add weston_backend::shutdown callback
Add a weston_backend::shutdown callback to split out the part of
weston_backend::destroy that needs to be done before compositor
shutdown.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2023-06-27 12:09:45 +01:00
Philipp Zabel ca1f6936c4 backend-rdp: GL renderer support
Let the GL renderer render to FBOs for RDP outputs and read the pixels
into the RDP frame buffer. This allows to run the RDP backend with the
GL renderer.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2023-06-15 15:48:26 +00:00
Philipp Zabel dbe5b53766 backend-rdp: add pixel format info array
Store pixel formats on the backend and stop open coding Pixman format
codes.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2023-06-15 15:48:26 +00:00
Philipp Zabel 17d7353b36 backend-rdp: move code to prepare for GL renderer support
Add switch statements where renderer specific API is called to prepare
for adding GL renderer support. No functional change.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2023-06-15 15:48:26 +00:00
Philipp Zabel e0c7fd1586 backend-rdp: bring back shadow_surface image
Partially revert commit 89e1831cd7 ("pixman-renderer: add
weston_renderbuffer and create/destroy interface") to bring back the
shadow_surface pixman image. The renderbuffer is only wrapped around it.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2023-06-15 15:48:26 +00:00
Philipp Zabel f154fbba97 libweston: consolidate 'Using GL/Pixman renderer' log message
Consolidates the 'Using GL/Pixman renderer' message emitted by the
PipeWire, RDP, VNC, and X11 backends by moving the weston_log() into
weston_compositor_init_renderer(). Only print the message after
initializing the renderer has succeeded.

This effectively adds the message to the DRM, headless, and Wayland
backends.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2023-05-04 14:47:49 +02:00
Philipp Zabel 0a1d77a728 backend-rdp: pass rdp_backend to rdp_head_create()
Pass the RDP backend to rdp_head_create().

That way the already known backend will not have to be found from the
compositor. This is trivial now, but in the multi-backend case would
entail iterating over all backends to find the correct one.

Also remove the now unused to_rdp_backend() helper.

Signed-off-by: Philipp Zabel <philipp.zabel@gmail.com>
2023-04-17 09:40:52 +02:00
Derek Foreman 8031b9d57f backend: Make input notification functions use weston_coord
Push weston_coord into the notification functions instead of passing
two doubles.

The touch handlers are passed a pointer to a weston_coord, which is
unusual. This is done so we can pass a NULL pointer instead of a
fabricated invalid coordinate when the touch type is TOUCH_UP.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2023-02-09 12:12:40 +00:00
Philipp Zabel c67773bc5c pixman-renderer: use pixel_format_info instead of pixman_format_code_t
Use struct pixel_format_info pointers instead of pixman_format_code_t
values at the API surface for output and image creation.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2023-01-28 12:59:16 +00:00
Philipp Zabel 14533cdd25 libweston: make weston_renderbuffer refcounted
Add weston_renderbuffer_ref/unref() functions and use them to
eventually destroy the weston_renderbuffer. Drop the explicit
renderbuffer_destroy vfunc from the pixman renderer interface.

Signed-off-by: Philipp Zabel <philipp.zabel@gmail.com>
2023-01-27 16:52:14 +01:00
Philipp Zabel eb9a740c20 libweston: move pixman_renderer_init() into weston_compositor_init_renderer()
Stop calling pixman_renderer_init() from backends directly.
Call it via weston_compositor_init_renderer() instead.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2023-01-23 20:05:21 +00:00
Philipp Zabel 116c234703 pixman-renderer: add pixman_renderbuffer specialization
Add a private struct pixman_renderbuffer that derives from struct
weston_renderbuffer and move the pixman renderer specific image and link
fields into it.

Add a pixman_renderbuffer_get_image() helper for the backends that need
to access the contained pixman image, RDP and X11.

Signed-off-by: Philipp Zabel <philipp.zabel@gmail.com>
2023-01-23 20:05:21 +00:00
Philipp Zabel 4d96635a3f pixman-renderer: track damage in weston_renderbuffer
Add a damage region to struct weston_renderbuffer and use it to replace
the previous_damage tracking in the drm backend.

Keep renderbuffers on a list in struct pixman_output_state and use it
to accumulate damage on all renderbuffers during repaint_output.
Now renderbuffers have to be created when pixman output state already
exists.
Reorder renderer output state and renderbuffer creation accordingly.

With this, pixman_renderer_output_set_hw_extra_damage() can be removed.

This can not yet replace the external damage tracking in the VNC
backend, which needsto know the accumulated damage that is not returned
from repaint_output.

Signed-off-by: Philipp Zabel <philipp.zabel@gmail.com>
2023-01-23 20:05:21 +00:00
Philipp Zabel 6757bae0f3 pixman-renderer: set renderbuffer via new repaint_output parameter
Add a struct weston_renderbuffer parameter to repaint_output and make
backends set the pixman image renderbuffer through this parameter
instead of using pixman_renderer_output_set_buffer()

Turn pixman_renderer_output_set_buffer() static.

Signed-off-by: Philipp Zabel <philipp.zabel@gmail.com>
2023-01-23 20:05:21 +00:00
Philipp Zabel 89e1831cd7 pixman-renderer: add weston_renderbuffer and create/destroy interface
Add a create_image_from_ptr vfunc to struct pixman_renderer_interface,
which wraps weston_renderbuffer creation for the pixman renderer via
pixman_image_create_bits(), as well as a renderbuffer_destroy vfunc
to dispose of the pixman image renderbuffer.
Also add create_image_no_clear using pixman_image_create_bits_no_clear()
instead.

Make the backends create and destroy their pixman image renderbuffers
through this interface.

Signed-off-by: Philipp Zabel <philipp.zabel@gmail.com>
2023-01-23 20:05:21 +00:00
Philipp Zabel 32c7629516 pixman-renderer: add pixman_renderer_interface
Add a struct pixman_renderer_interface with output_create and
output_destroy vfuncs and store a pointer to it in struct
weston_renderer.

Make all backends access the pixman_renderer_output_create/destroy
functions through this interface and turn them static.

Signed-off-by: Philipp Zabel <philipp.zabel@gmail.com>
2023-01-23 20:05:21 +00:00
Philipp Zabel 30cca75086 backend-rdp: store backend on struct rdp_output
To avoid retrieving the backend from the compositor all the time, store
a pointer to the rdp backend on its rdp_output structures.

This will be useful once the compositor contains more than one backend.

Signed-off-by: Philipp Zabel <philipp.zabel@gmail.com>
2023-01-16 17:11:08 +01:00
Philipp Zabel 6f977640e6 libweston, backends: pass backend parameter to weston_backend functions
Passing the backend as a parameter to the weston_backend function
pointers seems more natural and will be very useful once there can be
more than one backend.

Since all backends already store a pointer to the compositor instance,
replace the compositor parameter with the backend in all functions.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2023-01-13 18:55:59 +01:00
Hideyuki Nagase 70b03b2928 rdp: Add preliminary rdp multihead support
This sets up monitor layout callbacks, and enables input event translation
between the RDP space and the weston desktop. The RDP backend now uses
a heads changed callback instead of the simple head configurator.

We only allow a single monitor for now, but in the future RAIL will make
use of multi-head.

As a side effect, scaling is now supported in RDP sessions.

It should be noted that due to differences between RDP and wayland
representation of their global coordinate spaces, mixing DPI leads to
RDP monitor layouts that can't properly be represented in weston.

Co-authored-by: Steve Pronovost <spronovo@microsoft.com>
Co-authored-by: Brenton DeGeer <brdegeer@microsoft.com>
Signed-off-by: Hideyuki Nagase <hideyukn@microsoft.com>
Signed-off-by: Steve Pronovost <spronovo@microsoft.com>
Signed-off-by: Brenton DeGeer <brdegeer@microsoft.com>
2023-01-10 12:12:49 +00:00
Hideyuki Nagase 8a2d961b92 rdp: Pass a monitor configuration to rdp_head_create
Instead of passing a name, pass a FreeRDP rdpMonitor struct. For now the
only caller will pass a NULL to use default values.

Also, drop static from the function declaration as new code will call it
from another file shortly.

Co-authored-by: Steve Pronovost <spronovo@microsoft.com>
Co-authored-by: Brenton DeGeer <brdegeer@microsoft.com>
Signed-off-by: Hideyuki Nagase <hideyukn@microsoft.com>
Signed-off-by: Steve Pronovost <spronovo@microsoft.com>
Signed-off-by: Brenton DeGeer <brdegeer@microsoft.com>
2023-01-10 12:12:49 +00:00
Derek Foreman 3e27571001 rdp: Apply scale in context resets at activation time
Scale is currently always 1, but we can do this safely now to prepare for
when it isn't.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2023-01-10 12:12:49 +00:00
Derek Foreman bacae46632 rdp: Move output callback setup into rdp_output_create
In some upcoming changes rdp_output_set_size will be removed. There's
no need to have it do this setup, so move that into output_create.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2023-01-10 12:12:49 +00:00
Derek Foreman 801d9c55c8 rdp: Use xzalloc for output creation
Reduce error handling burden

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2023-01-10 12:12:49 +00:00
Derek Foreman f9832bcb0a rdp: Use xzalloc in rdp_head_create
We can no longer fail.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2023-01-10 12:12:49 +00:00
Hideyuki Nagase 1d2227f5b5 rdp: Transform damage regions
In the absence of scale factors, this has been accurate. Once we allow
scaling we need to apply a full transform.

Co-authored-by: Steve Pronovost <spronovo@microsoft.com>
Co-authored-by: Brenton DeGeer <brdegeer@microsoft.com>
Signed-off-by: Hideyuki Nagase <hideyukn@microsoft.com>
Signed-off-by: Steve Pronovost <spronovo@microsoft.com>
Signed-off-by: Brenton DeGeer <brdegeer@microsoft.com>
2023-01-10 12:12:49 +00:00
Derek Foreman 8e7cf52638 rdp: use mode instead of output size for full region refresh
Output dimensions are only correct here with unity scaling, but we're
going to allow scale factors shortly. The mode matches what RDP
expects.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2023-01-10 12:12:49 +00:00
Derek Foreman 7bd82a19d4 rdp: Only allow a single graphics mode
If a client connects to an RDP session it should replace the existing
mode, not add a new one.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2023-01-10 12:12:49 +00:00
Derek Foreman 42a2c0502f rdp: Set current mode flag properly in rdp_output_set_size
ensure_matching_mode() pays no attention to flags, we must set them on the
returned result afterwards.

This could be reproduced by making the initial connection to an rdp session
using the same mode it picked at startup.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2023-01-10 12:12:49 +00:00
Derek Foreman 50d42f88da rdp: Use xzalloc in rdp_insert_new_mode
We can remove some error handling if we don't allow this to fail.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2023-01-10 12:12:49 +00:00
Derek Foreman fc848b30c8 rdp: Move some head setup to rdp_head_create
We know these at creation time, so just set them immediately.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2023-01-10 12:12:49 +00:00
Derek Foreman b02ffbd244 rdp: Remove singleton output tracking
We don't need this anymore. Since we only support one output,
we  can use the first output for any place we used to use it.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2023-01-10 12:12:49 +00:00
Derek Foreman 6f2ab50405 rdp: Don't release the singleton output on backend creation failure
If an output exists, it should be cleaned up automatically when we release
all our heads later anyway.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2023-01-10 12:12:49 +00:00
Derek Foreman ac11926c61 rdp: be more careful to free listener on output creation failure
By the time we get to this failure we may (or may not) have implanted a
listener.

freerdp_listener_free() safely handles passed NULL pointers, so we don't
have to add any additional checks on our end.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2023-01-10 12:12:49 +00:00
Derek Foreman e4895fa5fc rdp: Switch to xzalloc for backend allocation
We're giving up on trying to recover from these kinds of failures.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2023-01-10 12:12:49 +00:00
Derek Foreman 00de8ceff7 rdp: Use the first output in rdp_peer_refresh_region
Currently, this is what backend->output would be anyway. This is another
step towards removing the singleton output stored in the backend.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2023-01-10 12:12:49 +00:00
Derek Foreman 0d06d709d6 rdp: Export rdp_head_destroy
We'll need this from other files for multi-head support.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2023-01-10 12:12:49 +00:00