1
0
Fork 0
Commit graph

28 commits

Author SHA1 Message Date
Robert Mader
2a2f9300d0 wayland/subsurface: Check for parent actor before unparenting
No need to assume the actor still has a parent. This silences warnings
in normal builds and prevents a crash in fully optimized ones.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1958>
2021-09-02 21:14:18 +00:00
Robert Mader
6e00e5e6e7 wayland/subsurface: Avoid placement ops for detached subsurfaces
If a subsurface first gets reordered and afterwards detached from
the parent before the parent surface got commited, we currently
would end up reattaching the subsurface to its previous parent.

While clients should avoid this behaviour, it's legit according
to the spec.

We already prevent similar cases where the subsurface is destroyed -
extend that check to detaching, which includes the destroy case.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1831>
2021-04-19 11:55:49 +00:00
Robert Mader
ba8499f9ec wayland/subsurface: Move placement ops to the parents pending state
Unlike other subsurface state, placement operations need to get
applied in order. As per spec:

```
Requests are handled in order and applied immediately to a pending
state. The final pending state is copied to the active state the
next time the state of the parent surface is applied.
```

Having placement operations being part of the subsurface state
makes it difficult to support arbitrary orderings. Make them
part of the parents surface pending state instead.

Closes https://gitlab.gnome.org/GNOME/mutter/-/issues/1691

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1768>
2021-03-14 00:38:18 +01:00
Robert Mader
6eeeffdc68 src: Stop using GSlice
It has been inofficially deprecated for years, is known to cause issues
with valgrind and potentially hides memory corruption.
Lets stop using it.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1512>
2021-02-22 13:52:27 +01:00
Jonas Ådahl
a54970805d wayland/subsurface: Don't include buffer-less subsurfaces in geometry
We'd get a wierd looking geometry if there were subsurfaces added
without buffers as we'd pick up on their positions even though they were
empty.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1557>
2020-12-03 21:39:13 +00:00
Robert Mader
4e9a67acc6 wayland/subsurface: Check for circular relationships
If a subsurface is equal to or an ancestor of the parent surface
we currently crash. Check for that case and terminate the client.

Closes https://gitlab.gnome.org/GNOME/mutter/-/issues/1521
2020-11-05 21:16:27 +01:00
Robert Mader
ae0d48b6fd wayland/subsurface: Only show subsurface if parent is mapped
The spec states:
```
A sub-surface becomes mapped, when a non-NULL wl_buffer is applied
and the parent surface is mapped. The order of which one happens
first is irrelevant. A sub-surface is hidden if the parent becomes hidden,
or if a NULL wl_buffer is applied. These rules apply recursively
through the tree of surfaces.
```

In the past we relied on Clutter actor behaviour to realize the recursive
part - which then broke in
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/664
when we changed the actor hierachy in regards to subsurfaces.

Explicitly encode the desired behaviour in `MetaWaylandSubsurface`, fixing
the issue and making it future proof.

Closes https://gitlab.gnome.org/GNOME/mutter/-/issues/1384
2020-10-14 18:55:21 +02:00
Robert Mader
8cbcd35fdf wayland/subsurface: Add check for parent surface
Just as we do in similar places. This avoids crashes under certain
circumstances.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1411
2020-08-23 22:32:53 +02:00
Jonas Ådahl
066bc5986d wayland: Drive frame callbacks from stage updates
Don't tie frame callbacks to actor painting, as it may end up in
situations where we miss sending frame callbacks when we should have. An
example of this is when a surface is partially off screen, and then
reports damage that is fully off screen. When this happen, we are likely
not to repaint anything, thus we won't send any frame callbacks even
though it's "suitable" for rendering again, as the surface is not on a
separate workspace or fully obscured.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/817
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1152

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1218
2020-05-26 16:46:57 +02:00
Jonas Ådahl
47002bf0cd wayland/surface: Put buffer reference on heap
Currently a buffer use count always reaches zero before it is replaced.
This is due to the fact that at the point a new buffer is attached, the
last potential user releases it (the stage) since the currently
displayed frame has a composited copy of the buffer.

This may however change, if a buffer is scanned out directly, meaning it
should not be released until the page flip callback is invoked.

