Commit graph

830 commits

Author SHA1 Message Date
Simon Ser 38020d157d Bump RLIMIT_NOFILE
Wayland compositors handle many file descriptors: client
connections, DMA-BUFs, sync_files, wl_data_device pipes, and so
on. Bump the limit to the max.

Closes: https://github.com/swaywm/sway/issues/6285
2021-10-30 08:19:35 -06:00
bR3iN 9969de9e00 Add smart_gaps inverse_outer command
Add a subcommand for `smart_gaps` that enables outer gaps only
on workspaces with exactly one visible child.
Also add documentation for `smart_gaps toggle`.
2021-10-29 13:37:58 +02:00
siikamiika 197d0ab82f commands/focus: focus view inside container
seat_get_focus_inactive_floating and seat_get_focus_inactive_tiling do
not always return a view, so get the previously focused view from the
container with seat_get_focus_inactive_view. This is the i3 behavior.
2021-10-21 13:13:54 -07:00
Hugo Osvaldo Barrera c16b2a26ed Avoid unecessary font metric calculations
Prior to 62d90a8e, titlebar's font height (and other related values)
would change any time any titlebar's content changed, so these values
were recalculated each time any titlebar's content changed (or a new
titlebar was created).

However, since the above was merge, these values no longer change so
often and we only need to recalculate them when the configured font
changes (and stop calling `config_update_font_height` each time
titlebars are rendered).

This commit removes all the unecessary calls to this function and avoids
all those unecessary calculations. Whenever the font strays from the
default value, the `font` command is called, and it calls
`config_update_font_height`, which is enough to keep the value always up
to date.

I've also added a default value to the `font_baseline` config, since
otherwise that's zero for setups that don't explicitly specify a font.
2021-09-20 09:25:47 +02:00
Ronan Pigott 00b10a93f1 commands: update split none command for a047b5ee4 2021-09-04 00:24:47 +02:00
Ronan Pigott de3c290427 command: implement split none 2021-09-03 23:50:20 +02:00
David Rosca 57d6f6f19e Add output modeline command
Only works with DRM backend.
2021-08-31 17:29:40 +02:00
Hugo Osvaldo Barrera 62d90a8e95 Use fixed titlebar heights
Use fixed titlebar heights. The default height is calculated based on
font metrics for the configured font and current locale.

Some testing with titles with emoji and CJK characters (which are
substantially higher in my setup) shows that the titlebars retain their
initial value, text does shift up or down, and all titlebars always
remain aligned.

Also drop some also now-unecessary title_height calculations.

Makes also needed to be updated, since they should be positioned with
the same rules.
2021-08-26 20:16:14 +02:00
Eric Engestrom b17cf58a4d cmd_bind_or_unbind_switch: fix copy/paste typo error message
`[0]` is the switch type, not its state; we want `[1]` for that, and
it's a string not an int :)
2021-08-14 10:46:17 +02:00
bR3iN c9458b9fb1 Add gaps <type> <scope> toggle <px> command
Add a subcommand for `gaps` that allows to toggle gaps at
runtime. This functionality is part of i3-gaps since [1]
but is missing in sway.

[1] https://github.com/Airblader/i3/pull/264
2021-07-22 10:12:33 +02:00
Simon Ser 4832fc937f Update wlr_box includes
Update for the breaking change in [1].

[1]: https://github.com/swaywm/wlroots/pull/3011
2021-07-07 11:29:14 +02:00
Ragnar Groot Koerkamp c0c4e260c4 Revert "Add workspace {prev,next}_on_output --create"
This reverts commit 487c83f0de.

