Commit Graph

20 Commits

Author SHA1 Message Date
Daniel Stone
2896a0e9ab text-backend: Don't restart client on exit
When we're shutting down, don't try to restart the IM client.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-06-19 21:32:47 +01:00
Daniel Stone
abe893d8ea frontend: Rename weston_client_start to wet_client_start
It's not libweston, so it shouldn't be weston_.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-06-19 21:32:47 +01:00
Michael Olbrich
00f08ec79c compositor/text-backend: use xzalloc everywhere
Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
2023-02-27 16:01:18 +01:00
Marius Vlad
8a610ffe41 compositor/text-backend: Avoid a potential UAF
The text_input_manager might be destroyed upon a compositor shutdown, so
verify if it's still set-up before attemping to use it to avoid a UAF.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2022-07-27 14:15:11 +03:00
Weng Xuetian
e99ed2ad36
Defer launch input method with wl_event_loop_add_idle.
Input method process may also be a XIM server which requires the correct
DISPLAY to be set after xwayland start up. This helps input method to
work for both wayland and Xwayland.

Signed-off-by: Weng Xuetian <wengxt@gmail.com>
2022-04-19 07:06:30 -07:00
Takuro Ashie
29d81c0d4a Fix crash on activating a text area without a real keyboard
It will cause on following situation:

* Enable weston-simple-im
  * It's also reproducible with IBus or Fcitx5
* Connect a mouse or a touch panel
* Don't connect keyboad
* Launch weston-editor and touch the text area

It doesn't reproduce with weston-keyboard because it doesn't use
grab_keyboard of input-method-context-v1.

Signed-off-by: Takuro Ashie <ashie@clear-code.com>
2021-11-18 11:29:56 +02:00
Takuro Ashie
5ff978a52b weston-keyboard: Enable to set as overlay panel
input-method-v1 protocol provides two surface type for the input
panel, `toplevel` and `overlay`. But there is no example for the later
one. This change enables to set weston-keyboard as overlay panel by the
environment variable `WESTON_KEYBOARD_SURFACE_TYPE=overlay` to
demonstrate this feature. In Addition, add weston.ini option
`overlay-keyboard` to set it.

Signed-off-by: Takuro Ashie <ashie@clear-code.com>
2021-10-14 21:17:07 +09: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
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
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
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
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
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
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
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
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
Jussi Kukkonen
649bbce607 include stdint.h for int32_t/uint32_t
Signed-off-by: Jussi Kukkonen <jussi.kukkonen@intel.com>
Reviewed-by: Yong Bakos <ybakos@humanoriented.com>
2016-07-26 16:26:08 -07:00
Pekka Paalanen
58f98c99f5 Move weston source to compositor/
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]
2016-06-23 17:44:54 +03:00