Commit graph

7591 commits

Author SHA1 Message Date
Kenny Levinsen
8ac1f72c9e config/output: Use INT_MAX as x/y unset value
We oftne use -1 to indicate unset values. In case of output (x, y), we
would consider the fields set if they are not both -1. This means that
(0, -1) and (-1, 0) are valid coordinates, but (-1, -1) is not.

We support negative output positioning, so we cannot use -1 to mean
unset. Zero is also not an option as that would disallow reverting a set
position back to (0, 0).

INT_MAX is an unreasonable output position, so use it to indicate unset
values, and only use the value when both are set.
2025-05-01 00:00:50 +02:00
Pavel 'LEdoian' Turinsky
6cac61b6b9 Fix includes with relative paths
The function `load_include_configs` already changes the directory to the
one containing the parent config. Therefore, `load_include_config`
trying to assemble the "full" path leads to repetition of path segments,
making the `realpath` call fail with ENOENT.

Just calling `realpath` on the path itself from the directory with the
parent configuration is sufficient, so there is no point in passing
`parent_dir` to `load_include_config`.
2025-04-28 23:34:23 +02:00
Simon Ser
6894b498a8 build: bump version to 1.11-rc2 2025-04-27 22:52:48 +02:00
Furkan Sahin
5b8874e3f4 sway/commands: Handle incorrect resize unit
problem: an invalid usage of the command resize set will cause sway to crash because it doesn't check for an invalid height.
solution: validate height along with width.
2025-04-27 22:04:25 +02:00
Simon Ser
38a42f97d4 Replace signal() with sigaction()
The man page for signal(3) reads:

> new applications should use sigaction() rather than signal()
2025-04-27 18:42:12 +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
86ff19fade build: bump version to 1.11-rc1 2025-04-20 13:31:10 +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
Simon Ser
d3e1c13e1f swaymsg, swaynag: drop sway_terminate() definitions
These are unused.
2025-04-17 23:31:55 +02:00
llyyr
8a8c78deac layer_shell: destroy layer_surface on assigned output destruction
According to the spec, the closed event should be sent when the surface
is no longer shown, because the output may have been destroyed or the
user may have asked for it to be removed. In such cases, the clients
should destroy the resource.

This fixes mako not being able to show notifications if the assigned
output was destroyed while a notificataion was still visible

Fixes: 188811f808 ("scene_graph: Port layer_shell")
2025-04-17 20:50:43 +02:00
Filip Vujičić
7733bf9963 Remove duplicate arrange_container 2025-04-17 19:05:36 +02:00
Simon Ser
3f0b3f8f9b Fix crash on shutdown when Xwayland is disabled 2025-04-14 10:21:18 +02:00
Loukas Agorgianitis
4943534929 server: fix shutdown crash when running on x11 backend
Signed-off-by: Loukas Agorgianitis <loukas@agorgianitis.com>
2025-04-14 09:30:49 +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
Ferdinand Bachmann
0a9b0b83eb server: 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
583862e6d1 idle_inhibit: Check if layer surface output is enabled
While we we cannot easily check for true visibility of layer surfaces as
easily as for views, we can check at least check that the output
associated with the surface is enabled.
2025-04-13 16:24:02 +02:00
Kenny Levinsen
cc482228a4 idle_inhibit: Assume view is invisible by default
We have historically considered surfaces without a view visible. This
made sense in case of layer surfaces which do not have a view, but it
also allows unmapped surfaces to act as global inhibitors irrespective
of the current view state, which is not the intention fo the protocol.

As we now explicitly handle layer surfaces, assume that views are only
visible if they can be found and their visibility checked.
2025-04-13 16:24:02 +02:00
Kenny Levinsen
541183b322 idle_inhibit: Explicitly handle layer surfaces
Layer surfaces do not have a view, and while they can be occluded they
are always visible on their associated output - assuming it is enabled.
2025-04-13 16:24:02 +02:00
Kenny Levinsen
5e6a6ea340 idle_inhibit: Ignore inhibitors when locked
When a session is locked, no views are visible and there is no way to
interact with the user session. This means that all inhibitors based on
visibility - with the exception being inhibitors on the session lock
surfaces themselves - become inert, allowing the session to go idle.

