Commit Graph

8202 Commits

Author SHA1 Message Date
Pekka Paalanen
f3bf7a0d5a gl-renderer: add error messages for missing EGL platforms
Found by inspection, looks like these cases could use an explicit error
message.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-05-18 14:18:53 +03:00
Pekka Paalanen
b383f52d31 gl_renderer: print more GL ES feature flags
This is a human readable replacement for printing out the list of all
available GL extensions that doesn't happen anymore by default.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-05-18 14:18:53 +03:00
Pekka Paalanen
092115786e gl-renderer: move extension lists away from log
Print all EGL and OpenGL extension lists into a new log scope
"gl-renderer" instead of the usual log.

These lists cluttered the log while they were very rarely actually
useful. Sometimes they might be interesting, so make them still
available through the new log scope.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-05-18 13:45:53 +03:00
Pekka Paalanen
ccb0d4f7ce gl-renderer: pass gr to gl_renderer_log_extensions()
Plumb struct gl_renderer all the way through to
gl_renderer_log_extensions(). In the future, the extension lists will be
printed into a debug scope specifically, and it will get the debug scope
from gr.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-05-18 13:45:53 +03:00
Marius Vlad
2327daf96b desktop-shell: Handle weston_curtain destruction
This fixes the following leaks for
weston_curtain/weston_buffer_create_solid_rgba when shutting down the
compositor:

        #0 0x7f9170372987 in __interceptor_calloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:154
        #1 0x7f915bfeb8b7 in zalloc ../include/libweston/zalloc.h:38
        #2 0x7f915bfec71d in weston_curtain_create ../shell-utils/shell-utils.c:150
        #3 0x7f915bfd9e51 in shell_ensure_fullscreen_black_view ../desktop-shell/shell.c:2082
        #4 0x7f915bfda2a9 in shell_configure_fullscreen ../desktop-shell/shell.c:2118
        #5 0x7f915bfdc72d in desktop_surface_committed ../desktop-shell/shell.c:2538
        #6 0x7f915bfa3ef5 in weston_desktop_api_committed ../libweston-desktop/libweston-desktop.c:159
        #7 0x7f915bfae778 in weston_desktop_xdg_toplevel_committed ../libweston-desktop/xdg-shell.c:746
        #8 0x7f915bfb0d45 in weston_desktop_xdg_surface_committed ../libweston-desktop/xdg-shell.c:1374
        #9 0x7f915bfa7382 in weston_desktop_surface_surface_committed ../libweston-desktop/surface.c:174
        #10 0x7f916fe628a6 in wl_signal_emit /home/mvlad/install-amd64/include/wayland-server-core.h:481
        #11 0x7f916fe7c0e2 in weston_surface_commit_state ../libweston/compositor.c:4062
        #12 0x7f916fe7c161 in weston_surface_commit ../libweston/compositor.c:4068
        #13 0x7f916fe7c6ef in surface_commit ../libweston/compositor.c:4146
        #14 0x7f916fc847e9  (/usr/lib/x86_64-linux-gnu/libffi.so.8+0x77e9)

        #0 0x7f9170372987 in __interceptor_calloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:154
        #1 0x7f916fe62aa3 in zalloc ../include/libweston/zalloc.h:38
        #2 0x7f916fe7398d in weston_buffer_create_solid_rgba ../libweston/compositor.c:2603
        #3 0x7f915bfec879 in weston_curtain_create ../shell-utils/shell-utils.c:162
        #4 0x7f915bfd9e51 in shell_ensure_fullscreen_black_view ../desktop-shell/shell.c:2082
        #5 0x7f915bfda2a9 in shell_configure_fullscreen ../desktop-shell/shell.c:2118
        #6 0x7f915bfdc72d in desktop_surface_committed ../desktop-shell/shell.c:2538
        #7 0x7f915bfa3ef5 in weston_desktop_api_committed ../libweston-desktop/libweston-desktop.c:159
        #8 0x7f915bfae778 in weston_desktop_xdg_toplevel_committed ../libweston-desktop/xdg-shell.c:746
        #9 0x7f915bfb0d45 in weston_desktop_xdg_surface_committed ../libweston-desktop/xdg-shell.c:1374
        #10 0x7f915bfa7382 in weston_desktop_surface_surface_committed ../libweston-desktop/surface.c:174
        #11 0x7f916fe628a6 in wl_signal_emit /home/mvlad/install-amd64/include/wayland-server-core.h:481
        #12 0x7f916fe7c0e2 in weston_surface_commit_state ../libweston/compositor.c:4062
        #13 0x7f916fe7c161 in weston_surface_commit ../libweston/compositor.c:4068
        #14 0x7f916fe7c6ef in surface_commit ../libweston/compositor.c:4146
        #15 0x7f916fc847e9  (/usr/lib/x86_64-linux-gnu/libffi.so.8+0x77e9)

