Commit Graph

400 Commits

Author SHA1 Message Date
Derek Foreman ca979aa219 desktop-shell: Fix incorrect use of black_surface_get_label
By some dark magic this accidentally doesn't crash because there are
zeroes in the right places at startup, but black_surface_get_label()
very much expects surface_private to be a view.

Let's hand craft a new bespoke label function for this use.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2022-04-14 07:39:25 +00:00
Daniel Stone 6cb2526b67 Move shell-utils to its own directory
shell-utils contains a number of helpers which are currently in use by
both desktop-shell and kiosk-shell. In order to extend this use to
fullscreen-shell as well (which can benefit from reusing the
weston_curtain infrastructure to be able to create solid-colour views
which may or may not be opaque, as well as one function within
fullscreen-shell which was copied wholesale to shell-utils), we need to
create a separate Meson dependency object, and avoid the existing
pattern of including the source from shared/ within the source list for
each shell.

This requires creating a new top-level directory for these shared helper
functions which are required by each shell, but are not part of
libweston in and of itself.

shell-utils depends on libweston-desktop; libweston-desktop depends on
libweston; libweston depends on shared.

Thus it is not possible to expose a dependency object from the shared/
directory which declares a dependency on the libweston-desktop
dependency, as Meson processes directories in order and resolves
variable references as they are parsed.

In order to break this deadlock, this commit creates a new top-level
directory called 'shell-utils' containing only this file, which can be
parsed by Meson after libweston-desktop (making the libweston-desktop
Meson dependency variable available to the build file to declare a
dependency on that), but before the shells (making the new Meson
depenendency object available to each shell which wishes to use it).

This commit contains no functional changes to any observable code.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-03-31 17:15:55 +00:00
Daniel Stone 15a553053a desktop-shell: Reuse curtains for fades
Use the common infrastructure we have, rather than open-coding again.

In changing to the common weston_curtain infrastructure which was
introduced in a previous commit, there are two small functional
derivations.

After adding the view to a layer, we explicitly call
weston_view_geometry_dirty(). This is believed to have no functional
impact, as weston_views have their geometry-dirty flag set when they are
created.

weston_surface_damage() is also called to ensure that the surface is
scheduled for a repaint. As there is currently no good common mechanic
in the common code to ensure that output repaint will occur, due to the
damage propagating outwards from the weston_surface, we are forced to
call this to predictably ensure that the output will be repainted after
we have made this change to the scene graph which should result in the
user observing the new content being repainted.

It is possible that these changes are not strictly required in order for
the correct behaviour to occur. However, it is felt that explicitly
adding these calls is perhaps the least fragile way to ensure that the
behaviour continues to be correct and breakage is not observed,
especially with both view mapping and surface damage identified as areas
for future work which could be beneficial to Weston. If it is felt that
these calls can be removed, then this is certainly possible at a later
stage.

Lastly, there are many users within desktop-shell of the common pattern
of creating a weston_curtain and inserting it into the scene graph to be
painted. These users have been an area of both theoretical concern and
real-life observed fragility and breakage recently. By making each user
follow a common and predictable pattern of usage, each user is no longer
its own special case. This should make it easier to make the
desktop-shell codebase more robust, not only simplifying the codebase,
but improving observed behaviour.

In doing this, it is hoped that future structural and interface changes
become easier to make, allowing us to improve some of the more difficult
corners of the libweston API.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-03-31 17:15:55 +00:00
Daniel Stone dc0f73bcac shell: Encapsulate weston_curtain in its own struct
This will allow us to create a solid weston_buffer as well, since we
need to store that separately.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-03-31 17:15:55 +00:00
Daniel Stone e031397e09 desktop-shell: Reuse curtains for focus animations
Just as we do for fullscreen backgrounds, reuse the curtain infrastructure
for focus animations.

This introduces a small functional change, in that the surface's output
is no longer directly assigned. Instead, we call
weston_view_set_output() ourselves. As setting the weston_view's
position (done from the common helper function of weston_curtain_create
which has been introduced in previous commits) will call
weston_view_set_position(), the view's geometry will be dirtied as a
result.

When the geometry of a weston_view is dirty, it is marked to be updated,
which will occur whilst traversing the view list during output repaint.
This occurs for every view which is currently assigned to a layer; when
building the view list, any view reachable through the view list whose
geometry is dirty will have its position recalculated and an output
assigned. Doing so results in the surface's current output being
updated.