Prepare for this by making the buffer reference a heap allocated struct,
enabling us to keep a pointer to it longer than the buffer is attached.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/798
2020-04-16 10:43:34 +02:00
Jonas Ådahl
722ae2b77a wayland/surface: Let roles set DND functions
The DND functions are role specific, with Xwayland surface being the
special one. Let the roles set it instead of having per role like logic
in MetaWaylandSurface.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/835
2020-02-19 22:34:28 +00:00
Jonas Ådahl
c0c74484bc wayland: Don't access MetaWaylandSurface::window directly
It'll be moved to the role owning it, accessed via a helper function
implemented by the role. Currently it still just fetches the field in
MetaWaylandSurface.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/835
2020-02-19 22:34:28 +00:00
Jonas Ådahl
5149e1e43a wayland: Move tree updating to the shell surface role
The shell surface role is the one where subsurfaces may exist, and it
has direct relation to the MetaWindowActorWayland which currently has
the subsurface stacking logic.

Instead of directly finding the window actor when dealing with
subsurfaces, notify the parent surface that the subsurface state
changed, so that it can outsource the application of this information to
the role. For subsurface roles, this simply means forward upward to the
parent; for shell surface roles, this means regenerate the surface actor
layering.

This allows us to move away from accessing the window directly from the
surface, which in turn allows us to change the ownership structure of
windows.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/835
2020-02-19 22:34:28 +00:00
Olivier Fourdan
934a829a57 wayland/subsurface: Keep subsurface actors reactive
The actors of Wayland subsurfaces are set to be reactive on creation,
when receiving the `wl_subcompositor.get_subsurface` request.

However, if a client creates several subsurfaces and then creates the
xdg_toplevel object after, the previous subsurface actors are reset.

As a result, Clutter picking will skip and ignore those actors in
`clutter_actor_should_pick_paint()` because they aren't marked as
reactive anymore.

An example of such a client being affected by this issue is SCTK, the
Rust library implementing client side decorations for Wayland used
internally by winit and alacritty.

Move the `set_reactive()` call from `get_subsurface()` to the subsurface
`sync_actor_subsurface_state()` vfunc to make sure those remain reactive
even after `xdg_surface.get_toplevel` is invoked.

Closes: https://gitlab.gnome.org/GNOME/mutter/issues/1024
https://gitlab.gnome.org/GNOME/mutter/merge_requests/1040
2020-02-10 08:51:41 +00:00
Jonas Ådahl
fcfe90aa9f wayland: Replace manual GNode subsurface iteration with macro
Similar to wl_list_foreach(), add
META_WAYLAND_SURFACE_FOREACH_SUBSURFACE() that iterates over all the
subsurfaces of a surface, without the caller needing to care about
implementation details, such as leaf nodes vs non-leaf nodes.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/961
2020-01-10 16:01:21 +00:00
Jonas Ådahl
f7e256e9a1 wayland/surface: Make cached subsurface state generic
This moves the cached subsurface surface state into the generic
MetaWaylandSurface namespace. Eventually it'll be used by other surface
roles which as well aim to implement synhcronization.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/907
2019-12-09 10:09:40 +01:00
Jonas Ådahl
bbec8abb68 wayland/surface: Rename MetaWaylandPendingState to MetaWaylandSurfaceState
The name didn't communicate it was about surface state, and it somewhat
confusingly had the name "pending" in it, which could be confused with
the fact that while it's used to collect pending state, it's also used
to cache previously committed pending state.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/907
2019-12-09 10:09:40 +01:00
Jonas Ådahl
8dc730e5ca wayland/surface: Move subsurface synchronization logic to role
It's an implementation detail of subsurfaces when to cache state
and when not to, so move that logic to the subsurface role
implementation.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/907
2019-12-09 10:09:40 +01:00
Robert Mader
66ae09b670 wayland/subsurface: Check if actor exists before unparenting
When we call the subsurface destructor the actor might be gone already.
Check first, like we do in other places, to avoid warnings.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/829
2019-10-07 08:29:18 +00:00
Robert Mader
bba8f6c53e wayland/actor-surface: Turn get_geometry_scale() into a vfunc
This allows us to implement more sophisticated logic for the different
cases. For DnD surfaces, use the geometry scale of the monitor where
the pointer is, instead of incorrectly assuming '1' as it was before.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/780
2019-09-27 15:48:36 +00:00
Robert Mader
77229f99b8 wayland: Implement subsurface.place_below() for parents
Flatten the subsurface actor tree, making all surface actors children
of the window actor.
Save the subsurface state in a GNode tree in MetaWaylandSurface, where
each surface holds two nodes, one branch, which can be the tree root
or be attached to a parent surfaces branch, and a leaf, which is
used to save the position relative to child branch nodes.

