Commit graph

9039 commits

Author SHA1 Message Date
Derek Foreman f7ddaa142a libweston: Replace weston_output_damage() with a flag
In the future we'd like to have multiple overlapping outputs.

weston_output_damage() currently adds damage to the output's coordinates
on the primary plane. This plane is shared between all outputs, so it
would result in damaging more than the intended output.

Eventually, plane damage will go away and be replaced by paint node damage,
and damaging the entire output would involve adding damage to a list of
paint nodes.

Instead, use a flag to indicate the output must be fully redrawn, and add
the damage during the repaint loop.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2023-07-11 07:26:43 -05:00
Derek Foreman f07af89f9c libweston: Move output damage subtraction out of backends
Right now every backend clears output damage from the primary plane when
it repaints. Instead of having this same operation spread across all
the backends, just do it in the core instead.

In the future, we want to remove damage tracking from the primary plane
entirely, and this is a small step in that direction.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2023-07-11 07:26:43 -05:00
Derek Foreman a9986ef984 libweston,backends: assert if z_order_list contains pnodes for wrong output
We've just made this impossible, so we can now clean up all the TODO
locations.

I've only turned some of them into assert()s, because they're all mostly
in the same place.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2023-07-11 07:26:23 -05:00
Derek Foreman 85e3a4723b libweston: Cull paint nodes when their views aren't on their outputs
In the future when we track damage with paint nodes we have a problem when
a paint node is moved off of its output - it immediately stops being
present, so we don't generate damage for the move that placed it off
screen.

We don't want paint nodes to exist when their view isn't on their output
anyway, so let's cull these nodes at the point where we assign outputs to
views.

In the damage-from-paint-nodes future, this will let us properly post
damage when the paint node is destroyed.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2023-07-10 08:13:42 -05:00
Derek Foreman e5dfc3bc1e libweston: delete paint nodes on view unmap
Paint nodes should only exist when they're visible.

In the future where we want to track damage with paint nodes we need
this to be enforced, or damage won't properly be tracked when a
paint node is hidden from us but continues to exist.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2023-07-10 08:13:15 -05:00
Derek Foreman 7ab7f28e8c libweston: Only create paint nodes for the correct output
We want an output's z_order_list to only contain paint nodes for that
output, but until now we've been pretty careless about this.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2023-07-10 08:02:02 -05:00
Alexandros Frantzis b7b0042777 xwayland: Notify the shell when a window drops the fullscreen state
Notify the shell of the state transition when going from fullscreen to
normal toplevel window.

Signed-off-by: Alexandros Frantzis <alexandros.frantzis@collabora.com>
2023-07-06 21:19:18 +00:00
Alexandros Frantzis ca7b631310 xwayland: Allow shells to make xwayland surfaces fullscreen
The fullscreen state for xwayland surfaces can currently only be
effectively set from the client side. This commit enables
libweston-desktop based shells to properly set the fullscreen state
for xwayland surfaces.

Signed-off-by: Alexandros Frantzis <alexandros.frantzis@collabora.com>
2023-07-06 21:19:18 +00:00
Marius Vlad eefd8ae2e0 desktop-shell: Handle all other shsurfs
The output resize handler we only accounts for the background and panel
surfaces, so this handles all other regular shsurfs.

