Commit Graph

41 Commits

Author SHA1 Message Date
Kirill Primak 28248dd83b xdg-shell: remove redundant NULL buffer check
This is already checked in role precommit handler, and if the buffer is
NULL due to failed upload, that means the surface was already unmapped.
2021-10-06 10:15:49 +02:00
tiosgz ce66244fd2 surface_at: check if surfaces are mapped 2021-10-02 11:38:40 +02:00
tiosgz 893434b2d4 for_each_surface: only iterate mapped surfaces
These functions are used mostly for rendering, where including unmapped
surfaces is undesired.

This is a breaking change. However, few to no usages will have to be
updated.
2021-10-02 11:38:40 +02:00
Simon Ser 744a5c2fef xdg-shell: stop clearing wlr_xdg_surface state on unmap
The protocol doesn't say we should, so let's not.

Also it's pointless to reset scheduled_serial, since 0 is a valid
serial.
2021-09-30 23:17:32 +03:00
Simon Ser 665a164f27 xdg-shell: rename wlr_xdg_surface.next_configure_serial
Rename it to scheduled_serial for consistency with the rest of
wlroots.
2021-09-30 23:17:32 +03:00
Simon Ser 0e34208344 xdg-shell: introduce wlr_xdg_surface.current
This holds the current state, and avoids having ad-hoc fields in
wlr_xdg_surface.
2021-09-30 23:17:32 +03:00
Kirill Primak db4afc2408 xdg-surface: add pending state
struct wlr_xdg_surface_state is introduced to hold the geometry
and configure serial to be applied on next wl_surface.commit.

This commit fixes our handling for ack_configure: instead of making
the request mutate our current state, it mutates the pending state
only.

Co-authored-by: Simon Ser <contact@emersion.fr>
2021-09-30 23:17:32 +03:00
Kirill Primak ccc84f11a4 xdg surface: check adding configure_idle for NULL 2021-09-21 10:09:09 +02:00
Kirill Primak 0e2d369106 xdg-surface: simplify configure mechanism
This commit removes any checks whether a configure will change anything
and makes configures be sent unconditionally. Additionally, configures
are scheduled on xdg_toplevel.{un,}set_{maximized,fullscreen} events.
2021-09-21 10:09:09 +02:00
Kirill Primak b72a217fcc xdg-toplevel: refactor configure/state flow
Previously, `wlr_xdg_toplevel` didn't follow the usual "current state +
pending state" pattern and instead had confusingly named
`client_pending` and `server_pending`. This commit removes them, and
instead introduces `wlr_xdg_toplevel.scheduled` to store the properties
that are yet to be sent to a client, and `wlr_xdg_toplevel.requested`
to store the properties that a client has requested. They have different
types to emphasize that they aren't actual states.
2021-09-21 10:09:09 +02:00
Simon Ser ba0525c5c0 surface: drop wlr_surface_state.buffer_resource
Instead, use wlr_surface_state.buffer only.
2021-09-06 14:21:23 -04:00
Simon Zeni e192d87731 move wlr_box from /types to /util 2021-07-06 21:43:17 +02:00
zccrs 11040d4942 Make the xdg_popup_get_position to public
Rename the xdg_popup_get_position to
wlr_xdg_popup_get_position
2021-06-03 09:50:54 +02:00
Isaac Freund f574ca934c xdg shell: remove wlr_xdg_surface_for_each_popup()
This function is inferior to wlr_xdg_surface_for_each_popup_surface()
for rendering as it does not iterate over subsurfaces. Furthermore,
no compositor is known to use this to iterate popups for any purpose
other than rendering. Therefore remove the function, which may of course
be reintroduced at a later date if a use-case is found.
2021-01-12 11:25:55 +01:00
Isaac Freund b482c90e1a xdg/layer shell: reduce code duplication in iterators 2021-01-08 14:53:45 +01:00
Isaac Freund 8f63557ed7 xdg shell: add wlr_xdg_surface_popup_surface_at()
This function will allow compositors to implement input handling in a
way consistent with rendering more easily.

