Commit graph

1613 commits

Author SHA1 Message Date
Simon Ser
cb33701f5e Add xdg_toplevel tag to criteria 2025-07-16 10:03:09 +02:00
Simon Ser
3826535ab0 Wire up xdg-toplevel-tag-v1 2025-07-16 10:03:09 +02:00
Simon Ser
94c819cc1f Add features.hdr to output IPC response 2025-07-09 01:25:11 +02:00
Simon Ser
bac8c0f4d0 Add support for HDR10 output 2025-07-09 01:25:11 +02:00
Simon Ser
a1ac2a2e93 Drop sway_output.events.disable
In general wl_signal isn't well-suited for Sway: Sway doesn't need
any modularity, and signals make it trickier to track down exactly
what happens down the stack.

Replace Sway's output disable signal with a simple list tracking
for the only user.
2025-07-02 21:21:53 +02:00
Kenny Levinsen
56f2db062d Revert "sway/tree: Simplify sway_node teardown"
This reverts commit e28e6484e8.

This change tried to remove nodes from all points of reference to allow
immediate destruction. However, it missed things like the children lists
cloned by transaction states of parent nodes.

Adding all that extra cleanup would not be in the spirit of a PR
claiming to simplify teardown. Let's wait for someone to come up with a
cleaner approach instead.

Fixes: https://github.com/swaywm/sway/pull/8738
2025-06-28 11:26:49 +02:00
Kenny Levinsen
e28e6484e8 sway/tree: Simplify sway_node teardown
A sway_node may end up being referenced in either a queued transaction,
pending transaction or as a dirty node. To manage this, the transaction
system has been responsible for destroying containers, workspaces and
outputs at the end of their last referenced transaction.

This significantly complicates the teardown flow of surfaces and
outputs. Instead, remove the node from transactions and dirty lists so
that the callsite can remove and free the node immediately.
2025-06-26 22:05:05 +02:00
Simon Ser
170c9c9525 Add support for toplevel capture
References: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/5078
2025-06-16 14:28:20 +02:00
hwsmm
4b15b3427f Rename get_current_time_msec to get_current_time_in_msec and move to util.c
get_current_time_msec conflicts with a function with the same name in wlroots.
2025-06-16 11:26:26 +02:00
Simon Ser
6816b51c86 Remove trailing spaces 2025-06-05 18:15:56 +02:00
YaoBing Xiao
9fb9e9f7d5 server: fix socket path memory leak
The socket path allocated with strdup() in server_init() was
not being freed in server_fini().
Remove const qualifier and add proper cleanup.
2025-06-05 09:59:46 +02:00
Konstantin Pospelov
7e7994dbb2 swaybar: deduplicate mode and workspace rendering code
The render_workspace_button and render_binding_mode_indicator functions are
almost the same. This commit extracts the common rendering code into a new
render_box function.
2025-05-25 14:48:14 +02:00
Kenny Levinsen
534491d3aa tree/workspace: Remove exclude arg from get_highest_available
workspace_output_get_highest_available took an output to exclude as
argument, meant to avoid accidentally reselecting an output we are
evacuating workspaces from.

Outputs are now removed from the list before we evacuate, making
exclusion unnecessary. Remove the argument.
2025-05-22 17:12:51 +02:00
Simon Ser
0e19d85d37 Use pthread_atfork() to restore signals and NOFILE limit
This ensures these functions are always called (even when a library
such as wlroots or libc perform the fork) and removes the need to
manually call them.
2025-04-21 15:17:36 +02:00
Simon Ser
1d4632f97f Drop wl_drm again
In [1] we re-introduced a debug flag to enable wl_drm. Time has
passed and Xwayland + VA-API + amdvlk now all support
linux-dmabuf-v1.

[1]: https://github.com/swaywm/sway/pull/7916
2025-04-20 13:28:36 +02:00
Simon Ser
0153bc92ab server: move sway_terminate() definition to header 2025-04-17 23:31:55 +02:00
Ferdinand Bachmann
240a69ad63 server: recreate renderer in idle callback to avoid UAF
Destroying the wlr_renderer in a callback to its own renderer_lost event
is unsafe due to wl_signal_emit*() still accessing it after it was
destroyed.

Delegate recreation of renderer to an idle callback and ensure that only
one such idle callback is scheduled at a time by storing the returned
event source.
2025-04-13 23:40:56 +02:00
Ferdinand Bachmann
ab2e1f5817 tree/container: remove event listeners on destroy
Change begin_destroy to remove event listeners before the final destroy,
since otherwise event listeners would be removed twice, which crashes.

