Commit Graph

136 Commits

Author SHA1 Message Date
Marius Vlad a86b590fea backend-drm: Fix ignoring config 'require-input' option
Without this patch, the DRM-backend would rewrite the 'require-input',
core section option given by the user.

This removes 'continue_without_input' DRM-backend option and takes into
consideration the cmd line option only if that was passed (Pekka Paalanen).

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2020-12-07 12:49:38 +02:00
Leandro Ribeiro cdb7218daf compositor: move tests quirks initialization to weston_compositor_create()
Until now we had the test quirks initialization in wet_main(),
just after calling weston_compositor_create(). But there are
some cases that require the quirks during struct weston_compositor
creation time.

Move test quirks initialization to weston_compositor_create()
in order to cover more use cases for the test quirks mechanism.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2020-11-17 12:38:42 +00:00
Leandro Ribeiro 32a5acde5b tests: add mechanism to change Weston's behavior when running certain tests
There are some specific cases in which we need Weston to
behave differently when running in the test suite. This
adds a new API to allow the tests to select these behaviors.

For instance, in the DRM backend we plan to add a writeback
connector screenshooter. In case it fails for some
reason, it should fallback to the renderer screenshooter
that all other backends use. But if we add a test to
ensure the correctness of the writeback screenshooter,
we don't want it to fallback to the renderer one, we
want it to fail. With this new API we can choose to
disable the fallback behavior specifically for this test.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2020-10-27 11:21:55 +00:00
Pekka Paalanen 43141231a0 compositor: delete segv_compositor
This was forgotten in "weston: remove SEGV and ABRT handlers". It is
unused.

Fixes: bb707dc0fe

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2020-10-21 13:59:18 +03:00
Manuel Stoeckl ae69381b6e compositor: avoid setting WAYLAND_DISPLAY=wayland-0
This commit alters the way that Weston picks a Wayland display socket
name. Instead of using wl_display_add_socket_auto to look for the first
available name in wayland-0, wayland-1, .... to wayland-32, the code now
checks names wayland-1, wayland-2, .... up to wayland-32.

This change is a workaround for a suboptimal behavior of
libwayland-client. If a client program calls wl_display_connect(NULL) and
the WAYLAND_DISPLAY environment variable is not set, then the program will
by default try to connect to 'wayland-0'. This is a problem when a
computer has a running Wayland compositor but is being accessed in some
other fashion, such as through an X session on a different virtual
terminal, over ssh, etc. Client programs launched through those means may
attempt to connect to an unrelated compositor. Changing libwayland
behavior to remove the default would also work, but a) libraries have
stronger backward compatibility expectations b) that would likely break
more people's setups than just changing Weston would.

Signed-off-by: Manuel Stoeckl <code@mstoeckl.com>
2020-09-15 11:03:18 +00:00
Marius Vlad c4076ef88a plug-ins: Migrate pipewire and remoting plug-ins headers to public header
directory

Weston is also a user of the plug-ins, so make use of it. With this
change we unconditionally install the plug-in headers even though
libweston might not be built with support for them.

Suggested-by: Pekka Paalanen <pekka.paalanen@collabora.com>
Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2020-09-04 10:36:48 +00:00
Leandro Ribeiro e57d8ae818 drm-backend: add --continue-without-input command line option to DRM-backend
In the test suite we may want to run a DRM-backend test on a
non-default seat, which may not have a input device associated.
Weston's default behavior is to not open if input devices are
not found, as it may cause troubles. For instance, Weston can
open but if no input device is set than the user can not
interact or leave it.

Add flag --continue-without-input to DRM-backend so we can run
these types of tests with no input. Notice that this won't force
the compositor to skip opening a input device if it finds it on
the non-default seat.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2020-06-02 13:47:15 +00:00
Antonio Caggiano 2eda978e95 compositor: Quit when failing to open log file
If users ask explicitly to log to a file, it makes sense to quit
when we fail opening that file. Continuing execution would mean
wasting users' time if they expect to find the log file at the
end of the session.

Signed-off-by: Antonio Caggiano <antonio.caggiano@collabora.com>
Suggested-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2020-06-01 18:03:33 +00:00
Antonio Caggiano fdc9b4bce5 compositor: Print error opening log file
When failing to open the log file nothing is reported to the user,
therefore we print a message on stderr when that happens.