We do not migrate the weston_curtain destruction from
desktop_surface_removed() to desktop_shell_destroy_surface() because
we'd want have the curtain removed before the animation starts.

If we were to move the black view destruction, *and* only handle it from
desktop_shell_destroy_surface() the animation runs but the black curtain
will be removed right at the end, effectively diminishing the effect of
the animations.

To this end, we keep both of the two worlds, if the client terminates on
its own, we keep the same animation effect, but if the compositor is
shutting down we destroy it immediately.

We remove wl_list_for_each_safe() and instead loop each time to avoid
using a stale pointer iterator which could cause a UAF as the shsurf
would be free'ed.

Suggested-by: Pekka Paalanen <pekka.paalanen@collabora.com>
Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2022-05-18 09:46:37 +03:00
Daniel Stone
4815936630 gl-renderer: Allocate textures per-buffer, not per-surface
Now that the gl_buffer_state owns everything related to buffers, move
the textures from there rather than living on the surface, to join the
EGLImage and/or SHM params.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-05-16 13:51:42 +01:00
Daniel Stone
62c0f1621c gl-renderer: Delete egl_image wrapper
Now that EGLImages are strongly associated with a gl_buffer_state, which
has a lifetime strictly bounded by a weston_buffer, we don't need to
have an egl_image wrapper having its own separate refcounting anymore.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-05-16 13:51:42 +01:00
Daniel Stone
3297d10287 gl-renderer: Cache gl_buffer_state on the weston_buffer
... apart from SHM.

EGL and dmabuf buffers already have a gl_buffer_state created for them
when we first attach the weston_buffer. By turning
gl_surface_state::buffer into a pointer, we can just reference rather
than inline the gl_buffer_state.

SHM buffers are special, in that we don't keep individual copies of them
within the GL renderer. Instead, the GL surface has a texture allocated
with a shadow copy of the most up-to-date surface content. Handle this
by allocating and destroying gl_buffer_state every time we need to
respecify textures or somehow meaningfully change the parameters.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-05-16 13:51:42 +01:00
Daniel Stone
acc3762506 gl-renderer: Store dmabuf buffer state in weston_buffer
Similarly to EGL buffers, store the gl_buffer_state for a dmabuf buffer
inside weston_buffer, rather than on the linux_dmabuf_buffer. This
slightly simplifies our gl_buffer_state handling, and will be used later
to eliminate the egl_image refcounting.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-05-16 13:51:42 +01:00
Daniel Stone
56dc4b8aaa gl-renderer: Remove unused dmabuf import_type
We don't need this now we don't try to reimport them on attach.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-05-16 13:51:42 +01:00
Daniel Stone
8b167a1703 gl-renderer: Store EGL buffer state in weston_buffer
Introduce a renderer_private hook for weston_buffer, and use this to
store a copy of the gl_buffer_state for EGL buffers (i.e. non-dmabuf, via
EGL_WL_bind_wayland_display).