It is believed that there is no functional impact from the
weston_surface not having a primary output assigned between creation and
output repaint being called.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-03-31 17:15:55 +00:00
Daniel Stone bd9b0676dd shell: Make input capture optional for curtains
desktop-shell's focus surfaces want to reuse this, but they don't want
to capture the input, instead allowing it to fall through.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-03-31 17:15:55 +00:00
Daniel Stone 64ef87554b desktop-shell: Clean up fullscreen black view code
Rationalise it a little bit so we don't need pre-declarations of static
functions, and the order of creation more closely matches the others,
including making the same calls to explicitly set the output.

Doing this makes the behaviour match the other users of the same code
pattern. In making them the same, we make desktop-shell code a little
less magically divergent where people might wonder what the correct
pattern is to use. After we have moved all users to a uniform pattern,
later commits are then able to migrate these users to common helper
code, which reduces code duplication, improves code clarity as it is no
longer necessary to wonder about the exact semantics of every
special-case user of this common pattern, and makes it easier to make
interface changes which improve and clarify the patterns which are
prevalent throughout the desktop-shell code.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-03-31 17:15:55 +00:00
Daniel Stone de0cd53264 desktop-shell: Remove redundant geometry dirty call
Dirtying the geometry only sets a flag on the view saying that the
geometry is dirty, so we don't need to do it twice back-to-back.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-03-31 17:15:55 +00:00
Daniel Stone 791e8b1c5f desktop-shell: Fix opaque region co-ordinate confusion
Opaque regions are in surface co-ordinate space, not global co-ordinate
space, so the region should be anchored to (0,0).

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-03-31 17:15:55 +00:00
Daniel Stone e81b8d7cc9 shell: Add alpha to weston_curtain_create
Not all solid-colour views want to be opaque: sometimes we use them with
non-opaque alpha values in order to shade views underneath them.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-03-31 17:15:55 +00:00
Daniel Stone d21563360a shell: Move weston_curtain_create params into the struct
Given that we have a struct for argument params, we might as well use it
rather than have them split between the struct and native params. For
consistency between the implementations, this also includes a shift from
float to int positioning for the base offset within the compositor's
global co-ordinate space.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-03-31 17:15:55 +00:00
Daniel Stone 3a298b0b05 shell: Rename weston_solid_color_surface to weston_curtain_params
The name implied that it was a surface in and of itself, rather than
parameters used by a helper to create a surface and view.

Rename it now that we have weston_curtain as a name, and clean up
initialisers.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-03-31 17:15:55 +00:00
Daniel Stone b77c2374ee shell: Rename solid_color_surface to weston_curtain
create_solid_color_surface actually returns a weston_view that it
creates internally. Since weston_solid_color_view is long and dull,
rename it to weston_curtain.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-03-31 17:15:55 +00:00
Daniel Stone 7059ec7807 desktop-shell: Explicitly destroy black views on shutdown
desktop_shell_removed() won't get called when we shut down, so
explicitly destroy the fullscreen black view.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-03-31 17:15:55 +00:00
Marius Vlad d40cedc8af desktop-shell: Remove wl_shell_surface::resize enum
And use the ones provided by libweston-desktop, as they are one
and the same.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2022-03-08 15:12:56 +02:00
Derek Foreman 66374d48f1 compositor: Remove desktop zoom
Zoom is a neat trick, but in its current form it's very hard to test
and maintain.

It also causes output damage to scale outside of the output's boundaries,
which leads to an extra clipping step that's only necessary when zoom
is enabled.

Remove it to simplify desktop-shell and compositor.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2022-02-03 15:51:20 +00:00
Marius Vlad d25d63e692 desktop-shell: Do not leave views in layers upon shell destruction
This properly takes care of removing any of the views being added into
different layers upon shell destruction. Aggregates the shell_surface
destruction into one place to make things much more clearer. Keep  the
animation part only the weston_desktop_surface destruction rather than
doing it at shutdown.

Fixes #509.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2021-12-17 11:04:28 +02:00
Marius Vlad 137c793f22 desktop-shell: Guard against invalid seats in get_shell_seat()
Starting with commit 'desktop-shell: Embed keyboard focus handle code
when activating' we are iterating over all the seats when removing a
weston_desktop_surface to be able to invalidate the activate surface.