The --create flag is undocumented, not in i3, and at least partially
broken (#5913), so this removes the feature.
2021-06-22 19:00:31 +02:00
Ragnar Groot Koerkamp d5c71231e5 Only call workspace_auto_back_and_forth when needed
Instead of disabling it for some workspace subcommands, this explicitly
calls it only in the 2 places it's actually needed: for switching to a
named or numbered workspace.
2021-06-18 16:15:02 +02:00
Ragnar Groot Koerkamp 3080f1b9ce Move auto_back_and_forth logic out of workspace_switch
This extracts the code to a separate workspace_auto_back_and_forth
function.
It also removes the bool argument by adding an extra if statement at the call
site, and repurposes the no_auto_back_and_forth variable to
auto_back_and_forth for simpler understanding.
2021-06-18 16:15:02 +02:00
Ragnar Groot Koerkamp 771cff23fb Fix #6299 Disable auto_back_and_forth for next_on_output
This forces no_auto_back_and_forth to true for `workspace
next_on_output` and `workspace prev_on_output` to keep parity with i3.
In i3, running next_on_output never changes focus to another output.
In Sway currently, with workspace_auto_back_and_forth set to yet,
running next_on_output on an output with only a single active workspace
will typically end up focussing the other output:
1. next_on_output focusses the current workspace, because it's the only
one
2. auto_back_and_forth focusses the last focussed workspace, because the
current workspace to focus is the current one. This will usually be on
the other monitor if the workspace there was last focussed.
2021-06-18 09:37:28 +02:00
Daniel Eklöf 1dd6df6a5d sway: commands: exec: restore SIGPIPE before exec:ing
Sway ignores SIGPIPE (by installing a SIG_IGN handler), in order to
“prevent IPC from crashing Sway”.

SIG_IGN handlers are the *only* signal handlers inherited in
sub-processes. As such, we should be a good citizen and restore
the SIGPIPE handler to its default handler.

Original bug report:
https://www.mail-archive.com/debian-bugs-dist@lists.debian.org/msg1806907.html
2021-06-05 11:50:11 +02:00
Daniel Otero b997147284 config: Fix swaybar pango_markup inconsistency
Until now, swaybar did not have pango markup enabled by default, even if
the sway config had it on. This patch aims to mimic the i3 behavior, but
maintaining the functionality of the "pango_markup" sway config command.
2021-06-03 14:18:23 +02:00
Bill Doyle cad6e59b93 Only defer seat attachment during initial startup
Deferred commands are only run once, during sway startup. This means
that deferring seat attachment based on whether we are reading the
config prevents devices from being reattached to the correct seat during
a config reload. Instead, only defer if the config is not yet active.

Fixes #6048.
2021-06-03 14:07:18 +02:00
Manuel Stoeckl 31b4b96ebf commands/exec: stop truncating >4095-byte commands 2021-05-10 10:57:58 +02:00
Ronan Pigott 137dbf3e6d cmd_fullscreen: ignore fullscreen request on workspaces 2021-05-10 10:30:44 +02:00
Simon Ser 31a2252e83 commands/exec_always: log error on execlp failure
And exit(1) instead of indicating success.
2021-04-22 23:12:49 +02:00
Simon Ser 7beeb9e61b Use execlp("sh") instead of execl("/bin/sh")
This stops assuming the POSIX shell command is located in /bin.
2021-04-22 23:12:49 +02:00
Michael Weiser 730efbc89c Prevent use-after-free on first bar subcommand error
If any error is encountered during execution of the first subcommand of
a freshly created bar configuration, parsing apparently is to be aborted
and the current bar config is freed. The pointer to that memory is left
dangling though, leading to a use-after-free on successive bar
subcommands. This quite reliably ends in a crash like so:

sway -c reproducer.config
00:00:00.083 [sway/config.c:865] Error on line 2 'foo bar': Unknown/invalid command 'foo' (s)
free(): double free detected in tcache 2
00:00:00.608 [swaynag/swaynag.c:451] failed to register with the wayland display
Aborted (core dumped)

Minimal reproducer config:
bar {
        foo bar
        position top
}

Other messages:
malloc(): unaligned fastbin chunk detected
double free or corruption (fasttop)

The invalid command has to be the first for a newly created bar config.
Removing the command or switching order so it's not the first one masks
the problem.

Prevent this from occuring by resetting the pointer to NULL after
freeing the memory.

Signed-off-by: Michael Weiser <michael.weiser@gmx.de>
2021-04-18 20:53:36 -07:00
Ronan Pigott ecfd687977 cmd_fullscreen: allow fullscreen on fullscreen split containers
Using the fullscreen command on a child of a fullscreen split
container will now fullscreen the child instead of unfullscreening
the parent.
2021-04-16 11:36:14 +02:00
Ivan Fedotov 346f5a9d14 Add toggle logic inside DPMS handler
Logic that obtains current DPMS state is put inside the handler.

sway_output from which the current DPMS state will be obtained is selected by the following logic:
* For '-' and '--' the focused output is used;
* For '*' error "Cannot apply toggle to all outputs" is reported;
* For everything else all_output_by_name_or_id() is used.

Fixes #5929.
2021-03-25 11:01:04 +01:00
ftilde 1afedcb94c Fix for_window criteria and mouse button bindings
Previously, the special case handling of scratchpad and unmark commands
was (probably accidentally) limited to criteria directly handled in the
execute_command function. This would exclude: 1. for_window criteria, as
these are handled externally for views and 2. and mouse bindings which
select target the node currently under the mouse cursor.

As a concrete example `for_window [app_id="foobar"] move scratchpad,
scratchpad show` would show (or hide due to the toggling functionality)
another window from the scratchpad, instead of showing the window with
app_id "foobar".

This commit replaces the "using_criteria" flag with "node_overridden"
with the more general notion of signifying that the node (and
container/workspace) in the current command handler context of the sway
config is not defined by the currently focused node, but instead
overridden by other means, i.e., criteria or mouse position.
2021-02-25 09:48:39 -05:00
lbonn c6e7cf1ae5 focus: beyond fullscreen when focused explicitly
When issuing a focus command on a specific container, users expect to
proceed it even if is hidden by a fullscreen window.

This matches the behavior of i3.
2021-02-25 09:40:20 -05:00
Kenny Levinsen a047b5ee4a container: Move pending state to state struct
Pending state is currently inlined directly in the container struct,
while the current state is in a state struct. A side-effect of this is
that it is not immediately obvious that pending double-buffered state is
accessed, nor is it obvious what state is double-buffered.

Instead, use the state struct for both current and pending.
2021-02-16 22:05:00 -05:00
Kenny Levinsen b5b628cb41 input: Only commit transactions when necessary
There is no need to check for transactions at the end of every user
input, as the vast majority of input will not issue transactions. This
implementation can also hide where changes are made without an
appropriate transaction commit, as a future unrelated input would issue
the commit instead.

Instead, commit transactions in places where changes are made or are
likely to be made.
2021-02-14 13:19:08 -05:00
Manuel Stoeckl cb3c727632 Declare all struct cmd_handler arrays const
And make the functions handling these arrays use const types.
2021-02-04 09:49:06 +01:00
Ronan Pigott d1bf3b8a86 cmd_move: update container representation in sibling swaps 2021-01-04 00:31:25 -05:00
Ronan Pigott 89ffeaae49 commands/move: reset geometry of promoted containers 2020-12-20 00:58:42 -05:00
Ronan Pigott 432c4df6e7 commands/move: squash workspace after directional con move 2020-12-20 00:58:42 -05:00
Ronan Pigott e95c299f0a commands/move: rework container_move_in_direction
This changes the move command to better match i3
behavior after the layout changes.

workspace_rejigger handled the case where containers would
escape their workspace in an orthogonal move by changing
the layout to accomodate them, but this case is now handled
within the loop.
2020-12-20 00:58:42 -05:00
Ronan Pigott b4850876dc Revert "commands/move: maintain workspace_layout when moving"
This is in preparation for changing the workspace_layout
command to work like it does in i3.

This reverts commit b4a75a1ab2.
2020-12-20 00:58:42 -05:00
Tudor Brindus 971aa90ccc commands/move: don't flatten on move; reap empty former parent instead
Some comparisons of current Sway versus i3 behavior:

1) T[T[T[app]]] + move left
* Sway: T[app]
* i3:   T[T[app]]

