Commit graph

9134 commits

Author SHA1 Message Date
Brendan King 751c1c9496 xwayland: fix segfault when running x11perf
Running "x11perf -reps 1 -repeat 1 -all" will segfault, due to
windows being left on lists after being destroyed.

The fix was devised after running Weston under valgrind whilst
x11perf was running.

Fixes: https://gitlab.freedesktop.org/wayland/weston/-/issues/797

Signed-off-by: Brendan King <Brendan.King@imgtec.com>
2023-08-11 14:18:13 +03:00
Daniel Stone f7d8095352 desktop-shell: Use weston_view_move_to_layer() in switcher
Use our new helper instead of doing this by hand.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-08-11 14:10:45 +03:00
Daniel Stone fb64b00da7 desktop-shell: Remove manual damage for minimised surfaces
We don't need to inflict any damage here, because it's been done for us
when we move the layers.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-08-11 14:10:45 +03:00
Daniel Stone 73050c358d desktop-shell: Don't open-code animate_focus_change()
It already does what we want, so just use it when we're losing focus.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-08-11 14:10:45 +03:00
Daniel Stone f17581fdd2 desktop-shell: Regularise focus_animation_type checks
Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-08-11 14:10:45 +03:00
Daniel Stone 72a52454ad desktop-shell: Reject invalid focus types in configuration
Just refuse to start up if someone passes an incorrect focus type.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-08-11 14:10:45 +03:00
Daniel Stone fca71ff4bb desktop-shell: Initialise lists earlier
Make sure that we can exit cleanly if we have to fail.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-08-11 14:10:45 +03:00
Daniel Stone f04e1ec9ab desktop-shell: Clean up animate_focus_change()
Now that we're not allocating surfaces on demand, animate_focus_change()
becomes a lot more straightforward and common, and using some local
variables sure does cut out a lot of typing.

Knowing that both from and to cannot both be NULL (because we check if
from == to), we can change the juggling to be extremely simple:
calculate where we need the curtains to be in the view list, put them
there, and set up the fade.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-08-11 14:10:45 +03:00
Daniel Stone 42334db41e desktop-shell: Create focus surfaces for animation up front
Rather than creating them the first time we need to switch focus, just
create them at startup if we're going to be needing them at some point.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-08-11 14:10:45 +03:00
Daniel Stone a168dc0659 desktop-shell: Don't set alpha for unused views
We don't need to be setting this because it isn't (yet) used anywhere.
It will get set when it is used.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-08-11 14:10:45 +03:00
Daniel Stone 6738c738ab desktop-shell: Use weston_view_move_to_layer for focus animation
Rather than juggling our layers manually, just use
weston_view_move_to_layer. This obviates the need for manually marking
the view as mapped.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-08-11 14:10:45 +03:00
Daniel Stone db97820919 desktop-shell: Simplify condition for focus change
We must have (from || to), because if (!from && !to), we would've caught
the if (from == to) early-return case.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-08-11 14:10:45 +03:00
Daniel Stone 77b9dbb730 desktop-shell: Remove yet another center_on_output()
However many times you thought this might reasonably be called when
setting up for fullscreen, there were more.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-08-11 14:10:45 +03:00
Daniel Stone e32557131e desktop-shell: Simplify confusing conditional
The only place we ever set shsurf->fullscreen.black_view is when we're
going into fullscreen, and we destroy it when we're going out of
fullscreen. Hence if we do ever have a fullscreen black view, we should
move it out of the way.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-08-11 14:10:45 +03:00
Daniel Stone a019aa6b2a desktop-shell: Flatten and rename shell_configure_fullscreen()
Merge shell_configure_fullscreen() and
shell_ensure_fullscreen_black_view() into shell_set_view_fullscreen().

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-08-11 14:10:45 +03:00
Daniel Stone e4e3cc198f desktop-shell: Delete pointless function wrapper
shell_map_fullscreen() just duplicated shell_configure_fullscreen()
exactly.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-08-11 14:10:45 +03:00
Daniel Stone 49a122bd30 desktop-shell: Assume fullscreen views are mapped
If we're asked to set a view as fullscreen, assume we're not doing so
with the surface not being mapped.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-08-11 14:10:45 +03:00
Daniel Stone 4bbe4e6e98 desktop-shell: Use weston_view_move_to_layer() for fullscreen
Use our helper to move stuff around.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-08-11 14:10:45 +03:00
Daniel Stone e2a48f6f68 desktop-shell: Deduplicate center_on_output() in fullscreen
weston_shell_utils_center_on_output() already handles the case where we
don't have an output to aim at.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-08-11 14:10:45 +03:00
Daniel Stone 2ab3d33903 desktop-shell: Deduplicate center_on_output() in fullscreen
weston_shell_utils_center_on_output() already calculates the subsurface
bounding box for us.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-08-11 14:10:45 +03:00
Daniel Stone 8ed7f0f459 desktop-shell: Use weston_view_move_to_layer() for minimised views
When we're moving a view to the minimised layer, use our new(ish) helper
to move it.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-08-11 14:10:45 +03:00
Tomohito Esaki 1e781d9f88 drm-backend: Drop support libgbm older than 21.1.1
Since drm-backend requires libgbm 21.1.1 or later, there is no need to
support the old libgbm which does not support modifiers or fd import.

