Commit Graph

1512 Commits

Author SHA1 Message Date
Marius Vlad 568d04ff11 weston-debug: Handle destruction of stream description
Memleak found by ASAN:

Direct leak of 258 byte(s) in 8 object(s) allocated from:
    #0 0x7f3eedb6e817 in __interceptor_strdup (/usr/lib/x86_64-linux-gnu/libasan.so.6+0x57817)
    #1 0x55821ce5e6a5 in stream_alloc ../clients/weston-debug.c:94
    #2 0x55821ce5e974 in stream_find ../clients/weston-debug.c:128
    #3 0x55821ce5eb15 in debug_advertise ../clients/weston-debug.c:157
    #4 0x7f3eed7b4d1c  (/usr/lib/x86_64-linux-gnu/libffi.so.7+0x6d1c)

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2021-06-01 13:55:33 +03:00
Pekka Paalanen 497d03edbf clients/keyboard: free input_panel_surface
Fixes ASan leak:

Direct leak of 80 byte(s) in 1 object(s) allocated from:
    #0 0x7fe7791f4518 in calloc (/lib/x86_64-linux-gnu/libasan.so.5+0xe9518)
    #1 0x7fe779100892 in zalloc ../../git/wayland/src/wayland-private.h:232
    #2 0x7fe779100892 in proxy_create ../../git/wayland/src/wayland-client.c:422
    #3 0x7fe779100ede in create_outgoing_proxy ../../git/wayland/src/wayland-client.c:651
    #4 0x7fe779100ede in wl_proxy_marshal_array_constructor_versioned ../../git/wayland/src/wayland-client.c:736
    #5 0x7fe779101226 in wl_proxy_marshal_constructor ../../git/wayland/src/wayland-client.c:834
    #6 0x56428c9bc578 in zwp_input_panel_v1_get_input_panel_surface protocol/input-method-unstable-v1-client-protocol.h:678
    #7 0x56428c9c0bbb in set_toplevel ../../git/weston/clients/keyboard.c:965
    #8 0x56428c9c0c8d in display_output_handler ../../git/weston/clients/keyboard.c:980
    #9 0x56428c9ddead in display_handle_mode ../../git/weston/clients/window.c:5700
    #10 0x7fe7786668ed in ffi_call_unix64 (/lib/x86_64-linux-gnu/libffi.so.6+0x68ed)
    #11 0x7fe7786662be in ffi_call (/lib/x86_64-linux-gnu/libffi.so.6+0x62be)
    #12 0x7fe779103fac in wl_closure_invoke ../../git/wayland/src/connection.c:1018
    #13 0x7fe779100a48 in dispatch_event ../../git/wayland/src/wayland-client.c:1452
    #14 0x7fe779101e43 in dispatch_queue ../../git/wayland/src/wayland-client.c:1598
    #15 0x7fe779101e43 in wl_display_dispatch_queue_pending ../../git/wayland/src/wayland-client.c:1840
    #16 0x56428c9e031c in handle_display_data ../../git/weston/clients/window.c:6211
    #17 0x56428c9e2147 in display_run ../../git/weston/clients/window.c:6553
    #18 0x56428c9c1559 in main ../../git/weston/clients/keyboard.c:1053
    #19 0x7fe77885e09a in __libc_start_main ../csu/libc-start.c:308
    #20 0x56428c9bc029 in _start (/home/pq/build/weston-meson/clients/weston-keyboard+0x19029)

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-05-31 12:35:01 +03:00
Pekka Paalanen 2af436bb9c clients/window: clean up xkb compose data
This fixes ASan report:
	SUMMARY: AddressSanitizer: 151360 byte(s) leaked in 451 allocation(s).

The leaks can be observed if you let weston-desktop-shell start fully
before shutting down Weston. Many simple test suite tests are too fast
to hit this, or do not even use desktop-shell.