This fixes a crash in wlroots listener checks. See #8509.
2025-04-13 23:40:56 +02:00
Ferdinand Bachmann
53126cdceb input/text_input: remove event listeners on destroy
sway_input_method_relay can be destroyed from two sources, either the
seat is destroyed or the manager protocol objects are destroyed due
compositor exit.

This fixes a crash in wlroots listener checks. See #8509.
2025-04-13 23:40:56 +02:00
Ferdinand Bachmann
92c82e6952 desktop/idle_inhibit: remove event listeners on destroy
This fixes a crash in wlroots listener checks. See #8509.
2025-04-13 23:40:56 +02:00
Ferdinand Bachmann
e51ecf71aa input/input-manager: remove event listeners on fini
This fixes a crash in wlroots listener checks. See #8509.
2025-04-13 23:40:56 +02:00
Kenny Levinsen
8238e5242b Use SIG_IGN for SIGCHLD instead of our own handler
The behavior of handlers registered with signal(3p) is not well-defined
for signals delivered more than once, as laid out in the man page.

We should replace our use of signal with sigaction, but for SIGCHLD
specifically we can also just skip the signals altogether by setting the
handler to SIG_IGN which causes child reaping to not be required.

Fixes: https://github.com/swaywm/sway/pull/8567
2025-03-11 09:15:05 +01:00
llyyr
5d7b9a8320 sway/server: create ext-data-control manager 2025-03-09 10:46:26 +01:00
Alexander Orzechowski
38005bd854 output: Expose output_configure_scene to header 2025-02-25 11:11:22 +01:00
Simon Ser
8acb0482da Add ext-image-copy-capture-v1 and ext-image-capture-source-v1
References: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/4545
2025-01-21 20:26:19 +03:00
Puck Meerburg
3ab1f0ca3d criteria: add sandbox properties 2025-01-13 08:54:23 +01:00
Jacob McNamee
cff16d32f9 tree/view: add getters for sandbox properties 2025-01-13 08:54:23 +01:00
Simon Ser
c55dff95bc stringop: move over has_prefix() 2025-01-07 16:35:31 +01:00
Kenny Levinsen
a2c73c9b8b ipc-server: Force modeset if needed after executing commands
IPC clients generally expect executed commands to have taken effect when
the command completes, while delayed modeset means that it can take
several milliseconds more before e.g. an output is enabled.

However, modesetting on every output command in the IPC call could on
systems with already slow modesetting behavior lead to an unresponsive
system for a not insignificant period of time.

To strike a balance, force modeset once all the commands of this IPC
call have executed if a modeset is pending.
2024-11-17 19:11:58 +01:00
Kenny Levinsen
6111297d91 config: Force modeset before running deferred configs
Some commands require outputs to be enabled. These commands are deferred
to allow outputs to be discovered, but the delayed modeset might only
run some time later.

Force a modeset to occur before running deferred commands.

Fixes: https://github.com/swaywm/sway/issues/8433
2024-11-17 19:11:58 +01:00
Kenny Levinsen
b73f54a966 desktop/output: Expose request_modeset
We remove the struct sway_server argument for consistency with the rest
of our internal APIs which rely on the global server instance.
2024-09-21 17:50:24 -04:00
Alexander Orzechowski
74e507962e text_input: Properly handle map/unmap events
The last implementation would ignore these and get it could get into
a bad state where it would start crashing sway.
2024-09-20 19:40:18 +02:00
Alexander Orzechowski
1537c9dae5 text_input: Move popup placement to own function 2024-09-20 19:40:18 +02:00
Kenny Levinsen
034d02f8a5 config/output: Add support for 6-bit render fmt
GUD devices uses RGB565 by default for performance reasons. Allow
specifying render_bit_depth 6 to pick this format. The definition works
out if you consider the maximum number of bits per channel instead of
the average.
2024-09-20 14:08:04 +02:00
Kenny Levinsen
785a459a55 ext-session-lock: Do not use commit listener to arrange
Arranging lock surfaces rely on the sway_output width and height being
updated, but these are only updated after the commit has been completed
and all commit listeners have executed. This means that the lock
surfaces will not be appropriately scaled to match a change in output
dimensions, and may reveal what is under the lock background.

Replace the implicit arrange through the output commit listener with an
explicit arrange after the output configuration is finalized.

