Commit graph

1240 commits

Author SHA1 Message Date
John Chadwick 7e420cb6e4 input: Add support for tablet protocol.
Sway has basic support for drawing tablets, but does not expose
properties such as pressure sensitivity. This implements the wlr tablet
v2 protocol, providing tablet events to Wayland clients.
2019-09-25 23:10:33 -04:00
Aleksis 982e01f46c remove unused layer shell surface variable 2019-09-07 20:22:54 +03:00
Brian Ashworth 1fd2c6ba49 swaybar: complete barconfig_update event handling
This adds complete support for the barconfig_update ipc event. This also
changes the bar command and subcommand handlers to correctly emit the
event. This makes it so all bar subcommands other than id and
swaybar_command are dynamically changeable at runtime. sway-bar.5 has
been updated accordingly
2019-09-04 16:48:50 -10:00
Ben Brown b46c53957f Fix typo for the force/immediate option in xwayland_mode enum 2019-09-02 17:06:38 +03:00
Brian Ashworth ff7d979d99 cmd_xwayland: add force for immediate launch
This just adds a force option to cmd_xwayland that allows for xwayland
to be immediately launched instead of lazily launched. This is useful
for slower machines so it can be part of the startup time instead of
when the user is actively trying to use it
2019-08-20 11:34:34 +09:00
Brian Ashworth 384afc5cb5 input/keyboard: send released only if pressed sent
This keeps track of whether surfaces received a key press event and
will only send a key release event if the pressed event was sent. This
also requires changing the keycodes that are sent via wl_keyboard_enter
to only include those that were previously sent. This makes it so
surfaces do not receive key release events for keys that they never
received a key press for and makes it so switching focus doesn't leak
keycodes that were consumed by bindings.
2019-08-20 11:14:56 +09:00
Simon Ser 7488d33d42 Remove xdg-shell v6 support
All major toolkits and apps have gained xdg-shell stable support.

Closes: https://github.com/swaywm/sway/issues/3690
2019-08-20 10:57:20 +09:00
Drew DeVault cb8f68d74b layer-shell: add support for popups 2019-08-14 22:10:05 +03:00
Brian Ashworth 8ee054b1b9 bindsym/code: add group support
This adds support for specifying a binding for a specific group. Any
binding without a group listed will be available in all groups. The
priority for matching bindings is as follows: input device, group, and
locked state.

For full compatibility with i3, this also adds Mode_switch as an alias
for Group2. Since i3 only supports this for backwards compatibility
with older versions of i3, it is implemented here, but not documented.
2019-08-01 18:54:58 +03:00
Simon Ser f984f21b6a Remove all wayland-server.h includes
The documentation for wayland-server.h says:

> Use of this header file is discouraged. Prefer including
> wayland-server-core.h instead, which does not include the server protocol
> header and as such only defines the library PI, excluding the deprecated API
> below.

Replacing wayland-server.h with wayland-server-core.h allows us to drop the
WL_HIDE_DEPRECATED declaration.

