diff --git a/include/sway/commands.h b/include/sway/commands.h index 27058587..a19b0ccf 100644 --- a/include/sway/commands.h +++ b/include/sway/commands.h @@ -190,6 +190,7 @@ sway_cmd cmd_title_align; sway_cmd cmd_title_format; sway_cmd cmd_titlebar_border_thickness; sway_cmd cmd_titlebar_padding; +sway_cmd cmd_titlebar_position; sway_cmd cmd_unbindcode; sway_cmd cmd_unbindswitch; sway_cmd cmd_unbindgesture; diff --git a/include/sway/config.h b/include/sway/config.h index f9da1967..64e7d2f0 100644 --- a/include/sway/config.h +++ b/include/sway/config.h @@ -473,6 +473,11 @@ enum xwayland_mode { XWAYLAND_MODE_IMMEDIATE, }; +enum titlebar_position { + TITLEBAR_TOP, + TITLEBAR_BOTTOM +}; + /** * The configuration struct. The result of loading a config file. */ @@ -534,6 +539,7 @@ struct sway_config { bool show_marks; enum alignment title_align; bool primary_selection; + enum titlebar_position titlebar_position; bool tiling_drag; int tiling_drag_threshold; diff --git a/sway/commands.c b/sway/commands.c index 55eda183..884d7ce8 100644 --- a/sway/commands.c +++ b/sway/commands.c @@ -93,6 +93,7 @@ static const struct cmd_handler handlers[] = { { "title_align", cmd_title_align }, { "titlebar_border_thickness", cmd_titlebar_border_thickness }, { "titlebar_padding", cmd_titlebar_padding }, + { "titlebar_position", cmd_titlebar_position }, { "unbindcode", cmd_unbindcode }, { "unbindgesture", cmd_unbindgesture }, { "unbindswitch", cmd_unbindswitch }, diff --git a/sway/commands/titlebar_position.c b/sway/commands/titlebar_position.c new file mode 100644 index 00000000..4c53e1f5 --- /dev/null +++ b/sway/commands/titlebar_position.c @@ -0,0 +1,30 @@ +#include "sway/commands.h" +#include "sway/config.h" +#include "sway/output.h" +#include "sway/tree/arrange.h" +#include "sway/tree/root.h" + +struct cmd_results *cmd_titlebar_position(int argc, char **argv) { + struct cmd_results *error = NULL; + if ((error = checkarg(argc, "titlebar_position", EXPECTED_AT_LEAST, 1))) { + return error; + } + + if (strcmp(argv[0], "top") == 0) { + config->titlebar_position = TITLEBAR_TOP; + } else if (strcmp(argv[0], "bottom") == 0) { + config->titlebar_position = TITLEBAR_BOTTOM; + } else { + return cmd_results_new(CMD_INVALID, + "Expected 'titlebar_position top|bottom'"); + } + + arrange_root(); + for (int i = 0; i < root->outputs->length; ++i) { + struct sway_output *output = root->outputs->items[i]; + output_damage_whole(output); + } + + return cmd_results_new(CMD_SUCCESS, NULL); +} + diff --git a/sway/config.c b/sway/config.c index 8c8c148d..a7022a42 100644 --- a/sway/config.c +++ b/sway/config.c @@ -271,6 +271,7 @@ static void config_defaults(struct sway_config *config) { config->reading = false; config->show_marks = true; config->title_align = ALIGN_LEFT; + config->titlebar_position = TITLEBAR_TOP; config->tiling_drag = true; config->tiling_drag_threshold = 9; config->primary_selection = true; diff --git a/sway/meson.build b/sway/meson.build index 3abd778d..3f8de954 100644 --- a/sway/meson.build +++ b/sway/meson.build @@ -117,6 +117,7 @@ sway_sources = files( 'commands/title_format.c', 'commands/titlebar_border_thickness.c', 'commands/titlebar_padding.c', + 'commands/titlebar_position.c', 'commands/unmark.c', 'commands/urgent.c', 'commands/workspace.c',