Commit graph

849 commits

Author SHA1 Message Date
Alvarito050506 60855b1569 compositor: Added autolaunch support.
The value of the `path` parameter is executed right before
wl_display_run.

The `watch` parameter is meant for things like tests using
the headless backend and the kiosk shell.

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

Signed-off-by: Alvarito050506 <donfrutosgomez@gmail.com>
2021-07-06 18:46:09 +00:00
Alvarito050506 1f57a1f998 compositor: Move child_process_list from global to wet_compositor.
Removes a global variable and makes it easier to avoid adding more
global variables in the next commit.

See https://gitlab.freedesktop.org/wayland/weston/-/merge_requests/652#note_975222

Signed-off-by: Alvarito050506 <donfrutosgomez@gmail.com>
2021-07-06 18:46:09 +00:00
Pekka Paalanen 2516e3308d compositor: fix leaking log_scopes
Found by ASan:

Direct leak of 30 byte(s) in 1 object(s) allocated from:
    #0 0x7f4dcf029810 in strdup (/lib/x86_64-linux-gnu/libasan.so.5+0x3a810)
    #1 0x7f4dcefd2143 in handle_option ../../git/weston/shared/option-parser.c:56
    #2 0x7f4dcefd2473 in long_option ../../git/weston/shared/option-parser.c:84
    #3 0x7f4dcefd2bb6 in parse_options ../../git/weston/shared/option-parser.c:175
    #4 0x7f4dcefc7b0d in wet_main ../../git/weston/compositor/main.c:3229
    #5 0x5593dfa38ffd in execute_compositor ../../git/weston/tests/weston-test-fixture-compositor.c:432
    #6 0x5593dfa3ca69 in weston_test_harness_execute_as_client ../../git/weston/tests/weston-test-runner.c:528
    #7 0x5593dfa2e511 in fixture_setup ../../git/weston/tests/ivi-shell-app-test.c:139
    #8 0x5593dfa2e596 in fixture_setup_run_ ../../git/weston/tests/ivi-shell-app-test.c:141
    #9 0x5593dfa3d01e in main ../../git/weston/tests/weston-test-runner.c:661
    #10 0x7f4dcec2d09a in __libc_start_main ../csu/libc-start.c:308
    #11 0x5593dfa2d769 in _start (/home/pq/build/weston-meson/tests/test-ivi-shell-app+0xd769)

when running

	ASAN_OPTIONS=fast_unwind_on_malloc=0,malloc_context_size=50 \
	LSAN_OPTIONS=suppressions=/home/pq/git/weston/.gitlab-ci/leak-sanitizer.supp \
	./tests/test-ivi-shell-app

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-06-16 14:41:08 +00:00
Pekka Paalanen 478123b967 Revert "compositor: add weston.ini option use-renderer-shadow"
This reverts commit 81ef6d0ab3.

This also removes a bit from "tests: ensure color-lcms plugin loads".

Use of the shadow buffer is determined automatically based on
color transformations by the previous commit
"gl-renderer: use shadow framebuffer automatically".

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-06-14 16:04:43 +03:00
Pekka Paalanen c87fa24059 compositor: add weston.ini option to enable color management
This new option allows loading the color-lcms plugin.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-06-14 12:53:41 +00:00
Damian Wrobel d3630ace1a compositor: Improve logging message
Signed-off-by: Damian Wrobel <dwrobel@ertelnet.rybnik.pl>
2021-05-14 14:57:06 +02:00
Pekka Paalanen a49ca3d205 compositor: fix UAF on text-backend tear-down
Found by Address sanitizer on test-devices:

==10640==ERROR: AddressSanitizer: heap-use-after-free on address 0x60c000000580 at pc 0x7fa0f050dcd1 bp 0x7fff41c908e0 sp 0x7fff41c908d8
WRITE of size 8 at 0x60c000000580 thread T0
    #0 0x7fa0f050dcd0 in unbind_input_method ../../git/weston/compositor/text-backend.c:852
    #1 0x7fa0efd1b20d in destroy_resource ../../git/wayland/src/wayland-server.c:724
    #2 0x7fa0efd1f7f1 in for_each_helper ../../git/wayland/src/wayland-util.c:372
    #3 0x7fa0efd1fcde in wl_map_for_each ../../git/wayland/src/wayland-util.c:385
    #4 0x7fa0efd1b35c in wl_client_destroy ../../git/wayland/src/wayland-server.c:883
    #5 0x7fa0f050ea82 in text_backend_destroy ../../git/weston/compositor/text-backend.c:1067
    #6 0x7fa0ebb69f2f in shell_destroy ../../git/weston/desktop-shell/shell.c:5012
    #7 0x7fa0efd55933 in wl_signal_emit /home/pq/local/include/wayland-server-core.h:478
    #8 0x7fa0efd7d061 in weston_compositor_destroy ../../git/weston/libweston/compositor.c:7896
    #9 0x7fa0f050a349 in wet_main ../../git/weston/compositor/main.c:3493
    #10 0x559c1e794354 in execute_compositor ../../git/weston/tests/weston-test-fixture-compositor.c:432
    #11 0x559c1e797dc0 in weston_test_harness_execute_as_client ../../git/weston/tests/weston-test-runner.c:528
    #12 0x559c1e786ab8 in fixture_setup ../../git/weston/tests/devices-test.c:39
    #13 0x559c1e786b3a in fixture_setup_run_ ../../git/weston/tests/devices-test.c:41
    #14 0x559c1e798375 in main ../../git/weston/tests/weston-test-runner.c:661
    #15 0x7fa0f016e09a in __libc_start_main ../csu/libc-start.c:308
    #16 0x559c1e786769 in _start (/home/pq/build/weston-meson/tests/test-devices+0xc769)

0x60c000000580 is located 0 bytes inside of 120-byte region [0x60c000000580,0x60c0000005f8)
freed by thread T0 here:
    #0 0x7fa0f0618fb0 in __interceptor_free (/lib/x86_64-linux-gnu/libasan.so.5+0xe8fb0)
    #1 0x7fa0f050df1d in input_method_notifier_destroy ../../git/weston/compositor/text-backend.c:902
    #2 0x7fa0efd86d77 in wl_signal_emit /home/pq/local/include/wayland-server-core.h:478
    #3 0x7fa0efd98086 in weston_seat_release ../../git/weston/libweston/input.c:3475
    #4 0x7fa0ebb0d002 in test_seat_release ../../git/weston/tests/weston-test.c:132
    #5 0x7fa0ebb0e197 in device_release ../../git/weston/tests/weston-test.c:314
    #6 0x7fa0efca88ed in ffi_call_unix64 (/lib/x86_64-linux-gnu/libffi.so.6+0x68ed)

previously allocated by thread T0 here:
    #0 0x7fa0f0619518 in calloc (/lib/x86_64-linux-gnu/libasan.so.5+0xe9518)
    #1 0x7fa0f050a8bf in zalloc ../../git/weston/include/libweston/zalloc.h:38
    #2 0x7fa0f050e6f1 in text_backend_seat_created ../../git/weston/compositor/text-backend.c:1011
    #3 0x7fa0f050e947 in handle_seat_created ../../git/weston/compositor/text-backend.c:1040
    #4 0x7fa0efd86d77 in wl_signal_emit /home/pq/local/include/wayland-server-core.h:478
    #5 0x7fa0efd97d57 in weston_seat_init ../../git/weston/libweston/input.c:3440
    #6 0x7fa0ebb0ce4b in test_seat_init ../../git/weston/tests/weston-test.c:110
    #7 0x7fa0ebb0f699 in wet_module_init ../../git/weston/tests/weston-test.c:592
    #8 0x7fa0f04f8d69 in wet_load_module ../../git/weston/compositor/main.c:941
    #9 0x7fa0f04f914d in load_modules ../../git/weston/compositor/main.c:1012
    #10 0x7fa0f0509ec1 in wet_main ../../git/weston/compositor/main.c:3441
    #11 0x559c1e794354 in execute_compositor ../../git/weston/tests/weston-test-fixture-compositor.c:432
    #12 0x559c1e797dc0 in weston_test_harness_execute_as_client ../../git/weston/tests/weston-test-runner.c:528
    #13 0x559c1e786ab8 in fixture_setup ../../git/weston/tests/devices-test.c:39
    #14 0x559c1e786b3a in fixture_setup_run_ ../../git/weston/tests/devices-test.c:41
    #15 0x559c1e798375 in main ../../git/weston/tests/weston-test-runner.c:661
    #16 0x7fa0f016e09a in __libc_start_main ../csu/libc-start.c:308

Fix UAF by resetting wl_resource user data, and ensuring it is valid
before used.

Setting seat->input_method to NULL may not be necessary since it is
being called from seat destroy listener, but added just in case.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-05-12 14:23:21 +03:00
Leandro Ribeiro 91f398bc30 libweston: do not forget to check if test_data is NULL
Since commit "libweston: add required_capabilities test suite quirk"
a new function that depends on test_data is being called in wet_main().

We should check if test_data is NULL before calling it, otherwise
we have a segfault when running outside the test suite.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2021-03-16 15:03:49 -03:00
Pekka Paalanen 19d31dd4c3 libweston: add required_capabilities test suite quirk
This allows tests to skip when required capabilities are not present.
The output damage test for the shadow buffer case needs this.

required_capabilities is added to struct weston_testsuite_quirks which
is libweston public API just because there is no better place currently.
This is a little weird because the code to check it is in compositor,
not libweston.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-03-12 16:14:28 +02:00
Pekka Paalanen ed2182f356 compositor: print all existing capability bits
Gives a string for all existing capability bits. This is useful for the
next commit.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-03-09 12:13:08 +02:00
Pekka Paalanen eb2aa7d8f3 compositor: move colon in capability printing
The capability strings will be printed also in another occasion, where
the colon does not fit with the capability description.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-03-09 12:13:08 +02:00
Vlad Zahorodnii 022ea43f9b xwayland: Pass -listenfd instead of -listen <fd>
The -listen <fd> option has been deprecated. Its replacement is -listenfd.

Signed-off-by: Vlad Zahorodnii <vlad.zahorodnii@kde.org>
2021-03-04 09:35:55 +00:00
Pekka Paalanen 81ef6d0ab3 compositor: add weston.ini option use-renderer-shadow
This adds an output section option use-renderer-shadow in weston.ini.
This option is only recognized with headless and DRM backends, because
it requires GL-renderer and does not support resizing outputs.