Upon compositor tear down the shell destroy might invalidate seats
before removal of the weston_desktop_surface making the shell_seat
itself invalid. This wasn't apparent at that time because we're not
handling at that the removal of surfaces from layers.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2021-11-24 12:17:26 +00:00
Marius Vlad 5699dbaae7 desktop-shell: Don't crash on when attemping to switch
Attempting to perform a switch on a surface (already) closed will trip
the assert in activate(), so check if we have a weston_desktop_surface
before trying to activate it.

Fixes #543

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2021-11-03 10:10:58 +02:00
Marius Vlad 2be09373b4 desktop-shell, kiosk-shell: Migrate helpers to create a view to shell-utils
Incidentally fixes #553

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2021-11-02 19:32:24 +02:00
Marius Vlad d98c7e86fb shared/shell-utils: Create common helpers functions for shells
Group common functions found in both kiosk-shell and deskop-shell to
a shared utils file.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2021-11-02 19:29:50 +02:00
Marius Vlad d6ccc8b025 libweston: Rename weston_view_activate() to weston_view_activate_input()
This way, we try to differentiate between input focus and window/surface
activation.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2021-11-02 19:04:33 +02:00
Marius Vlad f3584cf995 desktop-shell: Remove keyboard_focus_listener
We no longer make use of the keyboard_focus_listener so remove it
entirely.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
Suggested-by: Derek Foreman <derek.foreman@collabora.com>
2021-11-02 19:04:33 +02:00
Marius Vlad f12697bb3e desktop-shell: Embed keyboard focus handle code when activating
We shouldn't be constrained by having a keyboard plugged-in, so avoid
activating/de-activating the window/surface in the keyboard focus
handler and embed it straight into the window activation part.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2021-11-02 19:04:33 +02:00
Marius Vlad ab39e1d76d desktop-shell: Rename gain/lose keyboard focus to activate/de-activate
This way it better reflects that it handles activation rather that input
focus.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2021-11-02 19:04:33 +02:00
Marius Vlad 05bef4c18a desktop-shell: Remove no-op de-activation of the xdg top-level surface
The shsurf is calloc'ed so the surface count is always 0.  Not only
that but the surface is not set as active by default, so there's no
need to de-activate it.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2021-11-02 19:04:33 +02:00
Takuro Ashie beff0bd0f9 desktop-shell: Fix wrong initial position of input panel
When the surface type of input panel is set as an overlay panel, it's
expected to be shown at near the input cursor. But the current
implementation shows it at center-bottom on the desktop at first then
move it to the correct position while typing.

Signed-off-by: Takuro Ashie <ashie@clear-code.com>
2021-10-14 21:17:07 +09:00
Marius Vlad a7392c855d desktop-shell: Clear out missing listeners
The keyboard focus listener, caps changed and pointer focus listener
were missing when destroying the seat. These are necessary to avoid
using weston_desktop object even if it was destroyed, which happens due
to a focus out event and ultimately handled by the keyboard focus notify
callback.

Once the seats are destroyed (and implictly the focus handlers) we're
safe to destroy weston_desktop object as well.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2021-10-14 09:06:44 +00:00
Marius Vlad c114fd6ef6 desktop-shell: Keep track of seats
This properly tracks the seats and with it, destroys them before
destroying weston_desktop object.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2021-10-14 09:06:44 +00:00
Jonas Ådahl 56958aa6e9 desktop-shell: Damage subsurfaces when minimizing
Fixes an issue where subsurface extending outside of the main surface
wasn't damaged when minimized resulting in left-over content.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
2021-10-01 12:03:11 +02:00
Marius Vlad c30cb29248 desktop-shell: Use weston_surface_destroy() directly
Follow-up from commit 'desktop-shell: don't run fade animation if
compositor is inactive' where the reference was dropped directly,
instead of using weston_surface_destroy().

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2021-08-03 10:44:26 +03:00
Emmanuel Gil Peyrot eff793ab46 Fix indentation all through the project
Fixes a “regression” from 04918f3b0b, but
also other missed pieces.
2021-07-31 15:28:20 +00:00
Erik Kurzinger 04918f3b0b desktop-shell: don't run fade animation if compositor is inactive
When a window is closed, Weston will, by default, run a fade out animation and
defer destroying the underlying surface until it completes. However, if the
compositor is sleeping, and therefore not rendering any frames, this animation
will *never* complete. Therefore, if windows are repeatedly created and
destroyed while in sleep mode, these surfaces will keep accumulating, and since
the buffers attached to them may be backed by an fd, eventually the ulimit will
be reached resulting in a potential crash or other errors.

