Commit Graph

111 Commits

Author SHA1 Message Date
Simon Ser 0e5034d8ba compositor: add wlr_compositor_set_renderer()
Allows compositors to switch the wlr_renderer at runtime.

Useful for handling GPU resets.
2024-03-14 14:34:44 +01:00
Simon Ser 3075e6a6f9 compositor: use compositor to get renderer
This allows us to remove the renderer destroy listener. The
listener was buggy: compositors can't destroy surface resources on
their own.

The wlr_compositor will always outlive the wlr_surface, so no need
for a destroy listener.
2024-03-14 12:29:01 +00:00
Simon Ser 508d8c9a01 compositor: handle renderer destroy
Don't leave a stale renderer pointer behind.
2024-03-14 12:29:01 +00:00
Kirill Primak 5b08f91004 compositor: don't handle size or viewport src change in surface_update_damage()
This is incorrectly leads to buffer reuploading.
2024-02-01 14:51:43 +00:00
Kirill Primak 7dfbd87771 compositor: drop wlr_surface.external_damage 2024-02-01 14:51:43 +00:00
Kirill Primak 4688a371e0 compositor: don't get buffer from pending buffer resource too early
Fixes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3795
2024-01-27 17:48:07 +03:00
Kirill Primak 0052078bd3 compositor: introduce wlr_surface_reject_pending() 2024-01-27 12:05:05 +00:00
Simon Ser 96aec06b0a subcompositor: use wlr_surface_synced 2023-12-25 11:47:15 +01:00
Simon Ser 7e1ae5548c compositor: add wlr_surface_role.client_commit 2023-12-25 11:47:15 +01:00
Simon Ser d847516765 compositor: add wlr_surface_synced
A lot of protocols extend the wl_surface state. Such protocols need
to synchronize their extended state with wl_surface.commit and
cached states. Add a new utility for this purpose.
2023-12-25 11:47:15 +01:00
Simon Ser 34d5af4172 compositor: add wlr_surface_state_has_buffer() 2023-12-25 11:47:15 +01:00
Simon Ser 66b6c349e7 compositor: remove unnecessary wlr_surface.has_buffer
No need to store this bit, we can infer it from buffer_width and
buffer_height.
2023-12-25 11:43:41 +01:00
Simon Ser cd157a0bd9 compositor: adjust surface_state_move() comment 2023-12-25 11:43:41 +01:00
Simon Ser df27b29d49 compositor: reset wlr_surface.current.committed on commit
Knowing which fields changed in the last commit is more useful than
knowing which fields were ever set on the surface.
2023-12-25 10:36:26 +00:00
Simon Ser 6a2ff0dffe compositor: drop surface precommit event
This is unused.
2023-12-04 19:32:44 +01:00
Simon Ser 56ec13596a Cleanup wlr_matrix.h includes
Many files used to require wlr_matrix but no longer do.
2023-11-25 08:37:43 +01:00
Kirill Primak 7661ab2bf1 compositor: deprecate wlr/types/wlr_region.h
The only function in that header is now also declared in
wlr/types/wlr_compositor.h.
2023-11-24 15:09:31 +03:00
Simon Ser 2eb225236e util/transform: add wlr_output_transform_coords()
We hand-roll this in multiple places.
2023-11-23 11:07:34 +01:00
Simon Ser 9e702e9cfe util/transform: move over wl_output_transform helpers
These aren't really tied to wlr_output.
2023-11-23 11:03:57 +01:00
Kirill Primak 4d2e310122 compositor: add wlr_surface.unmap_commit
This flag can be used to figure out whether a particular commit has
unmapped the surface. Private state for now in case we find a better
way to track this.
2023-10-26 14:57:10 +00:00
eri 8ccbe45143
buffer: convert to try_from
References: wlroots/wlroots#884
2023-10-19 18:19:27 +02:00
Alexander Orzechowski 1b0694b794 treewide: Migrate from sizeof(struct) to sizeof(*pointer) where practical 2023-10-03 01:51:07 -04:00
Simon Ser 72787db98a compositor: drop wlr_surface_destroy_role_object()
This function is now unnecessary.
2023-08-21 18:56:09 +02:00
Simon Ser c74f89d4f8 Avoid using memcpy() to copy structs
We can just use a regular assignment instead. This is more
type-safe since there is no need to provide the struct size.