The only inhibitor type on normal views that one could argue should
remain active is INHIBIT_IDLE_OPEN, but for now we disable all view
inhibitors regardless of type.
2025-04-13 16:24:02 +02:00
Daniel De Graaf
8f089f0229 Use wl_event_loop_add_signal for exit signals
This avoids calling non-async-signal-safe functions from within a signal
handler.
2025-04-12 23:10:39 +02:00
Furkan Sahin
cb246cb9c2 ipc: standardize pretty print with raw print
`swaymsg -t get_inputs --raw` calls it a pointer but `--pretty` calls it
a Mouse. Previous commit 6737b90cb that set this to pointer probably
forgo to update the pretty one.

closes #8584
2025-04-09 01:10:03 +02:00
Claudia
a25645a5a6 Fix tabbed/stacking container height regression
Commit c2d6aff added a bounds check on `height - title_bar_height`,
repurposing the local variable `height` in an attempt to DRY out the
expression.

However, because re-assignment occurs inside the loop body, its result
would leak across loop iterations, compounding its effect and leading
to the artifact reported in issue #8625, where each child except the
first in a tabbed container would acquire a visible waterline.

Introduce a second variable and reset it in each loop iteration to get
rid of the waterline.

Fixes #8625.
2025-03-27 08:09:53 +01:00
Dennis Baurichter
ab455bbada man: clarify criteria (incl. PCRE2 usage)
Replace the XWayland-only class attribute in the examples:
- The first example given should work for Wayland-native windows.
- The example 'Kill all windows with the title "Emacs"' should use
  title, not class. Also, it's a substring (regex) match.

There are many different implementations of regular expressions with
incompatible syntax. For example, GNU grep alone provides three
different ones. Clarify the use of PCRE2 by sway criteria.
2025-03-23 15:03:24 +01:00
Kenny Levinsen
c2d6aff64c Avoid crashing on too many containers
If far too many containers are created, they can become so small that
their size calculations come out negative, leading to crashes on
asserts.

Instead, set a lower bound for sizes and disable the container entirely
if it goes below it, giving whatever space it used to the last
container.

The splits are not recalculated, so currently the effect is that if all
containers have the same width fraction, they keep getting narrower
until at some point they all round to zero and the last container will
be given all the available space.

A better behavior would have been if the additional container did not
contribute to size and fraction calculations at all, but it's an extreme
edge-case, anything is better than crashing, and this is easier to
implement.
2025-03-21 21:08:04 -04:00
Paul Riou
4b185a0fe0 stringop: fix has_prefix() arg order in config parsing
has_prefix() expects the prefix to be the 2nd argument, not the first.

The config parsing was broken when using `--input-device=`.

Introduced by: 0c60d1581f "Use has_prefix()
instead of strncmp() throughout"
2025-03-20 21:31:32 +01:00
ShootingStarDragons
d148560f50 text_input: Fix ime panic in ext-session-lock
in the origin text_input.c, we only check the sway_view and layershell,
but now we have the third shell named sessionlock, so we need to modify
both text_input.c and view.c to handle the new type of shell
2025-03-20 15:55:21 +01:00
Kenny Levinsen
30434b2beb desktop/output: Skip repaint if wlr_output is disabled
When the repaint timer fires, we check if the sway_output is disabled,
and if so, skip the output commit after having reset frame_pending.

The sway_output enable flag is only updated if the output is disabled
and removed from the layout, not if the power is disabled for e.g. idle.
This can lead to situations where a commit is attempted on a disabled
output, which will lead to an attempted and failed primary swapchain
allocation.

Use the wlr_output.enabled state to check if the output is active.
2025-03-20 12:40:27 +01:00
Piotr Piwoński
3a49409dae sway/commands: Return error if container is not in scratchpad 2025-03-18 22:28:05 +01:00
melvinm1
2f5b3c0999 Fix output repositioning in global fullscreen
Call wlr_scene_output_set_position when in global fullscreen to
correctly set output positions when repositioning outputs (using
swaymsg output or similar).
2025-03-16 17:48:30 +01:00
Kenny Levinsen
61cc08cf3c config/output: Reset everything before swaybg exec
swaybar and the exec command reset signal masks, signal handlers and
NOFILE limit before exec, but swaybg was missing all that.

Reset it for swaybg as well.
2025-03-11 09:15:05 +01: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
nilninull
9dcccf784b Add the DesktopNames key to the sway.desktop session file
According to
https://specifications.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html,
to set the value of XDG_CURRENT_DESKTOP, a DesktopNames key is
required in the session file.  And the value of XDG_CURRENT_DESKTOP is
used to run xdg-desktop-portal*.  If this value is not set,
xdg-desktop-portal-wlr will not run at login.
2025-03-08 12:56:03 +01:00
Chris Perl
048e304b8a Remove constraint that con->view != NULL to use __focused__ criteria
To use something like:

  [con_id=__focused__] mark --add --toggle foo

