aboutsummaryrefslogtreecommitdiff
path: root/sway/commands.c
AgeCommit message (Collapse)Author
2023-04-14Use format_str() throughoutSimon Ser
2023-04-14commands: add printf attribute to cmd_results_new()Simon Ser
And fix the resulting build failures.
2023-01-03Make cmd_handler.command constCarl Smedstad
2022-12-05Add `primary_selection` config optionAidan Dang
See: https://github.com/swaywm/sway/issues/4511 Adds a bool config option `primary_selection`, which explicitly enables/disables the primary selection clipboard. Defaults to enabled. This is implemented as a launch-only option which enables or disables the creation of the `zwp_primary_selection_device_manager_v1` global. Co-authored-by: Tilde Rose <t1lde@protonmail.com>
2022-06-16Allocate enough space for `cmd_results->error`kraftwerk28
2022-05-30sway: add bindgesture commandFlorian Franzen
Co-authored-by: Michael Weiser <michael.weiser@gmx.de>
2021-12-10Add focused_tab_titleVsevolod
2021-10-01commands: Remove unused code after 1d3681f52135Evgeniy Khramtsov
Clang 13 reports: ../sway/commands.c:470:23: error: variable 'context' set but not used [-Werror,-Wunused-but-set-variable] enum command_context context = 0; ^ Last use of was removed in commit 1d3681f52135. Downstream PR: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=258813
2021-02-25Fix for_window criteria and mouse button bindingsftilde
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-16container: Move pending state to state structKenny Levinsen
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-04Declare all struct cmd_handler arrays constManuel Stoeckl
And make the functions handling these arrays use const types.
2020-07-27commands: disallow runtime includeRonan Pigott
2020-05-21Remove code related to the security featuresÉrico Rolim
- Remove struct definitions - Remove struct members - Remove initializations and frees
2020-05-13commands: Add per-view shortcuts_inhibitor commandMichael Weiser
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-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.