Commit graph

782 commits

Author SHA1 Message Date
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 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 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
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
Emmanuel Gil Peyrot 1c5ce4c2cc DRM: Add support for HDMI content type
Some monitors expose a selector for the kind of content that will get
displayed, allowing them to optimise their settings for this particular
content type.

I got access to such a monitor, sadly even setting it to game mode
didn’t lower its atrocious latency, but drm_info[1] reports it to be set
correctly so hopefully it’ll work better with other monitors.

[1] https://github.com/ascent12/drm_info

Signed-off-by: Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
2022-11-03 15:40:00 +00:00
Derek Foreman 2ca2eac39a libweston: Split notify_pointer focus into notify/clear
This lets us say what we really mean instead of passing a NULL output
and garbage co-ordinates.

This will help later when manufacturing garbage coordinates becomes much
harder to do.

The clear_pointer_focus() path continues to do nothing, and is just a FIXME
macro, as it has been for a very long time...

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2022-10-25 15:58:24 -05:00
Stefan Agner 12f7665310 backend-vnc: add VNC support using Neat VNC library
This adds basic VNC protocol support using the Neat VNC library
(https://github.com/any1/neatvnc). Neat VNC depends on the AML main
loop library. The backend makes use of AML's integrated epoll backend
and connects AML via file descriptor with the Wayland event loop.

This implementation does not support authentication and hardcodes the
pixel format currently.

Co-authored-by: Philipp Zabel <p.zabel@pengutronix.de>
Co-authored-by: Rouven Czerwinski <r.czerwinski@pengutronix.de>
Signed-off-by: Stefan Agner <stefan@agner.ch>
[r.czerwinski@pengutronix.de:
 - use new (as of 0.5.0) Neat VNC buffer API, with a buffer pool]
Signed-off-by: Rouven Czerwinski <r.czerwinski@pengutronix.de>
[p.zabel@pengutronix.de:
 - transform repaint damage to output coordinates
 - transform pointer coordinates into global space
 - check that outputs and heads are in fact ours, see aab722bb1785..060ef82d9360
 - track damage across multiple frame buffers
 - choose pixel format by drm_fourcc, see 8b6c3fe0ad
 - enable ctrl and alt modifiers
 - fix frame timing to achieve a constant repaint rate
 - pass initial size explicitly, see f4559b0760
 - use resize_output with pixman-renderer, see 55d08f9634e8..84b5d0eb4bee
 - allow configuring the refresh rate]
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2022-10-18 07:31:42 +02:00
Derek Foreman 118ee6674b screen-share: split up damage tracking variables
This is all a little confusing, so let's split up the variables and throw
around some comments that better explain what's going on.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2022-09-28 09:14:19 +00:00
Derek Foreman 40804adbe1 screen-share: Fix first buffer damage
Our shared buffer isn't actually in output co-ordinates, so
initializing with the output's width/height isn't correct.

While we're here, remove the misleading comment. In a future
patch I'll try to document this code more accurately.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2022-09-28 09:14:19 +00:00
Derek Foreman d68ee26ff5 screen-share: Copy the damage region instead of intersecting it
The region has already been intersected with the output's region before
it was passed to us.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2022-09-28 09:14:19 +00:00
Derek Foreman cb5872f0a6 screen-share: Use weston_output_contains_point
Let's not open code this here anymore.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2022-09-23 12:08:34 +00:00
Marius Vlad eaf2de3441 compositor: Use weston_load_module
Except the module dir path, they're one and the same. This change
warrants a libweston version bump, if it hasn't been done already.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2022-09-23 11:47:40 +00:00
Derek Foreman 21deaee6a9 libweston: use weston_region_global_to_output more often
Use this anywhere we used weston_matrix_transform_region with an output
matrix.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2022-09-23 11:41:59 +00:00
Derek Foreman c12ec7a2e5 compositor: Remove weston_transformed_region
Replace all uses of weston_transform_region with
weston_matrix_transform_region, then remove the function completely.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2022-09-23 11:41:59 +00:00
Marius Vlad 8c4cdd782e compositor/shared: Suppress write(2) warnings
Fixes the following warnings when building with _FORTIFY_SOURCE
and optimizations enabled:

../shared/xalloc.h:49:9: error: ignoring return value of ‘write’ declared with attribute ‘warn_unused_result’ [-Werror=unused-result]
   49 |         write(STDERR_FILENO, oommsg, strlen(oommsg));
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

or
../compositor/main.c:427:25: error: ignoring return value of ‘write’ declared with attribute ‘warn_unused_result’ [-Werror=unused-result]
  427 |                         write(STDERR_FILENO, fail_seteuid,
      |                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  428 |                               strlen(fail_seteuid));
      |                               ~~~~~~~~~~~~~~~~~~~~~
../compositor/main.c:434:25: error: ignoring return value of ‘write’ declared with attribute ‘warn_unused_result’ [-Werror=unused-result]
  434 |                         write(STDERR_FILENO, fail_cloexec,
      |                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  435 |                               strlen(fail_cloexec));
      |                               ~~~~~~~~~~~~~~~~~~~~~
../compositor/main.c:442:25: error: ignoring return value of ‘write’ declared with attribute ‘warn_unused_result’ [-Werror=unused-result]
  442 |                         write(STDERR_FILENO, fail_exec, strlen(fail_exec));
      |                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2022-09-23 11:32:19 +00:00
vanfanel 3240ccc69d Don't change the max_bpc connector prop if mode=current.
As things are, even when mode=current is specified on the .ini file,
a full modeset is needed (and done), which causes a very noticeable
screen blinking. That is because setting the max_bpc on a connector
needs full modesetting.
The idea here is that if mode=current on the .ini, no modesetting
should be done, so the current max_bpc is programmed into the
connector.
But if a custom max-bpc=... is specified, that will be used instead,
even if mode=current on the .ini

Fixes: https://gitlab.freedesktop.org/wayland/weston/-/issues/660

Signed-off-by: vanfanel <redwindwanderer@gmail.com>
2022-09-23 11:05:34 +00:00
Marius Vlad 995d080cb9 compositor/main: Extract split/retrieve args passed shell client
The supplied path for executing the shell client could contain potential
arguments and not only the binary itself. Specifying the platform either
by using an argument (-platform wayland) or using an environmental
variable (QT_QPA_PLATFORM) with clients written in Qt is for instance
an example on why this might be useful to have in.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2022-09-23 11:01:57 +00:00
Thomas Petazzoni 6e529cb6ab compositor/main.c: use pixman renderer by default when gl-renderer not enabled
When the gl-renderer is not enabled, weston fails to start, as it
doesn't automatically fallback to the pixman renderer, which is
always enabled.

This commit changes the drm-backend to set by default the --use-pixman
option to true when the gl-renderer is disabled (BUILD_DRM_GBM is not
defined).

Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
2022-08-05 10:05:21 +00:00
Derek Foreman 8409b74ec2 libweston: Don't move outputs during enable
This is pretty counter-intuitive, and should probably happen outside of
the core in the front end while configuring the outputs.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2022-08-05 06:08:30 +00:00
Derek Foreman 214d48bbab compositor: Fix use after free at shutdown
Another case of forgetting to remove a listener from a list when
signal_emit_mutable fires.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2022-08-03 14:38:53 +03:00
Pekka Paalanen b966fd07ea libweston: change read_format to struct pixel_format_info
Everywhere we are standardising to drm_fourcc.h pixel format codes, and
using struct pixel_format_info as a general handle that allows us to
access the equivalent format in various APIs. In the name of
standardisation, convert weston_compositor::read_format to
pixel_format_info.

Pixman formats are defined CPU-endian, while DRM formats are defined
always little-endian. OpenGL has various definitions. Correctly mapping
between these when the CPU is big-endian is an extra chore we can
hopefully offload to pixel-formats.c.

GL-renderer read_format is still defined based on Pixman format, because
of the pecualiar way OpenGL defines a pixel format with
GL_UNSIGNED_BYTE. That matches the same Pixman format on big-endian but
not the same drm_fourcc.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-08-03 14:33:48 +03:00
Pekka Paalanen 03c229f4ce screen-share: use read_format consistently
This was using read_format for the read_pixels() call, and then using a
hardcoded format for interpreting the data received from read_pixels().
That works only by accident, read_format being the same as the hardcoded
format.

Use read_format for the interpreting too. This should guarantee the read
pixels are processed correctly.

Found by code inspection.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-08-03 14:33:48 +03:00
Marius Vlad 8a610ffe41 compositor/text-backend: Avoid a potential UAF
The text_input_manager might be destroyed upon a compositor shutdown, so
verify if it's still set-up before attemping to use it to avoid a UAF.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2022-07-27 14:15:11 +03:00
Derek Foreman 2badd284a5 compositor: Load xwayland module first
This is so the systemd-notify module, if used, will notify readiness after
we're ready to accept X connections, instead of before.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2022-07-26 17:20:09 +00:00
Derek Foreman 0972c6b2da compositor: Remove deprecated xwayland loading method
This is awkward and long deprecated, and makes us load xwayland after all
the other modules so we know if we have to load it or not. Let's remove it.

We do still need to prevent loading the module the wrong way, though.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2022-07-26 17:20:09 +00:00
Derek Foreman c79e1126b6 xwayland: give Xwayland its own session
If we leave xwayland in weston's process group, it can receive
signals from the controlling TTY intended for weston.

The easiest way to see this is to launch weston under gdb, start an
X client, and hit ctrl-c in the gdb session. The Xwayland server
will also catch the SIGINT, and the X client will be disconnected.

Instead, let's call setsid() when launching Xwayland, like we do
for launched clients.

Suggested-by: Hideyuki Nagase <hideyukn@microsoft.com>
Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2022-07-19 14:19:57 +00:00
Daniel Stone 53f895b476 wet_process: Do not weston_log() after fork()
[common equivalent of 77cf8cb006 in Xwayland from Pekka Paalanen; its
 commit message follows]

Between fork() and exec() in the child process it is only safe to use
async-signal-safe functions. weston_log() definitely is not one, it
allocates memory and does whatnot.

weston_log() is also inappropriate for other reasons: the child process
has its own stream buffers and flight-recorder. No-one looks into the
child process' flight recorder, so messages would be lost there. The
logging machinery might also attempt to write into debug streams,
meaning both parent and child could be writing simultaneously.

It seems that the best we can do is to pre-bake an error message and
only write() it out if exec() fails. There is no mention that even
strerror_r() might be safe to call, so we don't.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-07-19 14:12:37 +00:00
Daniel Stone 9ab97ebd72 wet_process: Use custom_env when forking clients
Use the custom_env framework we added for Xwayland when forking to
execute clients. This avoids calling the unsafe getenv in between fork
and exec.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-07-19 14:12:37 +00:00
Daniel Stone 8aa4571240 wet_process: Inline child_client_exec()
It was only a small function, and inlining it will allow us to make it
more safe without having to duplicate a ton of stuff.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-07-19 14:12:37 +00:00
Daniel Stone c0a76716c1 wet_process: Use fdstr when executing clients
This doesn't actually stop us from calling setenv() in between fork()
and exec() when starting clients, but gets us closer to Xwayland's safe
implementation by reusing one of the helpers it added.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-07-19 14:12:37 +00:00
Daniel Stone a3175727cb wet_process: Rearrange fork() if tree to case statement
Matches the safe Xwayland implementation more closely and makes it
easier to reuse it.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-07-19 14:12:37 +00:00
Daniel Stone 8b238905d7 xwayland: Use os_socketpair_cloexec()
We already have a helper for this; use it.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-07-19 14:12:37 +00:00
Daniel Stone 5dbe001661 xwayland: Use custom-env arg handling
Use the arg handling added in the previous commit so that the
environment is completely encapsulated inside the custom env.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-07-19 14:12:37 +00:00
Daniel Stone fafe5f0fc2 custom-env: Prepare for handling args as well as environment
Rename the bits handling environment variables (currently, all of it),
so we have room to handle args as well.

No functional changes.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-07-19 14:12:37 +00:00
Daniel Stone b685e075cd process-util: Move Xwayland fork helpers to shared
We'll want to reuse these inside desktop-shell as well as the Weston
frontend.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-07-19 14:12:37 +00:00
Pekka Paalanen 764c2aff8f xwayland: do not check execve() return value
Simplifies the code a bit.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-07-12 08:30:22 +00:00
Pekka Paalanen 1bd92dac01 xwayland: do not use setenv() after fork()
Between fork() and exec() in the child process it is only safe to use
async-signal-safe functions. Painfully, setenv() is not listed as such.

Therefore we must craft our own custom environment, and we get no help
from libc with that.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-07-12 08:30:22 +00:00
Pekka Paalanen d1b01ffb9a xwayland: use execv()
Constructing argv before-hand is a little easier to look at, but this is
mostly just anticipating more changes to how Weston spawns processes in
general.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-07-12 08:30:22 +00:00
Pekka Paalanen a3d7199bea xwayland: use pipe2()
We are already using pipe2() in many places, even in libweston, so let's
simplify the code here as well - not to mention avoid a theoretical
race.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-07-12 08:30:22 +00:00
Pekka Paalanen 4c0bdbfde9 xwayland: do not snprintf() after fork()
Between fork() and exec() in the child process it is only safe to use
async-signal-safe functions. Surprisingly, snprintf() is not such
function. See e.g. https://stackoverflow.com/a/6771799 and how snprintf
is not listed in signal-safety(7) manual.

Therefore we must prepare the fd argument strings before fork(). That is
only possible if we also do not dup() fd in the child process. Hence we
remove the close-on-exec flag instead in the child process which has
copies of the parent's file descriptors. Fortunately fcntl() is safe.

struct fdstr is helping to reduce code clutter a bit.

Additionally, if fork() fails, we now clean up the fds we created.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-07-12 08:30:22 +00:00
Pekka Paalanen 77cf8cb006 xwayland: do not weston_log() after fork()
Between fork() and exec() in the child process it is only safe to use
async-signal-safe functions. weston_log() definitely is not one, it
allocates memory and does whatnot.

weston_log() is also inappropriate for other reasons: the child process
has its own stream buffers and flight-recorder. No-one looks into the
child process' flight recorder, so messages would be lost there. The
logging machinery might also attempt to write into debug streams,
meaning both parent and child could be writing simultaneously.

It seems that the best we can do is to pre-bake an error message and
only write() it out if exec() fails. There is no mention that even
strerror_r() might be safe to call, so we don't.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-07-12 08:30:22 +00:00
Pekka Paalanen 71b40fc76b xwayland: move config reading up
Doing any kind of memory allocation calls between fork() and exec() in
the child process is prone to deadlocks and explosions. In general, only
async-signal-safe functions are safe there.

Move the config access to the parent process before fork() to avoid
problems.

See also:
https://gitlab.freedesktop.org/wayland/weston/-/merge_requests/941#note_1457053

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-07-12 08:30:22 +00:00
Pekka Paalanen e88a622434 Revert "xwayland: Don't dup() displayfd pipe"
This reverts commit 4aa885d4af.

Turns out the problem was not about dupping fds at all, but calling
non-async-signal-safe functions like strdup() between fork() and exec()
in the child process.

For more discussion, see:
https://gitlab.freedesktop.org/wayland/weston/-/merge_requests/941#note_1457053

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-07-12 08:30:22 +00:00
Pekka Paalanen ff94ba33cd compositor: fix shutdown when xwayland failed to start
This patch fixes the following:

AddressSanitizer:DEADLYSIGNAL
=================================================================
==528956==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000008 (pc 0x7fbc5d66bdd7 bp 0x7ffd465573c0 sp 0x7ffd46557398 T0)
==528956==The signal is caused by a WRITE memory access.
==528956==Hint: address points to the zero page.
    #0 0x7fbc5d66bdd7 in wl_list_remove ../../git/wayland/src/wayland-util.c:56
    #1 0x7fbc5cb8869e in wxw_compositor_destroy ../../git/weston/compositor/xwayland.c:357
    #2 0x7fbc5baf3ca6 in weston_signal_emit_mutable ../../git/weston/shared/signal.c:62
    #3 0x7fbc5ba4d6f9 in weston_compositor_destroy ../../git/weston/libweston/compositor.c:8639
    #4 0x7fbc5cb7a5f2 in wet_main ../../git/weston/compositor/main.c:3772
    #5 0x55bd13de2179 in main ../../git/weston/compositor/executable.c:33
    #6 0x7fbc5be61d09 in __libc_start_main ../csu/libc-start.c:308
    #7 0x55bd13de2099 in _start (/home/pq/local/bin/weston+0x1099)

The problem is triggered by configuring a bad path to Xwayland in
weston.ini, which causes exec() to fail. The fork() succeeded though,
which means the weston_process was already on the watch list, and the
watch can be handled, making sigchl_handler() leave the link
uninitialized.

Making sure the link remains removable fixes this.

Fixes: 18897253d4

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-07-08 11:56:04 +03:00
Pekka Paalanen 00641368e2 compositor: deprecate cms-static and cms-colord plugins
While developing the new color management, keeping these old plugins
working would require extra work. Let's deprecate these to see if anyone
cares about them, pending removal after the Weston 11.0.0 release.

CI will keep building these in the "Full build" configuration only. Doc
and no-GL builds are no different for these plugins, so there these are
no longer built.

See https://gitlab.freedesktop.org/wayland/weston/-/issues/634

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-07-06 10:38:44 +00:00
Daniel Stone 18897253d4 xwayland: Add compositor destroy listener to free allocation
Otherwise we just leak this into the void. Not good.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-07-05 13:25:37 +01:00
Daniel Stone 4aa885d4af xwayland: Don't dup() displayfd pipe
For some reason, this causes the reads to get completely lost sometimes
in CI.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-07-05 13:25:37 +01:00
Michael Olbrich 158c3ef0dd compositor: destroy the layout after the compositor
This way the backends will the actual outputs. And at that point the backend
knows the compositor is shutting down so it can handle this differently if
necessary.
Afterwards wet_compositor_destroy_layout() just deletes the remaining
datastructures.

Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
2022-07-04 18:42:48 +00:00
Daniel Stone b923802113 xwayland: Refactor argument string construction
Replace an oft-duplicated pattern with a trivial helper function. In
doing so, we observe that the one special case (displayfd 'didn't need
to be CLOEXEC') was wrong, because the X server does fork itself
internally, so there is nothing wrong with setting CLOEXEC.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-07-04 11:58:37 +00:00
Pekka Paalanen 8de94ec9c9 compositor: add weston.ini option max-bpc
For working around hardware limitations as explained in the man page.
Now added for completeness' sake without knowing if anyone will ever
need this.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-06-15 12:58:38 +00:00