This clean-up code is copied from keyboard_handle_keymap().

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-05-31 12:35:01 +03:00
Lujin Wang 928d3a0059 clients: Free output->make/model in output_destroy
== 8 bytes in 1 blocks are definitely lost in loss record 4 of 71
==    at 0x48450F8: malloc (vg_replace_malloc.c:309)
==    by 0x500213F: strdup (strdup.c:42)
==    by 0x40A57F: display_handle_geometry (in weston-desktop-shell)
==    by 0x4864D27: ffi_call_SYSV (in libffi.so.6.0.4)
==    by 0x4865697: ffi_call (in libffi.so.6.0.4)
==    by 0x4880E07: wl_closure_invoke (connection.c:935)
==    by 0x487DD73: dispatch_event.isra.5 (wayland-client.c:1310)
==    by 0x487EF87: dispatch_queue (wayland-client.c:1456)
==    by 0x487EF87: wl_display_dispatch_queue_pending (wayland-client.c:1698)
==    by 0x4104E3: handle_display_data (in weston-desktop-shell)
==    by 0x40FE8F: display_run (in weston-desktop-shell)
==    by 0x405AB3: main (in weston-desktop-shell)

Signed-off-by: Lujin Wang <luwang@nvidia.com>
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-05-31 12:35:01 +03:00
Pekka Paalanen c8c53bafd3 clients/window: destroy remaining globals
Destroy the remaining globals on exit. Fixes a bunch of leaks reported
by ASan.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-05-31 12:35:01 +03:00
Pekka Paalanen 1e08a81c43 clients/window: move code into global_destroy()
Another patch will want to call global_destroy() too.

Pure refactoring, no functional change.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-05-31 12:35:01 +03:00
Pekka Paalanen d9b949d8b9 keyboard: free stuff on exit
This fixes a bunch of leaks when trying to run a Weston test with
desktop-shell, which spawns weston-keyboard.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-05-31 12:35:01 +03:00
Pekka Paalanen 1f3e9045ad clients/window: fix leaks on start-up failure
Trying to run viewporter-test with ASan leak checking,
weston-desktop-shell helper client reports many leaks, because the
compositor quits before the client can start. Hence the
wl_display_roundtrip() fails.

Clean up by calling display_destroy() when wl_display_roundtrip() fails.
It's late enough that all kinds of things may have been allocated, so a
special local tear-down path is not feasible.

To make that work, display_destroy() must handle many things that might
be NULL which normally aren't. Also display_create() needs to initialize
lists early enough so that cleaning them up works.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-05-31 12:35:01 +03:00
Simon Ser 992ee045f1 clients/window: atomically update pointer cursor
Currently, Weston clients update the pointer cursor by first issuing
a wl_surface.commit request to update the buffer, then a
wl_pointer.set_cursor request to update the hotspot. This causes an
issue because buffer and hotspot aren't updated atomically: in-between
the two requests, the buffer is new but the hotspot is old.

To fix this issue, create a new surface each time the cursor is
updated.

Signed-off-by: Simon Ser <contact@emersion.fr>
2021-05-30 15:07:04 +00:00
Simon Ser 0ccad4b24f clients/simple-dmabuf-egl: don't add INVALID to modifier list
While this is harmless because gbm_bo_create_with_modifiers will just
fail, it's easy to misunderstand that gbm_bo_create_with_modifiers
accepts MOD_INVALID. Let's just keep modifiers_count to zero instead
and stop even trying to call that function with invalid input.

Stop using modifiers_count to decide whether the compositor supports a
format. Instead use a separate format_supported flag.

Signed-off-by: Simon Ser <contact@emersion.fr>
References: https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7601#note_778845
2021-05-17 11:59:58 +00:00
Christian Rauch 5c303cc116 destroy shm, pointer, keyboard, touch and seat on exit 2021-05-15 18:57:59 +01:00
Simon Ser 8df8532ee5 clients/simple-dmabuf-egl: add format option
This allows to specify a custom DRM format. For instance, to test
XBGR2101010:

    weston-simple-dmabuf-egl -f 0x30334258