This patch would reuse any previously saved position, or reposition the
surfaces to avoid placing them outside of the output area. For maximized
or fullscreen type of surfaces, issue a new configure event to let
clients react to the new output dimensions.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2023-07-06 19:06:22 +00:00
Marius Vlad aeabba8e18 desktop-shell: Keep track of shsurf being created/removed
We'd need to go over them when handling output resize so use
desktop_shell to hang of the list of shsurfs.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2023-07-06 19:06:22 +00:00
Marius Vlad ecab79bfb7 desktop-shell: Use a common helper to handle surface resizes
This introduces two helpers, shsurf_is_max_or_fullscreen() and
set_shsurf_size_maximized_or_fullscreen() to handle
maximized/unmaximized fullscreen/unfullscreen transitions.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2023-07-06 19:06:22 +00:00
Marius Vlad 9555118095 clients/window: Update min_allocation for smaller widths/heights
This makes sure we update min_allocation in situations where the
width and height passed is smaller than the one set previously
(obviously except for the first time). This has the side effect of
not overwriting pending_allocations such that we correctly resize when
passed a width/height smaller the ones set-up in the past.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2023-07-05 21:28:16 +03:00
Daniel Stone 23ea865508 surface: Remove weston_subsurface.unused_views
Now that we deterministically create views for subsurfaces, we don't
need to stash them away into unused_views to dynamically create and free
them at repaint time.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-07-04 15:52:21 +01:00
Daniel Stone 57cd2483f9 surface: Don't create new views in view_list_add()
Now we create subsurface views both when linking to the parent
subsurface, and when creating new views for the parent surface, we no
longer need to magically materialise new views when building the view
list.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-07-04 15:52:21 +01:00
Daniel Stone aac90fe400 surface: Create subsurface views when linking surface to parent
When we're linking a subsurface to its parent for the first time,
materialise new views for every view the parent has.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-07-04 15:52:21 +01:00
Daniel Stone 4b7fb56835 view: Destroy subsurface views with their parents
When we're destroying a parent view, also destroy any of its children
which are subsurface views that we've created automatically in the core.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-07-04 15:52:21 +01:00
Daniel Stone fc776c3b59 view: Add weston_view_add_transform and weston_view_remove_transform
They do what they say on the box, and inflict damage where required.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-07-04 15:52:21 +01:00
Daniel Stone 7d2c5e0c33 view: Add weston_view_set_alpha()
Does what it says on the box: sets the view's alpha, also inflicting
damage where required.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-07-04 15:52:21 +01:00
Daniel Stone f39b1e9fbd view: Mark view list as dirty when destroying mapped view
If a view is in the view list when it's being destroyed, we need to
rebuild the view list. However, doing so is currently very hairy as
views are created and destroyed at will ... including when rebuilding
the view list.

In preparation for creating and destroying subsurface views at the time
of the action rather than later at repaint time, pull out the immediate
view-list rebuild and simply mark the view list as needing a full
rebuild.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-07-04 15:52:21 +01:00
Daniel Stone 314f2ba0c3 view: Create subsurface views in weston_view_create()
When we create a new view for a top-level window, also create views for
all its children.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-07-04 15:52:21 +01:00
Daniel Stone bf228370ff view: Add view_list_needs_rebuild member
Most of the time when we're changing things about views, we don't need
to throw away the view list and rebuild it from scratch. The only times
when we need to do this are when views have been added to or removed
from the scene graph, or have been restacked within it.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-07-04 15:52:21 +01:00
Daniel Stone c699253da8 view: Add weston_view_geometry_dirty_internal()
weston_view_geometry_dirty_internal() can be used by internal callers to
mark a view's internal geometry as dirty, without signaling the need for
a full rebuild of the view list.

This is a transitional step towards eliminating
weston_view_geometry_dirty() from public API. Up until recently, the
view-manipulation API has been that users should manually manipulate
lists of transforms, layers, and other internal members, then call
weston_view_geometry_dirty() as well as manually provoking damage.

Now that we have helper functions to handle view manipulation, they
still need to mark the view geometry as being dirty. However, most of
them do not need to invoke a full rebuild of the view_list, which is
only required when views are added or removed from the scene graph, or
restacked.

weston_view_geometry_dirty() will assume that everything has changed
before eventually being ushered out of existence.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-07-04 15:52:21 +01:00
Daniel Stone c859dd1b9e surface: Only rebuild subsurface lists when necessary
There's no need to go through and rebuild the subsurface list every
time. In addition to being unnecessary work, it complicates things like
damage tracking.

Track a new surface dirty status indicating that the subsurface tree has
changed in some way, and only rebuild subsurface stacking when this has
occurred.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-07-04 15:52:21 +01:00
Daniel Stone ce6afda6a2 surface: Propagate surface status through commit call tree
When we're committing anything, return the collected status of what
we've just made live, including any changes resulting from subsurfaces
having changed.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-07-04 15:52:21 +01:00
Daniel Stone fc6d4392cb surface: Assert unused subsurface views are not mapped
This is just a consistency check, nothing else.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-07-04 15:52:21 +01:00
Daniel Stone 49b5df7f78 view: Update child view transforms from parent
weston_view_geometry_dirty() marks the passed-in view as dirty, as well
as all of its children.

