Fixes ASan reported leaks:
Direct leak of 88 byte(s) in 1 object(s) allocated from:
#0 0x7fcdc7382518 in calloc (/lib/x86_64-linux-gnu/libasan.so.5+0xe9518)
#1 0x7fcdc2d902f3 in zalloc ../../git/weston/include/libweston/zalloc.h:38
#2 0x7fcdc2d91cc2 in weston_desktop_xwayland_init ../../git/weston/libweston-desktop/xwayland.c:410
#3 0x7fcdc2d89aef in weston_desktop_create ../../git/weston/libweston-desktop/libweston-desktop.c:87
#4 0x7fcdc2db7300 in wet_shell_init ../../git/weston/ivi-shell/ivi-shell.c:642
#5 0x7fcdc7261de5 in wet_load_shell ../../git/weston/compositor/main.c:956
#6 0x7fcdc7272baa in wet_main ../../git/weston/compositor/main.c:3410
#7 0x55e12a669e29 in execute_compositor ../../git/weston/tests/weston-test-fixture-compositor.c:432
#8 0x55e12a66d85d in weston_test_harness_execute_as_client ../../git/weston/tests/weston-test-runner.c:528
#9 0x55e12a65dc48 in fixture_setup ../../git/weston/tests/ivi-layout-test-client.c:48
#10 0x55e12a65dcca in fixture_setup_run_ ../../git/weston/tests/ivi-layout-test-client.c:50
#11 0x55e12a66de12 in main ../../git/weston/tests/weston-test-runner.c:661
#12 0x7fcdc6ed709a in __libc_start_main ../csu/libc-start.c:308
#13 0x55e12a65d769 in _start (/home/pq/build/weston-meson/tests/test-ivi-layout-client+0xd769)
Indirect leak of 152 byte(s) in 1 object(s) allocated from:
#0 0x7fcdc7382518 in calloc (/lib/x86_64-linux-gnu/libasan.so.5+0xe9518)
#1 0x7fcdc2d89811 in zalloc ../../git/weston/include/libweston/zalloc.h:38
#2 0x7fcdc2d8992d in weston_desktop_create ../../git/weston/libweston-desktop/libweston-desktop.c:65
#3 0x7fcdc2db7300 in wet_shell_init ../../git/weston/ivi-shell/ivi-shell.c:642
#4 0x7fcdc7261de5 in wet_load_shell ../../git/weston/compositor/main.c:956
#5 0x7fcdc7272baa in wet_main ../../git/weston/compositor/main.c:3410
#6 0x55e12a669e29 in execute_compositor ../../git/weston/tests/weston-test-fixture-compositor.c:432
#7 0x55e12a66d85d in weston_test_harness_execute_as_client ../../git/weston/tests/weston-test-runner.c:528
#8 0x55e12a65dc48 in fixture_setup ../../git/weston/tests/ivi-layout-test-client.c:48
#9 0x55e12a65dcca in fixture_setup_run_ ../../git/weston/tests/ivi-layout-test-client.c:50
#10 0x55e12a66de12 in main ../../git/weston/tests/weston-test-runner.c:661
#11 0x7fcdc6ed709a in __libc_start_main ../csu/libc-start.c:308
#12 0x55e12a65d769 in _start (/home/pq/build/weston-meson/tests/test-ivi-layout-client+0xd769)
Indirect leak of 72 byte(s) in 1 object(s) allocated from:
#0 0x7fcdc7382518 in calloc (/lib/x86_64-linux-gnu/libasan.so.5+0xe9518)
#1 0x7fcdc2d8a5ae in zalloc ../../git/weston/include/libweston/zalloc.h:38
#2 0x7fcdc2d8a89e in weston_desktop_client_create ../../git/weston/libweston-desktop/client.c:108
#3 0x7fcdc2d91d2a in weston_desktop_xwayland_init ../../git/weston/libweston-desktop/xwayland.c:415
#4 0x7fcdc2d89aef in weston_desktop_create ../../git/weston/libweston-desktop/libweston-desktop.c:87
#5 0x7fcdc2db7300 in wet_shell_init ../../git/weston/ivi-shell/ivi-shell.c:642
#6 0x7fcdc7261de5 in wet_load_shell ../../git/weston/compositor/main.c:956
#7 0x7fcdc7272baa in wet_main ../../git/weston/compositor/main.c:3410
#8 0x55e12a669e29 in execute_compositor ../../git/weston/tests/weston-test-fixture-compositor.c:432
#9 0x55e12a66d85d in weston_test_harness_execute_as_client ../../git/weston/tests/weston-test-runner.c:528
#10 0x55e12a65dc48 in fixture_setup ../../git/weston/tests/ivi-layout-test-client.c:48
#11 0x55e12a65dcca in fixture_setup_run_ ../../git/weston/tests/ivi-layout-test-client.c:50
#12 0x55e12a66de12 in main ../../git/weston/tests/weston-test-runner.c:661
#13 0x7fcdc6ed709a in __libc_start_main ../csu/libc-start.c:308
#14 0x55e12a65d769 in _start (/home/pq/build/weston-meson/tests/test-ivi-layout-client+0xd769)
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
This ensures the layers are torn down properly.
See commit: libweston: add weston_layer_fini()
There would be a lot more to tear down here, but that is for another
time.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
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>
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>
This was forgetting to remove the compositor destroy listener if init failed,
which would lead to use-after-free on compositor tear-down. Found by
inspection.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
Since the surface_destroy_listener is only registered for ivi-shell
applications, it should only be removed for ivi-shell applications.
Signed-off-by: Michael Teyfel <mteyfel@de.adit-jv.com>
Removed assert, that checks if ivi-surface is not available, since this
can now happen with xdg-shell support.
Signed-off-by: Michael Teyfel <mteyfel@de.adit-jv.com>
Use the proper function to exit instead of the libwayland one, to allow main
handle_exit() to be called.
This is just to unify the exit paths.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
input panel related members of ivi_shell struct are
not required anymore. Also get_default_view(),
input_panel_setup() and input_panel_destroy() are not used.
Therefore, we can remove them.
Signed-off-by: Emre Ucan <eucan@de.adit-jv.com>
input panel implementation puts contents of an
application, which uses input_method protocol,
on top of all other surfaces. It is not controllable
with ivi-layout interface.
This is not acceptable for an In-Vehicle Infotainment
platform. Because we have to ensure configured scenegraph
cannot be hijacked by any rogue application.
Therefore, I am removing input panel implementation
Signed-off-by: Emre Ucan <eucan@de.adit-jv.com>
During de-init ensure removal of compositor destroy notification
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>
If compositor wakes up from sleep state, we have
to trigger repaint for all outputs.
Signed-off-by: Emre Ucan <eucan@de.adit-jv.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
it has only developermode option parameter.
The parameter is only used in init_ivi_shell.
Therefore, we can basically remove the struct,
and check the option locally in the function.
Signed-off-by: Emre Ucan <eucan@de.adit-jv.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
controller modules can be loaded as weston modules
from the main function of weston.
Signed-off-by: Emre Ucan <eucan@de.adit-jv.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Change code related to touch down 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>
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>
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>
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>
Currently, layers’ order depends on the module loading order and it does
not survive runtime modifications (like shell locking/unlocking).
With this patch, modules can safely add their own layer at the expected
position in the stack, with runtime persistence.
v4 Reviewed-by: Giulio Camuffo <giuliocamuffo@gmail.com>
Signed-off-by: Quentin Glidic <sardemff7+git@sardemff7.net>
Acked-by: Daniel Stone <daniels@collabora.com>
[Pekka: fix three whitespace issues]
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
The name suggests that it activates surfaces, but the code says it
rather just assigns keyboard focus. Rename it for clarity, and so the
original function name could be used for something more appropriate
later. Switch order of parameters since keyboard focus is a property of
the seat. Update all callers as appropriate.
Change was asked for by pq, May 26, 2016:
"This should be called weston_seat_set_keyboard_focus(seat, surface).
Keyboard focus is a property of the seat."
Signed-off-by: Bryce Harrington <bryce@osg.samsung.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
This is the start of separating weston-the-compositor source files from
libweston source files.
This is moving all the files related to the 'weston' binary. Also the
CMS and systemd plugins are moved.
xwayland plugin is not moved, because it will be turned into a
libweston feature.
To avoid breaking the build, #includes for weston.h are fixed to use
compositor/weston.h. This serves as a reminder that such files may need
further attention: moving to the right directory, or maybe using the
proper -I flags instead.
v2: Move also screen-share.c, and add a note about weston-launch.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Yong Bakos <ybakos@humanoriented.com>
Acked-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Quentin Glidic <sardemff7+git@sardemff7.net>
Tested-by: Quentin Glidic <sardemff7+git@sardemff7.net>
Tested-by: Benoit Gschwind <gschwind@gnu-log.net>
Acked-by: Benoit Gschwind <gschwind@gnu-log.net>
[Pekka: rebased]
A surface could have more than one views.
Therefore, it is not possible to map a surface to
a specific view. The implementation of the API
iterates the list of views of the surface, and
returns the first found view.
It is not necessary to have this API to found
a view of the surface. Therefore, I removed the API.
Signed-off-by: Emre Ucan <eucan@de.adit-jv.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
The config can now be retrieved with a new function defined in weston.h,
wet_get_config(weston_compositor*).
Signed-off-by: Giulio Camuffo <giuliocamuffo@gmail.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Quentin Glidic <sardemff7+git@sardemff7.net>
Add ivi-layout API for getting an ivi_layout_surface from a
weston_surface if it exists. This can be used by controllers that hook
up to core Weston callbacks and get handed a weston_surface, but need to
use ivi-layout API to manipulate it.
The only ways ivi-layout itself would be able to go from weston_surface
to ivi_layout_surface are either searching through the list of all
ivi_layout_surfaces or adding a dummy destroy listener to the
weston_surface. Therefore the implementation is delegated to
ivi-shell.c.
Ivi-shell.c can easily look up the ivi_shell_surface for a
weston_surface, and that will map 1:1 to an ivi_layout_surface.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Emre Ucan <eucan@de.adit-jv.com>
Add more sanity checks to get_ivi_shell_surface() just in case.
If the configure hook is set, we must always have non-NULL
configure_private.
Check the ivi_shell_surface matches the surface.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Eugen Friedrich <friedrix@gmail.com>
This should not get called unless there is an ivi_shell_surface.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Eugen Friedrich <friedrix@gmail.com>
To be used by the Weston timeline feature for identifying surfaces in a
trace. The 'get_label' functionality can also be used by any debugging
code, too.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Eugen Friedrich <friedrix@gmail.com>
This new header encapsulates the API that ivi-layout offers to
ivi-shell.c to call.
ivi-shell.c no longer uses ivi-layout-private.h. This limits the
ivi-layout internal structures to just ivi-layout code.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Emre Ucan <eucan@de.adit-jv.com>
For some reason, it seems that ivi-layout.c has tried hard to avoid
calling directly into ivi-shell.c. This means there is a jump through
hoops just to get the configure event sent to the clients. Ivi-shell
registers a listener for a ivi-layout signal for sending the event.
Instead, let ivi-layout.c call directly into ivi-shell.c, and expose a
function to send out the configure events. This reduces some confusion
on who calls what.
The main idea though is that this makes ivi-shell.c not depend on struct
ivi_layout_surface fields directly anymore. In following patches,
ivi_layout_surface can be made opaque for ivi-shell.c.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Emre Ucan <eucan@de.adit-jv.com>
Similar with Desktop shell, set activate to weston surface which is
left-clicked by pointer or touched. This is needed to focus it with a seat.
Without this, a feature who gets activated weston surface by using
weston_surface_get_main_surface doesn't work correctly because it can
not get correct focused weston surface. For example, input-panel uses
weston_surface_get_main_surface to get a weston surface. With this
weston surface, it get a member: output to decide which output shall
show a input-panel, software keyboard. Without activation,
input-panel-ivi can not find a correct output which shows e.g.
weston-editor who uses input-method.
Signed-off-by: Nobuhiko Tanibata <NOBUHIKO_TANIBATA@xddp.denso.co.jp>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Tested-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
- opening braces are on the same line as the if statement
- opening braces are not on the same line as the function name
- space between for/while/if and opening parenthesis
Signed-off-by: Dawid Gajownik <gajownik@gmail.com>
Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
Normally we need to check if a seat's [device_type]_count is > 0 before
we can use the associated pointer. However, in a binding you're
guaranteed that the seat has a device of that type. If we pass in
that type instead of the seat, it's obvious we don't have to test it.
The bindings can still get the seat pointer via whatever->seat if they
need it.
This is preparation for a follow up patch that prevents direct access
to seat->device_type pointers, and this will save us a few tests at
that point.
Reviewed-by: Jonas Ådahl <jadahl@gmail.com>
Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
We used to rely on the order in which the
weston_compositor::destroy_signal callbacks happened, to not access
freed memory. Don't know when, but this broke at least with ivi-shell,
which caused crashes in random places on compositor shutdown.
Valgrind found the following:
Invalid write of size 8
at 0xC2EDC69: unbind_input_panel (input-panel-ivi.c:340)
by 0x4E3B6BB: destroy_resource (wayland-server.c:537)
by 0x4E3E085: for_each_helper.isra.0 (wayland-util.c:359)
by 0x4E3E60D: wl_map_for_each (wayland-util.c:365)
by 0x4E3BEC7: wl_client_destroy (wayland-server.c:675)
by 0x4182F2: text_backend_notifier_destroy (text-backend.c:1047)
by 0x4084FB: wl_signal_emit (wayland-server-core.h:264)
by 0x4084FB: main (compositor.c:5465)
Address 0x67ea360 is 208 bytes inside a block of size 232 free'd
at 0x4C2A6BC: free (vg_replace_malloc.c:473)
by 0x4084FB: wl_signal_emit (wayland-server-core.h:264)
by 0x4084FB: main (compositor.c:5465)
Invalid write of size 8
at 0x4E3E0D7: wl_list_remove (wayland-util.c:57)
by 0xC2EDEE9: destroy_input_panel_surface (input-panel-ivi.c:191)
by 0x4E3B6BB: destroy_resource (wayland-server.c:537)
by 0x4E3BC7B: wl_resource_destroy (wayland-server.c:550)
by 0x40DB8B: wl_signal_emit (wayland-server-core.h:264)
by 0x40DB8B: weston_surface_destroy (compositor.c:1883)
by 0x40DB8B: weston_surface_destroy (compositor.c:1873)
by 0x4E3B6BB: destroy_resource (wayland-server.c:537)
by 0x4E3E085: for_each_helper.isra.0 (wayland-util.c:359)
by 0x4E3E60D: wl_map_for_each (wayland-util.c:365)
by 0x4E3BEC7: wl_client_destroy (wayland-server.c:675)
by 0x4182F2: text_backend_notifier_destroy (text-backend.c:1047)
by 0x4084FB: wl_signal_emit (wayland-server-core.h:264)
by 0x4084FB: main (compositor.c:5465)
Address 0x67ea370 is 224 bytes inside a block of size 232 free'd
at 0x4C2A6BC: free (vg_replace_malloc.c:473)
by 0x4084FB: wl_signal_emit (wayland-server-core.h:264)
by 0x4084FB: main (compositor.c:5465)
Invalid write of size 8
at 0x4E3E0E7: wl_list_remove (wayland-util.c:58)
by 0xC2EDEE9: destroy_input_panel_surface (input-panel-ivi.c:191)
by 0x4E3B6BB: destroy_resource (wayland-server.c:537)
by 0x4E3BC7B: wl_resource_destroy (wayland-server.c:550)
by 0x40DB8B: wl_signal_emit (wayland-server-core.h:264)
by 0x40DB8B: weston_surface_destroy (compositor.c:1883)
by 0x40DB8B: weston_surface_destroy (compositor.c:1873)
by 0x4E3B6BB: destroy_resource (wayland-server.c:537)
by 0x4E3E085: for_each_helper.isra.0 (wayland-util.c:359)
by 0x4E3E60D: wl_map_for_each (wayland-util.c:365)
by 0x4E3BEC7: wl_client_destroy (wayland-server.c:675)
by 0x4182F2: text_backend_notifier_destroy (text-backend.c:1047)
by 0x4084FB: wl_signal_emit (wayland-server-core.h:264)
by 0x4084FB: main (compositor.c:5465)
Address 0x67ea368 is 216 bytes inside a block of size 232 free'd
at 0x4C2A6BC: free (vg_replace_malloc.c:473)
by 0x4084FB: wl_signal_emit (wayland-server-core.h:264)
by 0x4084FB: main (compositor.c:5465)
Looking at the first of these, unbind_input_panel() gets called when the
text-backend destroys its helper client which has bound to input_panel
interface. This happens after the shell's destroy_signal callback has
been called, so the shell has already been freed.
The other two errors come from
wl_list_remove(&input_panel_surface->link);
which has gone stale when the shell was destroyed
(shell->input_panel.surfaces list).
Rather than creating even more destroy listeners and hooking them up in
spaghetti, modify text-backend to not hook up to the compositor destroy
signal. Instead, make it the text_backend_init() callers' responsibility
to also call text_backend_destroy() appropriately, before the shell goes
away.
This fixed all the above Valgrind errors, and avoid a crash with
ivi-shell when exiting Weston.
Also using desktop-shell exhibited similar Valgrind errors which are
fixed by this patch, but those didn't happen to cause any crashes AFAIK.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-By: Derek Foreman <derekf@osg.samsung.com>
ivi_shell_surface lifetime shall follow the ivi_surface protocol object
lifetime, and frees the ivi-id by destroying the ivi_layout_surface
from both wl_surface and ivi_surface destruction as the protocol specifies.
Signed-off-by: Nobuhiko Tanibata <NOBUHIKO_TANIBATA@xddp.denso.co.jp>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
To help reduce code duplication and also 'kitchen-sink' includes
the ARRAY_LENGTH macro was moved to a stand-alone file and
referenced from the sources consuming it. Other macros will be
added in subsequent passes.
Signed-off-by: Jon A. Cruz <jonc@osg.samsung.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
Whether a input method is used should be the responsibility
of the shell because some shells may not want to implement
an input method at all
Signed-off-by: Murray Calavera <murray.calavera@gmail.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
This method should not update weston_view directly. This shall be done by
controller via ivi_layout_*.
Signed-off-by: Nobuhiko Tanibata <nobuhiko_tanibata@xddp.denso.co.jp>
Acked-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>