The container must currently have a view. However, it is possible to
focus parent containers that do not have a view. For example, via:

  focus parent

Since containers without views can be the focused (meaning the container
is marked "focused": true in the output of: swaymsg -t get_tree), it
seems reasonable that a view is not required to target a container via
__focused__.
2025-03-07 17:53:40 +01:00
Kenny Levinsen
e3d9cc2aa5 Rework fork/exec strategy
cmd_exec_process is used whenever sway is meant to execute a child
process on behalf of the user, and had a lot of complexity.

In order to avoid having to wait on the user's process, a double-fork
was used, which in turn required us to wait on the outer process. In
order to track the child PID for launcher purposes, a pipe was used to
transmit the PID back to sway.

This resulted in sway blocking for 5-6 ms per exec on my system, which
is quite significant. The error handling was also quite lacking - the
read loop did not handle errors at all for example.

Instead, teach sway to handle SIGCHLD and do away with the double-fork.
This in turn allows us to get rid of the pipe as we can record the
child's PID directly. This reduces the time we block to just 1.5 ms on
my system. We'd be able to get down to just 150 µs if we could use
posix_spawn(3), but posix_spawn(3) cannot reset NOFILE. clone(2) or
vfork(2) would be alternatives, but that presents portability issues.

This change is replicated for swaybar, swaybg and swaynag handling,
which had similar albeit less complicated implementations.
2025-03-06 11:46:59 +01:00
Kenny Levinsen
962e1e70a6 sway_text_node: Remove use of source box
The source box is always set to the full buffer dimensions, making it
ineffective. Remove it.
2025-02-25 09:48:40 -05:00
Kenny Levinsen
8a60f30423 sway_text_node: Apply max_width when rendering
max_width was applied to the source box, but not to the cairo surface.
The cairo surface would therefore take on arbitrarily large dimensions
according to the required dimensions to fit the text input, which if
large enough would cause failures during output rendering and leave a
black hole in the titlebar.
2025-02-25 09:48:40 -05:00
Alexander Orzechowski
7fab75a7a6 commands/opacity: Call output_configure_scene on updated container
Calling container_update() wasn't enough: If there is no visible window
decorations (title bar, borders) container_update would basically no-op
and the scene wouldn't repaint with the update alpha. By also calling
output_configure_scene() we force a call to
wlr_scene_buffer_set_opacity() thus ensuring we update the scene.

Closes: #8580
2025-02-25 11:11:22 +01:00
Alexander Orzechowski
0da0d37f3d output: Allow configuring scene without an output 2025-02-25 11:11:22 +01:00
Alexander Orzechowski
38005bd854 output: Expose output_configure_scene to header 2025-02-25 11:11:22 +01:00
Mark Stosberg
10e50e6bf9 docs: use "window" instead of "view" throughout.
"view" is an internal term, while the commonly understood
user-facing term is "window"

Ref: #7323
2025-02-17 00:13:15 +01:00
Ferdinand Bachmann
c1031d8465 sway/ipc-json: add ext-foreign-toplevel-handle identifier to get_tree ipc output
Fixes #8291
2025-02-16 19:18:29 +01:00
Furkan Sahin
4852087e61 output/background: fix config ignoring fallback color
currently, the output background command handler prematurely
returns with an error if the background file cannot be accessed.
It should only error if user did not provide fallback color.

closes #8556

Changes

- Introduce variables to avoid uneccessary writing on output members
- Log a debug message when fallback is being used over inaccessible
   file
- Always parse the background color and swaynag warn if it is incorrect

- when updating output member variables, free previous values
- add cleanup label and goto it if `strdup` fails
- Move output->member initializations to before parsing fallback, Also
free and init output->background as well
2025-02-09 14:29:44 +01:00
Dan Baterisna
851b8c6fb6 man: Document bar mode toggle command
Functionality for switching swaybar's current mode between
hidden and docked currently exists, but is absent from the relevant
manpage.
2025-02-06 18:02:35 +01:00
Attila Fidan
d093c2e358 input/cursor: remove tool_proximity listener in destroy 2025-01-27 00:42:37 -05:00