The option is called use-renderer-shadow because this is what it does
right now. In the future the same setting will be used to turn on more
complex image processing when operational pieces required for color
management land. Once color management is implemented, this option is
expected to be removed. This option allows developer testing of features
to be used to implement color management.

This is a rewrite of "weston.ini: introduce use-shadow-fbo in output
config" by Harish Krupo. The main.c code is structured differently, the
weston.ini option is renamed, and the man page paragraph is moved to
weston.ini.man with different content.

Cc: Harish Krupo <harishkrupo@gmail.com>
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-02-25 13:16:02 +02:00
Pekka Paalanen b5265af620 libweston: add color ops cap and bool renderer shadow buffer
This adds the libweston capability bit for "color operations" which
refers to a renderer's support for operations needed for color
management. GL-renderer will grow the support while Pixman-renderer will
not, which is why the cap is needed.

To make an example use of the cap, this also adds new API:
weston_output_set_renderer_shadow_buffer(). This is a temporary API to
enable future experimental features. The first such feature will be the
renderer internal shadow buffer, the boolean variable for it taken from
Harish Krupo's "weston.ini: introduce use-shadow-fbo in output config".

Obviously this patch does not implement the renderer shadow buffer. No
renderer sets WESTON_CAP_COLOR_OPS yet so trying to enable it will fail.

The documentation here is deliberately vague, because the bits needed
for color management will come in trickling for a long time until we can
call it color management in any sense. Until then, the temporary API
shall remain, perhaps poorly named.

Cc: Harish Krupo <harishkrupo@gmail.com>
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-02-25 13:16:02 +02:00
Emmanuel Gil Peyrot 5b5decb99b compositor: Add suggestion when colord is enabled but not LCMS
Most other errors caused by missing dependencies offer this helpful
suggestion.

Signed-off-by: Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
2021-02-12 12:13:28 +00:00
xndcn ffe422116d screen-share: fix possible memory leak for out_pixman_error case
shm buffer should be freed in case of `out_pixman_error`, and should
be inserted into shared_output just before the success return.

Signed-off-by: xndcn <xndchn@gmail.com>
2021-01-27 14:59:26 +00:00
Anurup M 6aa46844a6 compositor: Fix possible memory leak when wl_display_create() fails
The buffer created for flight recorder, the allocations done in 'logger' and
'flight_rec' subscribers were not freed when wl_display_create() fails. So
move them to out_display

Signed-off-by: Anurup M <anurup.mokkil@gmail.com>
2020-12-10 09:19:09 +00:00
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 bc56729ffe screenshooter: rename some functions to avoid conflicts
We have two functions with the name weston_screenshooter_shoot():

    1. screenshot protocol function that the screenshooter
    client uses to request screenshots to the compositor

    2. libweston function used by the compositor to take
    screenshots as requested by the screenshooter client

Until now we had no problem with that, but in the next commits
we are going to use the screenshot protocol in the test suite,
which is also user of libweston. So rename screenshot protocol
function to weston_screenshooter_take_shot() to avoid the conflict.

For consistency, also rename screenshooter_shoot() to
screenshooter_take_shot() in compositor/weston-screenshooter.c

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2020-10-27 12:19:39 +00:00
Leandro Ribeiro 2d4dd70ff5 libweston: drop opaque struct wet_testsuite_data
Until now we had struct wet_testsuite_data as an opaque
struct that should be defined by the testsuite of libweston
users. Instead, keep the data as a void * and document that
users are responsible for defining the data type.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2020-10-27 11:21:55 +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
Jimmy Ohn e55c86a167 screen-share: don't get weston_config object before zalloc
we don't need to get the weston_config object before zalloc success.
2020-07-01 18:58:38 +09:00
Guillaume Champagne 478710c003 meson: enable undefined functions errors for colord
The missing build dependency was added. The override to disable this
check can be removed.

Signed-off-by: Guillaume Champagne <champagne.guillaume.c@gmail.com>
2020-06-03 11:00:21 +00:00
Guillaume Champagne 7451f9956e meson: add lcms2 dependency to cms-colord
cms-colord uses cms-helper functions which require lcms2. Therefore,
lcms2 must be added as a build dependency.

Signed-off-by: Guillaume Champagne <champagne.guillaume.c@gmail.com>
2020-06-03 11:00:21 +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
Philipp Zabel 4b1de0112b build: add rpath to modules that use symbols from libexec_weston
The cms-static, desktop-shell, hmi-controller, ivi-shell, and screen-share
modules use symbols from libexec_weston, e.g.:

  $ ldd /usr/lib/x86_64-linux-gnu/weston/desktop-shell.so | grep "not found"
  	libexec_weston.so.0 => not found

Loading these modules from weston happens to work because the weston executable
itself links against libexec_weston, and has an rpath set. Still, these modules
depend on a library in a non-standard location. Adding an rpath could help
static checkers to make sure all shared objects' dependencies are present.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2020-02-06 09:00:42 +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
Pekka Paalanen 61a6b03d6f compositor: add test suite data
Allow to set and get one opaque pointer. The test suite will then use this to
pass data from the test runner to the test plugin, so that the plugin can then
run what it needs to. This is useful when the test runner calls wet_main()
directly instead of forking a compositor.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2020-01-30 10:10:34 +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
Leandro Ribeiro 2a6cfef07e screen-share: define variable type before using as function argument
Define the void pointer as pixman_region32_t instead of using it
directly.

Void pointers are used by generic API's so each user can define
a data type as needed. Not doing this is dangerous, since void
pointers implicitly cast from/to any pointer without giving
warnings. So we must define its type instead of using it directly
in a function call.

Signed-off-by: Leandro Ribeiro <leandrohr@riseup.net>
2019-12-11 19:36:57 +00: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
Leandro Ribeiro 0f6bd69752 screen-share: get previous_damage from data argument instead of weston_output
Instead of getting previous_damage from the weston_output struct, get it from
the frame_signal data argument. This will make possible to remove
previous_damage from weston_output after we decide what to do with
output->previous_damage usage in DRM backend.

Signed-off-by: Leandro Ribeiro <leandrohr@riseup.net>
2019-11-27 13:47:14 -03: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
Pekka Paalanen 6ffbba3ac1 Use weston_compositor_add_destroy_listener_once() in plugins
This introduces a new convention of checking through the compositor destroy
listener if the plugin is already initialized. If the plugin is already
initialized, then the plugin entry function succeeds as a no-op. This makes it
safe to load the same plugin multiple times in a running compositor.

Currently module loading functions return failure if a plugin is already
loaded, but that will change in the future. Therefore we need this other method
of ensuring we do not double-initialize a plugin which would lead to list
corruptions the very least.

All plugins are converted to use the new helper, except:
- those that do not have a destroy listener already, and
- hmi-controller which does the same open-coded as the common code pattern
  did not fit there.

Plugins should always have a compositor destroy listener registered since they
very least allocate a struct to hold their data. Hence omissions are
highlighted in code.

Backends do not need this because weston_compositor_load_backend() already
protects against double-init. GL-renderer does not export a standard module
init function so cannot be initialized the usual way and therefore is not
vulnerable to double-init.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2019-11-21 16:32:55 +00:00
Pekka Paalanen 5caef6d355 colord: remove destroy listener on clean-up
This was forgetting to remove the compositor destroy listener, which would lead
to use-after-free on compositor tear-down especially on cms-colord init failure
paths. Found by inspection.

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 8e7f9501e4 Link Weston plugins to libexec-weston.so
All these plugins use symbols that were exported by the weston executable and
are now exported by libexec-weston.so. Linking these to libexec-weston.so fixes
unresolved symbols.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2019-10-24 13:40:51 +03:00
Pekka Paalanen 699d89c92f cms-colord: work around unresolved symbols
This is preparation for disallowing unresolved symbols project-wide.

This is a temporary fix that should be reverted and fixed properly later.

