Commit graph

788 commits

Author SHA1 Message Date
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
Antonin Décimo 2960b2c9b6 cmd/bar/colors: fix dereference of null pointer
`!*rgba` tests if the first byte of rgba isn't `'\0'`.
`hex_to_rgba_hex` returns NULL if `parse_color` fails. There's a null
pointer dereference in that case. The intended behavior is `!rgba`.
2020-07-30 22:02:42 -04:00
Thayne McCombs b20d52f71d Use wlr_output_layout_output_at to get output for move to cursor 2020-07-27 11:27:47 +02:00
Thayne McCombs cfa403fc58 Keep windows in bounds on move to position mouse
If the mouse/cursor/pointer is near the edge of an output when a "move
position to pointer" command is run, then the floating container will be
constrained to fit inside the bounds of the output as much as possible.

This behavior matches what i3 does in this scenario. I also think it is
a better user experience.

Relates to #4906

The logic for the bounds check follows the implementation in i3: 7330778223/src/floating.c (L536)
2020-07-27 11:27:47 +02:00
Nils Schulte b513981378 added ppt unit to move position command 2020-07-21 10:07:01 +02:00
Nils Schulte 6898d1963f moved and renamed movement-unit parsing to common 2020-07-21 10:07:01 +02:00
Geoffrey Casper ea3ba203cc Reload command now matches i3's implementation 2020-07-07 17:15:57 -04:00
Tudor Brindus b4a75a1ab2 commands/move: maintain workspace_layout when moving
Fixes #5157.
2020-07-03 18:40:59 -04:00
Tudor Brindus 92891fb1ed commands/move: unwrap workspace container on move to new workspace
If moving e.g. `T[app app]` into a new workspace with `workspace_layout
tabbed`, then post-move the tree in that workspace will be `T[T[app
app]]`. This still happens with horizontal or vertical workspace layout,
but is less visible since those containers have no decorations.

Fixes #5426.
2020-07-01 18:43:20 -04:00
Tudor Brindus eeb90a7963 input_cmd_click_method: fix typo in error text 2020-06-19 22:48:53 +02:00
Brian Ashworth 8cdcb77e12 seat_cmd_cursor: emit frame events
This emits frame events for the seat_cmd_cursor subcommands. The
wl_pointer frame event are required to notify clients when to process
the events. It will now be emitted after cursor movement, button press,
button release, and axis events.
2020-05-29 15:37:40 -04:00
Michael Weiser 0f11aa037a commands: Add per-view shortcuts_inhibitor command
Add a separate per-view shortcuts_inhibitor command that can be used
with criteria to override the per-seat defaults. This allows to e.g.
disable shortcuts inhibiting globally but enable it for specific,
known-good virtualization and remote desktop software or, alternatively,
to blacklist that one slightly broken piece of software that just
doesn't seem to get it right but insists on trying.

Add a flag to sway_view and handling logic in the input manager that
respects that flag if configured but falls back to per-seat config
otherwise. Add the actual command but with just enable and disable
subcommands since there's no value in duplicating the per-seat
activate/deactivate/toggle logic here. Split the inhibitor retrieval
helper in two so we can use the backend half in the command to retrieve
inhibitors for a specific surface and not just the currently focused
one. Extend the manual page with documentation of the command and
references to its per-seat sibling and usefulness with criteria.

Signed-off-by: Michael Weiser <michael.weiser@gmx.de>
2020-05-13 21:22:16 -04:00
Simon Ser 83d769805c Restrict relative output transforms to runtime changes
Prevent them from being used in the config file.

This is a breaking config file change.

References: https://github.com/swaywm/sway/issues/5236
2020-04-21 14:52:17 +02:00
Di Ma c0bce9138b Fix a use-after-free error in switch binding 2020-04-14 19:41:30 -04:00
Di Ma 2bece94b9b Fix a use-after-free error in switch binding 2020-04-14 19:41:30 -04:00
Simon Ser b300bace0f Implement create_output command for headless backend 2020-04-14 16:06:20 +02:00
Linus Heckemann df48c48123 add --no-repeat option for bindings
This allows e.g. triggering one command while a key is held, then
triggering another to undo the change performed by it afterwards. One
use case for this is triggering push-to-talk functionality for VoIP
tools without granting them full access to all input events.