Signed-off-by: Tomohito Esaki <etom@igel.co.jp>
2023-08-09 21:45:42 +03:00
Tomohito Esaki d31ab9163d clients/simple-dmabuf-egl: Drop support libgbm older than 21.1.1
Since clients using dmabuf require libgbm 21.1.1, there is no need to
support the old libgbm which does not support modifiers.

Signed-off-by: Tomohito Esaki <etom@igel.co.jp>
2023-08-09 21:45:42 +03:00
Tomohito Esaki fef8410866 clients/meson.build: Require libgbm 21.1.1 for clients using dmabuf
Since drm-backend requires libgbm 21.1.1, client samples using dmabuf
should be similar to drm-backend.

Signed-off-by: Tomohito Esaki <etom@igel.co.jp>
2023-08-09 21:45:42 +03:00
Tomohito Esaki 1ffd387d0e clients/simple-dmabuf-feedback: Drop support libgbm older than 21.1.1
Since simple-dmabuf-feedback requires libgbm 21.1.1, there is no need to
support the old libgbm which does not support modifiers.

Signed-off-by: Tomohito Esaki <etom@igel.co.jp>
2023-08-09 21:45:42 +03:00
Marius Vlad c59a02c15e desktop-shell: Don't reposition windows on every resize
Remove any attempt to reposition windows when handling an output resize.

This had some side-effects on x11 and wayland backends that keep moving
windows at random positions when manually the output.

A more smarter approach would be to move them only if they're actually
affected by a resize -- like no longer in the output's viewing area, but
that remains for another day.

Fixes: #793

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
Reported-by: Philipp Zabel <p.zabel@pengutronix.de>
2023-08-09 21:26:10 +03:00
Derek Foreman 3f2ce98278 libweston: Rebuild view list after adding an output
This fixes an assert() that can fire when outputs are hotplugged.

Fixes #787

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2023-08-07 09:39:26 -05:00
Philipp Zabel 63e473a9cf libweston: Move color manager fallback into weston_compositor_backends_loaded()
Initialize no-op color manager in weston_compositor_backends_loaded()
if weston_compositor_load_color_manager() was never called.

This makes weston_compositor_load_backend() live up to its name and
prepares it to be called multiple times.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2023-08-02 17:16:35 +02:00
Philipp Zabel 53a51461f9 libweston: Prepare weston_compositor_backends_loaded for extension
Move the presentation clock selection loop into
weston_compositor_set_presentation_clock() and refactor
weston_compositor_backends_loaded() to make it possible
to add more functionality.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2023-08-02 17:16:30 +02:00
Marius Vlad 0713ea7ee6 backend-drm/meson.build: Require at least mesa 21.1.1
We seem to be using at least mesa 21.1.1 since Weston 10, but we never
explicitly asked for it.