As part of this, we create the EGLImage along with the weston_buffer
information, and just take a reference to it each time it is attached.
If you have bisected a failure to update surface content to this commit,
it very likely means that your EGL implementation requires images to be
recreated rather than only rebound in order to have their content
updated, which is contrary to specification.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-05-16 13:51:42 +01:00
Daniel Stone
8544a4d09b weston_buffer: Move direct_display out of gl-renderer
Just make it a generic buffer attribute, not hidden away in GL.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-05-16 13:51:42 +01:00
Daniel Stone
57c34139d3 gl-renderer: Don't modify buffer_state in attach
At the moment, attach_shm() will modify the gl_buffer_state in place,
then compare it and see if it differs enough to require a new one. That
rather mixes up the old and new worlds, so quite explicitly build up a
shadow gl_buffer_state with variables first before we change the one
which already exists.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-05-16 13:51:42 +01:00
Daniel Stone
c9253c0012 renderer: Set surface->is_opaque in the core
No need for the renderers to do this now that we know what all of the
formats are.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-05-16 13:51:42 +01:00
Daniel Stone
193de3c2cf renderer: Remove get_content_size hook
Now that we can reliably access buffer dimensions from weston_buffer,
and gl-renderer isn't doing strange things with buffer widths, just use
that. The renderer interface is now unused and can be deleted.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-05-16 13:51:41 +01:00
Daniel Stone
21c65d7c9b gl-renderer: Remove gl_buffer_state.buffer_type
We can just get this from the weston_buffer.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-05-16 13:51:25 +01:00
Daniel Stone
5fdb5fdd90 gl-renderer: Don't match texture width to input pitch
This was only used for what was presumably an attempt at an
optimisation, to force the texture's pitch in pixels to match the SHM
buffer. This is really unlikely to have ever made a difference, given
the alignments GPUs demand.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-05-16 13:51:00 +01:00
Daniel Stone
907c9d1ffd gl-renderer: Clarify comment
Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-05-16 13:51:00 +01:00
Daniel Stone
90dbf4522d gl-renderer: Remove gl_buffer_state.y_inverted
It's just a shadow of weston_buffer.buffer_origin, which also has a
slightly more descriptive name.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-05-16 13:51:00 +01:00
Daniel Stone
c6af9c8581 gl-renderer: Remove gl_buffer_state.height
Low-hanging fruit: just get this from the weston_buffer.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-05-16 13:51:00 +01:00
Daniel Stone
70874428d6 gl-renderer: Make attach_shm return early on cache hit
If we can reuse the textures we already have, just return early, rather
than putting all the work in a large indented body.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-05-16 13:51:00 +01:00
Daniel Stone
1a65c1b8b1 gl-renderer: Shift buffer reference later in attach
Allow the various attach handlers to access the existing buffer, only
referencing the new buffer when they have successfully attached.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-05-16 13:51:00 +01:00
Daniel Stone
77e1a04220 gl-renderer: Remove extraneous parameters from attach
The handlers can chase the details of the buffers themselves.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-05-16 13:51:00 +01:00
Daniel Stone
0cdf576c92 gl-renderer: Convert attach to flat-return style
Deduplicate the no-buffer and the import-fail case, and try to fall
through where we can. This will make it easier to shift the buffer
reference change later, so the attach subhandlers can reference the old
buffer when checking for compatibility.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-05-16 13:51:00 +01:00
Daniel Stone
428ae215e8 gl-renderer: Add return value to attach handlers
It's good to know if we succeeded or failed to import our buffers. This
will also later make for a more smooth transition when we start
returning a gl_buffer_state from them.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-05-16 13:51:00 +01:00
Daniel Stone
bb624754f1 gl-renderer: Don't leak EGLImages on import fail
This only happens for the legacy renderer, but still, might as well
clean up after ourselves when we can't import a secondary plane.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-05-16 13:51:00 +01:00
Daniel Stone
4519461439 gl-renderer: Move EGL buffer error checks into attach_egl
Makes it more consistent with the others, and also easier to return
success/fail.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-05-16 13:51:00 +01:00
Daniel Stone
8f56743590 gl-renderer: Change surface_set_color to attach_solid
No functional change.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-05-16 13:51:00 +01:00
Daniel Stone
72fc647a96 gl-renderer: Split buffer state away from surface state
gl_surface_state has a bunch of members which are tied to the input
buffer, rather than the surface per se.