Fixes #3151
2020-03-30 14:18:27 +02:00
r-c-f 854497b242
check for workspace command name arg
* check for workspace command name arg (fix #5131)

For the 'workspace <name> output <output>' command, output_location must
be greater than zero or the attempt to get the workspace name with
join_args will segfault or abort() (depending on the flavor of
sway_assert() in use). This checks and returns an error instead.

* put workspace output error string on one line

To ease grepping as requested

* check for name in workspace gaps command as well

A malformed command here will lead to the same result seen in #5131, so
add a check. Done inside the cmd_workspace_gaps() function itself, to
take advantage of the existing 'Expected...' string.
2020-03-24 16:07:12 +01:00
Jason Nader 8b21bc6a79 commands/bind.c: remove unnecessary check 2020-03-15 14:30:05 +01:00
Michael Weiser 30e666f171 commands: Adjust style in cursors command
Remove some unnecessary brackets in an error condition check identified
during review of the shortcuts inhibitor command code (#5021).

Signed-off-by: Michael Weiser <michael.weiser@gmx.de>
2020-03-11 23:51:37 -04:00
Michael Weiser 3ee5aace33 commands: Add shortcuts_inhibitor command
Add a command to influence keyboard shortcuts inhibitors. In its current
form it can be used to activate, deactivate or toggle an existing
inhibitor on the surface currently receiving input. This can be used to
define an escape shortcut such as:

bindsym --inhibited $mod+Escape seat - shortcuts_inhibitor deactivate

It also allows the user to configure a per-seat default of whether
keyboard inhibitors are honoured by default (the default) or not. Using
the activate/toggle command they can then enable the lingering inhibitor
at a later time of their choosing.

As a side effect this allows to specifically address a named seat for
actions as well, whatever use-case that might serve.

Signed-off-by: Michael Weiser <michael.weiser@gmx.de>
2020-03-11 23:51:37 -04:00
Michael Weiser eeac0aa170 input: Add support for keyboard shortcuts inhibit
Adding support for the keyboard shortcuts inhibit protocol allows remote
desktop and virtualisation software to receive all keyboard input in
order to pass it through to their clients so users can fully interact
the their remote/virtual session. The software usually provides its own
key combination to release its "grab" to all keyboard input. The
inhibitor can be deactivated by the user by removing focus from the
surface using another input device such as the pointer.

Use support for the procotol in wlroots to add support to sway. Extend
the input manager with handlers for inhibitor creation and destruction
and appropriate bookkeeping. Attach the inhibitors to the seats they
apply to to avoid having to search the list of all currently existing
inhibitors on every keystroke and passing the inhibitor manager around.
Add a helper function to retrieve the inhibitor applying to the
currently focused surface of a seat, if one exists.

Extend bindsym with a flag for bindings that should be processed even if
an inhibitor is active. Conversely this disables all normal shortcuts if
an inhibitor is found for the currently focused surface in
keyboard::handle_key_event() since they don't have that flag set. Use
above helper function to determine if an inhibitor exists for the
surface that would eventually receive input.

Signed-off-by: Michael Weiser <michael.weiser@gmx.de>
2020-03-11 23:51:37 -04:00
Bor Grošelj Simić 27d5cf1316 input: implement cycling through keyboard layout list 2020-03-11 12:12:23 +01:00
Simon Ser 5d692b0581 Add an adaptive_sync output command
This enables/disables adaptive synchronization on the output.

For now, the default is disabled because it might cause flickering on
some hardware if clients don't submit frames at regular enough
intervals. In the future an "auto" option will only enable adaptive sync
if a fullscreen client opts-in via a Wayland protocol.
2020-03-07 00:32:04 +01:00
Torstein Husebø af294289b1 treewide: fix typos 2020-02-18 21:53:57 +01:00
Brian Ashworth ec7d3f181d input_cmd_events: add support for input types
This adds support for input type configs to input_cmd_events. This works
similar to the wildcard handling that existed where configs for the
devices are stored and the type config is reset to INT_MIN so that it
does not override.

This also condenses the toggle_send_events and
toggle_wildcard_send_events functions into a single function to reduce
code duplication.
2020-02-18 18:08:45 +01:00
Simon Ser ab00f7f319 Fix output transform rotation direction
This patch makes it so users that have configured their screen with a
transform don't have to update their config after the wlroots breaking
change.

References: https://github.com/swaywm/wlroots/pull/2023
2020-02-17 21:47:36 +01:00
Simon Ser a5a4d32816 Fix output transform anticlockwise
This wouldn't have any effect if the transform was flipped.
2020-02-17 21:47:36 +01:00
Brian Ashworth 7999845357 cmd_swap: fix test_mark condition
The condition in test_mark was checking the negation of list_seq_find.
This works fine for the first mark, but fails for every other mark. This
fixes the condition to check for anything other than -1, which is the
value returned from list_seq_find for index not found.
2020-02-13 10:26:14 +01:00
Brian Ashworth 33a984bbc5 config: fix validation exit code and log level
This makes it so invalid configs will return the exit code 1 when the
validation flag is given. This also reduces the log level to SWAY_ERROR,
which makes it so only the errors are shown. If someone wants more
verbose output, the can use the -V/--verbose or -d/--debug flags.
Additionally, this also makes it so swaybg will not be spawned when
validating the config.
2020-02-11 16:02:11 +01:00
Alex Maese 86ee240a4a Add ability to remove the floating modifier 2020-01-20 09:19:04 -07:00
Jason Nader a576bc27bf Check argc>0 before strcasecmp. Should shortcircuit 2020-01-18 10:36:03 +01:00
Jason Nader 450b40c635 commands/move: Fix crash when required args not provided
Fixes #4919.
2020-01-18 10:36:03 +01:00
Ronan Pigott 5501d14a2e cmd_split: Refuse to split scratchpad hidden split containers 2020-01-16 21:48:25 -05:00
Ronan Pigott 72ad35ba16 cmd_move: Fix crash when moving to scratchpad hidden split containers 2020-01-16 21:48:25 -05:00
Ronan Pigott d88d4bbd9d Fix crash when showing scratchpad hidden split containers 2020-01-16 21:48:25 -05:00
Ronan Pigott f68961fbe6 commands/split: Fix error message typos 2020-01-16 16:15:50 +01:00
Pedro Côrte-Real 8008344762 Avoid numerical instability in resize
Because the layout code rounds down the dimensions of the windows
resizing would often be off by one pixel. The width/height fraction
would not exactly reflect the final computed width and so the resize
code would end up calculating things wrong.

To fix this first snap the container size fractions to the pixel grid
and only then do the resize. Also use round() instead of floor() during
layout to avoid a slightly too small width. This applies in two cases:

1. For the container we are actually resizing using floor() might result
   in being 1px too small.
2. For the other containers it might result in resizing them down by 1px
   and then if the container being resized is the last all those extra
   pixels would make the resize too large.

Fixes #4391
2020-01-01 10:14:29 -07:00
Brian Ashworth de43f7c1db cmd_client_*: support optional args for i3 compat
For i3 compatibility, allow the indicator and child_border colors values
to be optional. The indicator will fallback to sane defaults and
child_border will fallback to the background color for the class.
2019-12-29 10:40:06 +01:00
Brian Ashworth f898ca9a83 bar_cmd_colors: remove add_color
This is the third commit in a series of commits to refactor color
handling in sway. This removes add_color from commands.c. It was only
being used by bar_cmd_colors. This also changes the functions to use
parse_color which is used to validate rgb(a) colors throughout the code
base and is also what i3bar is using to parse the colors after they are
passed over ipc. After parsing the color and ensuring it is valid, the
rgba hex string is then generated using snprintf. This refactor also
ensures that all the colors for the command are valid before applying
any of them.
2019-12-28 10:07:25 +01:00
Brian Ashworth 66dc33296c cmd_client_*: refactor duplicated code
This is the second in a series of commits to refactor the color handling
in sway. This removes the duplicated color parsing code in
sway/commands/client.c. Additionally, this combines the parsing of
colors to float arrays with that in sway/config.c and introduces a
color_to_rgba function in commom/util.c.

As an added bonus, this also makes it so non of the colors in a border
color class will be changed unless all of the colors specified are
valid. This ensures that an invalid command does not get partially
applied.
2019-12-28 10:07:25 +01:00
Brian Ashworth 452a615bb8 seat_cmd_keyboard_grouping: change keymap to smart
This removes `seat <seat> keyboard_grouping keymap` and replaces it with
`seat <seat> keyboard_grouping smart`. The smart keyboard grouping will
group based on both the keymap and repeat info. The reasoning for this
is that deciding what the repeat info should be for a group is either
arbitrary or non-deterministic when multiple keyboards in the group have
repeat info configured (unless somehow exposed to the user in a
reproducible uniquely identifiable fashion).
2019-12-16 12:03:11 -05:00
Drew DeVault 2f3c6cccf5 Add seat <seat> idle_{inhibit,wake} <sources...>
This adds seat configuration options which can be used to configure what
events affect the idle behavior of sway.

An example use-case is mobile devices: you would remove touch from the
list of idle_wake events. This allows the phone to stay on while you're
actively using it, but doesn't wake from idle on touch events while it's
sleeping in your pocket.
2019-12-12 10:37:30 -05:00