This can be demonstrated repeatedly launching and killing an X11 application
with Xwayland running.

while true; do xterm & pid=$!; sleep 0.5; kill $pid; done

As soon as the compositor goes to sleep, one can observe a steadily growing
list of dmabufs in the output of lsof.

As a fix, desktop_surface_removed should check whether the compositor is active
before kicking off the fade animation. If it is not, it should instead drop the
extra reference taken in desktop_surface_committed and then destroy the surface
immediately.

Signed-off-by: Erik Kurzinger <ekurzinger@nvidia.com>
2021-07-31 13:47:45 +00:00
Pekka Paalanen 719ca87399 desktop-shell: clean up shell_output better
This fixes the following ASan detected leaks:

Direct leak of 88 byte(s) in 1 object(s) allocated from:
    #0 0x7f8c3455f330 in __interceptor_malloc (/lib/x86_64-linux-gnu/libasan.so.5+0xe9330)
    #1 0x7f8c33c60906 in wl_event_loop_add_timer ../../git/wayland/src/event-loop.c:571
    #2 0x7f8c2ff98f46 in shell_fade_init ../../git/weston/desktop-shell/shell.c:4211
    #3 0x7f8c2ff9e1da in wet_shell_init ../../git/weston/desktop-shell/shell.c:5266
    #4 0x7f8c3443ede5 in wet_load_shell ../../git/weston/compositor/main.c:956
    #5 0x7f8c3444fdb9 in wet_main ../../git/weston/compositor/main.c:3434
    #6 0x55878ad3bfc6 in execute_compositor ../../git/weston/tests/weston-test-fixture-compositor.c:432
    #7 0x55878ad3f9fa in weston_test_harness_execute_as_client ../../git/weston/tests/weston-test-runner.c:528
    #8 0x55878ad2fbd6 in fixture_setup ../../git/weston/tests/viewporter-test.c:46
    #9 0x55878ad2fc58 in fixture_setup_run_ ../../git/weston/tests/viewporter-test.c:48
    #10 0x55878ad3ffaf in main ../../git/weston/tests/weston-test-runner.c:661
    #11 0x7f8c340b409a in __libc_start_main ../csu/libc-start.c:308
    #12 0x55878ad2f769 in _start (/home/pq/build/weston-meson/tests/test-viewporter+0xc769)

Indirect leak of 856 byte(s) in 1 object(s) allocated from:
    #0 0x7f8c3455f518 in calloc (/lib/x86_64-linux-gnu/libasan.so.5+0xe9518)
    #1 0x7f8c33c99b73 in zalloc ../../git/weston/include/libweston/zalloc.h:38
    #2 0x7f8c33c9cfb1 in weston_surface_create ../../git/weston/libweston/compositor.c:574
    #3 0x7f8c2ff98230 in shell_fade_create_surface_for_output ../../git/weston/desktop-shell/shell.c:4059
    #4 0x7f8c2ff98df6 in shell_fade_init ../../git/weston/desktop-shell/shell.c:4202
    #5 0x7f8c2ff9e1da in wet_shell_init ../../git/weston/desktop-shell/shell.c:5266
    #6 0x7f8c3443ede5 in wet_load_shell ../../git/weston/compositor/main.c:956
    #7 0x7f8c3444fdb9 in wet_main ../../git/weston/compositor/main.c:3434
    #8 0x55878ad3bfc6 in execute_compositor ../../git/weston/tests/weston-test-fixture-compositor.c:432
    #9 0x55878ad3f9fa in weston_test_harness_execute_as_client ../../git/weston/tests/weston-test-runner.c:528
    #10 0x55878ad2fbd6 in fixture_setup ../../git/weston/tests/viewporter-test.c:46
    #11 0x55878ad2fc58 in fixture_setup_run_ ../../git/weston/tests/viewporter-test.c:48
    #12 0x55878ad3ffaf in main ../../git/weston/tests/weston-test-runner.c:661
    #13 0x7f8c340b409a in __libc_start_main ../csu/libc-start.c:308
    #14 0x55878ad2f769 in _start (/home/pq/build/weston-meson/tests/test-viewporter+0xc769)