Split them out into a separate gl_buffer_state member as a first step
towards sanitising its use and lifetime.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-05-16 13:51:00 +01:00
Daniel Stone
0c65b23848 libweston: Move renderer interface to internal header
No-one should be implementing an external renderer, so move the
interface out of the public header.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-05-16 13:51:00 +01:00
Robert Mader
564828fb96 rdp: Silence compiler warning
This value is always `NULL`.

Silences:
`warning: ‘%s’ directive argument is null [-Wformat-overflow=]`

Signed-off-by: Robert Mader <robert.mader@collabora.com>
2022-05-16 09:41:29 +00:00
Robert Mader
2a2eeb6a33 libweston: Silence compiler warning
Silences:
`warning: ‘fourcc’ may be used uninitialized [-Wmaybe-uninitialized]`

Signed-off-by: Robert Mader <robert.mader@collabora.com>
2022-05-16 09:41:29 +00:00
Marius Vlad
ab42159bf3 desktop-shell: Add missing weston_view_destroy()
This fixes the following weston_view leak at compositor shutdown:

    #0 0x7f4250247987 in __interceptor_calloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:154
    #1 0x7f424fd37aa3 in zalloc ../include/libweston/zalloc.h:38
    #2 0x7f424fd3a05f in weston_view_create ../libweston/compositor.c:386
    #3 0x7f423be7be6a in weston_desktop_surface_create_desktop_view ../libweston-desktop/surface.c:364
    #4 0x7f423be7c0a8 in weston_desktop_surface_create_view ../libweston-desktop/surface.c:404
    #5 0x7f423beae91d in desktop_surface_added ../desktop-shell/shell.c:2273
    #6 0x7f423be77db1 in weston_desktop_api_surface_added ../libweston-desktop/libweston-desktop.c:138
    #7 0x7f423be80c73 in weston_desktop_xdg_toplevel_ensure_added ../libweston-desktop/xdg-shell.c:362
    #8 0x7f423be8207a in weston_desktop_xdg_toplevel_committed ../libweston-desktop/xdg-shell.c:697
    #9 0x7f423be84d45 in weston_desktop_xdg_surface_committed ../libweston-desktop/xdg-shell.c:1374
    #10 0x7f423be7b382 in weston_desktop_surface_surface_committed ../libweston-desktop/surface.c:174
    #11 0x7f424fd378a6 in wl_signal_emit /home/mvlad/install-amd64/include/wayland-server-core.h:481
    #12 0x7f424fd510e2 in weston_surface_commit_state ../libweston/compositor.c:4062
    #13 0x7f424fd51161 in weston_surface_commit ../libweston/compositor.c:4068
    #14 0x7f424fd516ef in surface_commit ../libweston/compositor.c:4146
    #15 0x7f424fb597e9  (/usr/lib/x86_64-linux-gnu/libffi.so.8+0x77e9)

With commit 'libweston, desktop-shell: Add a wrapper for weston_surface
reference' we've removed an explicit weston_view_destroy() call due to a
UAF which would've happen if we had close animations enabled, upon
terminating a client. In that patch I've incorrectly wrote this happened
when animations are off, but in fact it happened when they're on, see the
following trace:

READ of size 8 at 0x616000026498 thread T0
    #0 0x7f757fba8797 in weston_signal_emit_mutable ../shared/signal.c:52
    #1 0x7f757fb4bba1 in weston_view_destroy ../libweston/compositor.c:2269
    #2 0x7f756bca89c0 in desktop_shell_destroy_surface ../desktop-shell/shell.c:275
    #3 0x7f756bcb379e in fade_out_done_idle_cb ../desktop-shell/shell.c:2228
    #4 0x7f757faec1da in wl_event_loop_dispatch_idle ../src/event-loop.c:969
    #5 0x7f757faec31d in wl_event_loop_dispatch ../src/event-loop.c:1032
    #6 0x7f757faea114 in wl_display_run ../src/wayland-server.c:1408
    #7 0x7f757ff777ba in wet_main ../compositor/main.c:3589
    #8 0x55f765c8d17d in main ../compositor/executable.c:33
    #9 0x7f757fd997fc in __libc_start_main ../csu/libc-start.c:332
    #10 0x55f765c8d099 in _start (/home/mvlad/install-amd64/bin/weston+0x1099)

0x616000026498 is located 24 bytes inside of 608-byte region [0x616000026480,0x6160000266e0)
freed by thread T0 here:
    #0 0x7f758004c4d7 in __interceptor_free ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:127
    #1 0x7f757fb4bdc8 in weston_view_destroy ../libweston/compositor.c:2295
    #2 0x7f757fb4c14d in weston_surface_unref ../libweston/compositor.c:2334
    #3 0x7f756bca898b in desktop_shell_destroy_surface ../desktop-shell/shell.c:273
    #4 0x7f756bcb379e in fade_out_done_idle_cb ../desktop-shell/shell.c:2228
    #5 0x7f757faec1da in wl_event_loop_dispatch_idle ../src/event-loop.c:969

This patch re-introduces it to avoid leaking the view upon compositor
shutdown, but it does it in tandem with weston_desktop_surface_unlink_view(),
(which was added in a later patch) and before weston_surface_unref() call.

This way we should be safe to terminate/close  clients with additional views
created by libweston-desktop (pop-ups), but also in other different situations.

Verified it in the following circumstances:

- terminating a client with close animation on
- terminating a client with close animations off
- shutting down the compositor with clients running, with and
  without close animations
- terminating top-level clients with additional pop-ups with both with
  and without close animations

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2022-05-16 08:59:11 +00:00
Marius Vlad
9b0b5b57dd noop-renderer: Remove volatile and use compiler attribute
clang-13 complains about bitwise xor assigments like the following:

../libweston/noop-renderer.c:62:25: warning: variable 'unused' set but
not used [-Wunused-but-set-variable] volatile unsigned char unused = 0;

Use the __attribute__((unused)) instead.

Suggested-by: Pekka Paalanen <pekka.paalanen@collabora.com>
Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2022-05-16 08:24:59 +00:00
Derek Foreman
db06aea171 desktop-shell: Check height instead of checking width a second time
Fix an apparent copy and paste error in resize code. I'm not sure anything
sets the relevant callback that would lead to height being different than
width, so there's no easy way to demonstrate a bug, but this change
appears to rectify the intent of the code.

Reported-by: Hideyuki Nagase <hideyukn@microsoft.com>
Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2022-05-13 08:17:02 -05:00
Marius Vlad
299f87f073 desktop-shell: Clarify weston_view destruction at tear down
This documents the fact that other views are handled implictly by
libweston-desktop, and we shouldn't attempt to destroy indiscriminately
views that aren't created by desktop-shell.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2022-05-12 16:53:55 +03:00
Marius Vlad
d03f01377a desktop-shell: Check for a valid desktop_surface
This patch fixes the following trace:

    #0 0x7f07d1bcecfa in weston_desktop_surface_get_surface ../libweston-desktop/surface.c:585
    #1 0x7f07d1bfc9b8 in move_grab_motion ../desktop-shell/shell.c:1499
    #2 0x7f07e539f841 in notify_motion ../libweston/input.c:1794
    #3 0x7f07e1e8ace4 in handle_pointer_motion ../libweston/libinput-device.c:132
    #4 0x7f07e1e8cad5 in evdev_device_process_event ../libweston/libinput-device.c:535
    #5 0x7f07e1e89311 in udev_input_process_event ../libweston/libinput-seat.c:208
    #6 0x7f07e1e8932f in process_event ../libweston/libinput-seat.c:218
    #7 0x7f07e1e8935f in process_events ../libweston/libinput-seat.c:228
    #8 0x7f07e1e8940a in udev_input_dispatch ../libweston/libinput-seat.c:239
    #9 0x7f07e1e89437 in libinput_source_dispatch ../libweston/libinput-seat.c:249
    #10 0x7f07e53122b1 in wl_event_loop_dispatch ../src/event-loop.c:1027
    #11 0x7f07e5310114 in wl_display_run ../src/wayland-server.c:1408
    #12 0x7f07e579c7ba in wet_main ../compositor/main.c:3589
    #13 0x555611d6b17d in main ../compositor/executable.c:33
    #14 0x7f07e55be7fc in __libc_start_main ../csu/libc-start.c:332
    #15 0x555611d6b099 in _start (/home/mvlad/install-amd64/bin/weston+0x1099)