weston_view_update_transform() updates the geometry of its ancestors,
then itself.

Users are required (for now) to call weston_view_update_transform() in
order to not experience a disappointing amount of death-by-assert.

Users do not have a pointer to child views which are magically
materialised by the subsurface code.

The end result is disappointing. But it is less disappointing if
updating the transform for a view the user is actually aware exists,
also updates the transform for all its children.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-07-04 15:52:21 +01:00
Daniel Stone 0ff72e5374 surface: Ensure view is unmapped before destroy signal
When the destroy signal is fired, child views will disassociate
themselves from the parent. This means that we can no longer see what
the child views are - and that recursive unmapping does not work.

Make sure that views are fully unmapped before anything else happens in
destroy, so we can recursively unmap child views.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-07-04 15:52:21 +01:00
Daniel Stone 0189bfac9f surface: Add test for recursive subsurface unmapping
Make sure that in a 1 -> 2 -> 3 -> 4 parent->child subsurface nesting,
destroying surface 2 also immediately unmaps 3 and 4.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-07-04 15:52:21 +01:00
Daniel Stone da8c8f96d2 surface: No need to unmap views before destroy
This happens as a part of weston_view_destroy().

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-07-04 15:52:21 +01:00
Daniel Stone 17af1c4d20 surface: Unmap subsurface views, not surface, on parent destroy
Per the wl_subsurface spec:
      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.
      [...]
      If the parent wl_surface object is destroyed, the sub-surface is
      unmapped.

The terminology is kind of loose. My reading of this is that we should
'unmap' (hide from display, remove from input/focus consideration, etc)
a subsurface immediately when a parent is destroyed.

However, if the child surface is then paired with another parent which
is itself mapped, then the child surface should immediately be mapped,
because it has a non-NULL buffer already applied, and the parent surface
is mapped.

By marking the surface as 'unmapped' on parent destroy, we were removing
it from the scene graph, but also I think breaking the rules on mapping
by requiring another commit when it was reassociated with another,
already mapped, surface.

Removing the explicit surface unmap leaves the surface in the 'mapped'
state, but without any views, which I believe has the intended effect.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-07-04 15:52:21 +01:00
Daniel Stone 3d9aecc846 surface: Unmap subsurface views when parent is unmapped
Quoth the spec:
      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.

We currently apply this rule through reconstructing the view_list at
repaint time, materialising new views and garbage-collecting unwanted
views as appropriate. Since this can be a costly operation, it's best if
we move this closer to the source.

This makes the core recursively unmap any child views when the parent is
unmapped. Future commits will do the same for mapping new views.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-07-04 15:52:21 +01:00
Daniel Stone 3af596a8bc surface: Use parent_view to find subsurface views
View transform parents can be set by anyone. parent_view, on the other
hand, is only set for subsurfaces.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-07-04 15:52:21 +01:00
Daniel Stone 94a9cc1b24 Split weston_view_create() into public and internal
This is heading towards being able to materialise subsurface views
closer to the source. weston_view_create() - being used only by
window-management code - will ultimately create all required subsurface
views as well. The internal variant will be used by this and also by the
subsurface code as required.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-07-04 15:52:21 +01:00
Daniel Stone 0f99e081c4 surface: Add input-region dirty flag
Used when the input region changes.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-07-04 15:52:21 +01:00
Daniel Stone 3bba90764e surface: Add buffer-params dirty flag
This indicates that more than just the content changing, the form of the
buffer has changed in a way which may not be like-for-like to the
previous buffer but require significant reinterpretation. Examples
include the format, opacity, colour state, etc.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-07-04 15:52:21 +01:00
Daniel Stone 63f67f8a04 surface: Flatten apply_buffer_damage()
This function is now only ever executed conditionally, so flatten it
with an early return.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-07-04 15:52:21 +01:00
Daniel Stone eb6d511823 surface: Require wl_surface.attach for damage processing
Both wl_surface.damage and wl_surface.damage_buffer explicitly refer to
the 'pending buffer'. wl_surface.attach states that there is no pending
buffer after the commit is processed, so it follows that a commit which
includes damage but no attach will not process any damage.

Change surface-commit processing to ignore all damage unless a buffer
was attached in the same commit cycle.