2) H[V[H[V[app]]]] + move left
* Sway: H[app]
* i3:   H[V[app]]

After this commit, Sway behavior matches i3. The intermediate states
are now:

    T[T[T[app]]] -> T[T[app T[]]] -> T[T[app]]
    H[V[H[V[app]]]] -> H[V[app H[V[]]]] -> H[V[app]]
2020-12-20 00:58:42 -05:00
Ronan Pigott d54c8e885b commands/layout: don't change the layout of workspaces with children
In i3 the layout command on a workspace affects the workspace layout
only on empty workspaces. Otherwise children are placed in a new
container with the desired layout to preserve the workspace layout.
2020-12-20 00:58:42 -05:00
Ronan Pigott 2478f2f010 container: don't split single children
In i3 splits are ineffective on singleton H/V containers,
and the command is interpreted to affect the parent layout
instead.
2020-12-20 00:58:42 -05:00
Tudor Brindus cc2c0d5966 input/cursor: unhide cursor on synthetic input
Fixes #5847.
2020-12-06 09:38:49 +01:00
Tudor Brindus 07042486c3 tree/container: introduce container_is_sticky[_or_child] functions
To query whether a container is sticky, checking `con->is_sticky` is
insufficient. `container_is_floating_or_child` must also return true;
this led to a lot of repetition.