Calling wlr_xdg_surface_surface_at() and checking if the result is a
wlr_xdg_popup is flawed as there may be subsurfaces in the popup tree.
2021-01-08 12:05:13 +01:00
Isaac Freund c5c5ab9724 xdg shell: add wlr_xdg_surface_for_each_popup_surface()
When rendering, it is necessary to iterate the subsurfaces as well,
so add a function that makes this easy.
2021-01-08 10:33:16 +01:00
Ilia Bozhinov 9595f95452 xdg_shell: handle inert popups
xdg_popups can be destroyed by the compositor when closed. When this happens,
wlroots makes the xdg_popup surface inert and resets the xdg_surface role to
NONE.

Currently, wlroots sends a protocol error and asserts that an xdg_surface has
a role when committed. This is racy if at the same time the client commits an
xdg_popup and the compositor closes it. This patch removes the assertion and
ignores commits on xdg_surfaces without a role set.
2020-11-08 14:26:03 +01:00
Ilia Bozhinov 346188c015 xdg_shell: fix a typo 2020-10-27 18:49:19 +01:00
Isaac Freund 86e20f48c6 xdg-shell: handle serial wrapping overflow 2020-06-25 10:33:58 +02:00
Simon Ser 8bb2dc68ea xdg-shell: make wlr_xdg_surface_from_resource reject NULL
Most resources must not be NULL. Make it so callers need to check for
NULL explicitly. This makes it clearer in the handlers code that the
NULL wl_resource case needs to be handled, and allows callers to make a
difference between a NULL wl_resource and an inert resource.
2019-12-30 14:24:35 -07:00
Simon Ser 7e521fed97 xdg-shell: fix inert xdg_surface handling
Closes: https://github.com/swaywm/sway/issues/4834
Closes: https://github.com/swaywm/wlroots/issues/1890
2019-12-30 14:24:35 -07:00
Brian Ashworth 9914784594 wlr_xdg_toplevel: reparent on parent unmap
From the xdg-shell specification:
	If the parent is unmapped then its children are managed as
	though the parent of the now-unmapped parent has become the
	parent of this surface. If no parent exists for the now-unmapped
	parent then the children are managed as though they have no
	parent surface.
2019-08-15 11:19:06 +03:00
Brian Ashworth 4e614683b7 wlr_xdg_toplevel: store pending fullscreen output
Since the fullscreen request may be made before the toplevel's surface
is mapped, the requested fullscreen output needs to be stored so it
can be retrieved on map (along with the existing fullscreen property).

This commit makes the required changes for wlr_xdg_toplevel.
2019-03-27 10:04:10 +02:00
emersion 7f5967234c
xdg-shell: destroy child popups on unmap
It doesn't make sense to keep popups opened when unmapped. We also need to do
so in wlr_xdg_popup_destroy so that popups are destroyed in the correct order.
2019-02-05 19:29:00 +01:00
Connor E c1d0729d9a Make popup inert when destroyed. 2019-02-04 10:43:51 +01:00
Connor E b1cdd2b4b3 Use assertions instead of guard. 2019-01-14 16:05:24 +00:00
Connor E e7fff4f560 Remove wlr_xdg_surface_send_close. 2019-01-13 14:22:49 +00:00
Timidger 9af0c5338f
Standardize the wlr_box input paramaters
Fixes #1094
2018-12-21 13:56:10 -05:00
emersion 5515faa197
xdg-shell: emit xdg_surface destroy when role object is destroyed
Fixes https://github.com/swaywm/wlroots/issues/1407
2018-12-04 13:42:29 +01:00
emersion 95dfbe2962
xdg-shell: don't destroy xdg role state on role destroy
ie. don't destroy surface->toplevel on xdg_toplevel destroy. Instead do this on
xdg_surface destroy.

This allows compositors to add toplevel listeners when the surface appears and
remove them when the surface is destroyed.
2018-11-12 19:37:22 +01:00
Drew DeVault 5642c5cc8f
Merge pull request #1053 from emersion/xdg-decoration
Add xdg-decoration-unstable-v1 support
2018-08-02 09:33:10 -04:00
emersion 555721f714 Add xdg-decoration-unstable-v1 support 2018-07-28 22:48:07 +01:00
emersion 16d7e09d99 surface: add wlr_surface_role.precommit
This allows to emit the unmap event before the surface becomes
actually unmapped for most shells.
2018-07-15 19:30:19 +01:00
Drew DeVault c0b4217fce
Merge pull request #1116 from emersion/surface-role
surface: replace wlr_surface_set_role_committed with wlr_surface_role
2018-07-11 15:27:42 -07:00
emersion 7cbef15206
util: add wlr_ prefix to log symbols 2018-07-09 22:49:54 +01:00
emersion 33db4263a0
surface: replace wlr_surface_set_role_committed with wlr_surface_role 2018-07-07 22:45:16 +01:00
Ryan Dwyer 86f401e827 Introduce wlr_xdg_surface_for_each_popup
It is common to want to iterate an xdg-surface's popups separately from
the toplevel and subsurfaces. For example, popups are typically rendered
on top of most other surfaces.