/usr/bin/ld: compositor/fb12c4d@@cms-colord@sha/cms-helper.c.o: in function `weston_cms_set_color_profile':
/home/pq/build/weston-meson/../../git/weston/compositor/cms-helper.c:79: undefined reference to `cmsReadTag'
/usr/bin/ld: /home/pq/build/weston-meson/../../git/weston/compositor/cms-helper.c:91: undefined reference to `cmsEvalToneCurveFloat'
/usr/bin/ld: /home/pq/build/weston-meson/../../git/weston/compositor/cms-helper.c:92: undefined reference to `cmsEvalToneCurveFloat'
/usr/bin/ld: /home/pq/build/weston-meson/../../git/weston/compositor/cms-helper.c:93: undefined reference to `cmsEvalToneCurveFloat'
/usr/bin/ld: compositor/fb12c4d@@cms-colord@sha/cms-helper.c.o: in function `weston_cms_destroy_profile':
/home/pq/build/weston-meson/../../git/weston/compositor/cms-helper.c:108: undefined reference to `cmsCloseProfile'
/usr/bin/ld: compositor/fb12c4d@@cms-colord@sha/cms-helper.c.o: in function `weston_cms_load_profile':
/home/pq/build/weston-meson/../../git/weston/compositor/cms-helper.c:131: undefined reference to `cmsOpenProfileFromFile'

See also #263

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2019-10-24 13:40:51 +03: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
Pekka Paalanen 71ff95a544 build: separate deps for int and ext libweston users
We have two kinds of libweston users: internal and external. Weston, the
frontend, counts as an external user, and should not have access to libweston
private headers. The shell plugins are external users as well, because we
intend people to be able to write them. Renderers, backends, and some plugins
are internal users who will need access to private headers.

Create two different Meson dependency objects, one for each kind.

This makes it less likely to accidentally use a private header.

Screen-share is a Weston plugin and therefore counts as an external user, but
it needs the backend API to deliver input. Until we are comfortable exposing
public API for that purpose, let it use internal headers.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2019-10-24 13:29:33 +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 4f5e360180 build: simplify include_directories
Define common_inc which includes both public_inc and the project root directory.
The project root directory will allow access to config.h and all the shared/
headers.

Replacing all custom '.', '..', '../..', '../shared' etc. include paths with
common_inc reduces clutter in the target definitions and enforces the common
 #include directive style, as e.g. including shared/ headers without the
subdirectory name no longer works.

Unfortunately this does not prevent one from using private libweston headers
with the usual include pattern for public headers.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2019-10-04 17:14:22 +03: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
Ankit Nautiyal 93dde245ee libweston: Add functions to modify disable_planes counter for an output
The member disable_planes of weston_output signifies the recording
status of the output, and is incremented and decremented from various
places. This patch provides helper functions to increment and decrement
the counter. These functions can then be used to do processing, before
and after the recording has started or stopped.

Signed-off-by: Ankit Nautiyal <ankit.k.nautiyal@intel.com>
2019-08-26 16:18:22 +05:30
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
Stefan Agner bf5b6219ae screen-share: use pixman_image_composite32 instead of pixman_blt
The function pixman_blt may return false in case there is no
accelerated blit function available. In this case the remote shared
screen stays black.

This has been observed on Weston compiled for aarch64. In currrent
pixman 0.38.4 there is no accelerated pixman_blt function for
aarch64 available.

Use pixman_image_composite32 instead which is guaranteed to have a
working fallback implementation.

Fixes: #253

Signed-off-by: Stefan Agner <stefan@agner.ch>
2019-08-16 07:51:20 +00:00
Stefan Agner ab840fc855 screen-share: move damage calculation after screen resize
Calculate damage region after resizing the cache image. This
avoids unnecessary calculation of damaged regions on resize,
makes sure that the whole screen is considered damaged on
resize and simplifies error handling.

Signed-off-by: Stefan Agner <stefan@agner.ch>
2019-08-16 07:51:20 +00:00
Stefan Agner 64e2964159 screen-share: fix error handling
Make sure damage region gets properly unreferenced in error cases.

Signed-off-by: Stefan Agner <stefan@agner.ch>
2019-08-16 07:51:20 +00:00
Stefan Agner 2b2c9a6f7f screen-share: align read_pixels call with screenshooter
Calculate y_orig separately first makes it easer to understand the
code and aligns with how pixels are read in screenshooter.c.

Signed-off-by: Stefan Agner <stefan@agner.ch>
2019-08-16 07:51:20 +00: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
Stefan Agner f6e7d2ce67 screen-share: destroy seat on remove
Destroy seats when they get removed. This makes sure that seats
properly disappear when screen-share RDP clients disconnect.
There will be no excessive amount of mouse pointer anymore after
several client connection/disconnections.

Signed-off-by: Stefan Agner <stefan@agner.ch>
2019-07-23 16:08:04 +00: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
Marius Vlad 63ef078ada libweston: Migrate functions that operate on 'weston_output' into backend header
Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2019-07-18 06:43:38 +00:00
Marius Vlad 9eb2064b85 libweston: Migrate functions that operate on input objects
This include 'weston_keyboard', 'weston_touch', 'weston_pointer' and
other released classes.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2019-07-18 06:43:38 +00:00
Pekka Paalanen 1c0d04bff7 libweston: do not include config-parser.h
config-parser.h is a helper API that libweston core must never depend on. Using
it is a compositor frontend decision.

Including it in libweston.h would give the wrong message.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2019-07-18 06:43:38 +00: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
Silva Alejandro Ismael 21a1f40760 compositor: fix segfaults if wl_display_create fails
Added check to log the error if wl_display_create return NULL.

Fixes: #101

Signed-off-by: Silva Alejandro Ismael <silva.alejandro.ismael@gmail.com>
2019-05-31 16:39:43 -03:00
Scott Anderson 2edbcbd9cd compositor: Fix incorrect use of bool options
WESTON_OPTION_BOOLEAN takes a pointer to an int as an argument, but
there were several cases of being passed a pointer to a bool instead.
This changes it to use a local int instead, and then write that value to
the bool.

Signed-off-by: Scott Anderson <scott.anderson@collabora.com>
2019-05-29 18:30:06 +12:00
Marius Vlad f4f4c2bcf1 libweston: Add weston-debug header to libweston
Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2019-05-10 12:02:00 +00:00
Marius Vlad 7e4db95373 libweston: Rename weston_debug_scope_ to weston_log_scope_
Rename also the functions which work on weston_log_scope.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2019-05-10 12:02:00 +00:00
Marius Vlad 5d5e335845 libweston: Rename weston_debug_scope to weston_log_scope
This is a continuation of the previous patch to align more closely to
the weston log framework.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2019-05-10 12:02:00 +00:00
Marius Vlad 3d7d978c21 libweston: Rename weston_debug_compositor to weston_log_context
As we transition towards a more generic API for weston loggging
framework rename weston_debug_compositor to weston_log_context to show
the fact that this is not really debug but a logging context.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2019-05-10 12:02:00 +00:00
Marius Vlad 1e2fda2ea1 compositor: Convert weston-debug framework to use weston_debug_compositor
Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2019-05-10 12:01:59 +00:00
Marius Vlad 880b485d76 libweston: Decouple weston_debug_compositor from weston_compositor
This patch allows initialization of weston-debug/log framework much earlier
than weston_compositor, which in turn will provide the option start
logging before weston_compositor has been created.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2019-05-10 12:01:59 +00:00
Antonio Borneo 3957863667 log: remove "%m" from format strings by using strerror(errno)
The printf() format specifier "%m" is a glibc extension to print
the string returned by strerror(errno). While supported by other
libraries (e.g. uClibc and musl), it is not widely portable.

In Weston code the format string is often passed to a logging
function that calls other syscalls before the conversion of "%m"
takes place. If one of such syscall modifies the value in errno,
the conversion of "%m" will incorrectly report the error string
corresponding to the new value of errno.

Remove all the occurrences of the specifier "%m" in Weston code
by using directly the string returned by strerror(errno).
While there, fix some minor indentation issue.

Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
2019-05-02 22:10:30 +02:00
Pekka Paalanen cda1488ce0 Rename version.h to libweston/version.h
This is an installed public header, and without the subdir would surely
conflict with something else.

include/libweston/meson.build is necessary for putting the generated header in
the right subdirectory so that '#include <libweston/version.h>' can work.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2019-04-18 12:31:46 +03:00
Pekka Paalanen eebb7dc9ce Rename xwayland-api.h to libweston/xwayland-api.h
See "Rename compositor.h to libweston/libweston.h" for rationale.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2019-04-18 12:31:46 +03:00
Pekka Paalanen ecbdcfd373 Rename zalloc.h to libweston/zalloc.h
It is a public installed header used by libweston.h.

See "Rename compositor.h to libweston/libweston.h" for rationale.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2019-04-18 12:31:46 +03:00
Pekka Paalanen 9eda0ea825 Rename windowed-output-api.h to libweston/windowed-output-api.h
See "Rename compositor.h to libweston/libweston.h" for rationale.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2019-04-18 12:31:46 +03:00
Pekka Paalanen 7571027f17 Rename public backend headers
The backend headers are renamed from compositor-foo.h to backend-foo.h to
better describe their purpose. These headers are public libweston API for each
specific backend.

The headers will also be used like

 #include <libweston/backend-drm.h>

instead of

 #include <compositor-drm.h>

to give them a more explicit namespace.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2019-04-18 12:31:46 +03:00
Pekka Paalanen 3d5d9476e3 Rename compositor.h to libweston/libweston.h
The main idea is to make libweston users use the form

 #include <libweston/libweston.h>

instead of the plain

 #include <compositor.h>

which is prone to name conflicts. This is reflected both in the installed
files, and the internal header search paths so that Weston would use the exact
same form as an external project using libweston would.

The public headers are moved under a new top-level directory include/ to make
them clearly stand out as special (public API).

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2019-04-18 12:31:46 +03:00
Héctor Orón Martínez 250f1066ff support byte-by-byte reproducible build
build path ends in the final binary package causing the
build not to be reproducible byte-by-byte.

Reference:
https://bugs.debian.org/899358

Signed-off-by: Héctor Orón Martínez <zumbi@debian.org>
2019-04-09 10:08:23 +00:00
Pekka Paalanen fc76388fa1 Remove autotools build
Weston 6.0.0 was released with both autotools and Meson build systems. That
should be enough for downstream to migrate to Meson build on their on pace.

Maintaining two build systems is a hassle, keep the one that is easier to work
with and let the other one go.

doc/dozygen/tool*.doxygen.in are not deleted, because they have not been
integrated with Meson yet.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2019-03-28 13:56:44 +02:00
Pekka Paalanen 191c453f83 meson: link cms-colord with glib and gobject
cms-colord.c calls things like g_string_free() and g_object_unref(), so it
needs to link glib-2.0 and gobject-2.0 explicitly, instead of relying on colord
pkg-config bringing them in.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2019-03-28 09:43:23 +00:00
Daniel Stone 8a4585c27f compositor: Don't ignore --use-pixman for Wayland backend
We loaded the use-pixman configuration value from both the command line
and the configuration file, but completely ignored the former. Make sure
we actually use both.

Tested with all permutations of config/command line.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Tested-by: Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
2019-03-28 09:40:54 +00:00
Stefan Agner 483c6d4d06 meson: fix building screen-share module
When building screen-share module with meson loading the module
fails with:
  [00:01:28.604] Failed to load module: /usr/local/lib/weston/screen-share.so: undefined symbol: os_create_anonymous_file
  Failed to process Wayland connection: Broken pipe
  failed to create display: Broken pipe

The function os_create_anonymous_file is defined in libshared,
adding libshared to the dependency makes sure the function gets
compiled into screen-share.so.

Fixes: https://gitlab.freedesktop.org/wayland/weston/issues/208

Signed-off-by: Stefan Agner <stefan@agner.ch>
2019-03-20 00:09:51 +01:00
Emmanuel Gil Peyrot 426c24673f Fix typos all around (thanks codespell!) 2019-02-20 16:47:35 +01:00
Philipp Zabel b68847a8bc meson: fix compositor build with xwayland disabled
If xwayland is disabled, compositor/weston is built without
compositor/xwayland.c, which defines wet_load_xwayland.

  compositor/fb12c4d@@weston@exe/main.c.o: In function `main':
  ../weston-5.0.0-169-g2d4cc4f4dd6a/compositor/main.c:3103: undefined reference to `wet_load_xwayland'

Provide an empty stub for wet_load_xwayland if xwayland is disabled.
With that we also have to remove xwayland.c from the autotools build
if xwayland is disabled, to avoid a multiple definition error.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2019-02-15 23:26:16 +01:00
Eric Toombs 6e229ca263 weston: add more libinput config options
This is so that, for instance, people using weston as their main Wayland
compositor can invert the sense of two finger scrolling or change
pointer acceleration using weston.ini, rather than having to edit C
code.

All of the options that libinput itself exposes through its API are now
exposed in weston.ini.  The new options are called `tap-and-drag`,
`tap-and-drag-lock`, `disable-while-typing`, `middle-emulation`,
`left-handed`, `rotation`, `accel-profile`, `accel-speed`,
`scroll-method`, `natural-scroll`, and `scroll-button`. I have
successfully tested everything except for `rotation`, out of a lack of
hardware support.

weston now depends directly on libevdev for turning button name strings into
kernel input codes. This was needed for the `scroll-button` config
option. (weston already depends indirectly on libevdev through
libinput, so I figured people would be OK with this.) As a practical
matter for debian-style packagers, weston now has a build dependency on
libevdev-dev.

Right now, the code applies the same options to all attached devices
that a given option is relevant for. There are plans for multiple
[libinput] sections, each with different device filters, for users who
need more control here.

Signed-off-by: Eric Toombs <3672-ewtoombs@users.noreply.gitlab.freedesktop.org>
2019-02-06 08:23:02 +00:00
Eric Toombs 9d2220380a weston: deprecate enable_tap in favour of enable-tap
This is to increase consistency in config option naming in weston.ini.
(Prefer hyphens over underscores to separate words.)

If enable_tap is present in weston.ini, an obnoxious error message is
logged with weston_log(). In terms of configuration, if enable-tap is
present, enable_tap is ignored.

Signed-off-by: Eric Toombs <3672-ewtoombs@users.noreply.gitlab.freedesktop.org>
2019-02-06 08:23:02 +00:00
Thomas Zimmermann 22dd67ccea weston: Add config option to enable pixman-based rendering
Pixman can be used for rendering if the default GLESv2 rendering
is broken or cannot be used.

Pixman-based rendering is already available with the command-line
switch '--use-pixman'. This patch adds support for this option to
the configuration file. Putting

  [core]
  use-pixman=true

into 'weston.ini' enables pixman-based rendering for all backends
that support it. With this change, pixman has to be enabled only
once.

Fixes: https://gitlab.freedesktop.org/wayland/weston/issues/27
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
2019-01-31 08:58:28 +00:00
Pekka Paalanen d64649b56b meson: better errors for systemd-notify deps
Helps people avoid libsystemd if they don't want it.

Signed-off-by: Pekka Paalanen <pq@iki.fi>
2018-12-31 15:16:53 +02:00
Pekka Paalanen 217a15c1b2 meson: better error for cms-colord deps
Helps people avoid colord if they don't want it.

Signed-off-by: Pekka Paalanen <pq@iki.fi>
2018-12-31 15:16:53 +02:00
Pekka Paalanen 37dabe5f3f meson: better error cms-static deps
Helps people to avoid lcms2 if they don't want it.

Signed-off-by: Pekka Paalanen <pq@iki.fi>
2018-12-31 15:16:53 +02:00
Greg V 8a8558dd59 build: use '-Wl,' wrapper for the -export-dynamic linker flag
Meson links with the C compiler, not the raw linker.
With clang+LLD, the bare flag would be ignored.

Signed-off-by: Greg V <greg@unrelenting.technology>
2018-12-20 18:37:34 +00:00
Marius Vlad d85fe29c1f compositor: Install weston-screenshooter in BINDIR
Previously weston-screenshooter was installed in LIBEXECDIR, but given
that now it can be invoked by the user whenever debug protocol is
enabled, let's intall it into BINDIR. This way, it can be invoked
without the need to modify PATH.

Signed-off-by: Marius Vlad <marius.vlad0@gmail.com>
2018-12-18 15:37:34 +02:00
Marius Vlad 64fbd0f41f compositor: Add some handy wrappers for wet_get_binary_path()
This allows to possibility to specify where to look for the executable
but also simplifies the need of having to pass either BINDIR/LIBEXECDIR
for retrieving full-path of the executable.

Signed-off-by: Marius Vlad <marius.vlad0@gmail.com>
2018-12-18 15:37:34 +02:00
Marius Vlad 4e1d9bc72f libweston: Allow taking screenshots when debug protocol is enabled
Screenshots of the outputs can only be taken by having a keyboard
plug-ed in, as to avoid potential malicious intent. On the other hand,
this is problematic as there are cases where a keyboard cannot
be used as a input device. A particular use-case is that for
multiple devices it can be cumbersome to connect a keyboard such
that using ssh can be much easier and can be further automated.

This patch allows taking screenshots without the need of having a
keyboard connected when debug protocol is enabled.

Add also a few words about the fact that this is a serious issue
and can lead to silently leaking the output contents.

Signed-off-by: Marius Vlad <marius.vlad0@gmail.com>
2018-12-18 15:37:34 +02:00
Daniel Stone 8011b0fa03 Add Meson build system
Meson is a build system, currently implemented in Python, with multiple
output backends, including Ninja and Make. The build file syntax is
clean and easy to read unlike autotools. In practise, configuring and
building with Meson and Ninja has been observed to be much faster than
with autotools. Also cross-building support is excellent.

More information at http://mesonbuild.com

Since moving to Meson requires some changes from users in any case, we
took this opportunity to revamp build options. Most of the build options
still exist, some have changed names or more, and a few have been
dropped. The option to choose the Cairo flavour is not implemented since
for the longest time the Cairo image backend has been the only
recommended one.

This Meson build should be fully functional and it installs everything
an all-enabled autotools build does. Installed pkg-config files have
some minor differences that should be insignificant. Building of some
developer documentation that was never installed with autotools is
missing.

It is expected that the autotools build system will be removed soon
after the next Weston release.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Co-authored-by: Pekka Paalanen <pq@iki.fi>
Signed-off-by: Pekka Paalanen <pq@iki.fi>
2018-12-09 14:50:54 +02:00
Tomohito Esaki f709d22038 Add remoting plugin for output streaming
Remoting plugin support streaming image of virtual output on drm-backend
to remote output. By appending remote-output section in weston.ini,
weston loads remoting plugin module and creates virtual outputs via
remoting plugin. The mode, host, and port properties are configurable in
remote-output section.

This plugin send motion jpeg images to client via RTP using gstreamer.
Client can receive by using following pipeline of gst-launch.

gst-launch-1.0 rtpbin name=rtpbin \
   udpsrc caps="application/x-rtp,media=(string)video,clock-rate=(int)90000,
		encoding-name=JPEG,payload=26" port=[PORTNUMBER] !
          rtpbin.recv_rtp_sink_0 \
   rtpbin. ! rtpjpegdepay ! jpegdec ! autovideosink \
   udpsrc port=[PORTNUMBER+1] ! rtpbin.recv_rtcp_sink_0 \
   rtpbin.send_rtcp_src_0 !
          udpsink port=[PORTNUMBER+2] sync=false async=false

where, PORTNUMBER is specified in weston.ini.

Signed-off-by: Tomohito Esaki <etom@igel.co.jp>
2018-10-30 17:09:01 +09:00
Tomohito Esaki f59dc1112b weston: Add set up SIGUSR1 blocking early using pthread_sigmask()
Xwayland block SIGUSR1 signal for handling this signal. However, if some
weston plugins creates additional threads before xwayland is loaded,
this signal get delivered these threads and causes weston quit.
Therefore, we should set up SIGUSR1 blocking early so that these threads
can inherit the setting when created.

Signed-off-by: Tomohito Esaki <etom@igel.co.jp>
2018-10-30 17:09:01 +09:00
Alexandros Frantzis 7e2d4beb08 xwayland: Silence format-truncation compilation warnings
We are currently formatting 32-bit signed integers into 8 byte buffers,
which are too small, causing the compiler to complain. Update the buffer
size to the minimum required value of 12 bytes: 1 for the sign, 10 for
the number, and 1 for the null byte terminator.

Signed-off-by: Alexandros Frantzis <alexandros.frantzis@collabora.com>
2018-10-12 13:00:08 +03:00
Philipp Zabel b9454fde9f weston: keep non-desktop displays turned off by default
Keep non-desktop heads representing e.g. head mounted displays turned off by
default. When using the DRM backend they can still be enabled by setting an
explicit [output] mode (or "mode=preferred") in weston.ini.

Signed-off-by: Philipp Zabel <philipp.zabel@gmail.com>
2018-09-23 09:18:00 +00:00
Stefan Agner 3b1c1efe34 main: do not exit in case stdin is a closed stream
Weston should not exit if stdin is a closed stream. This allows
to launch with a closed stdin:

  # weston <&-

This fixes screen sharing using weston: Weston closes the stdin
before forking itself to execute the screen sharing instance of
weston. Before this patch screen sharing failed with:
  Screen share failed: No wl_shm found
  unknown child process exited

Fixes: f0d39b2243 ("weston: Set CLOEXEC on stdin")
Signed-off-by: Stefan Agner <stefan@agner.ch>
2018-09-17 14:42:50 +00:00
Pekka Paalanen 5c91bb8d28 compositor: protocol logger
This is better than running Weston with WAYLAND_DEBUG=server:
- It is enabled on demand, no unnecessary flooding and no need to
  restart the compositor if debug was enabled.
- It prints client pointers so that messages with different clients can
  be seen apart.

Signed-off-by: Pekka Paalanen <pq@iki.fi>

parse and print message arguments in protocol_log_fn

Signed-off-by: Maniraj Devadoss <Maniraj.Devadoss@in.bosch.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Daniel Stone <daniels@collabora.com>
2018-09-17 13:29:48 +01:00
Pekka Paalanen d3630ed489 compositor: offer logs via weston-debug
This registers a new weston-debug scope "log" through which one can get
live log output interspersed with possible other debugging prints. This
is implemented by passing the format and varargs received in our usual
logging entrypoints through to the debug scope as well.

Anywhere where the varargs set is used twice (once for vfprintf, another
for the debug scope), we copy the va_list in order to avoid reusing it,
which leads to memory safety issues.

Signed-off-by: Pekka Paalanen <pq@iki.fi>
Signed-off-by: Maniraj Devadoss <Maniraj.Devadoss@in.bosch.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Daniel Stone <daniels@collabora.com>
2018-09-17 13:29:48 +01:00
Pekka Paalanen 771b7cfc11 compositor: add option to enable weston_debug
Let users enable the compositor debug protocol on the compositor command
line. This allows weston-debug tool to work.

Signed-off-by: Pekka Paalanen <pq@iki.fi>
Signed-off-by: Maniraj Devadoss <Maniraj.Devadoss@in.bosch.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2018-09-17 13:29:24 +01:00
Derek Foreman f8f7fd69df input: add weston_keyboard_send_keymap helper function
We've always had "send_keymap" internally, but some places failed to use
it.  Since we also use this in the text backend, export it.

Reviewed-by: Daniel Stone <daniels@collabora.com>
2018-08-17 09:25:21 -05:00
Harsha M M b8b2c72709 libweston: Remove signals from the list during de-init
During de-init ensure removal of added signals from list. Otherwise
a dongling pointer is left behind which will affect other plugins.

Signed-off-by: Harsha M M <harsha.manjulamallikarjun@in.bosch.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2018-08-08 12:22:24 +03:00
nerdopolis 352804488a main: don't configure /dev/fb0 by default
The framebuffer backend now detects the framebuffer device
dynamically. Don't assume that the framebuffer device is /dev/fb0

Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
2018-07-02 15:29:38 +03:00
nerdopolis d68109b960 compositor-fbdev: support the --seat option, (and XDG_SEAT variable)
This allows the fbdev backend to run on, and use devices from the
specified seat, similar to the drm backend.

Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
2018-07-02 15:29:38 +03:00
nerdopolis b16c4ac55b libweston: set the seat automatically based on the XDG_SEAT environment variable
This will allow the seat to be set by the environment as pam_systemd typically
sets the XDG_SEAT variable

Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
2018-07-02 15:29:38 +03:00
Pekka Paalanen 9071817089 weston: add force-on option for DRM
Add a new boolean output section key "force-on". When set to true, the
output will be enabled regardless of connector status. This is the
opposite of the mode=off setting.

Forcing connectors on is useful in special circumstances: avoid output
configuration changes due to hotplug e.g. with KVM switches, or hardware
with unreliable connector status readout for example.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Ian Ray <ian.ray@ge.com>
2018-06-29 16:08:35 +03:00
Pekka Paalanen 944dd235b4 weston: support clone mode on DRM-frontend
Add a new output section key "same-as" for configuring clone mode. An
output marked "same-as" another output will be configured identically to
the other output.

The current implementation supports only CRTC sharing for clone mode.
Independent CRTC clone mode cannot be supported until output layout
logic is moved from libweston into the frontend and libweston's damage
tracking issues stemming from overlapping outputs are solved.

Quite a lot of infrastructure is needed to properly configure clone
mode. The implemented logic allows easy addition of independent CRTC
clone mode once libweston supports it. The idea is that wet_layoutput is
the item to be laid out and all weston_outputs a wet_layoutput
contains show exactly the same area of the desktop.

The configuration logic attempts to automatically fall back to creating
more weston_outputs when all heads do not work under the same
weston_output. For now, the fallback path ends with an error message.

Enabling a weston_output is bit complicated, because one needs to first
collect all relevant heads, try to attach them all to the weston_output,
and then back up head by head until enabling the weston_output succeeds.
A new weston_output is created for the left-over heads and the process
is repeated.

CRTC-sharing clone mode is the most efficient clone mode, offering
synchronized scanout timings, but it is not always supported by
hardware.

v10:
- rebased trivial conflicts in man page
- switch to gitlab issue URL

v9:
- replace weston_compositor_set_heads_changed_cb() with
  weston_compositor_add_heads_changed_listener()
- remove workaround in simple_head_enable()

v6:
- Add man-page note about cms-colord.
- Don't create an output just to turn it off.

Fixes: https://gitlab.freedesktop.org/wayland/weston/issues/22

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Acked-by: Derek Foreman <derekf@osg.samsung.com>
Acked-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Ian Ray <ian.ray@ge.com>
2018-06-29 16:07:03 +03:00
Pekka Paalanen c5aaaa7b39 shared: remove weston_config_get_libexec_dir()
Now that WESTON_MODULE_MAP supersedes WESTON_BUILD_DIR for libexec
binaries, we don't need to check in WESTON_BUILD_DIR anymore.

There was only one user of weston_config_get_libexec_dir(), so remove
the whole function. There is no reason to export it.

Due to libshared.la being pulled into libweston, this probably was
libweston ABI unintended. Regardless, libweston major has already been
bumped.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Emre Ucan <eucan@de.adit-jv.com>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
2018-06-20 16:01:03 +03:00
Daniel Stone e03c111e4e tests: Don't rely on build directory layout
Rather than having a hardcoded dependency on the build-directory layout,
use an explicit module-map environment variable, which rewrites requests
for modules and helper/libexec binaries to specific paths.

Pekka: This will help with migration to Meson where setting up the paths
according to autotools would be painful and unnecessary.

Emre: This should also help setting up the test suite after a
cross-compile.

Pekka: A caveat here is that this patch makes it slightly easier to load
external backends by abusing the module map. External backends are
specifically not supported in libweston.

Signed-off-by: Daniel Stone <daniels@collabora.com>

v2:

Fixed ivi_layout-test-plugin.c:wet_module_init().
Do not change the lookup name of ivi-layout.ivi.

Improved documentation of weston_module_path_from_env() and made it cope
with map strings that a) do not end with a semicolon, and b) have
multiple consecutive semicolons.

Let WESTON_MODULE_MAP be printed into the test log so that it is easier
to run tests manually.

Reviewed-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Emre Ucan <eucan@de.adit-jv.com>

Suggested by Emil: Use a variable for strlen(name).

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
2018-06-20 14:36:52 +03:00
Peter Hutterer a1fd4302bc compositor: print usage to stdout on success (not stderr) - this time really
Fix all the other printfs too.

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

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2018-06-12 10:33:46 +03:00
Peter Hutterer 70e8a32fb7 compositor: print usage to stdout on success (not stderr)
Triggered by weston --help, the usage() output should not look like an error.

Note that there is only one caller of usage() at the moment, but let's handle
this here based on the status in case we add other cases.

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

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2018-06-11 16:21:46 +03:00
Louis-Francis Ratté-Boulianne 5a1b0cf0e7 weston: add touchscreen_calibrator option
Add an option to enable the touchscreen calibrator interface. This is a
global on/off toggle, in lack of more fine-grained access restrictions.

As Weston should not hardcode system specifics, the actual permanent
saving of a new calibration is left for a user supplied script or a
program. Usually this script would write an appropriate udev rule to set
LIBINPUT_CALIBRATION_MATRIX for the touch device.

Co-developed by Louis-Francis and Pekka.

v2:
- use syspath instead of devpath

Signed-off-by: Louis-Francis Ratté-Boulianne <lfrb@collabora.com>
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
v1 Tested-by: Matt Hoosier <matt.hoosier@gmail.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-05-30 14:46:24 +03:00
Pekka Paalanen 325ff4cba1 main: add setting for DRM/pixman shadow framebuffer
Allows to control the Pixman-renderer shadow framebuffer usage from
weston.ini. It defaults to enabled, and whether it is a good idea to
disable or not depends on the platform and the workload.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Signed-off-by: Fabien Lahoudere <fabien.lahoudere@collabora.com>
Reviewed-by: Ian Ray <ian.ray@ge.com>
2018-05-24 17:20:04 +03:00
Pekka Paalanen 03dc95a131 weston: use wet.compositor consistently in main()
Rename user_data to wet, because it is called wet everywhere else.

Drop the local variable ec, because that is available as wet.compositor.

This models a little better that wet_compositor owns weston_compositor,
and not the other way around.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Acked-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
2018-05-02 12:08:34 +03:00
Pekka Paalanen 3ffc6876ca weston: store weston_compositor in wet_compositor
This makes it easier to just pass wet_compositor around and take the
weston_compositor from it.

It feels weird to go from weston_compositor to wet_compositor all the
time in internal functions. It's necessary in callbacks that cannot
carry wet_compositor, but otherwise it is awkward.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Acked-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
2018-05-02 12:08:34 +03:00
Pekka Paalanen 925788fc76 Update copyrights for Collabora and General Electric Company
Looking at the diff statistics of the changes authored by me and landed
since 4.0.0 release points out these files as having major changes.
Update the copyright holders accordingly, as both clone mode and
touchscreen calibration related patches are copyright both Collabora and
GE.

I have kept the redundant "Copyright ©" form only to keep things
consistent, even when either the word or the mark would be enough.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Acked-by: Ian Ray <ian.ray@ge.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
2018-04-26 16:55:03 +03:00
Pekka Paalanen 8a8dcac431 libweston: remove output_pending_signal
The signal has been replaced with the heads_changed hook and is no
longer useful.

weston_pending_output_coldplug() is renamed to
weston_compositor_flush_heads_changed() for two reasons: it better
describes what it does now, and it serves as an obvious flag that
libweston ABI has been broken.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Ian Ray <ian.ray@ge.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Acked-by: Derek Foreman <derekf@osg.samsung.com>
2018-04-17 15:19:57 +03:00
Pekka Paalanen e868c3fc15 libweston: change windowed_output_api output_create to create_head
Rename the function pointer to create_head() because that is what it
does on backends that are converted to the head-based API. Update the
documentation to match.

Surprisingly this is not an ABI break, as the function behaviour and
signature remain intact. Hence API_NAME is not bumped.

This is only an API break, and main.c is fixed accordingly.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Ian Ray <ian.ray@ge.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Acked-by: Derek Foreman <derekf@osg.samsung.com>
2018-04-17 15:19:57 +03:00
Pekka Paalanen 1394ac303e weston: migrate DRM to head-based output API
Migrate the DRM frontend to use the simple head-based output
configurator, maintaining the exact same features and semantics as
before.

This is an intermediate step. It is unoptimal to create a weston_output
just to turn it off, but the libweston implementation and the DRM
backend require it for now. In the future, the DRM frontend will get its
own configurator that does not create useless weston_outputs and
supports clone mode by attaching multiple heads to the same
weston_output. Clone mode is not yet supported by libweston/DRM.

Until we remove the need to create a weston_output just to turn it
"off", that is, disable it, we will hit simple_head_enable() for heads
we have already disabled. As long as the DRM-backend conversion to the
head-based API is not complete, attempting to create an output for a
head again would lead to a crash. This problem does not exist right now,
but it will after the patch "compositor-drm: start migration to
head-based output API". Therefore, check if the head we are about to
process is already attached, and do nothing if so. DRM outputs set to
"off" are the only ones legitimately hitting this condition.

This is the last frontend migrated, wet_set_pending_output_handler() is
deleted as dead code.

v9:
- Add the workaround in simple_head_enable().

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
v6 Reviewed-by: Ian Ray <ian.ray@ge.com>
v7 Reviewed-by: Daniel Stone <daniels@collabora.com>
Acked-by: Derek Foreman <derekf@osg.samsung.com>
2018-04-17 15:19:57 +03:00
Pekka Paalanen 63d58390ce weston: migrate RDP to head-based output API
Migrate the RDP frontend to use the new head-based output configuration
API: listen for heads_changed, and process all heads.

v7:
- remove unnecessary 'goto out' in load_rdp_backend()

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Ian Ray <ian.ray@ge.com>
Acked-by: Daniel Stone <daniels@collabora.com>
Acked-by: Derek Foreman <derekf@osg.samsung.com>
2018-04-17 15:19:57 +03:00
Pekka Paalanen 33961bd78e weston: migrate fbdev to head-based output API
Migrate the fbdev frontend to use the new head-based output
configuration API: listen for heads_changed, and process all heads.

v7:
- remove unnecessary 'goto out' in load_fbdev_backend()

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Ian Ray <ian.ray@ge.com>
Acked-by: Daniel Stone <daniels@collabora.com>
Acked-by: Derek Foreman <derekf@osg.samsung.com>
2018-04-17 15:19:57 +03:00
Pekka Paalanen 46e2f02449 weston: migrate wayland to head-based output API
Migrate the Wayland frontend to use the new head-based output
configuration API: listen for heads_changed, and process all heads.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Ian Ray <ian.ray@ge.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Acked-by: Derek Foreman <derekf@osg.samsung.com>
2018-04-17 15:19:57 +03:00
Pekka Paalanen 30465bdca6 weston: migrate x11 to head-based output API
Migrate the x11 frontend to use the new head-based output configuration
API: listen for heads_changed, and process all heads.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Ian Ray <ian.ray@ge.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Acked-by: Derek Foreman <derekf@osg.samsung.com>
2018-04-17 15:19:57 +03:00
Pekka Paalanen cd8a1a8182 weston: migrate headless to head-based output API
Migrate the headless frontend to use the new head-based output
configuration API: listen for heads_changed, and process all heads.

The simple_heads_changed() function is written to be able to cater for
all backends. The rest will be migrated individually.

The head destroy listeners are not exactly necessary, for headless
anyway, but this is an example excercising the API. Also
is_device_changed() check is mostly useful with DRM.

v8:
- replace weston_compositor_set_heads_changed_cb() with
  weston_compositor_add_heads_changed_listener()
- fix comment on wet_head_tracker_create()

v3: Print "Detected a monitor change" only for enabled heads.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
v6 Reviewed-by: Ian Ray <ian.ray@ge.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Acked-by: Derek Foreman <derekf@osg.samsung.com>
2018-04-17 15:19:57 +03:00
Pekka Paalanen 3717e639ee weston: move weston_output_enable() into callers
Move the call out of wet_configure_windowed_output_from_config() and
into its callers.

This allows to migrate each frontend one by one.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Ian Ray <ian.ray@ge.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Acked-by: Derek Foreman <derekf@osg.samsung.com>
2018-04-17 15:19:57 +03:00
Pekka Paalanen cf0a476b8e cms-colord: find a good head
The 'head' member of 'struct weston_output' is going to go unused and
then disappear, so stop using it and find a head from the proper list.

However, this leaves a problem in cms-colord: if you have multiple
monitors driver with the same CRTC, what do you say to the color
management system? The monitors could be different, but all the color
LUTs etc. are in the CRTC and are shared, as is the framebuffer.

Do the simple hack here and just use whatever head happens to be the
first in the list.

The warning is printed in get_output_id(), because if heads are added or
removed while the output is enabled, the id could change.

v6:
- add weston_output_get_first_head(), at first use
- add warning message for nr. heads > 1

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Ian Ray <ian.ray@ge.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Acked-by: Derek Foreman <derekf@osg.samsung.com>
2018-04-12 14:26:17 +03:00
Pekka Paalanen 055c1137ae libweston: make wl_output point to weston_head
The user data of a wl_resource representing a wl_output protocol object
used to be a pointer to weston_output. Now that weston_output is being
split, wl_output more accurately refers to weston_head which is a single
monitor.

Change the wl_output user data to point to weston_head.
weston_output_from_resource() is replaced with
weston_head_from_resource().

This change is not strictly necessary, but architecturally it is the
right thing to do. In the future there might appear the need to refer to
a specific head of a cloned pair, for instance.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
v5 Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Ian Ray <ian.ray@ge.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Acked-by: Derek Foreman <derekf@osg.samsung.com>
2018-04-10 14:33:59 +03:00
Pekka Paalanen 01f60211b2 libweston: introduce weston_head
In order to support clone modes, libweston needs the concept of a head
that is separate from weston_output. While weston_output manages buffers
and the repaint state machine, weston_head will represent a single
monitor. In the future it will be possible to have a single
weston_output drive one or more weston_heads for a clone mode that
shares the framebuffers between all cloned heads.

All the fields that are obviously properties of the monitor are moved
from weston_output into weston_head.

As moving the fields requires one to touch all the backends for all the
assingments, introduce setter functions for them while we are here. The
setters are identical to the old assignments, for now.

As a temporary measure, weston_output embeds a single head. Also the
ugly casts in weston_head_set_monitor_strings() will be removed by a
follow-up patch.

Libweston major version is bumped, because weston_output struct layout
is changed.

v7:
- Bump libweston major version.

v6:
- adapt to upstream changes in weston_output_set_transform()

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
v5 Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
v6 Reviewed-by: Ian Ray <ian.ray@ge.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Acked-by: Derek Foreman <derekf@osg.samsung.com>
2018-04-10 14:31:05 +03:00
Dima Ryazanov 02c5697704 weston: Add a help string for --xwayland
Signed-off-by: Dima Ryazanov <dima@gmail.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2018-03-16 13:59:00 +02:00
Alexandros Frantzis 8480d13f6d libweston: Make weston_seat release safe
Ensure the server can safely handle client requests for wl_seat resource
that have become inert due to weston_seat object release and subsequent
destruction.

The clean-up involves, among other things, unsetting the destroyed
weston_seat object from the user data of wl_seat resources, and handling
this NULL user data case where required.

The list of sites extracting and using weston_seat object from wl_seat
resources which were audited for this patch are:

Legend:
N/A = Not Applicable (not implemented by weston)
FIXED = Fixed in the commit
OK = Already works correctly

== keyboard_shortcuts_inhibit_unstable_v1 ==
[N/A] zwp_keyboard_shortcuts_inhibit_manager_v1.inhibit_shortcuts
== tablet_input_unstable_v{1,2} ==
[N/A] zwp_tablet_manager_v{1,2}.get_tablet_seat
== text_input_unstable_v1 ==
[FIXED] zwp_text_input_v1.activate
[FIXED] zwp_text_input_v1.deactivate
== wl_data_device ==
[FIXED] wl_data_device_manager.get_data_device
[OK] wl_data_device.start_drag
[FIXED] wl_data_device.set_selection
[OK] wl_data_device.release
== wl_shell ==
[FIXED] wl_shell_surface.move
[FIXED] wl_shell_surface.resize
[FIXED] wl_shell_surface.set_popup
== xdg_shell and xdg_shell_unstable_v6 ==
[FIXED] xdg_toplevel.show_window_menu
[FIXED] xdg_toplevel.move
[FIXED] xdg_toplevel.resize
[FIXED] xdg_popup.grab
== xdg_shell_unstable_v5 ==
[FIXED] xdg_shell.get_xdg_popup
[FIXED] xdg_surface.show_window_menu
[FIXED] xdg_surface.move
[FIXED] xdg_surface.resize

Signed-off-by: Alexandros Frantzis <alexandros.frantzis@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Quentin Glidic <sardemff7+git@sardemff7.net>
2018-02-15 13:14:14 +02:00
Pekka Paalanen bb707dc0fe weston: remove SEGV and ABRT handlers
Catching an ABRT is kind of ok, catching a SEGV is russian roulette. We
have been quite lucky with it, but I've started hitting crashes inside
malloc() which causes a deadlock when our SEGV handler needs to malloc()
as well (weston_log_timestamp()).

One reason to catch SEGV and ABRT was to attempt to restore the VT on
the DRM-backend. Nowadays that job is done by logind or weston-launch.

The signal handler also printed a backtrace, which for me personally has
been extremely helpful. Arguably it's not necessary though, when we have
core files and services that catch cores. For instance, if using
systemd, 'coredumpctl gdb' is delightfully easy for getting into the
saved core.

Therefore, this code does more harm than it is useful, so remove it. We
also drop an optional dependency to libunwind.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Daniel Stone <daniels@collabora.com>
2018-02-09 15:16:07 +00:00
Pekka Paalanen 8a9c8b08cf weston: add --drm-device option for DRM-backend
Developers with testing rigs having multiple graphics cards plugged in
often want to test things on a specific card. We have ways to choose a
card through seat assignments, but configuring that run by run is
awkward.

Add a command line option for opening a specific DRM device.

v2: call it --drm-device instead of --device

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Daniel Stone <daniels@collabora.com>
2017-12-18 13:58:17 +02:00
Joshua Watt dd61625d18 text-backend: Allow client hiding of input panel
Previously, the hide_input_panel and show_input_panel messages for the text
input protocol were limited to specific cases, such as showing the panel on
activation, or making the panel visible after activation. Now, clients are
allowed to toggle the panel visiblity at will as long as they are the currently
active client

Signed-off-by: Joshua Watt <JPEWhacker@gmail.com>
Tested-by: Silvan Jegen <s.jegen@gmail.com>
Reviewed-by: Jan Arne Petersen <janarne@gmail.com>
2017-11-30 16:14:30 +02:00
Pekka Paalanen 1fdeb68013 weston: add wait-for-debugger option
When you need to start Weston via weston-launch, systemd unit, or any
other runner, it is annoying to try to get in with a debugger,
especially if the thing you are interested in happens at start-up. To
make it easy, a new option is introduced.

The new option, implemented both as a command line option and a
weston.ini option, raises SIGSTOP early in the start-up, before the
weston_compositor has been created. This allows one to attach a debugger
at a known point in execution, and resume execution with SIGCONT.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Acked-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Quentin Glidic <sardemff7+git@sardemff7.net>
Reviewed-by: Ian Ray <ian.ray@ge.com>
2017-11-28 09:17:24 +02:00
Pekka Paalanen 3baf9ce7e8 weston: arm SEGV handler earlier
It is useful to print the backtrace regardless of whether we have a
compositor and a backend initialized yet. Move catch_signals() to the
earliest point in main() and protect the SEGV handler from dereferencing
NULL when we don't yet have a compositor or a backend.

The SEGV handler uses weston_log(), so cannot move catch_signals() any
earlier.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Quentin Glidic <sardemff7+git@sardemff7.net>
Reviewed-by: Daniel Stone <daniels@collabora.com>
2017-11-27 15:41:18 +02:00
Alexandros Frantzis 409b01fd6d libweston: Use struct timespec for compositor time
Change weston_compositor_get_time to return the current compositor time
as a struct timespec. Also, use clock_gettime (with CLOCK_REALTIME) to
get the time, since it's equivalent to the currently used gettimeofday
call, but returns the data directly in a struct timespec.

This commit is part of a larger effort to transition the Weston codebase
to struct timespec.

Signed-off-by: Alexandros Frantzis <alexandros.frantzis@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2017-11-27 11:42:07 +02:00
Alexandros Frantzis 47e79c860b libweston: Use struct timespec for key events
Change code related to key events to use struct timespec to represent
time.

This commit is part of a larger effort to transition the Weston codebase
to struct timespec.

Signed-off-by: Alexandros Frantzis <alexandros.frantzis@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2017-11-27 11:42:07 +02:00
Alexandros Frantzis 80321942e7 libweston: Use struct timespec for axis events
Change code related to axis events to use struct timespec to represent
time.

This commit is part of a larger effort to transition the Weston codebase
to struct timespec.

Signed-off-by: Alexandros Frantzis <alexandros.frantzis@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2017-11-27 11:42:07 +02:00
Alexandros Frantzis 215bedc88b libweston: Use struct timespec for button events
Change code related to button events to use struct timespec to represent
time.

This commit is part of a larger effort to transition the Weston codebase
to struct timespec.

Signed-off-by: Alexandros Frantzis <alexandros.frantzis@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2017-11-27 11:42:07 +02:00
Alexandros Frantzis 84b31f8956 libweston: Use struct timespec for motion events
Change code related to motion events to use struct timespec to represent
time.

This commit is part of a larger effort to transition the Weston codebase
to struct timespec.

Signed-off-by: Alexandros Frantzis <alexandros.frantzis@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2017-11-27 11:42:07 +02:00
Pekka Paalanen aedcd8ebb0 weston: fix boolean wayland backend options
Surprisingly, WESTON_OPTION_BOOLEAN uses the type int32_t, not bool.
Passing in a pointer bool does not end well. Fix this to pass in
pointers as parse_options() expects.

This fixes a bug where 'weston --use-pixman --sprawl' would work but
'weston --sprawl --use-pixman' would ignore the --sprawl option.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Quentin Glidic <sardemff7+git@sardemff7.net>
Acked-by: Daniel Stone <daniels@collabora.com>
2017-10-23 10:29:42 +03:00
Ucan, Emre (ADITG/SW1) 38ea2d2254 compositor-drm: remove connector option
Remove the option, because it is hard to use.
Drm connector ids are hard to reach for users,
and they can change when kernel or device tree
is modified.

Signed-off-by: Emre Ucan <eucan@de.adit-jv.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
[Pekka: bump WESTON_DRM_BACKEND_CONFIG_VERSION]
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2017-09-04 15:47:03 +03:00
Pekka Paalanen 9ffb25009c libweston: introduce weston_output_from_resource()
This is a simple wrapper for casting the user data of a wl_resource into
a struct weston_output pointer. Using the wrapper clearly marks all the
places where a wl_output protocol object is used.

Replace ALL wl_output related calls to wl_resource_get_user_data() with
a call to weston_output_from_resource().

v2: add type assert in weston_output_from_resource().

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Armin Krezović <krezovic.armin@gmail.com>
2017-07-25 16:08:48 +03:00
Derek Foreman f0d39b2243
weston: Set CLOEXEC on stdin
We don't want to leak this into apps launched from the panel.

stdout and stderr are left for now because some things launched
by weston - such as weston-keyboard - share weston's log by
printing to those fds.

I'm singling out stdin because it's never needed by a child process
and because it's value is 0, which makes it easy to accidentally
do bad things to (commit 5c611d933f)

Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Quentin Glidic <sardemff7+git@sardemff7.net>
2017-03-24 21:16:43 +01:00
Emmanuel Gil Peyrot 11ae2a3036 compositor-drm: pageflip timeout implementation
Weston will not repaint until previous update has been acked by a
pageflip event coming from the drm driver. However, some buggy drivers
won’t return those events or will stop sending them at some point and
Weston output repaints will completely freeze. To ease developers’ task
in testing their drivers, this patch makes compositor-drm use a timer
to detect cases where those pageflip events stop coming.

This timeout implementation is software only and includes basic
features usually found in a watchdog. We simply exit Weston gracefully
with a log message and an exit code when the timout is reached.

The timeout value can be set via weston.ini by adding a
pageflip-timeout=<MILLISECONDS> entry under [core]
section. Setting it to 0 disables the timeout feature.

v2:
- Made sure we would get both the pageflip and the vblank events before
  stopping the timer.
- Reordered the error and success cases in
  drm_output_pageflip_timer_create() to be more in line with the rest
  of the code.

v3:
- Reordered (de)arming of the timer with the code around it to avoid it
  being rearmed before the current dearming.
- Return the proper value for the dispatcher in the pageflip_timeout
  callback.
- Also display the output name in case the timer fires.

v4:
- Reordered a forgotten timer rearming after its drmModePageFlip().

Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=83884
Signed-off-by: Frederic Plourde <frederic.plourde at collabora.co.uk>
Signed-off-by: Emmanuel Gil Peyrot <emmanuel.peyrot@collabora.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2017-03-07 16:42:40 +02:00
Daniel Stone f589dac2b0 screen-share: Use wl_list_for_each_safe on destroy
Destroying the shared seat removes the link from so->seat_list.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Acked-by: Bryce Harrington <bryce@osg.samsung.com>
2017-02-21 12:28:15 -08:00
Daniel Stone f81959e39d screen-share: Avoid NULL dereference
Don't try to dereference the seat if it's NULL.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
2017-02-21 12:27:08 -08:00
Armin Krezović e6b7136641
compositor: Improve xwayland warning message
And fix formatting.

Signed-off-by: Armin Krezović <krezovic.armin@gmail.com>
Reviewed-by: Quentin Glidic <sardemff7+git@sardemff7.net>
2017-02-09 21:51:30 +01:00
Ucan, Emre (ADITG/SW1) 1298073b5a systemd: fix Wincompatible-pointer-type
The parameter is passed in safe_strtoint function.
The function expects its parameters in int32_t
data type. Therefore, c compiler throws a
-Wincompatible-pointer-type warning.

This patch changes data type of the parameter
to int32_t.

Signed-off-by: Emre Ucan <eucan@de.adit-jv.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2017-01-27 17:25:11 +02:00
Armin Krezović 605ac8e685 compositor-drm: Restore use-current-mode functionality
It got lost during the porting to the config API.

Signed-off-by: Armin Krezović <krezovic.armin@gmail.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
2017-01-26 14:14:14 +00:00
Ben be9c7d8135 Remove dbus-launch from weston.desktop
Most display managers handle starting a dbus session daemon for you, so
it does not make sense to start our own. Without this patch, if you run
weston from gdm, programs cannot connect to the dbus session daemon.

Reviewed-by: Daniel Stone <daniels@collabora.com>
2017-01-18 12:21:57 +00:00
Quentin Glidic 6d3887baec
weston: Add a specific option to load XWayland
Signed-off-by: Quentin Glidic <sardemff7+git@sardemff7.net>
Reviewed-by: Daniel Stone <daniels@collabora.com>
2017-01-17 18:25:01 +01:00
Quentin Glidic da01c1d105
weston: Make the shell entrypoint specific
This avoids loading a shell as a module, so we are sure to have only one
shell loaded at a time.

Signed-off-by: Quentin Glidic <sardemff7+git@sardemff7.net>
Reviewed-by: Daniel Stone <daniels@collabora.com>
2017-01-17 18:24:58 +01:00
Quentin Glidic 8af2beccbd
weston: Properly namespace modules entrypoint
Signed-off-by: Quentin Glidic <sardemff7+git@sardemff7.net>
Reviewed-by: Daniel Stone <daniels@collabora.com>
2017-01-17 18:24:56 +01:00
Quentin Glidic 3d7ca3b9ea
libweston: Properly namespace modules entrypoint
Use different functions so we cannot load a libweston common module in
weston directly or the other way around.

Signed-off-by: Quentin Glidic <sardemff7+git@sardemff7.net>
Reviewed-by: Daniel Stone <daniels@collabora.com>
2017-01-17 18:24:53 +01:00
Daniel Stone beb97e5f79 libweston: Make module loading safe against long paths
Avoid any buffer overflows here by checking we don't go over PATH_MAX
with stupid module names.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2016-11-30 10:27:51 +00:00
Quentin Glidic 46dc9b440b libweston: Move text_backend_* to weston.h
Signed-off-by: Quentin Glidic <sardemff7+git@sardemff7.net>
Reviewed-by: Daniel Stone <daniels@collabora.com>
2016-11-21 11:03:20 +00:00
Daniel Stone 97863d6f0d text-input: Clear out context->input pointer
If we destroy the text_input (e.g. due to surface deactivation) whilst
the IM manager (the client holding the input_method_context resource,
usually weston-keyboard) sends an event, we can hit a segfault in
text-backend. This is because we free the text_input structure, but
don't actually clear the context->input structure even when we send the
deactivate event.

This is clearly intended to be catered for, since context->input is
always checked for NULL before we relay any events.

This is enough to fix one cause of text-test failing, but it's
ultimately error-prone until we have a no-op test-shell; there is still
a race where weston-desktop-shell can launch weston-keyboard before
text-test manages to bind zwp_text_input_manager.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Maniphest Tasks: https://phabricator.freedesktop.org/T7615
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2016-11-18 15:42:42 +02:00
Daniel Díaz 75b7197f4e Add configuration option for no input device.
As it has been discussed in the past [1], running Weston
without any input device at launch might be beneficial for
some use cases.

Certainly, it's best for the vast majority of users (and
the project) to require an input device to be present, as
to avoid frustration and hassle, but for those brave souls
that so prefer, this patch lets them run without any input
device at all.

This introduces a simple configuration in weston.ini:
  [core]
  require-input=true

True is the default, so no behavioral change is introduced.

[1] https://lists.freedesktop.org/archives/wayland-devel/2015-November/025193.html

Signed-off-by: Daniel Díaz <daniel.diaz@linaro.org>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Daniel Stone <daniels@collabora.com>
2016-10-22 15:04:58 +01:00
Armin Krezović 2045016d8e
compositor-wayland: Convert fullscreen flag to bool
Signed-off-by: Armin Krezović <krezovic.armin@gmail.com>
Reviewed-by: Quentin Glidic <sardemff7+git@sardemff7.net>
2016-10-14 10:42:17 +02:00
Armin Krezović 7f1c0b8a35
compositor-wayland: Convert sprawl flag to boolean
Signed-off-by: Armin Krezović <krezovic.armin@gmail.com>
Reviewed-by: Quentin Glidic <sardemff7+git@sardemff7.net>
2016-10-10 13:42:59 +02:00
Armin Krezović 7e71b8755a
compositor-wayland: Convert use-pixman flag to boolean
Signed-off-by: Armin Krezović <krezovic.armin@gmail.com>
Reviewed-by: Quentin Glidic <sardemff7+git@sardemff7.net>
2016-10-10 13:41:18 +02:00
Armin Krezović c3d2f960d2 weston: Port X11 backend to new output handling API
This is a complete port of the X11 backend that
uses recently added output handling API for output
configuration.

- Output can be configured at runtime by passing the
  necessary configuration parameters, which can be
  filled in manually, obtained from the configuration
  file or obtained from the command line using
  previously added functionality. It is required that
  the scale and transform values are set using the
  previously added functionality.

- Output can be created at runtime using the output
  API. The output creation only creates a pending
  output, which needs to be configured the same way as
  mentioned above.

Same as before, a single output is created at runtime
using the default configuration or a configuration
parsed from the command line. The output-count
functionality is also preserved, which means more than
one output can be created initially, and more outputs can
be added at runtime using the output API.

v2:

 - Fix wet_configure_windowed_output_from_config() usage.
 - Call x11_output_disable() explicitly from
   x11_output_destroy().

v3:

 - Remove unneeded free().
 - Disallow calling x11_output_configure more than once.
 - Remove unneeded checks for output->name == NULL as that
   has been disallowed.
 - Use weston_compositor_add_pending_output().
 - Bump weston_x11_backend_config version to 2.

Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Signed-off-by: Armin Krezović <krezovic.armin@gmail.com>
2016-10-05 14:59:09 +03:00
Armin Krezović 174448a91b weston: Port Wayland backend to new output handling API
This is a complete port of the Wayland backend that
uses the recently added output handling API for output
configuration.

- Output can be configured at runtime by passing the
  necessary configuration parameters, which can be
  filled in manually, obtained from the configuration
  file or obtained from the command line using
  previously added functionality. It is required that
  the scale and transform values are set using the
  previously added functionality.

- Output can be created at runtime using the output
  API. The output creation only creates a pending
  output, which needs to be configured the same way as
  mentioned above.

However, the backend can behave both as windowed backend
and as a backend that issues "hotplug" events, when
running under fullscreen shell or with --sprawl command
line option. The first case was covered by reusing
previously added functionality. The second case required
another API to be introduced and implemented into both
the backend and compositor for handling output setup.

After everything has been set, output needs to be
enabled manually using weston_output_enable().

v2:

 - Fix wet_configure_windowed_output_from_config() usage.
 - Call wayland_output_disable() explicitly from
   wayland_output_destroy().

v3:

 - Get rid of weston_wayland_output_api and rework output
   creation and configuration in case wayland backend is
   started with --sprawl or on fullscreen-shell.
 - Remove unneeded free().
 - Disallow calling wayland_output_configure more than once.
 - Remove unneeded checks for output->name == NULL as that
   has been disallowed.
 - Use weston_compositor_add_pending_output().

v4:

 - Drop unused fields from weston_wayland_backend_config
   and bump WESTON_WAYLAND_BACKEND_CONFIG_VERSION to 2.
 - Move output creation to backend itself when
   --fullscreen is used.
 - Prevent possible duplicated output names by assigning
   a different name to outputs created without any
   configuration specified.

Signed-off-by: Armin Krezović <krezovic.armin@gmail.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2016-10-05 14:54:12 +03:00
Armin Krezović 8f1dca1369 weston: Port RDP backend to new output handling API
This is a complete port of the RDP backend that uses
the recently added output handling API for output
configuration.

Output can be configured at runtime by passing the
necessary configuration parameters, which can be
filled in manually or obtained from the command line
using previously added functionality. It is required
that the scale and transform values are set using
the previously added functionality.

After everything has been set, output needs to be
enabled manually using weston_output_enable().

v2:

 - Rename output_configure() to output_set_size()
   in plugin API and describe it.
 - Manually fetch parsed_options from wet_compositor.
 - Call rdp_output_disable() explicitly from
   rdp_output_destroy().

v3:

 - Disallow calling rdp_output_set_size more than once.
 - Manually assign a hardcoded name to an output as that's
   now mandatory.
 - Use weston_compositor_add_pending_output().
 - Bump weston_rdp_backend_config version to 2.

Reviewed-by: Quentin Glidic <sardemff7+git@sardemff7.net>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Signed-off-by: Armin Krezović <krezovic.armin@gmail.com>
2016-10-03 14:24:08 +03:00
Armin Krezović 7fb17756fc weston: Port headless backend to new output handling API
This is a complete port of the headless backend that
uses the recently added output handling API for output
configuration.

- Output can be configured at runtime by passing the
  necessary configuration parameters, which can be
  filled in manually, obtained from the configuration
  file or obtained from the command line using
  previously added functionality. It is required that
  the scale and transform values are set using the
  previously added functionality.

- Output can be created at runtime using the output
  API. The output creation only creates a pending
  output, which needs to be configured the same way as
  mentioned above.

After everything has been set, output needs to be
enabled manually using weston_output_enable().

Same as before, a single output is created at runtime
using the default configuration or a configuration
parsed from the command line. The no-outputs
functionality is also preserved, which means that no
output will be created initially, but more outputs can
be added at runtime using the output API.

New feature:

This patch also adds, as a bonus of using shared
functionality, support for setting options for outputs
created by this backend in the weston config file in
addition to setting them from the command line.

v2:

 - Fix wet_configure_windowed_output_from_config() usage.
 - Call headless_output_disable() explicitly from
   headless_output_destroy().

v3:

 - Add scale support to output width and height.
 - Use scaled values in calls to various functions which
   require width and height.
 - Disallow calling headless_output_configure more than once.
 - Remove unneeded checks for output->name == NULL as that
   has been disallowed.
 - Use weston_compositor_add_pending_output().
 - Bump weston_headless_backend_config version to 2.

Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Signed-off-by: Armin Krezović <krezovic.armin@gmail.com>
2016-10-03 14:24:08 +03:00
Armin Krezović 6ba369dad4 weston: Port fbdev backend to new output handling API
This is a complete port of the fbdev backend that uses
the recently added output handling API for output
configuration.

It is required that the scale and transform values are
set using the previously added functionality.

After everything has been set, output needs to be
enabled manually using weston_output_enable().

v2:

 - Use weston_compositor_add_pending_output().
 - Bump weston_fbdev_backend_config version to 2.

Reviewed-by: Quentin Glidic <sardemff7+git@sardemff7.net>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Signed-off-by: Armin Krezović <krezovic.armin@gmail.com>
2016-10-03 14:24:08 +03:00
Armin Krezović 083681325b weston: Port DRM backend to new output handling API
This is a complete port of the DRM backend that uses
the recently added output handling API for output
configuration.

Output can be configured at runtime by passing the
necessary configuration parameters, which can be
filled in manually or obtained from the configuration
file using previously added functionality. It is
required that the scale and transform values are set
using the previously added functionality.

After everything has been set, output needs to be
enabled manually using weston_output_enable().

v2:

 - Added missing drmModeFreeCrtc() to drm_output_enable()
   cleanup list in case of failure.
 - Split drm_backend_disable() into drm_backend_deinit()
   to accomodate for changes in the first patch in the
   series. Moved restoring original crtc to
   drm_output_destroy().

v3:

 - Moved origcrtc allocation to drm_output_set_mode().
 - Swapped connector_get_current_mode() and
   drm_output_add_mode() calls in drm_output_set_mode()
   to match current weston.
 - Moved crtc_allocator and connector_allocator update
   from drm_output_enable() to create_output_for_connector()
   to avoid problems when more than one monitor is connected
   at startup and crtc allocator wasn't updated before
   create_output_for_connector() was called second time,
   resulting in one screen being turned off.
 - Moved crtc_allocator and connector_allocator update from
   drm_output_deinit() to drm_output_destroy(), as it
   should not be called on drm_output_disable().
 - Use weston_compositor_add_pending_output().
 - Bump weston_drm_backend_config version to 2.

v4:

 - Reset output->original_crtc to NULL if drm_output_set_mode()
   fails.
 - Remove unneeded log message when disabling an output when a
   pageflip is pending.
 - Document that create_output_for_connector() takes ownership
   of the connector.
 - Free the connector if create output conditionals are not met
   in create_outputs() and update_outputs().

Signed-off-by: Armin Krezović <krezovic.armin@gmail.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2016-10-03 14:22:50 +03:00