Commit Graph

60 Commits

Author SHA1 Message Date
Simon Ser 842093bb84 Define _POSIX_C_SOURCE globally
Stop trying to maintain a per-file _POSIX_C_SOURCE. Instead,
require POSIX.1-2008 globally. A lot of core source files depend
on that already.

Some care must be taken on a few select files where we need a bit
more than POSIX. Some files need XSI extensions (_XOPEN_SOURCE) and
some files need BSD extensions (_DEFAULT_SOURCE). In both cases,
these feature test macros imply _POSIX_C_SOURCE. Make sure to not
define both these macros and _POSIX_C_SOURCE explicitly to avoid
POSIX requirement conflicts (e.g. _POSIX_C_SOURCE says POSIX.1-2001
but _XOPEN_SOURCE says POSIX.1-2008).

Additionally, there is one special case in render/vulkan/vulkan.c.
That file needs major()/minor(), and these are system-specific.
On FreeBSD, _POSIX_C_SOURCE hides system-specific symbols so we need
to make sure it's not defined for this file. On Linux, we can
explicitly include <sys/sysmacros.h> and ensure that apart from
symbols defined there the file only uses POSIX toys.
2024-02-15 15:41:12 +01:00
Kirill Primak 0052078bd3 compositor: introduce wlr_surface_reject_pending() 2024-01-27 12:05:05 +00:00
Kirill Primak be1c48cbfb layer-shell: forbid set_size with values ≥INT32_MAX 2024-01-22 19:01:57 +03:00
Simon Ser a6122c3ec5 layer-shell-v1: use wlr_surface_synced 2023-12-25 11:47:15 +01:00
Kirill Primak e841366068 layer-shell: emit new_surface event at the proper time 2023-11-23 13:02:10 +00:00
Kirill Primak d8515b3446 layer-shell: track surface init state 2023-10-26 14:57:10 +00:00
Kirill Primak f750c7445d layer-shell: don't use wlr_surface_role.unmap hook
A layer-shell surface can be unmapped if wlr_layer_shell_v1 is
destroyed or the client has committed a NULL buffer. Let's use the
previously introduced wlr_surface.unmap_commit to handle the latter
case instead; this is more consistent with the xdg_surface
implementation logic, where using the hook is more trouble than it's
worth.

Additionally, this commit adds an unconditional surface reset on
destroy, so popups are properly cleaned up even if originally created
with an unmapped layer-shell surface as a parent. Doing so with the
role unmap hook would either result in possibly resetting the surface
twice, which is suboptimal, or having an awkward
`if (mapped) { unmap() } else { reset() }` check.
2023-10-26 14:57:10 +00:00
Kirill Primak e1c2671725 layer-shell: check the configured flag earlier 2023-10-26 14:57:10 +00:00
Kirill Primak 0de3659698 Drop wl_client and user data assertions in bind handlers
A client can never be NULL and user data assertions aren't really
useful there.
2023-10-10 20:10:00 +03:00
Kirill Primak 65f6f556d9 layer-shell: check for NULL in wlr_layer_surface_v1_destroy() 2023-10-09 19:26:19 +00:00
Alexander Orzechowski 1b0694b794 treewide: Migrate from sizeof(struct) to sizeof(*pointer) where practical 2023-10-03 01:51:07 -04:00
Kirill Primak 7df11ada5e Unmap wlr_surface before making its role object inert 2023-07-26 20:39:03 +00:00
Kirill Primak 7f2ed1e62c layer-shell: don't remove inert role resource 2023-07-10 10:03:24 +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 0f67580aab compositor: introduce wlr_surface_set_role_object() 2023-06-23 11:54:05 +00:00
Kirill Primak c63f3659c5 layer-shell: use unified map logic 2023-06-02 17:26:18 +00:00
Kirill Primak b0437fc416 xdg-shell: use unified map logic 2023-06-02 17:26:18 +00:00
Kirill Primak dc7b5ab21e layer-shell: forbid changing the existing popup parent 2023-02-03 19:29:11 +03:00
Simon Ser f9bd416d41 layer-shell-v1: convert to try_from
References: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/884
2023-02-01 20:13:53 +01:00
Simon Ser 9f793d3503 layer-shell-v1: specify version in constructor
This allows compositors to indicate which features they support,
and is required to eventually make this API stable.