Each time a surface is added or reordered in the tree, unparent all
surface actors from the window actor, traverse all leaves of the
tree and readd the corresponding surface actors back to the window
actor.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/664
2019-08-27 11:31:00 +03:00
Georges Basile Stavracas Neto
fb9e8768a3 window-actor: Handle geometry scale
Geometry scale is applied to each surface individually, using
Clutter scales, and not only this breaks subsurfaces, it also
pollutes the toolkit and makes the actor tree slightly too
fragile. If GNOME Shell mistakenly tries to set the actor scale
of any of these surfaces, for example, various artifacts might
happen.

Move geometry scale handling to MetaWindowActor. It is applied
as a child transform operation, so that the Clutter-managed
scale properties are left untouched.

In the future where the entirety of the window is managed by a
ClutterContent itself, the geometry scale will be applied
directly into the transform matrix of MetaWindowActor. However,
doing that now would break the various ClutterClones used by
GNOME Shell, so the child transform is an acceptable compromise
during this transition.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/409
2019-08-23 13:23:07 +00:00
Robert Mader
7e2a0ede16 wayland: Move check for present window out of the actor-surface class
All child classes of `MetaWaylandShellSurface` as well as
`MetaWaylandSurfaceRoleXWayland` should only sync their actor if
their toplevel surface has a window. Currently this check is done
in the actor-surface class, but not all surface classes have a
toplevel window, e.g. dnd-surfaces.
Move the check to the right places.

For subsurfaces this assumes that the subsurface is not the child of
a window-less surface (like, as stated above, e.g. a dnd-surface).
If we want to support subsurfaces of window-less surfaces in the future
we have to extend the check here.
But as this is not a regression, ignore this case for now.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/537
2019-05-09 09:06:52 +00:00
Robert Mader
db22c13c4f wayland: Use surface size helper functions
Use meta_wayland_surface_get_width / meta_wayland_surface_get_width
to determine the size of a surface.
2018-08-20 14:37:10 +00:00
Carlos Garnacho
69ca584168 wayland: Handle get_subsurface() with a role-less parent surface
The order of role creation is undetermined, so we can't account that
the parent surface will have a role (and an actor) at the time of
creating the wl_subsurface role for a child surface.

So we must do it both ways, add the subsurface as a child on
get_subsurface() if the parent already got a role, and lazily add
child subsurface actors to the current one if the parent surface got
it at a later point.

Related: #132
2018-06-08 17:31:25 +02:00
Carlos Garnacho
70036429bd wayland: Abstract access to the actor corresponding to a wl_surface
The actor itself will be shuffled around, abstract all external
access to it behind a function to make that easier later on.
2018-04-23 12:24:46 +02:00
Jonas Ådahl
44624736c5 wayland: Push actor state instead of itself pulling
Make the Wayland objects push the state relevant to their role to the
MetaSurfaceActor instead of MetaSurfaceActorWayland pulling the state
from the associated surface.

This makes the relationship between the actor and the objects that
constructs it more clear; the actor is a drawable that the protocol
objects control, not the other way around.

This will make it easier to "detach" a surface actor from a surface,
which is necessary when unmapping a window while the underlying surface
is yet to be destroyed and potentially reused.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/5
https://bugzilla.gnome.org/show_bug.cgi?id=791938
2018-02-23 18:57:47 +08:00
Jonas Ådahl
704b73b041 wayland: Restructure surface role building blocks code
This commit moves out non-core wl_surface related code into separate
code units, while renaming types to fit a common scheme. The changes
done are:

 * ClutterActor based surface roles built upon
   MetaWalyandSurfaceRoleActorSurface. This object has been renamed to
   MetaWaylandActorSurface and related functionality has moved into
   meta-wayland-actor-surface.c.

 * The code related to roles backed by a MetaWindow (i.e. built upon
   MetaWaylandShellSurface) was moved into meta-wayland-shell-surface.c

 * The majority of subsurface related code was moved into into
   meta-wayland-subsurface.c and the object was renamed
   MetaWaylandSubsurface.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/5
https://bugzilla.gnome.org/show_bug.cgi?id=791938
2018-02-23 18:57:40 +08:00