Signed-off-by: Antonio Caggiano <antonio.caggiano@collabora.com>
Suggested-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2020-06-01 18:03:33 +00:00
Daniel Stone 5450456da2 compositor: Fail on invalid transform for headless
As in aaf35586f4, we want to fail when we are passed an invalid
transform name, not just blindly configure on using the normal
transform. The previous commit missed the callsite from the headless
backend's command-line parsing.

Fix this so that headless fails when an invalid transform is specified
on the command line.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2020-03-11 10:38:08 +00:00
Daniel Stone 1c0507b12a compositor: Use weston_head transform for output default
If the output only has a single weston_head attached to it, take its
declared transform as the default transform.

With the previous patches, this allows a device declaring the KMS 'panel
orientation' property (e.g. through DeviceTree) to autoconfigure to the
correct display rotation when running Weston.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2020-03-06 21:50:38 +00:00
Daniel Stone aaf35586f4 compositor: Fail output configuration on invalid transform
If an invalid transformation is provided for an output, fail the output
configuration rather than continuing on using whatever we chose as the
default transform.

After !383, this will result in configurations using the old definition
failing and exiting, rather than continuing on the wrong way around.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2020-03-06 21:50:38 +00:00
Daniel Stone 31af69d868 compositor: Fix default transforms when output section declared
Regardless of the default transform passed in, weston_parse_transform
would always return 'normal' if there was an output section. This is
because, if a section was declared for that output, it would ask
weston_config for the transform, with the default being 'normal'.

Fix it so we return the passed-in default transform when we have a
matching output section without a transform key. If the transform is
declared but invalid, we can remove the line resetting to the default
transform, because we've already set the default transform up top.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2020-03-06 21:47:51 +00:00
Pekka Paalanen dd84ecf44d compositor: add scale cmdline option for headless
The test suite wants to start using different output scales, and this is the
easiest API to configure it.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2020-02-27 16:08:42 +02:00
Pekka Paalanen 8060d826b7 Redefine output rotations
It was discovered in issue #99 that the implementations of the 90 and 270
degree rotations were actually the inverse of what the Wayland specification
spelled out. This patch fixes the libweston implementation to follow the
specification.

As a result, the behaviour of the the weston.ini transform key also changes. To
force all users to re-think their configuration, the transform key values are
also changed. Since Weston and libweston change their behaviour, the handling
of clients' buffer transform changes too.

All the functions had their 90/270 cases simply swapped, probably due to
confusion of whether WL_OUTPUT_TRANSFORM_* refers to rotating the monitor or
the content.

Hint: a key to understanding weston_matrix_rotate_xy(m, c, s) is that the
rotation matrix is formed as

  c -s
  s  c

that is, it's column-major. This fooled me at first.

Fixing window.c fixes weston-terminal and weston-transformed.

In simple-damage, window_get_transformed_ball() is fixed to follow the proper
transform definitions, but the fix to the viewport path in redraw() is purely
mechanical.  The viewport path looks broken to me in the presence of any
transform, but it is not this patch's job to fix it.

Screen-share fix just repeats the general code fix pattern, I did not even try
to understand that bit.

https://gitlab.freedesktop.org/wayland/weston/issues/99

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2020-02-27 11:08:48 +00:00
Leandro Ribeiro 9aaaf96a6a compositor: destroy log context only after the destruction of subscribers
Before commit "weston-log: destroy subscriptions with
destruction of subscribers", we had to destroy subscribers
before the log context. Currently there's no required order,
both are valid.

But since we've created log context before the subscribers,
we can destroy it after them. This is a style change and
also a prove that now this order is valid as well.

Signed-off-by: Leandro Ribeiro <leandrohr@riseup.net>
2020-02-10 10:53:50 +00:00
Leandro Ribeiro 1ded661aac weston-log: merge functions that destroy different types of subscribers
Log subscriber API is not type-safe. File and flight recorder
subscribers are created with functions that return
weston_log_subscriber objects. But there's a problem: to destroy
these objects you have to call the right function for each type
of subscriber, and a user calling the wrong destroy function
wouldn't get a warning.

Merge functions that destroy different types of subscribers, making
the log subscriber API type-safe.

Signed-off-by: Leandro Ribeiro <leandrohr@riseup.net>
2020-02-10 10:53:50 +00:00
Guillaume Champagne 9096dee405 headless: fix uninitialized variable
`no_outputs` is declared on the stack and left uninitialized if no
weston option changing its value is provided.

