This adds a libinput_config change type to the input event for when
the libinput config for a device changes
In order for this to be possible to track, the libinput config code
had to be refactored. It is now extracted into a separate file to
isolate it from the rest of the input management code.
This adds an ipc event related to input devices. Currently the
following changes are supported:
- added: when an input device becomes available
- removed: when an input device is no longer available
- xkb_keymap_changed: (keyboards only) the keymap changed
- xkb_layout_changed: (keyboards only) the effective layout changed
Adds a new commend "xkb_file", which constructs the internal
xkb_keymap from a xkb file rather than an RMLVO configuration.
This allows greater flexibility when specifying xkb configurations.
An xkb file can be dumped with the xkbcomp program.
Instead of tracking gaps per child apply gaps in two logical places:
1. In tiled containers use the layout code to add the gaps between
windows. This is much simpler and guarantees that the sizing of children
is correct.
2. In the workspace itself apply all the gaps around the edge. Here
we're in the correct position to size inner and outer gaps correctly and
decide on smart gaps in a single location.
Fixes#4296
Because meson does not provide a simple way to get the relative build
path, it is computed with a pair of foreach loops. As meson does not
have a simple way to compute string length (except via underscorify
and 63 split operations), the build script uses a shell command
instead.
If the compiler does not suppot -fmacro-prefix-map, then fall back
to passing in the relative path prefix, and use its length to offset
the uses of __FILE__ in log messages so that the build path is at
least still not included in the logs. This is significantly more
efficient than calling _sway_strip_path.
Instead of using container->width/height as both the input and output
of the layout calculation have container->width_fraction/height_fraction
as the share of the parent this container occupies and calculate the
layout based on that. That way the container arrangement can always be
recalculated even if width/height have been altered by things like
fullscreen.
To do this several parts are reworked:
- The vertical and horizontal arrangement code is ajusted to work with
fractions instead of directly with width/height
- The resize code is then changed to manipulate the fractions when
working on tiled containers.
- Finally the places that manipulated width/height are adjusted to
match. The adjusted parts are container split, swap, and the input
seat code.
It's possible that some parts of the code are now adjusting width and
height only for those to be immediately recalculated. That's harmless
and since non-tiled containers are still sized with width/height
directly it may avoid breaking other corner cases.
Fixes#3547Fixes#4297
This adds a --reload flag to cmd_bindswitch that allows for the binding
to be executed on reload. One possible use case for this is to allow
users to disable outputs when the lid closes and enable them when the
lid opens without having to open and re-close the lid after a reload.
Without this change, the handlers listed in the config_handlers or
command_handlers arrays (depending on reading or active) in commands.c
would be valid subcommands. To make matters worse, they would also take
precedence over the defined subcommand handlers.
This corrects find_handler to only work on the handler array given
instead of implicitly trying others.
Currently container_replace removes the container from the scratchpad
and re-adds it afterwards. For the split commands this results in the
container being send to the scratchpad, which results in a NULL segfault
if the same container should be shown.
Pass an optional workspace to root_scratchpad_add_container, if the
workspace is passed the window will continue to show on the workspace.
If NULL is passed it is sent to the scratchpad.
This was an issue if no other window except the scratchpad container was
on the workspace.
Fixes#4240
This adds the logic to defer binding execution while sway is still
initializing. Without this, the binding command would be executed, but
the command handler would return CMD_DEFER, which was being treated as
a failure to run. To avoid partial executions, this will defer all
bindings while config->active is false.
This patch fixes faulty command parsing introduced by
f0f5de9a9e. When that commit allowed
criteria reset on ';' delimeters in commands lists, it failed to account
for its inner ','-parsing loop eating threw the entire rest of the
string.
This patch refactors argsep to use a list of multiple separators, and
(optionally) return the separator that it matched against in this
iteration via a pointer. This allows it to hint at the command parser
which separator was used at the end of the last command, allowing it to
trigger a potential secondary read of the criteria.
Fixes#4239
This allows for an optional validation stage when storing an input
config. Currently, only the xkb keymap is validated. If storing the
delta input config will result in any invalid xkb keymaps, the input
config will not be stored and error will be populated with the first
line of the xkbcommon log.
Before the delta input config is stored, this attempts to compile a
keymap with it. If the keymap fails to compile, then the first line of
the xkbcommon log entry will be included with a `CMD_FAILURE`, the
entire xkbcommon log entry will be included in the sway error log, and
the delta will not be stored.
This only handles basic issues such as a layouts not existing. This
will NOT catch more complex issues such as when a variant does
exist, but not for the given layout (ex: `azerty` is a valid variant,
but the `us` layout does not have a `azerty` variant).
New 'seat <name> xcursor_theme <theme> [<size>]' command that
configures the default xcursor theme.
The default seat's xcursor theme is also propagated to XWayland, and
exported through the XCURSOR_THEME and XCURSOR_SIZE environment
variables. This is done every time the default seat's configuration is
changed.
Subsurfaces need access to the parent get_root_coords impl for positioning in
popups. To do this, we store a reference to the parent view_child where
applicable.
Fixes#4191.
This attempts to use the default keymap when the one defined in the
input config fails to compile. The goal is to make it so the keyboard
is always in a usable state, even if it is not the user's requested
settings as usability is more important.
This also removes the calls to `getenv` for the `XKB_DEFAULT_*` family
of environment variables. The reasoning is libxkbcommon will fallback
to using those (and then the system defaults) when any of the rule
names are `NULL` or an empty string anyway so there is no need for
sway to duplicate the efforts.
* `bindsym --to-code` enables keysym to keycode translation.
* If there are no `xkb_layout` commands in the config file, the translation
uses the XKB_DEFAULT_LAYOUT value.
* It there is one or more `xkb_layout` command, the translation uses
the first one.
* If the translation is unsuccessful, a message is logged and the binding
is stored as BINDING_KEYSYM.
* The binding keysyms are stored and re-translated when a change in the input
configuration may affect the translated bindings.
The new upstream is https://github.com/swaywm/swaybg
This commit also refactors our use of gdk-pixbuf a bit, since the only
remaining reverse dependency is swaybar tray support.
This allows swaybar to become visible when the mode changes (to any
mode other than the default). swaybar will be hidden again when the
modifier is pressed and released or when switching back to the default
mode.
This also applies the same logic to visible by urgency to hide swaybar
when the modifier is pressed and released.
These changes are to match i3's behavior.
This revamps the type configs for swaynag. All sizing attributes for
swaynag are now `ssize_t` instead of `uint32_t` to allow for a default
value of `-1`, which allows for `0` to be a valid value. Additionally,
the initialization of the type configs has been changed from a simple
calloc to use a new function `swaynag_type_new`. `swaynag_type_new`
calloc's the memory, checks for an allocation failure, sets the name,
and all sizes to -1. The layering order has also been changed to
default, general config, type config, and as highest priority command
line arguments. Finally, `swaynag_type_merge` has been modified to
handle the layering and sizing changes.
This adds a 3 second timeout to the initial reply in swaymsg. This
prevents swaymsg from hanging when `swaymsg -t get_{inputs,seats}` is
used in i3. The timeout is removed when waiting for a subscribed event
or monitoring for subscribed events.
This also adds type checks to commands where i3 does not reply with all
of the properties that sway does (such as `modes` in `get_outputs`).
This is mostly just a behavioral adjustment since swaymsg should run on
i3. When running under i3, some command reply's (such as the one for
`get_outputs) may have more useful information in the raw json than the
pretty printed version.
Add support for configurations that apply to a type of inputs
(i.e. natural scrolling on all touchpads). A type config is
differentiated by a `type:` prefix followed by the type it
corresponds to.
When new devices appear, the device config is merged on top of its
type config (if it exists). New type configs are applied on top of
existing configs.
Use libinput_device_config_tap_get_finger_count to determine whether
a pointer is a touchpad.
swaymsg is also updated to reflect the new touchpad type.
When setting fullscreen on a hidden scratchpad container, there was a
check to see if there was an existing fullscreen container on the
workspace so it could be fullscreen disabled first. Since the workspace
is NULL, it would cause a SIGSEGV. This adds a NULL check to avoid the
crash.
This also changes the behavior of how fullscreen is handled when adding
a container to the scratchpad or changing visibility of a scratchpad
container to match i3's. The behavior is as follows:
- When adding a container to the scratchpad or hiding a container back
into the scratchpad, there is an implicit fullscreen disable
- When setting fullscreen on a container that is hidden in the
scratchpad, it will be fullscreen when shown (and fullscreen disabled
when hidden as stated above)
- When setting fullscreen global on a container that is hidden in the
scratchpad, it will be shown immediately as fullscreen global. The
container is not moved to a workspace and remains in the
scratchpad. The container will be visible until fullscreen disabled
or killed. Since the container is in the scratchpad, running
`scratchpad show` or `move container to scratchpad` will have no
effect
This also changes `container_replace` to transfer fullscreen and
scratchpad status.
This honors the fullscreen output request for
`xdg_toplevel_set_fullscreen` and `zxdg_toplevel_v6_set_fullscreen`.
If the request was sent before mapping, the fullscreen output request
will be retrieved from the client_pending state for the toplevel. The
output will be passed to `view_map` and if there is a workspace on the
output, the view will be placed on that workspace.
If the request comes in after being mapped, the view will be moved to
the workspace on the output (if there is one) before becoming
fullscreen.
This makes it so there will only be one swaybg instance running
instead of one per output. swaybg's cli has been changed to a xrandr
like interface, where you select an output and then change properties
for that output and then select another output and repeat. This also
makes it so swaybg is only killed and respawned when a background
changes or when reloading.
This matches i3's behavior of setting scratchpad containers to 50% of
the workspace's width and 75% of the workspace's height, bound by the
minimum and maximum floating width/height.
This fixes a crash in `container_init_floating` when a xwayland view
sends a configure request while in the scratchpad.
`container_init_floating` gets called so the configured minimum and
maximum sizes gets respected when resizing to the requested size. Since
the workspace was NULL, it would SIGSEGV when attempting to get the
workspace's output for the output box retrieval.
This extracts the resizing portion of `container_init_floating` into a
separate function. If the container is in the scratchpad, it will just
be resized and skip the centering.
Additionally, `container_init_floating` has been renamed to
`container_floating_resize_and_center` to more accurately describe what
it does.
This implements the following command to set/unset a user idle
inhibitor for a view:
`inhibit_idle focus|fullscreen|open|none|visible`
The modes are as follows:
- focus: inhibited when the view is focused by any seat
- fullscreen: inhibited when the view is fullscreen (or a descendant of
a fullscreen container) and is visible on any output
- open: inhibited until the view is closed or the inhibitor is unset or
changed
- none: unsets any user set idle inhibitors for the view
- visible: inhibited when the view is visible on any output
This should have no effect on idle inhibitors set by the applications
themselves and those should still work as intended.
Since this operates on the view in the handler context, it is possible
to set it on the currently focused view, on any existing view with
criteria, or for any future view with for_window.
Many laptop screens report unknown subpixel order. Allow users to manually set subpixel hinting to work around this.
Addresses https://github.com/swaywm/sway/issues/3163
This change adds support for renaming a workspace when `exec` command
is being processed by keeping sway_workspace and pid_workspace names in
sync.
The change can be verified by running following command:
swaymsg exec <application>; swaymsg rename workspace number 1 to 5
Fixes: #3952
This fixes the behavior of `__focused__` when there is no focused view
to match i3's behavior of successfully matching no views instead of
returning an error of a missing value. It also applies the same logic
when a token is not applicable (or unset) for a view such as `app_id`
for a focused xwayland view or `class` for a focused xdg-shell view.
This adds an `autofail` boolean to `struct criteria`. If it is set to
`true`, then `criteria_matches_view` will immediately bail out as a
no match. If `autofail` is set, the criteria will also not be
considered empty by `criteria_is_empty`.
To set this new `autofail` property, `get_focused_prop` will now take
in a boolean pointer of the same name. If `__focused__` is supported
for the token and there is no focused view or the focused view does not
have a value for the token, then the boolean will be set to true. In
`parse_token`, the boolean value will be checked and if set to true,
then `criteria->autofail` will be set to true and `parse_token` will
bail successfully. Tokens will still be parsed to make sure the whole
criteria is syntactically valid, which is also why
`&criteria->autofail` is not passed to `get_focused_prop` and a local
boolean is declared in `parse_token`.