Commit graph

7515 commits

Author SHA1 Message Date
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
Bill Li
3ff60987f3 Drop wlr_matrix.h include from sway/desktop/output.c
wlr_matrix is now private API.

Fixes #8549
2025-01-26 18:36:07 -05: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
llyyr
30c858423d config/output: don't leak background_fallback 2025-01-16 16:03:36 +01:00
Jacob McNamee
0b08dce08c swaymsg: pretty-print sandbox properties 2025-01-13 08:54:23 +01:00
Jacob McNamee
f177d05441 tree/container: support sandbox properties in title format 2025-01-13 08:54:23 +01:00
Puck Meerburg
3ab1f0ca3d criteria: add sandbox properties 2025-01-13 08:54:23 +01:00
Puck Meerburg
60f06fc4f1 ipc-json: add sandbox properties to view JSON 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
Jim
e3f0ba4cd9 Increase max default buffer size to 1 MiB
Increasing the max default buffer size prevents clients from crashing
when they need more than 4096 bytes. This can happen when the GUI thread
of the application is blocked, especially when moving your mouse over it
with high mouse sensitivity.
2025-01-12 22:38:04 +01:00
llyyr
3629a832e5 layer_shell: cleanup new_popup listener when destroying node 2025-01-11 10:32:08 -05:00
Simon Ser
a6c0441ee0 config/output: don't hardcode DMA-BUF in search_render_format()
We could be running with a backend which doesn't support DMA-BUFs,
e.g. inside a parent Wayland compositor without GPU acceleration.
2025-01-08 11:57:45 +01:00
mtvare6
c7c0a5a1b3 config/output: skip format checks if all are supported
Fixes #8496
2025-01-08 08:25:39 +01:00
Simon Ser
a1838c5522 Fix has_prefix() comparisons with 0
has_prefix() returns a bool, unlike strncmp() which returns an int.

Fixes: 0c60d1581f ("Use has_prefix() instead of strncmp() throughout")
Closes: https://github.com/swaywm/sway/issues/8527
2025-01-07 18:56:02 +01:00
Simon Ser
0c60d1581f Use has_prefix() instead of strncmp() throughout
This is safer than hardcoded string lengths.
2025-01-07 16:35:31 +01:00
Simon Ser
c55dff95bc stringop: move over has_prefix() 2025-01-07 16:35:31 +01:00
Hong Xu
801bc76ce3 Explain that the title bar always shows 2024-12-21 11:37:50 +01:00
Alexander Orzechowski
f293418d9d swaybar: Handle opaque region properly
The background color can be set individually for the different
elements of the bar. If any of the backgrounds have transparency, we have
to bail out from advertising an opaque surface.
2024-12-08 18:28:25 +01:00
Baltazár Radics
4eb86fce07 input/libinput: fix parsing input drag_lock command
Regression introduced by by b160fac9f7a
2024-12-08 16:15:48 +01:00
György Kurucz
1d783794b5 input/libinput: fix builtin device detection logic
Fixes: #8468
2024-11-23 11:17:17 +01:00
Violet Purcell
4faf0f9098 tree/container: remove output_{enter,leave} listeners in destroy
0d6cc471e9
added an assert that all signals are clear when destroying a
wlr_scene_buffer, which is currently triggering due to sway not removing
the output_enter and output_leave listeners on the container before
calling wlr_scene_node_destroy on output_handler. Remove the listeners
before wlr_scene_node_destroy is called.
2024-11-23 13:10:06 +03:00
Simon Ser
bbadf9b8b1 Add support for LIBINPUT_CONFIG_DRAG_LOCK_ENABLED_STICKY
Use it as the default, as recommended by the libinput release
notes:
https://lists.freedesktop.org/archives/wayland-devel/2024-November/043860.html
2024-11-23 13:06:49 +03:00
Simon Ser
e2409aa496 ipc-json: handle LIBINPUT_CONFIG_DRAG_LOCK_ENABLED_STICKY
New entry introduced in libinput 1.27.0.
2024-11-23 13:06:49 +03:00
Kenny Levinsen
5312376077 desktop/output: Clear repaint timer earlier in destroy
The teardown of a sway_output is split in two: begin_destroy and
output_destroy. The former clears some state such as NULL'ing the
reference to wlr_output, while the latter frees the struct and its
remaining resources.

If an output is destroyed while a repaint timer is pending, future frame
callbacks will no longer occur as the listener is torn down in
begin_destroy, but the repaint timer is not torn down and may still
fire until output_destroy is hit. As begin_destroy cleared the reference
to wlr_output, this leads to a NULL-pointer dereference.

Tear down the repaint timer in begin_destroy as there is no need for it.

Fixes: fdc4318ac6 ("desktop/output: Clear frame_pending even output is disabled")
2024-11-17 16:03:35 -05:00
mtvare6
fec3da7d58 commands/include: handle many files in single line
i3 supports including multiple files in a single line, whereas sway
limits to single file per line.
2024-11-17 19:18:51 +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