Signed-off-by: Simon Ser <contact@emersion.fr>
2021-03-22 16:02:47 +00:00
Pekka Paalanen 4b301fe7f2 Add weston-drm-fourcc.h
This header is for sharing fallback definitions for drm_fourcc.h. A new
test in tests/yuv-buffer-test.c is going to be needing XYUV8888 format,
and more new formats will be expected with HDR supports.

Share these fallback definitions in one place instead of copying them
all over.

All users of drm_fourcc.h are converted to include weston-drm-fourcc.h
instead for consistency: have the same definitions available everywhere.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-02-25 14:35:03 +02:00
Pekka Paalanen b9ca801324 drop MOD_INVALID, MOD_LINEAR definitions
MOD_INVALID came with libdrm 2.4.83 and MOD_LINEAR came with libdrm
2.4.82. libweston unconditionally depends on libdrm >= 2.4.95, so the
fallback is not necessary.

Since linux-dmabuf.h itself has no use for these and also forgets to
include drm_fourcc.h, .c files including drm_fourcc.h after this header
would trigger compiler warnings.

linux-dmabuf.c does need these, so add the proper include.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-02-25 14:35:03 +02:00
Veeresh Kadasani ed4a0e9275 desktop-shell:change expiration of minute and sec
Fixes: #400

the clock on upper right corner of screen for
desktop shell is behind one minute when compared
to output of date command, so change initial expiration
it_value for minute and sec to remove the delay.

Signed-off-by: Veeresh Kadasani <veeresh.kadasani@huawei.com>
2021-01-21 16:04:34 +05:30
Anurup M c640cb600d desktop-shell: Add missing weston_config_destroy() for desktop.config
desktop.config sections could be freed after it's use. This will avoid
memory leak.

Signed-off-by: Anurup M <anurup.mokkil@gmail.com>
2020-12-08 09:15:20 +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
Tanmay Shah 8ef3ce5c67 clients: Fix shell background image setting.
If weston.ini is not setting background-image path,
then desktop-shell sets ${DATDIR}/weston/pattern.png
as background. However in this case  width and height
is set to 1 during background config and is being
scaled to avoid allocation of buffer.

This behavior is not right. Along with background-image
path, we should also check if background-color is set.
If background color is set, then only scale 1x1 buffer.

This would allow to set pattern.png as default wallpaper
of weston correctly, if background-color is also not set
in weston.ini file.

Fixes: 3623e46dc5
Signed-off-by: Tanmay Shah <tanmay@codeaurora.org>
2020-10-19 07:23:43 +00:00
Olivier Fourdan 85382d394a clients: deprecate weston-info
weston-info is now deprecated in favor of wayland-info which is part of
wayland-utils.

Add a note to weston-info to inform users that weston-info is deprecated
and will be removed soon.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
2020-08-14 10:31:49 +00:00
Peter Hutterer a2086bba66 libweston: replace 0 with the enum value for the xkb init flags
No functional changes, this is cosmetics only.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-05-14 11:49:54 +10: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
Pekka Paalanen 8555877c6c clients: transformed does not recognize -d
It has no such command line option.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2020-02-27 11:08:48 +00:00
Simon Ser 598d3a15b7
clients/window: fail earlier when frame_create fails
This adds a new NULL check to fail earlier when frame_create fails. This can
happen because PNG files couldn't be loaded from the data directory.

Signed-off-by: Simon Ser <contact@emersion.fr>
2020-02-10 15:49:20 +01:00
Marius Vlad dd718b0788 clients/simple-dmabuf-v4l: Dmabuf-contiguous for vivid module
For certain cases when using vivid module, some display-controllers
require to allocate the dmabuf in a contiguous fashion so explain that
to the user when adding details about vivid module.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2020-01-29 14:39:04 +00:00
Marius Vlad ab2c72b05c clients/simple-dmabuf-v4l: Add 'weston-direct-display' protocol
Makes use of weston-direct-display protocol to pass the dmabuf
straight to the display-controller if such a path is possible.