The remaining memcpy() calls perform array copies or copies from
void pointers (which may be unaligned).
2023-08-03 14:40:28 +00:00
Simon Ser 7a9f8d8d6b Use struct initializers instead of memset()
This is a bit more type-safe.
2023-07-07 17:31:11 +02:00
Simon Ser 8a5b5e6f28 compositor: listen to role_resource destroy signal
Call wlr_surface_destroy_role_object() when the role_resource is
destroyed.
2023-06-23 14:33:26 +02:00
Simon Ser 89cb484220 compositor: replace role_data with role_resource
This increases type safety, makes it more obvious that role_data
must represent the role object, and will allow for automatic
cleanup when the resource is destroyed.
2023-06-23 14:23:27 +02:00
Kirill Primak fc9b58e84d compositor: don't call role unmap hook without an object 2023-06-23 11:54:05 +00:00
Kirill Primak 0f67580aab compositor: introduce wlr_surface_set_role_object() 2023-06-23 11:54:05 +00:00
Kirill Primak 0040c78c0b compositor: fix wlr_surface_set_role() error messages 2023-06-23 11:54:05 +00:00
Kirill Primak 753f3cc4fa compositor: add wlr_surface_role.no_object
This commit allows to make a role as not represented by an object,
which fixes calling role commit handlers for roles like cursor
surfaces.

Fixes: 099b9de752
2023-06-14 14:06:28 +00:00
Kirill Primak 37b5f8a89e compositor: unmap subsurfaces too on unmap
Similar to 49e9be62ae.
2023-06-05 19:14:35 +00:00
Kirill Primak b61d5922f1 compositor: notify subsurfaces about a commit in the rendering order
This is the default order used across wlroots unless the reversed order
specifically is required (e.g. in wlr_surface_surface_at()).
2023-06-03 14:36:41 +00:00
Kirill Primak 49e9be62ae subcompositor: consider mapping on parent map
Fixes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3654
2023-06-03 14:36:41 +00:00
Kirill Primak d086ee1b9e compositor: remove wlr_surface_role.precommit
It was previously used to handle unmapping properly but is obsolete now.
2023-06-02 21:04:16 +03:00
Kirill Primak c590bb600f subcompositor: use unified map logic 2023-06-02 17:26:18 +00:00
Kirill Primak 6b40e08148 compositor: introduce unified map logic 2023-06-02 17:26:18 +00:00
Alexander Orzechowski ec796afb6e wlr_compositor: Decide opacity from new has_buffer flag.
`wlr_surface_get_texture` will always return NULL if the compositor was
not given a renderer.
2023-05-04 11:53:26 +02:00
Alexander Orzechowski 394accbe4a wlr_compositer: Keep track if surface has committed a buffer before.
This would break if you are running with a NULL renderer.
2023-05-04 11:53:26 +02:00
Simon Ser dae2deb3c9 compositor: add wlr_surface_set_preferred_buffer_transform()
References: https://gitlab.freedesktop.org/wayland/wayland/-/merge_requests/220
2023-04-14 17:07:26 +02:00
Simon Ser 42edd36785 compositor: add wlr_surface_set_preferred_buffer_scale()
References: https://gitlab.freedesktop.org/wayland/wayland/-/merge_requests/220
2023-04-14 17:07:26 +02:00
Simon Ser 0bb574239d compositor: pass version in wlr_compositor_create
This allows wlroots to support newer versions of the interface
without breaking the API.
2023-04-14 17:07:26 +02:00
Kirill Primak 87e7584dd4 compositor: use defunct_role_object error 2023-04-14 17:04:00 +02:00
Simon Ser eb3e8f08a8 subcompositor: convert to try_from
References: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/884
2023-02-01 20:14:39 +01:00
Simon Ser 512deebd82 compositor: add wlr_surface.events.precommit 2022-12-05 10:51:46 +01:00
Simon Ser 42016fa262 compositor: make renderer optional
This is a first step towards moving texture uploading out of
wlr_compositor.

This commit allows compositors to opt-out of the texture uploading
by passing a NULL wlr_renderer. An immediate user of this is
gamescope, which currently implements a stub wlr_renderer just to
make wlr_compositor happy.
2022-11-24 21:55:24 +00:00
Simon Ser 1978a91717 compositor: release current buffer after commit event
Some compositors may want to access the original buffer in their
commit handler.
2022-11-24 21:55:24 +00:00
Simon Ser 258bf9be1e compositor: drop wlr_surface.{sx,sy}
The concept of a persistent accumulated surface offset is wrong
from a protocol point-of-view. wl_surface.offset is tied to a
commit, its interpretation depends on the surface role.

For example, with the following sequence:

    wl_surface@1.offset(1, 1)
    wl_surface@1.commit()
    wl_pointer@2.set_cursor(wl_surface@1, 42, 42)

The final cursor hotspot is (42, 42): the commit which happened
before the set_cursor request has no impact on the hotspot
computation.

The wlr_output_cursor logic already uses wlr_surface.current.{dx,dy}.
wlr_scene's drag icon doesn't, update it accordingly.
2022-11-15 13:41:09 +00:00
Simon Ser c5d79bfb26 region: constify 2022-11-11 23:11:17 +00:00
Kirill Primak 388de59df3 compositor: use the correct input region 2022-11-07 21:06:12 +00:00