Fixes: #790

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2023-08-02 15:42:19 +03:00
Derek Foreman b75f1c0fd1 libweston: Delete paint nodes when views change layers
Since we use paint nodes to track damage, we have to be very careful to
make sure that we never have paint nodes that aren't actually being
displayed on their outputs.

Shells may move views to invisible layers (minimized_layer, inactive_layer)
and this currently leaves the paint node alive but not visible on its
output.

When this happens, the paint node's previous visible region is left
undamaged, and the paint node is removed from processing.

Let's delete paint nodes when their views change layers, thus creating
damage for their full visible region.

This may create excess damage if the paint node moves between two visible
layers, but this is probably far less harmful than leaving pieces of
invisible views on screen.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2023-08-02 12:08:19 +03:00
Derek Foreman ea4700c81f libweston: Fix "fix paint_node_damage_below"
Commit 43b59786 errantly claimed that paint_node_damage_below() needed to
damage all planes because it's used when moving paint nodes between
planes.

This is wrong because the destination plane will receive damage correctly
from paint_node_update_late() when the node's visible region is added to
its damage.

Leave the rest of that commit's changes, but make it once again only
damage the plane the node is currently on.

The problem this caused is easily seen by turning on triangle fan debug
and moving the mouse. Extra damage is generated beneath the cursor plane.

Fixes 43b59786

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2023-08-02 12:08:19 +03:00
Philipp Zabel 1d59530e4b libweston: Set the presentation clock in the compositor
Let backends declare the presentation clocks they can use with a
new bitfield weston_backend::supported_presentation_clocks and set
presentation clock after loading the backend in the compositor.

Make weston_compositor_set_presentation_clock() internal and replace
weston_compositor_set_presentation_clock_software() with an exported
weston_compositor_backends_loaded(), which is called by the compositor
after the backend is loaded.

In the future, this can be extended to determine the subset of clocks
supported by all backends.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2023-08-02 11:51:56 +03:00
Philipp Zabel 51d23a409a gl-renderer: Stop reading presentation clock without shaders to time
Stop reading the presentation clock if the return value is never used.

Signed-off-by: Philipp Zabel <philipp.zabel@gmail.com>
2023-08-02 11:51:56 +03:00
Sergio Gómez 1953931482 kiosk-shell: Implement new view layer handling logic in surface activation
Replace previous logic when placing views in the weston layers upon surface
activation with new one that takes into account the surface tree lists design
from the previous commits.

This commit is based on previous code by Alexandros Frantzis.

Fixes: #680

Signed-off-by: Sergio Gómez <sergio.g.delreal@gmail.com>
2023-07-27 10:13:48 +03:00
Sergio Gómez 5d5e8642c9 kiosk-shell: Set the new active surface tree for inactive focus successor
If we have a successor view that comes from the inactive layer, this means that
we have a change in the active surface tree, so call
kiosk_shell_output_set_active_surface_tree() on the root of that view's kiosk
surface.
If we have no successors, just reset the current active surface tree.

Signed-off-by: Sergio Gómez <sergio.g.delreal@gmail.com>
2023-07-27 10:13:48 +03:00
Sergio Gómez cc837eea61 kiosk-shell: Redesign the function 'find_focus_successor()'
The function find_focus_successor() is called when destroying a surface to find
a successor to the current focus. It, however, has the following issues:

- Its first parameter is the weston layer from which to search for a successor.
  This is an unnecessary flexibility for our use, which only adds complexity to
  the user of the function by having to make a call for each layer. We know
  that we want to search for a successor first in the normal layer, and if that
  fails, then in the inactive layer. So we change the signature of
  find_focus_successor(), removing this first parameter.