Removes the Y_INVERT flag in case that was passed, and notifies
the user about it, as the weston implementation would force going
through the renderer when passing the Y_INVERT flag, but in the same
time direct-display avoids any GPU import so having them both in the
same time would result into weston refusing the create a buffer.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2020-01-29 14:39:04 +00:00
Marius Vlad b6d1509d63 clients/simple-dmabuf-v4l: Add Y_INVERT option flag
Allow clients to pass Y_INVERT, not only when v4l reports it so.
Document it briefly and add a note about this Y_INVERT flag is passed
if the camera sensors is detected as being y-flipped.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2020-01-29 14:39:04 +00:00
Marius Vlad 3345452c1b clients/simple-dmabuf-v4l: Convert to use getopt_long
Makes adding further flags/options/args much easier.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
Suggested-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2020-01-29 14:39:04 +00:00
Marius Vlad baa1ef22e8 clients/dmabuf-v4l: Pass FLAGS_Y_INVERT to linux-dmabuf if v4l2 reports so
Zero-initialize the display as to correctly pass the options if it was
supplied (@emersion).

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2020-01-29 14:39:04 +00:00
Marius Vlad 4960955e0f client/dmabuf-v4l: Use zwp_linux_dmabuf version 3
We're missing format checks and still using first version of
zwp_linux_dmabuf protocol. Use the latest release and check that the
advertised formats/modifier accepts the user-supplied requested DRM
format.

Accept the format only if the modifier is LINEAR (@emersion).

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2020-01-29 14:39:04 +00:00
Guillaume Champagne 1cb09480e2 window: fix missing prototypes warning
Declare touch_handle_shape and touch_handle_orientation as static
functions as they are local to window.c.

Signed-off-by: Guillaume Champagne <champagne.guillaume.c@gmail.com>
2020-01-29 09:49:41 +00:00
Michael Forney ba3b384b93 clients/presentation-shm: Add missing dependency on xdg-shell protocol
Signed-off-by: Michael Forney <mforney@mforney.org>
2019-12-18 18:51:55 +00:00
Marius Vlad dee14a0a9e clients/simple-dmabuf-egl: Add some notes when using direct-display
protocol

As dmabuf uses a different coordinate (top-left) system than OpenGL
(bottom-left) using both direct-display with the Y_INVERT dmabuf attrib
flag would result in the image being inverted (direct-display will
remove the Y_INVERT flag, which caused the image to be displayed
correctly). Notifies users that direct-display is in use.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
Suggested-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2019-12-11 19:40:24 +00:00
Leandro Ribeiro f0cd00a855 clients/window: drop support for rgb565
Remove member preferred_format from struct window and hardcode
ARGB32 pixel format for clients/window.

The member preferred_format was first added to allow hinting
of a preference for RGB565 when creating a window. But it is
not being used for a long time now. So it's safe to remove it
from the code, dropping support for RGB565 in clients/window.

Signed-off-by: Leandro Ribeiro <leandrohr@riseup.net>
2019-12-11 19:28:30 +00:00
Simon Ser abdb0a29f2
clients: remove leftover from simple-dmabuf-drm
This header is not used anymore.

Signed-off-by: Simon Ser <contact@emersion.fr>
Fixes: 0a4f6e7d6d ("clients: drop simple-dmabuf-drm")
Reported-by: Marius Vlad <marius.vlad@collabora.com>
2019-12-02 10:44:27 +01: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
Simon Ser 0a4f6e7d6d
clients: drop simple-dmabuf-drm
This client contains driver-specific code to allocate buffers. However clients
shouldn't contain driver-specific code and should rely on e.g. mesa to allocate
buffers via standard interfaces.