Signed-off-by: Guillaume Champagne <champagne.guillaume.c@gmail.com>
2020-02-04 13:30:19 +00:00
Leandro Ribeiro ca640d5120 libweston: fold weston_compositor_tear_down() into weston_compositor_destroy()
The only reason why we have both weston_compositor_tear_down() and
weston_compositor_destroy() is that the only we had to destroy
the log context was keeping weston_compositor alive and calling
weston_log_ctx_compositor_destroy().

After commit "weston-log: replace weston_log_ctx_compositor_destroy()
by weston_log_ctx_destroy()", it's not necessary to keep a zombie
weston_compositor just to be able to call
weston_log_ctx_compositor_destroy().

Fold weston_compositor_tear_down() into weston_compositor_destroy(),
as this split is useless now.

Signed-off-by: Leandro Ribeiro <leandrohr@riseup.net>
2020-01-29 12:15:16 -03:00
Leandro Ribeiro 4ec38d18b3 weston-log: replace weston_log_ctx_compositor_destroy() by weston_log_ctx_destroy()
The function weston_log_ctx_compositor_destroy(), which destroys struct
weston_log_context, takes weston_compositor as argument. We may have a
weston_log_context unlinked from a weston_compositor and currently there
is no way to destroy it.

Add function weston_log_ctx_destroy(), what makes the destruction of
weston_log_context independent of weston_compositor.

With this change, one could destroy a weston_compositor and keep the
related weston_log_context (since now weston_log_context can be destroyed
without the need of a weston_compositor). But if weston_compositor gets
destroyed it's also necessary to destroy weston_log_context::global,
as the debug protocol depends on the compositor. So a listener has been
added to the destroy signal of weston_compositor.

Signed-off-by: Leandro Ribeiro <leandrohr@riseup.net>
2020-01-29 12:08:54 -03:00
Leandro Ribeiro 4f13595aa7 weston-log: rename weston_log_ctx_compositor_create() to weston_log_ctx_create()
Since weston_log_ctx_compositor_create() does not have any relation
with weston_compositor, rename it to weston_log_ctx_create().

Signed-off-by: Leandro Ribeiro <leandrohr@riseup.net>
2020-01-29 12:08:54 -03:00
Leandro Ribeiro f014964f6f weston-log: rename the confusing function name weston_compositor_log_scope_destroy()
There's a function named weston_compositor_log_scope_destroy()
but it doesn't take a struct weston_compositor argument.

Rename it to weston_log_scope_destroy(), as the argument is a
struct weston_log_scope.

Signed-off-by: Leandro Ribeiro <leandrohr@riseup.net>
2020-01-27 13:43:24 -03:00
Leandro Ribeiro 5976dbbbb5 weston-log: rename the confusing function name weston_compositor_add_log_scope()
There's a function named weston_compositor_add_log_scope()
but it doesn't take a struct weston_compositor argument.

Rename it to weston_log_ctx_add_log_scope(), as
the log_scope is being added to a log_context.

Also, bump libweston_major to 9.

Signed-off-by: Leandro Ribeiro <leandrohr@riseup.net>
2020-01-27 13:42:42 -03:00
Daniel Stone dd8219b3fb option-parser: Make bools boolean
When option-parser is confronted with a boolean option, have it write a
bool rather than treating the value as a pointer to an int32.

(lib)weston already heavily uses bool types internally, so this has the
nice side effect of eliminating quite a few local variables which only
existed as integer shadows of internal boolean variables.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2019-11-28 19:24:13 +00:00
Daniel Stone 51d995ad82 config-parser: Make get_bool be bool
Wayland innovated a lot of cool things, but non-binary boolean values is
the great advances of our time.

Make config_parser_get_bool() work on boolean values, and switch all its
users.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2019-11-28 19:24:13 +00:00
Pekka Paalanen 3025353e83 compositor: allow double-loading modules
This is necessary for the test harness to be able to execute the compositor
multiple times in the same process. As we never unload opened modules, the
first compositor iteration will leave them all loaded and following compositor
iterations will then have them already loaded.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2019-11-21 16:32:55 +00:00
Marius Vlad 9c4b5c4931 compositor: Fix some warning when passing debugoptimized to meson
Increase the buf size such it can accomodate sufficiently large local
buffers. Spotted whilst looking for something else.