Indirect leak of 608 byte(s) in 1 object(s) allocated from:
    #0 0x7f8c3455f518 in calloc (/lib/x86_64-linux-gnu/libasan.so.5+0xe9518)
    #1 0x7f8c33c99b73 in zalloc ../../git/weston/include/libweston/zalloc.h:38
    #2 0x7f8c33c9bed5 in weston_view_create ../../git/weston/libweston/compositor.c:365
    #3 0x7f8c2ff98251 in shell_fade_create_surface_for_output ../../git/weston/desktop-shell/shell.c:4063
    #4 0x7f8c2ff98df6 in shell_fade_init ../../git/weston/desktop-shell/shell.c:4202
    #5 0x7f8c2ff9e1da in wet_shell_init ../../git/weston/desktop-shell/shell.c:5266
    #6 0x7f8c3443ede5 in wet_load_shell ../../git/weston/compositor/main.c:956
    #7 0x7f8c3444fdb9 in wet_main ../../git/weston/compositor/main.c:3434
    #8 0x55878ad3bfc6 in execute_compositor ../../git/weston/tests/weston-test-fixture-compositor.c:432
    #9 0x55878ad3f9fa in weston_test_harness_execute_as_client ../../git/weston/tests/weston-test-runner.c:528
    #10 0x55878ad2fbd6 in fixture_setup ../../git/weston/tests/viewporter-test.c:46
    #11 0x55878ad2fc58 in fixture_setup_run_ ../../git/weston/tests/viewporter-test.c:48
    #12 0x55878ad3ffaf in main ../../git/weston/tests/weston-test-runner.c:661
    #13 0x7f8c340b409a in __libc_start_main ../csu/libc-start.c:308
    #14 0x55878ad2f769 in _start (/home/pq/build/weston-meson/tests/test-viewporter+0xc769)

They were found with:

	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-viewporter test_viewporter_double_create

Turns out shell_destroy() had an open-coded and outdated copy of the
tear-down sequence, so fixing the leaks in only handle_output_destroy()
was not enough.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-05-31 12:35:01 +03:00
Pekka Paalanen 0d5e4ffb96 desktop-shell: rename output_listener to shell_output
Most other places call a variable like this 'shell_output', so let's do
that here too. The old name was really confusing.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-05-31 12:35:01 +03:00
Pekka Paalanen abd7292969 desktop-shell: destroy weston_desktop
Plugs ASan reported leaks:

Direct leak of 88 byte(s) in 1 object(s) allocated from:
    #0 0x7f338f70a518 in calloc (/lib/x86_64-linux-gnu/libasan.so.5+0xe9518)
    #1 0x7f338afe22f3 in zalloc ../../git/weston/include/libweston/zalloc.h:38
    #2 0x7f338afe3cc2 in weston_desktop_xwayland_init ../../git/weston/libweston-desktop/xwayland.c:410
    #3 0x7f338afdbaef in weston_desktop_create ../../git/weston/libweston-desktop/libweston-desktop.c:87
    #4 0x7f338b148d39 in wet_shell_init ../../git/weston/desktop-shell/shell.c:5224
    #5 0x7f338f5e9de5 in wet_load_shell ../../git/weston/compositor/main.c:956
    #6 0x7f338f5fadb9 in wet_main ../../git/weston/compositor/main.c:3434
    #7 0x5646d2392fc6 in execute_compositor ../../git/weston/tests/weston-test-fixture-compositor.c:432
    #8 0x5646d23969fa in weston_test_harness_execute_as_client ../../git/weston/tests/weston-test-runner.c:528
    #9 0x5646d2386bd6 in fixture_setup ../../git/weston/tests/viewporter-test.c:46
    #10 0x5646d2386c58 in fixture_setup_run_ ../../git/weston/tests/viewporter-test.c:48
    #11 0x5646d2396faf in main ../../git/weston/tests/weston-test-runner.c:661
    #12 0x7f338f25f09a in __libc_start_main ../csu/libc-start.c:308
    #13 0x5646d2386769 in _start (/home/pq/build/weston-meson/tests/test-viewporter+0xc769)