Additionally, because the build system always tries to enable all features, some
experimental drivers and drivers that aren't included in amd64 distribution
packages were required. Users would need to manually disable some drivers.
Releasers would need to install libdrm from source (because the release process
forbids adding custom build flags). Dropping simple-dmabuf-drm simplifies both
building and releasing.

The functionality previously tested via simple-dmabuf-drm can now be tested with
simple-dmabuf-egl.

Signed-off-by: Simon Ser <contact@emersion.fr>
2019-11-28 15:20:13 +01:00
Harish Krupo 3623e46dc5 desktop-shell: Set 1x1 buffers for solid-color backgrounds
When we are going to set a solid color for the background, use
a 1x1 buffer and set the viewport to the full size. This avoids
un-necessary allocation of buffer memory.

Signed-off-by: Harish Krupo <harish.krupo.kps@intel.com>
2019-11-25 21:54:40 +00:00
Harish Krupo 7bcbab1f2f clients/window: Add viewport destination support
Add support for setting the widget's destination wp viewport.
Setting it in the widget instead of being set directly by the client
ensure that the widget can be identified in widget_find_widget.

v2: Return -1 on error (Pekka)
    Scale allocated x and y when viewport is set (Pekka)
    Allow user to set -1 for viewport width and height (Pekka)

v3: Use NULL instead of 0 (Daniel)
    return 0 if width and height are -1 (Daniel)

Signed-off-by: Harish Krupo <harish.krupo.kps@intel.com>
2019-11-25 21:54:40 +00:00
Marius Vlad 7e0f20311f clients/fullscreen: Refuse to resize the surface size when fullscreen'ed
This would be causing a protocol error in which the buffer size needs to
match the one provided in the configure event.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2019-11-25 20:40:24 +00:00
Veeresh Kadasani bdfc11cd1b simple-dmabuf-egl: make application generic
Don't exit if EGL_KHR_no_config_context extension
is not supported

Signed-off-by: Veeresh Kadasani <external.vkadasani@jp.adit-jv.com>
2019-11-25 20:16:45 +00:00
Jeffy Chen 9774917049 clients: Add more sanity checks to catch destroyed window
Add a sanity check to touch_handle_down() and data_device_enter() as
what we did for pointer and keyboard.

Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
2019-11-21 16:54:38 +00:00
Jeffy Chen 179458ad23 clients: Drop corresponding touch points when destroying windows
This is to avoid memory leaking of these touch points.

Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
2019-11-21 16:54:38 +00:00
Marius Vlad 21627136b2 clients/simple-dmabuf-drm: Make use of direct-display
Uses weston-direct-display extension.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2019-11-21 14:28:58 +02:00
Marius Vlad 4ee832d361 clients/simple-dmabuf-egl: Make use of direct-display
Uses weston-direct-display extension.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2019-11-21 14:28:53 +02:00
Drew DeVault a1eeaf48c6 simple-dmabuf-egl: update to xdg-shell stable 2019-11-12 11:35:56 -05:00
Sebastian Wick ac1b92dfea clients/window: bump wl_seat version to 7
Since version 7 clients must use MAP_PRIVATE to map the keymap fd.

Signed-off-by: Sebastian Wick <sebastian@sebastianwick.net>
2019-11-04 15:10:05 +01:00
Sebastian Wick 5b64fbd965 clients/window: bump wl_seat version to 6
Hook up listeners for touch shape and touch orientation.

Signed-off-by: Sebastian Wick <sebastian@sebastianwick.net>
2019-11-04 15:10:04 +01:00
Stefan Agner 88c8f69a2f clients: avoid build error without gl-renderer
Make sure gl-renderer is enabled when building the EGL and EGL
dmabuf clients. This avoids missing declaration warnings and
linking errors such as:
  ../clients/simple-dmabuf-egl.c:1142: undefined reference to `weston_check_egl_extension
  ...
  ../clients/simple-egl.c:206: undefined reference to `weston_check_egl_extension'

Signed-off-by: Stefan Agner <stefan@agner.ch>
2019-10-24 09:09:33 +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