This commit introduces `container_is_sticky[_or_child]` functions, and
switches all stickiness checks to use them. (Including ones where the
container is already known to be floating, for consistency.)
2020-11-11 20:43:58 -05:00
Tudor Brindus 60d95414d4 commands/focus: force container warp when fulfilling focus mode_toggle
This commit switches focusing behavior to force a warp when executing
`focus mode_toggle`.

Fixes #5772.
2020-11-01 03:43:00 -05:00
Tamir Zahavi-Brunner 96578aa91e hide_cursor: Add an option to hide when typing
Add an option for the `hide_cursor` command to hide the cursor when
typing, i.e. whenever a key is pressed.
2020-10-30 09:59:54 +01:00
Ronan Pigott d06c1ac1e9 commands/move: fix crash when moving sphsc child 2020-10-24 02:15:30 -04:00
Daniel De Graaf 1be66c98f2 commands/resize: don't consider 1px resizes to be invalid
A "resize shrink width 1px" will cause grow_x to be 0 while grow_width is -1,
incorrectly rejecting the command even though the resize is not a noop.  Fix
this by checking width/height instead of x/y.
2020-10-22 09:10:10 +02:00
Tudor Brindus ed247c031c input/tablet: add tool_mode option to set tablet tools as relative input
Closes #4139.
2020-10-12 15:01:37 +02:00
Tarmack 989123a2a5 Add support for workspace_min_width bar option. 2020-10-11 19:12:42 +02:00
Tudor Brindus 392d4808c3 commands/move: fix single-split escaping on move
Prior to this commit, having a layout like T[app1 V[app2]], focusing
app2, and then doing `move left` would result in T[app2 app1]. Now, the
resulting layout is T[app1 app2], which matches i3 behavior.

`container_flatten` updates `container->parent`, meaning that the
existing check would never be true.
2020-10-04 21:02:35 -04:00
Konstantin Pospelov fd216b3a81 exec: fix validation during config reload
Split cmd_exec_always into separate methods for general validation and
process creation. This fixes a potential call of join_args with 0 arguments.
2020-08-24 09:41:54 +02:00
Rex Hackbro 12a9ae013e fix force_display_urgency_hint parsing 2020-08-03 15:39:48 +02:00
Antonin Décimo bbf7b92fe4 Fix incorrect format specifiers 2020-07-30 22:02:42 -04:00