This commit si similar to wlroots' ca45f4490ccc ("Remove all wayland-server.h
includes").
2019-07-27 17:16:56 -04:00
Ashkan Kiani e4bba906b6 Avoid adding duplicate criteria for no_focus and command 2019-07-27 03:53:05 +03:00
Brian Ashworth 1a16262903 ipc: add input::libinput_config event
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.
2019-07-23 20:45:46 +03:00
Brian Ashworth 6effca7b61 ipc: add an input event
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
2019-07-23 20:45:46 +03:00
Ed Younis eb770e88b7 Implement input_cmd_xkb_file (#3999)
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.
2019-07-17 19:26:58 -04:00
Josef Gajdusek ac87df23ea Update output manager on layout change
The output manager config was not properly updated if the position
of the output got changed.
2019-07-17 19:36:15 +03:00
Pedro Côrte-Real 44c2fafa4f Sanity check gaps between tiled containers
When the gaps become too large for the space available gracefully
reduced them all the way to 0 if needed.

Fixes #4294
2019-07-15 23:46:27 -04:00
Pedro Côrte-Real d0233af3b3 Rework gaps code to be simpler and correct
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
2019-07-15 23:46:27 -04:00
Manuel Stoeckl 2dc4978d8a Use -fmacro-prefix-map to strip build path
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.
2019-07-15 16:35:50 -04:00
Pedro Côrte-Real e3a3917d3a Layout tiled using a width/height fraction
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 #3547
Fixes #4297
2019-07-14 11:13:55 -04:00
Brian Ashworth 152e30c374 cmd_bindswitch: add option to execute on reload
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.
2019-07-09 10:00:57 +03:00
Sebastian Parborg 538b36c0e2 Make mouse drag in tiled mode swap containers if no edge is selected
Now the highlighted center area of containers triggers a swap action
instead of moving around the containers.
2019-07-09 02:56:55 -04:00
Sergei Dolgov 01ec18e802 Add calibration_matrix config option
Can be used to change the orientation of a touchscreen.

Example usage with swaymsg:

    # identity
    swaymsg input type:touch calibration_matrix '"1 0 0 0 1 0"'

    # 90 degree clockwise
    swaymsg input type:touch calibration_matrix '"0 -1 1 1 0 0"'

    # 180 degree clockwise
    swaymsg input type:touch calibration_matrix '"-1 0 1 0 -1 1"'

    # 270 degree clockwise
    swaymsg input type:touch calibration_matrix '"0 1 0 -1 0 1"'

Documentation:

    https://wayland.freedesktop.org/libinput/doc/latest/absolute-axes.html#calibration-of-absolute-devices
2019-07-05 18:41:56 +03:00
Brian Ashworth c346c020bf config: fix find_handler logic
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.
2019-06-20 10:13:58 +03:00
Rouven Czerwinski ddad41f423 Fix sway crashes for scratchpad layouts
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
2019-06-16 12:29:16 -04:00
Brian Ashworth 9670ccee68 bindings: defer while initiailizing
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.
2019-06-12 07:56:41 +03:00
Matt Coffin 2b5bf78faf Fix segfaults caused by faulty command parsing
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
2019-06-11 14:40:36 -04:00
Simon Ser 2bccb387d8 Add a new xkb_switch_layout command
This allows users to programatically change the active layout.
2019-06-09 15:20:14 -04:00
Brian Ashworth 5b1a8d62b9 config/input: validate xkb keymap before storing
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.
2019-06-09 20:13:22 +03:00
Brian Ashworth be2d2a299a commands/input: perform basic keymap validation
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).
2019-06-09 20:13:22 +03:00
Daniel Eklöf 190546fd31 add seat sub command 'xcursor_theme'
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.
2019-06-05 11:00:10 -04:00
Kenny Levinsen 4925882920 Use parent get_root_coords in subsurfaces
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.
2019-05-30 14:25:07 -04:00
Josef Gajdusek b3a5effef2 Implement wlr-output-management-v1 2019-05-24 18:59:14 +03:00
Brian Ashworth 23c64ab22d input/keyboard: attempt default keymap on failure
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.
2019-05-14 08:23:26 -06:00
Moelf ed2e553b8d Implement output toggle
discussed in #4136, this can't handle wildcard but won't crash.
2019-05-14 00:11:04 -04:00
Brian Ashworth 18ce0eec60 Spawn swaybar as a wayland client
This just makes it so swaybar is handled as a wayland client
2019-05-12 11:02:42 +03:00
Konstantin Pospelov c42497aca0 bindsym: change xkb_rule_names initialization 2019-04-26 20:56:48 +03:00
Konstantin Pospelov ddf63ffabe bindsym: consider xkb_rule_names for --to-code 2019-04-26 20:56:48 +03:00
Konstantin Pospelov f1609abe4c config: simplify keysym translation fields
Do not store `xkb_keymap` since it can be retrieved from `xkb_state`.
2019-04-26 20:56:48 +03:00
Konstantin Pospelov a09c144b8b Implement bindsym --to-code
* `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.
2019-04-26 20:56:48 +03:00
Drew DeVault 236ca63419 swaybg: split into standalone project
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.
2019-04-25 18:44:28 +03:00
Brian Ashworth dc7a3930a7 swaybar: add multiseat support
This just adds multiseat support to swaybar
2019-04-24 07:16:37 -06:00
Brian Ashworth 583ceff6f6 swaybar: hide mode visibility improvements
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.
2019-04-24 07:14:48 -06:00
Brian Ashworth 9099adbbe6 swaynag: revamp type configs
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.
2019-04-20 09:14:41 -06:00
Alex Maese 35ddd9aab3 Add unbindsym/unbindcode command for swaybar 2019-04-17 23:29:43 -04:00
Alex Maese 8d4f8aea46 Add unbindswitch command 2019-04-17 23:29:43 -04:00
Alex Maese 852f1f0b34 Create unbindsym and unbindcode commands 2019-04-17 23:29:43 -04:00
Brian Ashworth d7d29fe546 swaymsg: add timeout and type checks
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.
2019-04-17 09:07:08 +03:00
Connor E b2cfcebef6 Add deprecation warnings for new_float, new_window, and force_focus_wrapping. 2019-04-14 20:44:12 -04:00
Benjamin Cheng bd3720585e Implement input type configs (#3784)
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.
2019-04-14 19:31:36 -04:00
Benjamin Cheng 6737b90cb9 Add heuristics to differentiate touchpads
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.
2019-04-14 19:31:36 -04:00