(Thanks to @pH5 for his spec analysis which I've just paraphrased here.)

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-07-04 15:52:21 +01:00
Daniel Stone d8669679c4 surface: Add position dirty member
This is used when a surface is repositioned via offsets.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-07-04 15:52:21 +01:00
Daniel Stone 3c1e2e5c32 surface: Add comments to weston_surface_status member
Explain what each member implies.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-07-04 15:52:21 +01:00
Daniel Stone 6526346b72 surface: Replace viewport.changed with weston_surface_status
Instead of having an individual bool, reuse the surface state's dirty
status for viewport changes.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-07-04 15:52:21 +01:00
Daniel Stone 8255274a92 surface: Replace newly_attached with weston_surface_status
Instead of having a bool for whether or not a buffer has been attached
in this commit cycle, use a status bitmask.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-07-04 15:52:21 +01:00
Daniel Stone 160f91b8e1 surface: Only rebuild surface size where necessary
The only time we need to go through recalculating the surface size is
when either the buffer dimensions or the surface transforms have
changed. Now that we have dirty flags, use them to avoid a calculation
where required.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-07-04 15:52:21 +01:00
Daniel Stone e9c67aedba desktop-shell: Remove unused fullscreen transform
I don't know when this stopped being used, but it's obviously not
any more.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-07-04 15:52:21 +01:00
Derek Foreman 3ec2ebc7e2 libweston: Build view list for all outputs at once
Instead of passing an output to weston_compositor_build_view_list(),
have it set up all the output z_order_lists at once.

This is a preamble for MR !1285 which wants to maintain a compositor
wide dirty bit for the view list.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2023-07-04 15:52:21 +01:00
Derek Foreman 8a673efada libweston: Build z_order_list after view_list
Moves the output specific stuff into one place, after the view_list is
already properly set up.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2023-07-04 15:52:21 +01:00
marius vlad 3044d8ed72 backend-drm: Use resize_output to allow changing the fb
A video mode change would be needed to change the underlying renderer
framebuffer. All other backends make uses of this so let's do it for the
DRM-backend as well.

This would also be needed for the output capture to function properly as
we need call weston_output_update_capture_info() when a new mode set has
set. Otherwise we'd run into mismatched dimensions for the current mode
versus the dimensions set-up initially in weston_output_capture_source_info.

Signed-off-by: marius vlad <marius.vlad@collabora.com>
2023-07-04 11:41:29 +00:00
Daniel Stone 17e4a77831 tests: Initialise breakpoint list for all test types
The list of client breakpoints was used for both client tests and plugin
tests - anything that uses the weston-test module - but was only
initialised in the client-test path. Make it unconditional.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Fixes: efde2fa0b1 ("tests: Add client<->compositor breakpoint support")
2023-07-03 22:39:38 +01:00
Philipp Zabel 1c262efd70 backend-wayland: Prepare for more renderers, reject no-op
Turn the Pixman/GL if/else conditionals into switch cases to make it
easier to add support for other renderers in the future.

Also makes sure that weston --backend=wayland --renderer=noop fails
with an error message instead of segfaulting.

Signed-off-by: Philipp Zabel <philipp.zabel@gmail.com>
2023-06-30 16:36:52 +00:00
Daniel Stone ce113969e3 tests: Add paint-node test
This is a very simple test, mostly intended as a demonstration of the
new client<->compositor breakpoint infrastructure. It ensures that for a
simple test surface, a paint node has been created in the output's
paint-node list, reflecting the properties of the attached buffer.

This is an example of properties which are not observable by regular
clients.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-06-30 11:42:00 +00:00
Daniel Stone efde2fa0b1 tests: Add client<->compositor breakpoint support
Add support for clients to request the server insert breakpoints at
various points in its processing. These breakpoints are handled
internally by semaphores (visible to tests through helpers): when the
server reaches the specified point, it will pause execution until the
client allows it to restart.

A weston_compositor pointer returned at each breakpoint allows the
client to reach across the thread boundary and access the server's
internal data structures. This can be used to, for example, inspect
paint nodes, internal damage, or any other work which is not necessarily
client-visible.

The majority of tests will not need to use this infrastructure; it is
only intended for tightly-coupled tests which can very specifically
dictate and anticipate the server's execution flow.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-06-30 11:42:00 +00:00