Commit Graph

67 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 811ca199c4 xdg-shell: drop automatic surface configuration
Compositors now are expected to wait for an initial commit by checking
wlr_xdg_surface.initial_commit on every surface commit and send
(schedule) configure events manually.
2024-02-06 13:48:00 +00:00
Kirill Primak 0052078bd3 compositor: introduce wlr_surface_reject_pending() 2024-01-27 12:05:05 +00:00
Simon Ser b80337a8f2 xdg-shell: assert that configure events carry positive or zero sizes
Negative values here would indicate a compositor bug. For xdg_popup,
zero values are not allowed.
2024-01-22 17:49:38 +01:00
Simon Ser 9201431c29 xdg-shell: use wlr_surface_synced for toplevel 2023-12-25 11:47:15 +01:00
Kirill Primak c85838892d xdg-{shell,decoration}: improve events
This commit changes the behavior of `new_*` signals to better match
their names (see https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3608).
wlr_xdg_shell.events.new_surface is now emitted when an xdg_surface is
created, and wlr_xdg_shell.events.new_{toplevel,popup} events are
introduced to get notified when an xdg_{toplevel,popup} is created.
Same applies to
`wlr_xdg_decoration_manager_v1.events.new_toplevel_decoration`. As a
result, wlr_xdg_surface.added and wlr_xdg_toplevel_decoration_v1.added
are removed, as we no longer need to track whether the corresponding
event was emitted.

Additionally, this commit changes the behavior of
wlr_xdg_surface.events.destroy: it is now emitted when the xdg_surface
is destroyed, as the name suggests.
wlr_xdg_{toplevel,popup}.events.destroy events are added to get
notified when an xdg_{toplevel,popup} is destroyed.
2023-11-23 12:52:20 +00:00
Manuel Stoeckl a3d22dbe97 xdg-toplevel: check that title provided actually is UTF-8
While the xdg-shell protocol requires this, it does not yet have
a dedicated error code for invalid titles; this commit makes
wlroots send a generic error instead.
2023-11-22 22:03:00 +03:00
Simon Ser 319e4125ab xdg-shell: add wlr_xdg_{toplevel,popup}_try_from_wlr_surface()
Convenience helpers for compositors. Saves them the trouble of
manually checking the role (and if they forget to do so, prevents
an invalid cast).
2023-11-13 10:31:00 +01:00
Kirill Primak 5fac9b1beb xdg-toplevel: don't send maximized if tiled is requested but not supported
This is a bit too magical and may break compositors which try not to
send duplicate configure events.
2023-10-29 15:51:12 +00:00
Kirill Primak d253d70786 xdg-shell: use wlr_surface.unmap_commit 2023-10-26 19:06:40 +03:00
Kirill Primak 86c30b8715 seat: remove wlr_seat_validate_grab_serial()
It makes little sense to have a catch-all grab vaildation function,
considering that e.g. tablet tool implicit grabs are possible as well.
Besides, the function has always returned true anyway.
2023-10-06 08:51:47 +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 0fdbdc36c0 xdg-surface: fix init state flow
Fixes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3677
2023-10-02 18:37:09 +00:00
Kirill Primak bd5c4f4a4a xdg-shell: rework roles 2023-08-21 16:30:29 +00:00
Leonardo Hernández Hernández e8d545a977
xdg-shell: add support for v6
This adds the suspended toplevel state
2023-07-23 20:30:43 -06: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 b0437fc416 xdg-shell: use unified map logic 2023-06-02 17:26:18 +00:00
Kirill Primak a3489f2c64 xdg-shell: improve unmapping logic slightly 2023-03-12 11:09:36 +00:00
Isaac Freund 5ae17de23f
xdg-shell: improve validation of resize edges
The current validation doesn't catch some invalid values such as 3 or 7.
2023-03-02 21:31:51 +01:00
Simon Ser df0c926a7a xdg-shell: rename wlr_xdg_toplevel.added to sent_initial_configure
This is more descriptive, and avoids the confusion with
wlr_xdg_surface.added.
2023-01-31 16:20:33 +01:00
Simon Ser e1a1dc4be5 xdg-shell: remove unnecessary return
We're at the end of the function anyways.
2023-01-31 16:20:33 +01:00
Simon Ser e69dd909f7 xdg-shell: reset added/committed flag on unmap
When a client attaches a NULL buffer to its wl_surface, it's
unmapped. This resets the xdg_surface in its initial state. An
extra NULL commit makes the compositor send an initial configure
event.

Note, wlr_xdg_toplevel.added is separate from wlr_xdg_surface.added.