../compositor/main.c:157:22: warning: ‘%s’ directive output may be
truncated writing up to 511 bytes into a region of size 128
[-Wformat-truncation=]
  157 |  snprintf(buf, len, "%s[%s.%03li]", datestr,
      |                      ^~             ~~~~~~~
../compositor/main.c:157:21: note: directive argument in the range
[-9223372036854775, 9223372036854775]
  157 |  snprintf(buf, len, "%s[%s.%03li]", datestr,
      |                     ^~~~~~~~~~~~~~
../compositor/main.c:157:2: note: ‘snprintf’ output between 7 and 659
bytes into a destination of size 128
  157 |  snprintf(buf, len, "%s[%s.%03li]", datestr,
      |  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  158 |    timestr, (tv.tv_usec / 1000));
      |    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2019-11-14 10:54:40 +02:00
Marius Vlad ded0b77316 compositor: Pass the entire string in one-shot when writting logger data
This fixes the situation where the same logger scope is passed multiple
times and the timestamp is being sent before the log mesasge.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
Reported-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2019-11-05 13:59:18 +02:00
Marius Vlad 91dffa37a6 compositor: Allow protocol to be displayed when asked for, even if we're not supplying debug argument
This wasn't intentional it just kept the way it was done before.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
Reported-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2019-11-04 17:04:08 +02:00
Pekka Paalanen b35c21f70c compositor: turn weston main() into a lib
This takes everything that was in 'weston' the executable a turns it into
library. A new trivial 'weston' executable is written.

Creating the library will allow future improvements:

- we can link weston plugins against the library, meaning that they no longer
  need unresolved symbols to be allowed during linking

- tests do not have to fork() and exec() 'weston', they can just link to the
  library and call wet_main() after setting things up; this will help with
  using a debugger

install_rpath is set so that we can install the library into weston's module
directory, away from the normal libraries in a system. This is one library we
do not intend for others to use.

The library has no stable ABI and is not versioned.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2019-10-24 13:40:51 +03:00
Marius Vlad 9bb1c3a3c2 weston-log: Add 'destroy_subscription' callback for the subscription
As 'new_subscription' can create additional objects, 'destroy_subscription'
will be needed when cleaning up.

As this requires a libweston_major bump (noticed by @pq), bump it up to
8.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
Suggested-by: Daniel Stone <daniel.stone@collabora.com>
2019-10-17 19:42:55 +03:00
Pekka Paalanen c57a8cccd3 compositor: add use-gl option to headless
This will allow one to run the headless backend with GL-renderer.

Implements: https://gitlab.freedesktop.org/wayland/weston/issues/278

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2019-10-11 12:16:35 +00:00
Pekka Paalanen c232f8d934 Unify the include style of shared/ headers
When all shared/ headers are included in the same way, we can drop unnecessary
include seach paths from the compiler.

This include style was chosen because it is prevalent in the code base. Doing
anything different would have been a bigger patch.

This also means that we need to keep the project root directory in the include
search path, which means that one could accidentally include private headers
with

	#include "libweston/dbus.h"

or even

	#include <libweston/dbus.h>

IMO such problem is smaller than the churn caused by any of the alternatives,
and we should be able to catch those in review. We might even be able to catch
those with grep in CI if necessary.

The "bad" include style was found with:
$ for h in shared/*.h; do git grep -F $(basename $h); done | grep -vF '"shared/'

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2019-10-04 16:04:48 +03:00
Miguel A. Vico 5c5f0272d9 compositor: Do not trigger invalid destructors when hotunplugging
When hotunplugging a display, the compositor will tear the top-level
wet_output object down, freeing its memory.

However, destruction of the backend output might be delayed in certain
situations (e.g. destroying DRM output while in the middle of a page
flip).

When the backend output is finally destroyed, it will trigger a
destruction callback previously added by the compositor, which point to
data belonging to the top-level wet_output object.

In order to avoid access to invalid data when the backend output is
destroyed after the top-level wet_output object, remove the destruction
callback from the corresponding list before freeing the object.

Signed-off-by: Miguel A Vico Moya <mvicomoya@nvidia.com>
2019-09-25 13:25:39 -07:00
Marius Vlad e568488548 compositor: Return the number of bytes written as to format properly
Otherwise 'log_extensions()' will not know how to properly format the
data.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
Reported-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2019-08-19 12:52:29 +03:00
Marius Vlad 7216d4c44b compositor: Bring back the old timestamp format for the log scope
Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
Reported-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2019-08-12 18:31:46 +00:00
Marius Vlad bed9b81a39 compositor: Use only 'log' scope to print libwayland messages
No need to duplicate messages.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2019-08-06 14:34:17 +03:00
Michael Olbrich d5d5aa91a2 Add pipewire plugin
It is quite similar to the remoting plugin. It just exports the frames via
pipewire instead of the builtin GStreamer pipeline.
It implements the same virtual output API. Virtual outputs can be created
by adding 'pipewire-output' sections to weston.ini.

The generated frames can be accessed with any pipewire client. e.g. with
GStreamer:

gst-launch-1.0 pipewiresrc ! video/x-raw,format=BGRx ! ...

Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
2019-07-19 08:01:55 +02:00
Marius Vlad e2d2ab7ed5 compositor: Remove from main displaying available log scopes
Place the subscribe parts and displaying of available scopes out of
main as it makes no sense to keep them there.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2019-07-18 13:34:04 +03:00
Marius Vlad 592555831a compositor: Add debug key-binding to display/dump flight recorder contents
Uses (debug key-binding mod+shift+space) KEY_D to display/dump
the contents of the flight recorder.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2019-07-18 13:34:04 +03:00
Marius Vlad b5ac5a9aa1 compositor: Plug-in the flight recorder
Create a flight recorder subscriber and allow subscribring to scopes
over the command line.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2019-07-18 13:34:04 +03:00
Marius Vlad b599ad7701 compositor: Create the 'log' scope much earlier
Logging should start as early as possible so create the log scope as
early as possible, before subscribing to it.

Open the logfile before creating the 'logger' subscriber, making sure
we're logging to the file properly.

Also migrate `weston_log_set_handler()` to avoid potential calls to
`weston_log` before installing the log handler.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2019-07-18 13:34:04 +03:00
Marius Vlad 284d5345ad compositor: Destroy the compositor before the log scope
Destroying the compositor after destroying the log scope will not print
out the messages in the tear down/clean-up phase of the compositor, so
add a new tear_down function which allows keeping a valid reference to
the compositor. This way we can destroy the compositor before destroying
the scope and keep the debug messages.

While at it remove the log context destroy part from the clean-up
of the compositor and make it stand on its own.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2019-07-18 13:34:04 +03:00
Marius Vlad f387f8409a compositor: Plug-in the file stream
Pass log scopes from the command line to subscribe log scopes
dynamically to the 'logger' subscriber.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2019-07-18 13:34:04 +03:00
Marius Vlad c901e8913e weston-debug: Rename weston-debug to weston-log to better reflect its purpose
No changes in functionality have been made.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2019-07-18 10:49:39 +03:00
Tomohito Esaki 3ea03bb85e remoting: make a gstreamer pipeline configurable
Allow a gstreamer pipeline to be configurable via an weston.ini. It is
necessary that source is appsrc, its name is "src", and sink name is
"sink" in pipeline. Also, remoting plugin ignore port and host
configuration if the gst-pipeline is specified.
2019-07-09 14:22:25 +00:00
Ankit Nautiyal 2844f8eaaf compositor: Enable HDCP for an output using weston.ini
This patch enables a user to opt for HDCP per output, by writing into
the output section of weston.ini configuration file. HDCP is always
enabled by default for the outputs.

Signed-off-by: Ankit Nautiyal <ankit.k.nautiyal@intel.com>
2019-07-05 14:13:30 +05:30
Stefan Agner b0e16d4c53 backend-rdp: allow to force compression off
By default the client communicates its preference with regards to
compression to the server. However, some clients always use
compression, which is not ideal for certain environments (e.g.
low performance embedded devices in a local network with plenty
of bandwidth). Allow to disable compression server-side which will
override the clients request for compression.

Signed-off-by: Stefan Agner <stefan@agner.ch>
2019-06-20 16:39:13 +02:00
Daniel Stone 814335821e weston: Properly test for output-creation failure
We were testing the wrong variable to see if output creation had failed:
instead of testing the return of the function we'd just called, we were
testing something we'd already checked earlier.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2019-06-11 10:36:55 +00:00
Fabrice Fontaine 137b811ecd Fix build with kernel < 4.4
weston includes input-event-codes.h since version 5.0.91 and
6e229ca263

input-event-codes.h is available only since kernel 4.4 and
f902dd8934

To fix this build failure, replace include on linux/input-event-codes.h
by linux/input.h

Fixes:
 - http://autobuild.buildroot.org/results/210c2759900f15ea0030d088f6f45cd8bb199b29

Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
2019-06-10 14:02:29 +02:00