This might have regressed by other transition away from output commit
listeners for other arrange tasks, but even then it would have
erroneously relied on signalling order.
2024-09-20 00:26:36 -04:00
Kenny Levinsen
d7a76d381b config/output: Rename to apply_stored_output_configs 2024-09-10 14:13:36 -04:00
Kenny Levinsen
29b3f00e6f config/output: Accept a list of output_configs to use
Instead of using a single finalized output config per output, accept a
regular list of output configs like the one ultimately stored for
configuration purposes. This allows the output management code to test
an augmented configuration while still using the same output config
logic, without having to mutate the stored configuration.

This in turn allows us to make a few APIs private. A bug note about an
existing issue with derade to off is added as well.
2024-09-10 14:13:36 -04:00
Kenny Levinsen
af28ac04a4 (desktop|tree)/output: Do not use layout listener to arrange
Output layout changes originate from the centralized modeset
infrastructure and request_state which already takes care of arranging
and updating outputs as needed.
2024-09-04 13:49:35 -04:00
Kenny Levinsen
b83e5aaa54 desktop/output: Do not use commit listener to arrange
The reasoning for using a commit handler is to ensure that all paths for
output changes are correctly handled. With the centralized modeset
infrastructure in place, we can move the logic there. This allows us to
be smarter and avoid extraneous arranges, output manager updates and
transaction commits.

The side-effect is a minor duplication for the special-case
request_state, but the shared path will be relied upon further in future
commits to justify this duplication.
2024-09-04 13:49:35 -04:00
Norbert Bolanowski
be840f730e move title_format to container 2024-09-02 16:49:05 -04:00
Alexander Orzechowski
c3279944fb output: Use wlr_scene_set_gamma_control_manager_v1 2024-08-14 20:45:04 +03:00
Ricardo Steijn
9a1c411abd
Add support for tearing-control-v1
References: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/3871

Adds option to allow tearing per output, as well as an option to force
enable or disable tearing for a specific application using a window
rule. Only works with fullscreen applications.
2024-08-05 02:13:49 +02:00
Tarcísio Eduardo Moreira Crocomo
5be5a50051 Implement clickfinger_button_map support. 2024-07-04 22:47:46 +02:00
Simon Ser
d8c4a2d5fe tree/container: drop decl for container_update_textures_recursive()
This function doesn't exist anymore.
2024-07-03 17:50:32 -04:00
Kenny Levinsen
b04f4136bc desktop/output: Debounce modesets
Output changes often happen in rapid succession. Instead of doing the
modesets one by one, set a 10 millisecond debounce timer.
2024-07-03 10:06:22 -04:00
Manuel Stoeckl
40ca4150b2 sway/commands/output: Add command to set color profile
This makes it possible to render output buffers in a different color
space, by specifying an ICC profile for the output.
2024-06-07 19:01:49 +02:00
Simon Ser
d0bd591ee7 Drop server.h include from input/input-manager.h
The only reason it's included there is for a declaration of
struct sway_server, but we can just forward-declare it.

This avoids rebuilding almost all of Sway when touching server.h.
All other server.h includes are from source files, not headers.
2024-05-27 09:28:43 -04:00
Simon Ser
700f4805bc server: hide xdg_output from unprivileged clients
Regular Wayland clients shouldn't care about the position or size
of outputs. Hide xdg_output from unprivileged clients to make sure
they're not doing shenanigans with this information.
2024-05-27 09:27:20 -04:00
Simon Ser
9704152414 build: drop xwayland option
Instead of having a build-time option to enable/disable xwayland
support, just use the wlroots build config: enable xwayland in
Sway if it was enabled when building wlroots. I don't see any
use-case for disabling xwayland in Sway when enabled in wlroots:
Sway doesn't pull in any additional dependency (just pulls in
dependencies that wlroots already needs). We have a config command
to disable xwayland at runtime anyways.

This makes it so xwayland behaves the same way as other features
such as libinput backend and session support. This also reduces
the build matrix (less combinations of build options).

I think we originally introduced the xwayland option when we didn't
have a good way to figure out the wlroots build config from the
Sway build system.
2024-05-21 11:44:39 -04:00
Kenny Levinsen
4c28916d68 config/output: Search for output config fallbacks
The original sway output config implementation enabled one output at a
time, testing modes, render formats and VRR support as it went along.
While this sort of fallback is easy to do, it has the downside of not
considering the effect of neighbor outputs on the configuration
viability.

With backend-wide commits, we can now better consider the effect of
neighbor outputs, but to handle the fact that we commit all outputs at
once we need to perform a more elaborate search of viable
configurations.

Implement a recursive configuration search for when the primary
configuration failed to apply.
2024-05-02 16:16:42 +02:00