A highly unlikely, but still valid operation, is to close/destroy the
window while still having it grabbed and moved around, basically having
an in-flight destruction of grabbed moving window. Another situation
would be that the client terminates abruptly (crashing for instance),
while being dragged which might take down the compositor.

This could happen for both touch/pointer grab operations and could cause
a NULL pointer access while accessing desktop_surface when being used
to retrieve the underlying weston_surface.

With this patch we check for a valid desktop_surface and return early
if that's not the case.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2022-05-12 16:53:55 +03:00
Marius Vlad
c41cdcabb4 desktop-shell: Migrate surface_unlink_view
Moving weston_desktop_surface_unlink_view() to
desktop_shell_destroy_surface() makes sure we don't leak the underlying
weston_desktop_view when tearing/shutting down the compositor.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2022-05-12 16:53:55 +03:00
Marius Vlad
be5b6f9cdc desktop-shell: Rename destroy_layer functions
No functional change. Makes it obvious that we also call
weston_layer_fini().

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2022-05-12 16:53:55 +03:00
Marius Vlad
9cf602840d desktop-shell: Create a distinct view for the fade-out close anim
Creates a distinct view, separated from the one created by
libweston-desktop, in order to avoid a potential ownership fight with
libweston-desktop upon destroying the view. Upon weston_desktop_surface
destruction, libweston-desktop inflicts damage on the view it creates,
so we need the view to be alive at that time.

This wasn't such an issue before because we had different destruction paths but
with commit 'desktop-shell: Do not leave views in layers upon shell
destruction' all of the destruction paths now land in the same spot
+ handle compositor tear down.

Note as we still use the same weston_surface we'll keep the previous
construct where we were taking a reference to keep it alive.

The original view is destroyed when releasing the ownership, while for
the view created in this patch we handle the destruction directly upon
compositor tear down.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2022-05-12 16:53:55 +03:00
Marius Vlad
bd8314078d libweston, desktop-shell: Add a wrapper for weston_surface reference
Similar to how we do it with drm_fb ref counts, increase a reference
count and return the same object.

Plug-in in desktop-shell when we map up the view in order to survive a
weston_surface destruction.

Astute readers will notice that this patch removes weston_view_destroy()
while keeping the balance between removing and adding a
weston_surface_unref() call in desktop_shell_destroy_surface().

The reason is to let weston_surface_unref() handle destruction on its
own. If multiple references are taken, then weston_surface_unref()
doesn't destroy the view, it just decreases the reference, with
a latter call to weston_surface_unref() to determine if the view
should be destroyed as well.  This situation happens if we have
close animation enabled, were we have more than one reference taken: one
when mapping the view/surface and when when the surface itself was created,
(what we call, a weak reference).

If only a single reference is taken (for instance if we don't have close
animations enabled) then this weston_surface_unref()
call is inert as that reference is not set-up, leaving libweston to
handle the view destruction.

Following that with a weston_view_destroy() explicit call would cause a
UAF as the view was previous destroyed by a weston_surface_unref() call.