References: https://github.com/swaywm/sway/issues/7260
2022-11-14 09:52:13 +01:00
Kirill Primak 099b9de752 compositor: drop role object NULL checks in handlers
Instead, move the check to the caller.
2022-11-06 17:00:00 +03:00
Kirill Primak 3da2cf3eb3 layer-shell: use role object destroy handler 2022-11-06 17:00:00 +03:00
Alexander Orzechowski ef4baea0e2 Use wl_signal_emit_mutable 2022-08-18 07:16:16 -04:00
Kenny Levinsen 668b2740ff Set mapped before firing map/unmap events
This allows whatever the user calls from the signal handlers to react to observe
the new state rather than the old, e.g. that a surface is no longer mapped in
the unmap handler.
2022-08-06 00:19:38 +02:00
Kirill Primak 6f1fce9cb4 xdg-popup: use current/pending state pattern 2022-05-27 13:31:30 +00:00
Guido Günther 4cc2a03620 layer-shell: Make wlr_layer_surface_v1_from_resource public
This allows compositors to leverage the `wl_instance_of` based type
check.
2022-03-23 09:19:43 +00:00
Kirill Primak 41412cadbe xdg-popup: fix functions' main argument type
With this commit, `wlr_xdg_popup_*()` functions now expect
a `wlr_xdg_popup` instead of a `wlr_xdg_surface`.
2022-02-02 21:06:12 +03:00
Kirill Primak 50827ed7f5 surface: improve role precommit hook
Now the role precommit hook is called before the commit, not on
wl_surface.commit request, and takes a state which is to be applied.
2022-01-13 15:15:54 +03:00
Kirill Primak 617eb4fb93 surface: deprecate wlr_surface.h 2022-01-13 10:06:41 +00:00
Isaac Freund 92d137c78a layer-shell: fix type of margins
These currently use uint32_t while they are an int32_t in the protocol.
2021-12-17 10:57:21 +00:00
Stacy Harper 8e566f716c layer-shell: don't set committed flag if the property didn't change
This fixes configure loop in Sway when clients re-send same properties
on every configure event.

Original issue: https://todo.sr.ht/~mil/sxmo-tickets/413
2021-12-15 16:24:33 +03:00
Kirill Primak cdaab82020 layer-shell: move NULL buffer check to role precommit handler
This will allow compositor to access the current buffer before
unmapping.
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 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 754f40f9cb layer-shell: add `committed` bitmask 2021-09-24 14:38:32 +02:00
Kirill Primak 59fa3637c3 layer-shell: refactor configure/state flow
Same logic as xdg-toplevel.
2021-09-23 21:22:41 +02:00
Isaac Freund 3364eec07e layer-shell: replace close() with destroy()
The protocol specifies that all requests (aside from destroy) are
ignored after the compositor sends the closed event. Therefore,
destroying the wlroots object and rendering the resource inert
when sending the closed event keeps things simpler for wlroots and
compositors.
2021-08-14 20:25:46 +02:00
Daniel Kondor b7dc4f2990 layer-shell: allow new values for keyboard-interactivity
Value is now an enum with a new value ("on-demand") that compositors can use to allow "normal" keyboard focus semantics regardless of the layer the client surface is on. An error is sent for invalid keyboard interactivity values. The old behavior is retained for clients using the previous version of the protocol.

Also adjusted the layer-shell example program to use the new keyboard interactivity options.
2021-01-12 20:13:52 +01:00
Isaac Freund 07111828c5 layer shell: rename popup iterator for consistency
This iterates over the subsurfaces of popups as well, so rename it to
match wlr_xdg_surface_for_each_popup_surface().
2021-01-12 11:26:08 +01:00
Isaac Freund b482c90e1a xdg/layer shell: reduce code duplication in iterators 2021-01-08 14:53:45 +01:00
Isaac Freund 4ee4a36c0c layer shell: add wlr_layer_surface_v1_popup_surface_at()
This function will allow compositors to implement input handling in a
way consistent with rendering more easily.

Calling wlr_layer_surface_v1_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 87e216b740 layer shell: advertise version 3
This should have been done in 45c0877 but was overlooked unfortunately.
2021-01-07 12:12:08 +01:00
Isaac Freund 8dec751a6d layer-shell: error on 0 dimension without anchors
The protocol requires clients to set opposing anchors when requesting
a width or height of 0.

The goal of this patch is not to break clients that rely on this
behavior but to improve the consistency of the layer shell ecosystem
through adherence to the protocol.
2020-10-09 15:42:46 +02:00
Isaac Freund 8ad2cc39eb layer-shell: add for_each_popup
This brings the layer-shell api in line with that of xdg-shell and
avoids reimplementing this function in every compositor in order to
render layer shell popups correctly.
2020-09-10 17:44:55 +02:00
Antonin Décimo d9bb792794 Fix incorrect format parameters 2020-07-27 10:49:19 +02:00
Isaac Freund 92c85858a9 layer-shell: remove unused surface list
This was rendered useless in 5cde359.
2020-07-07 12:11:31 +02:00
Isaac Freund 45c0877e34 layer-shell: upgrade to v3, implement destructor 2020-06-30 13:33:15 +02:00
Isaac Freund b937c7b05e layer-shell: handle serial wrapping overflow 2020-06-25 10:33:58 +02:00