Indirect leak of 152 byte(s) in 1 object(s) allocated from:
    #0 0x7f338f70a518 in calloc (/lib/x86_64-linux-gnu/libasan.so.5+0xe9518)
    #1 0x7f338afdb811 in zalloc ../../git/weston/include/libweston/zalloc.h:38
    #2 0x7f338afdb92d in weston_desktop_create ../../git/weston/libweston-desktop/libweston-desktop.c:65
    #3 0x7f338b148d39 in wet_shell_init ../../git/weston/desktop-shell/shell.c:5224
    #4 0x7f338f5e9de5 in wet_load_shell ../../git/weston/compositor/main.c:956
    #5 0x7f338f5fadb9 in wet_main ../../git/weston/compositor/main.c:3434
    #6 0x5646d2392fc6 in execute_compositor ../../git/weston/tests/weston-test-fixture-compositor.c:432
    #7 0x5646d23969fa in weston_test_harness_execute_as_client ../../git/weston/tests/weston-test-runner.c:528
    #8 0x5646d2386bd6 in fixture_setup ../../git/weston/tests/viewporter-test.c:46
    #9 0x5646d2386c58 in fixture_setup_run_ ../../git/weston/tests/viewporter-test.c:48
    #10 0x5646d2396faf in main ../../git/weston/tests/weston-test-runner.c:661
    #11 0x7f338f25f09a in __libc_start_main ../csu/libc-start.c:308
    #12 0x5646d2386769 in _start (/home/pq/build/weston-meson/tests/test-viewporter+0xc769)

Indirect leak of 72 byte(s) in 1 object(s) allocated from:
    #0 0x7f338f70a518 in calloc (/lib/x86_64-linux-gnu/libasan.so.5+0xe9518)
    #1 0x7f338afdc5ae in zalloc ../../git/weston/include/libweston/zalloc.h:38
    #2 0x7f338afdc89e in weston_desktop_client_create ../../git/weston/libweston-desktop/client.c:108
    #3 0x7f338afe3d2a in weston_desktop_xwayland_init ../../git/weston/libweston-desktop/xwayland.c:415
    #4 0x7f338afdbaef in weston_desktop_create ../../git/weston/libweston-desktop/libweston-desktop.c:87
    #5 0x7f338b148d39 in wet_shell_init ../../git/weston/desktop-shell/shell.c:5224
    #6 0x7f338f5e9de5 in wet_load_shell ../../git/weston/compositor/main.c:956
    #7 0x7f338f5fadb9 in wet_main ../../git/weston/compositor/main.c:3434
    #8 0x5646d2392fc6 in execute_compositor ../../git/weston/tests/weston-test-fixture-compositor.c:432
    #9 0x5646d23969fa in weston_test_harness_execute_as_client ../../git/weston/tests/weston-test-runner.c:528
    #10 0x5646d2386bd6 in fixture_setup ../../git/weston/tests/viewporter-test.c:46
    #11 0x5646d2386c58 in fixture_setup_run_ ../../git/weston/tests/viewporter-test.c:48
    #12 0x5646d2396faf in main ../../git/weston/tests/weston-test-runner.c:661
    #13 0x7f338f25f09a in __libc_start_main ../csu/libc-start.c:308
    #14 0x5646d2386769 in _start (/home/pq/build/weston-meson/tests/test-viewporter+0xc769)

Oops.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-05-31 12:35:01 +03:00
Pekka Paalanen 4bb326bc8c desktop-shell: call weston_layer_fini()
This ensures the layers are torn down properly.

See commit: libweston: add weston_layer_fini()

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-05-28 13:38:28 +03:00
Leandro Ribeiro 2ac73a8b53 exposay: delete outer padding from struct exposay_output
After some changes in the exposay layout, the outer padding makes
no sense anymore. It was used to avoid the panel to get overlapped
by the exposay surfaces and to keep distance from the borders
of the window.

Currently, the exposay is centralized and the panel cannot get
overlapped. The outer padding just creates unnecessary unused
space, what makes exposay's surfaces smaller.

Delete outer padding from struct exposay_output.

Signed-off-by: Leandro Ribeiro <leandrohr@riseup.net>
2020-08-26 14:10:50 +00:00
Leandro Ribeiro 82b4d42943 exposay: centralize surfaces of the last row when we don't have enough surfaces
The exposay grid is square, but we don't always have enough surfaces
to fill all the columns of the last row. The code to centralize
the surfaces of the last row is not working.

Fix the code that centralizes the surfaces in the last row, making
it more visually pleasant.

Signed-off-by: Leandro Ribeiro <leandrohr@riseup.net>
2020-08-26 14:10:50 +00:00
Leandro Ribeiro 55b4b47ec1 exposay: centralize exposay's surfaces in their own square
Commit "exposay: add margins to centralize exposay" has centralized
the whole exposay, but that's not enough. The internal surfaces of
exposay are not centralized.