- It includes logic to decide whether to do the search or not: if the destroyed
  surface is different from the surface that currently has focus, and if their
  outputs are the same, then abort and don't do the search. This returns NULL to
  the calling function. The problem is that the function also returns NULL if
  it does the search and finds no successor. The distinction for the failing
  reason is lost, and the user of the function needs to add more logic to know
  the reason for failure. To simplify, we take the logic out of
  find_focus_successor() and inside the caller.

- It returns the successor view, although it receives surfaces and the client
  has logic to retrieve the surface corresponding to the returned view. To
  simplify and maintain symmetry, we change the signature so that the function
  returns the surface corresponding to the successor view.

Fixes: #738

Signed-off-by: Sergio Gómez <sergio.g.delreal@gmail.com>
2023-07-27 10:13:48 +03:00
Sergio Gómez d53efc6cc3 kiosk-shell: Distinguish between 'destroy_signal' and 'parent_destroy_signal'
Currently, the 'parent_destroy_listener' is being paired with
'destroy_signal'. The signal is emitted from kiosk_shell_surface_destroy(),
which is the appropriate place to emit this general-purpose surface destruction
signal.

However, we need to inform the children of the surface destruction before
finding the focus successor and activating it, that is, before calling
find_focus_successor() and kiosk_shell_surface_activate(), which happen before
kiosk_shell_surface_destroy().
Since there are currently other uses for 'destroy_signal' (e.g. in
kiosk-shell-grab.c), don't mess with it and simply add a new
'parent_destroy_signal', placing its emition where we need it.

Signed-off-by: Sergio Gómez <sergio.g.delreal@gmail.com>
2023-07-27 10:13:48 +03:00
Sergio Gómez beece0215f kiosk-shell: Handle relinking of surface trees when setting a parent
This commit adds code to maintain the correct order and linking of a surface in
its surface tree list for when a new parent is being set on it.

If the new parent is not NULL, the child might already belong to the same
surface tree as the new parent's root, in which case no relinking is necessary.
Check this by calling kiosk_shell_surface_is_surface_in_tree(shsurf, shroot),
to see if 'shsurf' is in the surface tree list represented by 'shroot', where
'shroot' is the new parent's root surface. In case 'shsurf' doesn't belong to
this surface tree, relink it there.

If parent is NULL, 'shsurf' will become root of a new surface tree list. In
this case 'shroot' is the root surface of shsurf's current surface tree list.
Iterate through the surface tree list of this 'shroot' to relink all
descendents of 'shsurf' into this new list and set it as the new active surface
tree for the output.

Signed-off-by: Sergio Gómez <sergio.g.delreal@gmail.com>
2023-07-27 10:13:48 +03:00
Sergio Gómez 1077a8ed9b kiosk-shell: Introduce an "active surface tree" for each kiosk shell output
This commit introduces to the kiosk shell output structure a pointer to a
surface tree list. This pointer will reference the surface tree list currently
active on the output. (Surface tree lists were introduced in the previous
commit)

Each output will have at most one active surface tree. A surface tree being
active on an output means that all views for this output belonging to that
surface tree, and only those views, are in the normal layer.

kiosk_shell_output_set_active_surface_tree() sets the current active surface
tree for the specified output, replacing the previous one.

Set the new active surface tree when first mapping a surface

Signed-off-by: Sergio Gómez <sergio.g.delreal@gmail.com>
2023-07-27 10:13:48 +03:00
Sergio Gómez a1c3c09959 kiosk-shell: Introduce surface tree lists to the kiosk shell
The following patchset implements proper z-order for xdg surfaces in the kiosk
shell. For this it introduces to the kiosk shell the concept of a "surface
tree": a list of kiosk shell surface structures having a common ancestor (in
the xdg protocol sense).

The design is based on the following assumptions that the kiosk shell currently
makes:

- A kiosk surface with no parent must be fullscreen.
- If a parent is set on a kiosk surface, that surface is assigned the output of
  the root kiosk surface. This means that all kiosk surfaces in a surface tree
  will always have the same output.
- There is no possibility to minimize a kiosk surface.

With these in mind, the following design decisions were deemed convenient:

- For every output, at most one surface tree list will be active. This means
  that, for a given output, only views belonging to surfaces of the same
  surface tree will be in the normal layer. Moreover, all such views will be in
  the normal layer if the surface tree list is active.
- The z-order of surface trees (the weston views' relative placement in the
  normal layer) is determined by the placement of their corresponding kiosk
  surface in the surface tree list.

Each kiosk shell surface begins its life as root of its own surface tree list.
Whenever a parent is set on a surface, that surface is linked to the surface
tree list of the root surface of the parent. If a parent kiosk shell surface is
destroyed, its children will keep the link to the root surface's surface tree
list. If the destroyed parent is also the root surface of the surface tree,
each child is unlinked from this root and they become the root of a new surface
tree.

This commit introduces to the kiosk_shell_surface structure the fields
'surface_tree_list', representing the surface tree list to which the surface is
linked at creation as its root, and 'surface_tree_link', the link to the
surface tree list.

Signed-off-by: Sergio Gómez <sergio.g.delreal@gmail.com>
2023-07-27 10:13:48 +03:00
Philipp Zabel 5c1adb1cab ivi-layout: Remove weston_view_schedule_repaint()
There is no need to manually schedule a repaint anymore, it will be
triggered by changes to opacity or transform.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2023-07-25 10:46:59 +03:00
Philipp Zabel 1ad9687571 ivi-layout: Use weston_view_move_to_layer()
Use the weston_view_move_to_layer() helper instead of calling
weston_layer_entry_insert() / weston_view_unmap() directly.

This requires us to stop just clearing out the layer view list and then
adding visible surfaces' views to it. Instead, we have to explicitly
move all views onto or off of the layers.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2023-07-25 10:46:59 +03:00
Philipp Zabel d0dc464f15 ivi-layout: Use weston_view_set_alpha()
Stop setting view->alpha directly. Use weston_view_set_alpha() to also
apply damage as required.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2023-07-25 10:46:59 +03:00
Philipp Zabel 2df127c180 ivi-layout: Use weston_view_add/remove_transform()
Stop manipulating the view->geometry.transformation_list directly and
replace weston_view_geometry_dirty() and weston_view_update_transform()
calls with weston_view_add/remove_transform().

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2023-07-25 10:46:59 +03:00
Daniel Stone fdc0bafd4c input: Don't schedule repaints for drag-and-drop
We don't need to manually schedule a repaint when we've moved the view
for a drag & drop icon.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-07-24 12:35:47 +03:00
Daniel Stone 6da16f0998 animation: Remove unnecessary repaint schedule
We don't need to manually schedule a repaint after we've updated our
views - which happens as a side effect of destroying the transform/etc
within the animation.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-07-24 12:35:47 +03:00
Daniel Stone bd97abf18f input: Remove unnecessary repaint schedules
There's no need to call weston_view_schedule_repaint() once we've
updated view properties.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-07-24 12:35:47 +03:00
Daniel Stone 760d60f508 desktop-shell: Remove unnecessary repaint schedules
We don't need to explicitly schedule a repaint once we've reconfigured
some views.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-07-24 12:35:47 +03:00
Daniel Stone 259420dde1 view: Schedule view repaint when changing properties
Whenever a view is moved, we should schedule a repaint for the outputs
the view is on. This avoids users having to do it by hand every time
they change something. There is no change in determinism of behaviour
(e.g. 'I can reconfigure views as often as I like and it won't take
effect until I schedule a repaint' isn't true, because output repaints
might happen for reasons outside your control).

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-07-24 12:35:47 +03:00