aboutsummaryrefslogtreecommitdiff
path: root/sway/commands.c
AgeCommit message (Collapse)Author
2020-02-04criteria: match containers without viewAnders
Closes #4929 Replaces criteria_get_views with criteria_get_containers which can return containers without views when the criteria only contains container properties.
2019-12-28bar_cmd_colors: remove add_colorBrian Ashworth
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-11-17view: add max_render_timeIvan Molodetskikh
2019-11-01Fix various memory leakslbonn
Found with clang-tidy
2019-08-22ipc: collapse multi-container command resultsLaurent Bonnans
Match i3's behavior and only return one status response per command, even if it applies to several nodes. Also returns an error if the criteria returns an empty match. Closes #4483
2019-06-20config: fix find_handler logicBrian Ashworth
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-11Fix segfaults caused by faulty command parsingMatt Coffin
This patch fixes faulty command parsing introduced by f0f5de9a9e87ca1f0d74e7cbf82ffceba51ffbe6. 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-05criteria: reset on semicolon separationBrian Ashworth
This matches i3's behavior of only retaining criteria across comma separated commands. When separating commands with a semicolon, the criteria is reset and allows for new criteria to be set, if desired.
2019-04-17Add unbindswitch commandAlex Maese
2019-04-17Create unbindsym and unbindcode commandsAlex Maese
2019-04-14Add deprecation warnings for new_float, new_window, and force_focus_wrapping.Connor E
2019-03-24Implement inhibit_idle commandBrian Ashworth
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.
2019-03-24Fix #3924Philipe Goulet
Removes "unescape_string(argv[i]);". Since "do_var_replacement(argv[i])" never adds escape characters, it is both wrong and unnecessary to remove escape characters on the next line. This caused characters that were meant to be escaped to not be anymore.
2019-03-19Support WLR_INPUT_DEVICE_SWITCH in swayRyan Walklin
This commit adds support for laptop lid and tablet mode switches as provided by evdev/libinput and handled by wlroots. Adds a new bindswitch command with syntax: bindswitch <switch>:<state> <command> Where <switch> is one of: tablet for WLR_SWITCH_TYPE_TABLET_MODE lid for WLR_SWITCH_TYPE_LID <state> is one of: on for WLR_SWITCH_STATE_ON off for WLR_SWITCH_STATE_OFF toggle for WLR_SWITCH_STATE_TOGGLE (Note that WLR_SWITCH_STATE_TOGGLE doesn't map to libinput and will trigger at both on and off events)
2019-03-15Fix quoting of commands passed to for_windowminus
E.g. `for_window [class="mpv"] move container to output "Dell Inc. ..."` does not work because the executed move command only uses `Dell` as output name.
2019-02-26execute_command: do not strip qoutes for cmd_modeBrian Ashworth
`cmd_mode` performs its own quote stripping for the mode string to avoid double stripping quotes for `cmd_bindcode` and `cmd_bindsym` in `config_command` and `execute_command`. Stripping quotes in `execute_command` for `cmd_mode` will also result in double stripping, which will cause issues for any mode string with spaces, such as pango markup.
2019-02-05Fix quote strippingemersion
Let's not use !strcmp(…) anymore.
2019-02-05execute_command: dont strip quotes for exec_alwaysBrian Ashworth
This removes quote stripping for `exec_always` in `execute_command`. Since `exec_always` commands will be deferred in the config and processed by `execute_command`, the quotes need to be left intact like they are for `exec`.
2019-01-31pointer_constraint: change to a seat subcommandBrian Ashworth
This changes the `pointer_constraint` command to be a subcommand of seat to allow for per-seat settings. The current implementation that is not a seat subcommand will only operate on the current seat and will segfault in the config due to `config->handler_context.seat` only being set at runtime. This also allows for the wildcard identifier to be used to alter the pointer constraint settings on all seats and allows for the setting to be merged with the rest of the seat config.
2019-01-30Add pointer_constraint commandDrew DeVault
2019-01-23Make json-c include respect pkg-config --cflagsJan Beich
json-c.pc contains `Cflags: -I${includedir}/json-c`, so `<json-c/json.h>` won't be found unless the parent directory is searched by default.
2019-01-21Replace wlr_log with sway_logM Stoeckl
This commit mostly duplicates the wlr_log functions, although with a sway_* prefix. (This is very similar to PR #2009.) However, the logging function no longer needs to be replaceable, so sway_log_init's second argument is used to set the exit callback for sway_abort. wlr_log_init is still invoked in sway/main.c This commit makes it easier to remove the wlroots dependency for the helper programs swaymsg, swaybg, swaybar, and swaynag.
2019-01-14Remove now-unused "input" argument of cmd_results_newM Stoeckl
Patch tested by compiling with `__attribute__ ((format (printf, 2, 3)))` applied to `cmd_results_new`. String usage constants have been converted from pointers to arrays when encountered. General handler format strings were sometimes modified to include the old input string, especially for unknown command errors.
2019-01-14Remove 'input' field of IPC command return jsonM Stoeckl
This field is not in i3 and provides imprecise and redundant information. (Specifically, when swaymsg is given a list of commands, the IPC return array already indicates precisely which number command failed; knowing the name of the command is not useful when multiple commands of the same type are provided.)
2019-01-13Merge pull request #3144 from emersion/cmd-xwaylandDrew DeVault
Add xwayland command
2019-01-08Merge pull request #3275 from ianyfan/remove-readlineemersion
Rewrite strip_whitespace and remove readline.c
2019-01-02Implement tiling_drag_thresholdBrian Ashworth
Implements `tiling_drag_threshold <threshold>` to prevent accidental dragging of tiling containers. If a container (and all of its descendants) are unfocused and the tile bar is pressed, a threshold will be used before actually starting the drag. Once the threshold has been exceeded, the cursor will change to the grab icon and the operation will switch from `OP_MOVE_TILING_THRESHOLD` to `OP_MOVE_TILING`.
2019-01-01stringop.c: rewrite strip_whitespaceIan Fan
2018-12-30hide_cursor: change to a seat subcommandBrian Ashworth
This makes hide_cursor a seat subcommand, which allows for seat specific timeouts.
2018-12-29Revamp seat configsBrian Ashworth
This makes seat configs work like output and input configs do. This also adds support for wildcard seat configs. A seat config is still created in the main seat command handler, but instead of creating a new one in the subcommands and destroying the main seat command's instance, the seat subcommands modify the main one. The seat config is then stored, where it is merged appropriately. The seat config returned from `store_seat_config` is then applied. When attempting to apply a wildcard seat config, a seat specific config is queried for and if found, that is used. Otherwise, the wildcard config is applied directly. Additionally, instead of adding input devices to the default seat directly when there is no seat configs, a seat config for the default seat is created with only fallback set to true, which is more explicit. It also fixes an issue where running a seat command at runtime (with no seat config in the sway config), would result in all input devices being removed from the default seat and leaving sway in an unusable state. Also, instead of checking for any seat config, the search is for a seat config with a fallback option seat. This makes it so if there are only seat configs with fallback set to -1, the default seat is still created since there is no explicit notion on what to do regarding fallbacks. However, if there is even a single fallback 0, then the default seat is not used as a fallback. This will be needed for seat subcommands like hide_cursor where the user may only want to set that property without effecting anything else.
2018-12-25Implement hide_cursor <timeout> commandBrian Ashworth
Allows the cursor to be hidden after a specified timeout in milliseconds
2018-12-09Cleanup list codeIan Fan
2018-12-05Fix command list executionmwenzkowski
Determine the container/workspace a command is run on, each time when a command of the command list will be run. Previously the container/workspace was determined only once at the beginning of command list execution, which led to wrong behaviour because commands wouldn't take into account when a previous command changed the focused container.
2018-11-28Merge pull request #3204 from RedSoxFan/cmd-res-listemersion
Change execute_command to return a list of results
2018-11-28Do not strip quotes for cmd_modeBrian Ashworth
Like with cmd_bindsym and cmd_bindcode, the quotes should not be stripped for cmd_mode. cmd_mode performs its own stripping for the mode name and the only valid subcommands are cmd_bindsym and cmd_bindcode.
2018-11-27Change execute_command to return a list of resultsBrian Ashworth
This matches i3's behavior of returning a list of results that contain the result of each command that was executed. Additionally, the `parse_error` attribute has been added to the IPC JSON reply.
2018-11-25Implement title alignmentBrian Ashworth
This adds support for `i3 4.16`'s ability to set the title alignment. The command is `title_align left|center|right`. When the title is on the right, marks are moved to the left. Otherwise, they are on the right.
2018-11-22Adding commands for configuring titlebar borders and paddingFlorent de Lamotte
2018-11-19Add xwayland commandemersion
2018-11-10Alter config variable replacement processBrian Ashworth
Currently, variables cannot contain commands and cannot span more than one argument. This is due to variable replacement happening after determining the handler and after splitting the config line into arguments. This changes the process to: 0. Check for empty lines and block boundaries 1. Split the arguments as before 2. Verify that the first argument is not a variable. If needed the following occurs a. Perform variable replacement on just the first argument b. Join the arguments back together then split the arguments again. This is needed when the variable contains the command and arguments for the command. 3. Determine the handler 4. If the handler is cmd_set, escape the variable name so that it does not get replaced 5. Join the arguments back together, do variable replacement on the full command, and split the arguments again 6. Perform any needed quote stripping or unescaping on arguments 7. Run the command handler This allows for config snippets such as: ``` set $super bindsym Mod4 $super+a exec some-command ``` and ``` set $bg bg #ffffff solid_color output * $bg ```
2018-10-23commands: replace EXPECTED_LESS_THAN with EXPECTED_AT_MOSTIan Fan
This makes it a bit more obvious what the expected number of arguments is.
2018-10-23commands: clean-up checkarg functionIan Fan
Consolidates logic and fixes mistake that used argc instead of val for determining plural.
2018-10-23commands: remove EXPECTED_MORE_THANIan Fan
Its uses have been replaced with EXPECTED_AT_LEAST.
2018-10-20Remove raise_floating directiveRyan Dwyer
The directive controlled whether floating views should raise to the top when the cursor is moved over it while using focus_follows_mouse. The default was enabled, which is undesirable. For example, if you have two floating views where one completely covers the other, the smaller one would be inaccessible because moving the mouse over the bigger one would raise it above the smaller one. There is no known use case for having raise_floating enabled, so this patch removes the directive and implements the raise_floating disabled behaviour instead.
2018-10-20Minor refactor of input managerRyan Dwyer
The input manager is a singleton object. Passing the sway_input_manager argument to each of its functions is unnecessary, while removing the argument makes it obvious to the caller that it's a singleton. This patch removes the argument and makes the input manager use server.input instead. On a similar note: * sway_input_manager.server is removed in favour of using the server global. * seat.input is removed because it can get it from server.input. Due to a circular dependency, creating seat0 is now done directly in server_init rather than in input_manager_create. This is because creating seats must be done after server.input is set. Lastly, it now stores the default seat name using a constant and removes a second reference to seat0 (in input_manager_get_default_seat).
2018-10-08Implement popup_during_fullscreenRyan Dwyer
This introduces a new view_impl function: is_transient_for. Similar to container_has_ancestor but works using the surface parents rather than the tree. This patch modifies view_is_visible, container_at and so on to allow transient views to function normally when they're in front of a fullscreen view.
2018-10-07Shim client.background and client.placeholderDrew DeVault
These are not supported by sway, but are valid i3 commands and should not cause config errors. Also includes a couple of minor touch-ups.
2018-10-03Add configuration for raising containers on focusJonathan Buch
* New configuration option: raise_floating (From the discussion on https://github.com/i3/i3/issues/2990) * By default, it still raises the window on focus, otherwise it will raise the window on click.
2018-10-01Handle border options for gapsBrian Ashworth
Fixes `hide_edge_borders smart` when gaps are in use. Implements `hide_edge_borders smart_no_gaps` and `smart_borders on|no_gaps|off`. Since `smart_borders on` is equivalent to `hide_edge_borders smart` and `smart_borders no_gaps` is equivalent to `hide_edge_borders smart_no_gaps`, I opted to just save the last value set for `hide_edge_borders` and restore that on `smart_borders off`. This simplifies the conditions for setting the border.
2018-09-30Do not strip quotes for cmd_setBrian Ashworth