A side-effect of not keeping the weston_view_destroy() call would
happen when tearing down the compositor. If close animations are enabled,
weston_surface_unref() would not destroy the view, and because
weston_view_destroy() no longer exists, we would still have the
view in the other layers by the time we check-up if layers
have views present.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2022-05-12 16:53:34 +03:00
Marius Vlad
d3ed2eb345 libweston: Assert if ref-count balance is wrong
Calling weston_surface_unref() one time too many could be a sign we
haven't correctly increased the ref count for it.

Also, if we don't have a surface being passed, do no attempt to
use it.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2022-05-12 16:46:32 +03:00
Marius Vlad
0d8e94af61 libweston: Rename weston_surface_destroy() to weston_surface_unref()
Make it obvious that weston_surface has a reference counting happening
and destruction of the weston_surface happens when the last
weston_surface reference has been accounted for.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2022-05-12 16:46:31 +03:00
Robert Mader
53a221ccaa libweston/linux-dmabuf: create surface feedback on demand
Unconditionally creating a surface feedback for each surface
creates unnecessary overhead and noise in the logs. Thus
create it when the first surface feedback resource for a
surface is requested and delete it again once all those
resources have been destroyed.

Signed-off-by: Robert Mader <robert.mader@collabora.com>
2022-05-12 11:53:04 +00:00
Robert Mader
34f7e01c2b clients/simple-dmabuf-feedback: use time instead of redraws
Weston uses a timeout of 2 seconds before it sends scanout
tranches to clients in order to not trigger excessive buffer
reallocations in clients.
`simple-dmabuf-feedback` in turn counts redraws (200) before
exiting. That doesn't work on e.g. 144Hz screens, thus use a
timer here as well.

Signed-off-by: Robert Mader <robert.mader@collabora.com>
2022-05-12 11:53:04 +00:00
Robert Mader
29d480813a backend-drm: Add failure reasons for failing gbm_bo_import
And add it to the list of failures triggering a resend of
dmabuf feedback scanout tranches.

Closes https://gitlab.freedesktop.org/wayland/weston/-/issues/614

Signed-off-by: Robert Mader <robert.mader@collabora.com>
2022-05-12 11:53:04 +00:00
Marius Vlad
70353dace3 desktop-shell: Refuse to set a surface to maximized
For a surface that is already fullscreen making it maximized means to
exit fullscreen then set to it maximized. Instead of doing it, refuse to
do anything until the user explicitly performs that operation.

With this approach we follow other DE (desktop environments) which would
not perform any operation until the user exits fullscreen state.

Fixes #321

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2022-05-10 12:13:28 +00:00
Erik Faye-Lund
fed2ee51f2 simple-egl: clean up unused callback
Unused since 45ee1f9ef7, which itself
removes code that was unused since
1e65840b61.

Signed-off-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
2022-05-10 08:03:27 +00:00
Hideyuki Nagase
8a776be925 rdp: Add US international keyboard layout
Co-authored-by: Steve Pronovost <spronovo@microsoft.com>
Co-authored-by: Brenton DeGeer <brdegeer@microsoft.com>
Signed-off-by: Hideyuki Nagase <hideyukn@microsoft.com>
Signed-off-by: Steve Pronovost <spronovo@microsoft.com>
Signed-off-by: Brenton DeGeer <brdegeer@microsoft.com>
2022-05-09 08:56:23 -05:00
Hideyuki Nagase
e3b95f2d27 rdp: Add hebrew standard layout
Co-authored-by: Steve Pronovost <spronovo@microsoft.com>
Co-authored-by: Brenton DeGeer <brdegeer@microsoft.com>
Signed-off-by: Hideyuki Nagase <hideyukn@microsoft.com>
Signed-off-by: Steve Pronovost <spronovo@microsoft.com>
Signed-off-by: Brenton DeGeer <brdegeer@microsoft.com>
2022-05-09 08:56:23 -05:00