Closes: https://github.com/swaywm/sway/issues/7397
2023-01-31 16:20:10 +01:00
Kirill Primak c2fb5289c2 xdg-shell: send invalid_size errors 2022-11-17 10:03:52 +00:00
Kirill Primak acd5a64fd1 xdg-shell: use role object destroy handler 2022-11-06 17:00:00 +03:00
Kirill Primak 1243a855d4 xdg-shell: fix geometry types 2022-11-05 18:30:09 +00:00
Kirill Primak a049d66dd7 xdg-toplevel: send invalid_parent error 2022-10-14 10:57:49 +00:00
Kirill Primak ebd4c83cd6 xdg-toplevel: validate resize_edge 2022-09-17 08:20:24 +00:00
Alexander Orzechowski ef4baea0e2 Use wl_signal_emit_mutable 2022-08-18 07:16:16 -04:00
Simon Ser f1e05a6493 xdg-shell: add support for v5
This version adds a wm_capabilities event.
2022-08-01 18:50:16 +02:00
Kirill Primak 8d2fa15e9d xdg-toplevel: post no memory on strdup() fail 2022-06-21 17:37:45 +03:00
Kirill Primak e7b217efb9 xdg-shell: improve shell version check 2022-06-11 20:22:54 +03:00
Simon Ser e383c1f1db xdg-shell: add support for v4
This adds a configure_bounds event to let the client know of the
preferred maximum window geometry size.
2022-06-01 18:18:54 +02:00
Simon Ser 8fe3aa29da xdg-shell: specify version in wlr_xdg_shell_create
With protocol additions such as [1], compositors currently have no
way to opt out of the version upgrade. The protocol upgrade will
always be backwards-compatible but may require new compositor
features.

The status quo doesn't make it possible to ship a protocol addition
without breaking the wlroots API. This will be an issue for API
stabilization [2].

To address this, let compositors provide a maximum version in the
function creating the global. We need to support all previous versions
of the interface anyways because of older clients.

This mechanism works the same way as Wayland clients passing a version
in wl_global.bind.

[1]: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/3514
[2]: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/1008

References: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3397
2022-05-15 15:44:40 +00:00
Kirill Primak 8b0d4947cc xdg-toplevel: store states on the stack 2022-05-10 19:19:08 +03:00
Kirill Primak dec2565f2b xdg-toplevel: don't schedule configures on state requests 2022-04-13 17:00:06 +00:00
Kirill Primak bf3f60ff73 xdg-toplevel: treat unmapped parents as NULL 2022-04-13 16:48:15 +00:00
Kirill Primak b5b15b2625 xdg-{toplevel,popup}: extract destructors 2022-02-21 17:26:51 +00:00
Kirill Primak 34a71eae31 xdg-shell: drop wlr_xdg_toplevel_set_fullscreen_event
Instead, compositors can read relevant values from
wlr_xdg_toplevel.requested.
2022-02-02 21:06:12 +03:00
Kirill Primak d2b36b7bd1 xdg-shell: fix potential use-after-free 2022-02-02 21:06:12 +03:00
Kirill Primak c35d14ecfa xdg-shell: extract role-specific unmap logic 2022-02-02 21:06:12 +03:00
Kirill Primak e59aa3e0e7 xdg-toplevel: change object type in event structs
This commit replaces wlr_xdg_toplevel_*_event::surface with a toplevel
field.
2022-02-02 21:06:12 +03:00
Kirill Primak 1e4c1a3b58 xdg-toplevel: change parent type to xdg-toplevel
This commit changes wlr_xdg_toplevel::parent type from wlr_xdg_surface
to wlr_xdg_toplevel.
2022-02-02 21:06:12 +03:00
Kirill Primak 27c8865a4d xdg-shell: unify function arguments' names
`wlr_xdg_surface`s are now named "surface" everywhere, and
`wlr_surface`s are called "wlr_surface".
2022-02-02 21:06:12 +03:00
Kirill Primak affe0d8713 xdg-toplevel: fix functions' main argument type
With this commit, `wlr_xdg_toplevel_*()` functions now expect
a `wlr_xdg_toplevel` instead of a `wlr_xdg_surface`.
2022-02-02 21:06:11 +03:00
Kirill Primak 05dd990e43 xdg-shell: rename surface role handlers 2022-02-02 21:04:59 +03: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
Ilia Bozhinov 42d033e738 xdg-shell: add wlr_xdg_toplevel_set_parent
Co-authored-by: Jason Francis <cycl0ps@tuta.io>
2021-01-05 20:32:56 +01:00
Isaac Freund 2072d59da5 xdg-shell: split last-acked and current state
These states are distinct in the time period between the ack_configure
and the next commit on the surface. Splitting these states avoids the
following race for example:

- client starts at 1000x1000
- wlr_xdg_toplevel_set_size 500x500
- size is different -> configure sent
- client acks the configure
- wlr_xdg_toplevel_set_size 1000x1000
- compare_xdg_toplevel_state returns true since there is no pending
  configure and the currently committed size is still 1000x1000
- no new configure is sent
- client commits at the size it last acked, 500x500
2020-08-27 12:36:29 +02:00