Each internal surface of exposay is a square, but most of the windows
are rectangular. Add margin to centralize exposay's surfaces in their
own square.

Signed-off-by: Leandro Ribeiro <leandrohr@riseup.net>
2020-08-26 14:10:50 +00:00
Leandro Ribeiro 048c628139 exposay: add margins to centralize exposay
The exposay is being rendered in the top-left corner of the
screen. Add margins to render it in the center, making it
more visually pleasant.

Signed-off-by: Leandro Ribeiro <leandrohr@riseup.net>
2020-08-26 14:10:50 +00:00
Leandro Ribeiro 33e29d88cc exposay: make inner border dependent of exposay's surfaces size
We've been using an inner border of fixed size (80px), but this
is dangerous. If you have too many open applications or a small
window, the surface size computed will be negative, crashing
the exposay: "error: weston_view transformation not invertible".

Also, it creates a lot of unnecessary space, making the exposay
unusable when we have a small window or many applications open.

Make inner border to be 10% of surface size and surface size to
be 90% of its original size, avoiding the crashes and making it
more visually pleasant.

Signed-off-by: Leandro Ribeiro <leandrohr@riseup.net>
2020-08-26 14:10:50 +00:00
Leandro Ribeiro b68454e893 exposay: do not account panel size to compute exposay area
Commit "desktop-shell: make get_output_work_area() global" allowed
the usage of get_output_work_area() in exposay. This is necessary to
avoid overlapping the panel when rendering exposay's surfaces.

Use get_output_work_area() to not take into account the panel size,
instead of considering that the whole screen is available to
render exposay's surfaces.

Signed-off-by: Leandro Ribeiro <leandrohr@riseup.net>
2020-08-26 14:10:50 +00:00
Leandro Ribeiro 0c59e92f0c desktop-shell: make get_output_work_area() global
get_output_work_area() can be used by exposay to know the free space
where it can render its surfaces, what avoids overlapping the panel.

Currently this function is declared as static in
desktop-shell/shell.c, so it cannot be used by exposay.

Remove static from get_output_work_area() and add it to shell.h
so it can be used by exposay as well.

Signed-off-by: Leandro Ribeiro <leandrohr@riseup.net>
2020-08-26 14:10:50 +00:00
Leandro Ribeiro fd874ff533 exposay: move constant value calculation out of loop
In exposay_layout(), int pad is being calculated within the
loop. This is unnecessary, as its value is constant. Move it
out of the loop.

Signed-off-by: Leandro Ribeiro <leandrohr@riseup.net>
2020-08-26 14:10:50 +00:00
ganjing c1e7151eb6 desktop-shell: check memory allocation in switcher_binding
after calling malloc() , be sure to determine whether the allocating for memory space is successful

Signed-off-by: ganjing <ganjing@uniontech.com>
2020-08-14 02:00:25 +00:00
Marius Vlad 6ebda36a3f desktop-shell: Avoid retrieving output's width/height if none present
As in some circumstances there could be no output connected, avoid
retrieving the width/height of the output if none was found/connected.

Fixes: #384

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2020-06-23 10:36:47 +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
Marius Vlad a27658e981 desktop-shell: Do not try to add a child to a non-existent parent
Introduced with a8da2084, it seems that there are cases when there's no
parent available (zenity, for instance).

Removes any potential child and re-initialize it, in case the parent is
not set. (Simon Ser)

Fixes: #340

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
Reviewed-by: Simon Ser <contact@emersion.fr>
Reported-by: n3rdopolis <bluescreenavenger@gmail.com>
2020-01-17 12:47:32 +02:00
Stefan Agner a8da208453 desktop-shell: make sure child window stays active
If a xdg_toplevel surface has a child (or multiple), the desktop shell
still allows to activate the parent. This can be problematic with
modal dialogs such as message boxes which then are hidden behind the
main window, which might be non-responsive to inputs at this this
point.

The protocol specifies set_parent as follows: "Set the 'parent' of
this surface. This surface should be stacked above the parent surface
and all other ancestor surfaces."

Track parent/child relationship in desktop-shell. Follow the protocol
recommendation and make sure the child stays stacked above the parent.

Fixes: #231

Signed-off-by: Stefan Agner <stefan@agner.ch>
2020-01-13 13:18:00 +01:00