aboutsummaryrefslogtreecommitdiffstats
path: root/sway/commands/bar.c
Commit message (Collapse)AuthorAge
* Define _POSIX_C_SOURCE globallyLibravatar Simon Ser2024-02-23
| | | | See discussion in https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/4555
* Use format_str() throughoutLibravatar Simon Ser2023-04-14
|
* Prevent use-after-free on first bar subcommand errorLibravatar Michael Weiser2021-04-18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If any error is encountered during execution of the first subcommand of a freshly created bar configuration, parsing apparently is to be aborted and the current bar config is freed. The pointer to that memory is left dangling though, leading to a use-after-free on successive bar subcommands. This quite reliably ends in a crash like so: sway -c reproducer.config 00:00:00.083 [sway/config.c:865] Error on line 2 'foo bar': Unknown/invalid command 'foo' (s) free(): double free detected in tcache 2 00:00:00.608 [swaynag/swaynag.c:451] failed to register with the wayland display Aborted (core dumped) Minimal reproducer config: bar { foo bar position top } Other messages: malloc(): unaligned fastbin chunk detected double free or corruption (fasttop) The invalid command has to be the first for a newly created bar config. Removing the command or switching order so it's not the first one masks the problem. Prevent this from occuring by resetting the pointer to NULL after freeing the memory. Signed-off-by: Michael Weiser <michael.weiser@gmx.de>
* Declare all struct cmd_handler arrays constLibravatar Manuel Stoeckl2021-02-04
| | | | And make the functions handling these arrays use const types.
* Add support for workspace_min_width bar option.Libravatar Tarmack2020-10-11
|
* swaybar: complete barconfig_update event handlingLibravatar Brian Ashworth2019-09-04
| | | | | | | | 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
* commands/bar: fix mode and hidden_state at runtimeLibravatar Brian Ashworth2019-05-22
| | | | | | | | | For compatibility with i3, `bar mode` and `bar hidden_state` do not require bar-ids (in the normal location) at runtime since they follow the alternative syntax: `bar mode|hidden_state <option> [<bar-id>]` This removes the incorrect error that the bar-id is missing for those two bar subcommands
* commands/bar: improve error for invalid subcommandLibravatar Alyssa Ross2019-05-19
| | | | | | | | | | | Running a command like this produced a confusing error message: $ swaymsg bar bar-0 colors background #ff0000 Error: Unknown/invalid command 'bar-0' This patch makes the error message use argv[1] instead of argv[0] (from config_subcommand's implementation), so it actually uses the name of the command, rather than the id of the bar.
* bar: fix segfault with missing or invalid bar idLibravatar Alyssa Ross2019-05-17
| | | | | | | | | | | | | | | | | | | | | | | | | | Prior to this patch, if I ran something like this, sway would crash: swaymsg bar height 50 or swaymsg bar not-a-bar-id color bg #ff0000 This was in contrast to other bar subcommands, like status_command, which would exit with a "No bar defined" message. The difference between the subcommands that crashed and the ones that exited was that some subcommands had a check to see if a bar was specified, while others just assumed that it had been and carried on until they segfaulted. Because this check was identical in every subcommand it was present in, and I couldn't think of a case where it would be valid to run a bar subcommand without specifying which bar to apply it to, I moved this check from individual subcommands into the bar command, which is already responsible for actually setting the specified bar. This reduced code duplication, and fixed the crash for the subcommands that were missing this check.
* Add unbindsym/unbindcode command for swaybarLibravatar Alex Maese2019-04-17
|
* util.c: remove numlen functionLibravatar Ian Fan2019-01-22
| | | | Its uses have been replaced by snprintf, which is more in line with its usage.
* Replace wlr_log with sway_logLibravatar M Stoeckl2019-01-21
| | | | | | | | | | | | | 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.
* bar_cmd_tray_bind: Use mouse button helpersLibravatar Brian Ashworth2019-01-16
| | | | | | | | | | | | | | | | This modifies `bar_cmd_tray_bindsym` to use `get_mouse_bindsym` for parsing mouse buttons. This also introduces `bar_cmd_tray_bindcode`, which will use `get_mouse_bindcode` for parsing mouse buttons. Like with sway bindings, the two commands are encapsulated in a single file to maximize shared code. This also modifies tray bindings to work off of events codes rather than x11 buttons, which allows for any mouse buttons to be used. For `get_bar_config`, `event_code` has been added to the `tray_bindings` section and will include to event code for the button. If the event code can be mapped to a x11 button, `input_code` will still be the x11 button number. Otherwise, `input_code` will be `0`.
* Remove now-unused "input" argument of cmd_results_newLibravatar M Stoeckl2019-01-14
| | | | | | | | | 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.
* Merge pull request #3344 from RedSoxFan/bar-mouse-bindings-improvedLibravatar Drew DeVault2019-01-13
|\ | | | | Improve mouse button parsing: bar mouse bindings
| * bar_cmd_bind: utilize mouse button helpersLibravatar Brian Ashworth2019-01-10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This modifies `bar_cmd_bindsym` to use `get_mouse_bindsym` for parsing mouse buttons. This also introduces `cmd_bar_bindcode`, which will use `get_mouse_bindcode` for parsing mouse buttons. Like sway bindings, the two commands are encapsulated in a single file with shared code. This also modifies swaybar to operate off of event codes rather than x11 button numbers, which allows for any mouse button to be used. This introduces two new IPC properties: - For `get_bar_config`, `event_code` has been added to the `bindings` section and will include to event code for the button. If the event code can be mapped to a x11 button, `input_code` will still be the x11 button number. Otherwise, `input_code` will be `0`. - Likewise for `click_events`, `event` has been added and will include the event code for the button clicked. If the event code can be mapped to a x11 button, `button` will still be the x11 button number. Otherwise, `button` will be `0`.
* | swaybar: add status_edge_padding commandLibravatar Brian Ashworth2019-01-11
| | | | | | | | | | This adds the bar subcommand `status_edge_padding <padding>` to set the padding used when the status line is on the right edge of the bar.
* | swaybar: add status_padding commandLibravatar Brian Ashworth2019-01-11
|/ | | | | | Adds the bar subcommand `status_padding <padding>` which allows setting the padding used for swaybar. If `status_padding` is set to `0`, blocks will be able to take up the full height of the bar.
* swaybar: implement tray configLibravatar Ian Fan2018-12-31
|
* Implement bar gapsLibravatar Brian Ashworth2018-11-28
| | | | | | | | | Adds the bar subcommand `gaps <amount>|<horizontal> <vertical>|<top> <right> <bottom> <left>` to set gaps for swaybar. Due to restrictions on margins for a layer_surface, only the sides that are anchored to an edge of the screen can have gaps. Since there is support for per-side outer gaps for workspaces, those should be able to be used instead for the last side.
* Implement strip_workspace_name.Libravatar Connor E2018-11-17
|
* cmd_bar: simplify logicLibravatar Brian Ashworth2018-10-13
|
* cmd_bar: fix bar id issuesLibravatar Brian Ashworth2018-10-13
| | | | | | Allows bar-subcommand to be a valid bar-ids Destroys runtime created bar if trying to use a config only subcommand Allow subcommands (except for id) to be ids
* Fix bar subcommand handler structs and selectionLibravatar Brian Ashworth2018-10-13
|
* Allow status_command to be disabled via IPCLibravatar Ryan Dwyer2018-10-08
|
* Change _XOPEN_SOURCE defines to _POSIX_C_SOURCELibravatar sghctoma2018-09-03
|
* Fix feature macros for FreeBSDLibravatar sghctoma2018-08-30
| | | | | On FreeBSD, snprintf and vsnprintf are visible only if _XOPEN_SOURCE >= 600.
* Update for swaywm/wlroots#1126Libravatar emersion2018-07-09
|
* Address first round of review for generic blocksLibravatar Brian Ashworth2018-06-02
|
* Make command block implementation genericLibravatar Brian Ashworth2018-06-02
|
* Use statically allocated text bufferLibravatar Drew DeVault2018-03-29
|
* Add bar configuration commandsLibravatar Drew DeVault2018-03-29
|
* Move everything to sway/old/Libravatar Drew DeVault2017-11-18
|
* UnGNUify the codebaseLibravatar Drew DeVault2017-03-10
|
* Handle allocation failure in commandsLibravatar Drew DeVault2016-12-15
|
* merge in latest commitsLibravatar Zandr Martin2016-09-02
|
* refactor commands.cLibravatar Zandr Martin2016-09-01