wlr_xdg_surface_for_each_surface continues to iterate both surfaces and
popups to maintain backwards compatibility.
2018-07-01 23:24:39 +10:00
Dominique Martinet ffd37b664f xdg_shell: destroy children popups with parent surface
popups have a link in parent's surface->popups list and needs
to be freed before:

==6902==ERROR: AddressSanitizer: heap-use-after-free on address 0x6120001a0300 at pc 0x7fc1447acb50 bp 0x7fffd396e680 sp 0x7fffd396e670
WRITE of size 8 at 0x6120001a0300 thread T0
    #0 0x7fc1447acb4f in wl_list_remove ../util/signal.c:55
    #1 0x7fc14477d206 in destroy_xdg_popup_v6 ../types/xdg_shell_v6/wlr_xdg_popup_v6.c:162
    #2 0x7fc1447816e0 in destroy_xdg_surface_v6 ../types/xdg_shell_v6/wlr_xdg_surface_v6.c:108
    #3 0x7fc144a1c025 in destroy_resource src/wayland-server.c:688
    #4 0x7fc144a1c091 in wl_resource_destroy src/wayland-server.c:705
    #5 0x7fc14477fd6f in xdg_client_v6_handle_resource_destroy ../types/xdg_shell_v6/wlr_xdg_shell_v6.c:72
    #6 0x7fc144a1c025 in destroy_resource src/wayland-server.c:688
    #7 0x7fc144a20851  (/lib64/libwayland-server.so.0+0xc851)
    #8 0x7fc144a20d92  (/lib64/libwayland-server.so.0+0xcd92)
    #9 0x7fc144a1c140 in wl_client_destroy src/wayland-server.c:847
    #10 0x7fc144a1c21c in destroy_client_with_error src/wayland-server.c:307
    #11 0x7fc144a1c21c in wl_client_connection_data src/wayland-server.c:330
    #12 0x7fc144a1df01 in wl_event_loop_dispatch src/event-loop.c:641
    #13 0x7fc144a1c601 in wl_display_run src/wayland-server.c:1260
    #14 0x40a2f4 in main ../sway/main.c:433
    #15 0x7fc143ef718a in __libc_start_main ../csu/libc-start.c:308
    #16 0x40b749 in _start (/opt/wayland/bin/sway+0x40b749)

0x6120001a0300 is located 64 bytes inside of 264-byte region [0x6120001a02c0,0x6120001a03c8)
freed by thread T0 here:
    #0 0x7fc14690d880 in __interceptor_free (/lib64/libasan.so.5+0xee880)
    #1 0x7fc1447acce8 in wlr_signal_emit_safe ../util/signal.c:29
    #2 0x7fc1447a3cac in surface_handle_resource_destroy ../types/wlr_surface.c:576
    #3 0x7fc144a1c025 in destroy_resource src/wayland-server.c:688

previously allocated by thread T0 here:
    #0 0x7fc14690de50 in calloc (/lib64/libasan.so.5+0xeee50)
    #1 0x7fc144781d38 in create_xdg_surface_v6 ../types/xdg_shell_v6/wlr_xdg_surface_v6.c:415
    #2 0x7fc14147503d in ffi_call_unix64 (/lib64/libffi.so.6+0x603d)

Alternative would be to have popups listen to the parent's surface
destroy event and remove themselves from the list at this point OR on
their own destroy, whichever happens first, but that seems more
complicated for little benefit.
2018-06-25 17:54:25 +09:00
Markus Ongyerth 3994762ae0 Add wlr_surface_get_geometry
This function defaults and clips the xdg-surface geometry to the
bounding box of the surface + its subsurfaces, as specified by the
protocol spec.
2018-06-01 15:21:18 +02:00
emersion 3036507463
xdg-shell: split into multiple files 2018-05-14 22:28:45 +01:00