From e1bd348fc45aab4ee43bd6575002980137dd35a9 Mon Sep 17 00:00:00 2001 From: neuromagus Date: Fri, 1 Mar 2024 12:44:54 +0300 Subject: [PATCH] added 'disable_titlebar' option --- include/sway/commands.h | 1 + include/sway/config.h | 1 + sway/commands.c | 1 + sway/commands/disable_titlebar.c | 15 +++++++++++++++ sway/config.c | 1 + sway/meson.build | 1 + sway/sway.5.scd | 3 +++ sway/tree/container.c | 4 ++++ 8 files changed, 27 insertions(+) create mode 100644 sway/commands/disable_titlebar.c diff --git a/include/sway/commands.h b/include/sway/commands.h index 27058587..ff44d54c 100644 --- a/include/sway/commands.h +++ b/include/sway/commands.h @@ -124,6 +124,7 @@ sway_cmd cmd_create_output; sway_cmd cmd_default_border; sway_cmd cmd_default_floating_border; sway_cmd cmd_default_orientation; +sway_cmd cmd_disable_titlebar; sway_cmd cmd_exec; sway_cmd cmd_exec_always; sway_cmd cmd_exit; diff --git a/include/sway/config.h b/include/sway/config.h index f9da1967..2792cab1 100644 --- a/include/sway/config.h +++ b/include/sway/config.h @@ -532,6 +532,7 @@ struct sway_config { bool validating; bool auto_back_and_forth; bool show_marks; + bool disable_titlebar; enum alignment title_align; bool primary_selection; diff --git a/sway/commands.c b/sway/commands.c index 8d003dfa..984b35d4 100644 --- a/sway/commands.c +++ b/sway/commands.c @@ -57,6 +57,7 @@ static const struct cmd_handler handlers[] = { { "client.urgent", cmd_client_urgent }, { "default_border", cmd_default_border }, { "default_floating_border", cmd_default_floating_border }, + { "disable_titlebar", cmd_disable_titlebar }, { "exec", cmd_exec }, { "exec_always", cmd_exec_always }, { "floating_maximum_size", cmd_floating_maximum_size }, diff --git a/sway/commands/disable_titlebar.c b/sway/commands/disable_titlebar.c new file mode 100644 index 00000000..6f3b1a0c --- /dev/null +++ b/sway/commands/disable_titlebar.c @@ -0,0 +1,15 @@ +#include "sway/commands.h" +#include "sway/config.h" +#include "util.h" + +struct cmd_results *cmd_disable_titlebar(int argc, char **argv) { + struct cmd_results *error = NULL; + if ((error = checkarg(argc, "disable_titlebar", EXPECTED_EQUAL_TO, 1))) { + return error; + } + + config->disable_titlebar = parse_boolean(argv[0], config->disable_titlebar); + + return cmd_results_new(CMD_SUCCESS, NULL); +} + diff --git a/sway/config.c b/sway/config.c index 568c8b53..53f6534a 100644 --- a/sway/config.c +++ b/sway/config.c @@ -271,6 +271,7 @@ static void config_defaults(struct sway_config *config) { config->auto_back_and_forth = false; config->reading = false; config->show_marks = true; + config->disable_titlebar = false; config->title_align = ALIGN_LEFT; config->tiling_drag = true; config->tiling_drag_threshold = 9; diff --git a/sway/meson.build b/sway/meson.build index d937e425..bfc8e110 100644 --- a/sway/meson.build +++ b/sway/meson.build @@ -50,6 +50,7 @@ sway_sources = files( 'commands/default_border.c', 'commands/default_floating_border.c', 'commands/default_orientation.c', + 'commands/disable_titlebar.c', 'commands/exit.c', 'commands/exec.c', 'commands/exec_always.c', diff --git a/sway/sway.5.scd b/sway/sway.5.scd index 7e58b528..9377261d 100644 --- a/sway/sway.5.scd +++ b/sway/sway.5.scd @@ -726,6 +726,9 @@ The default colors are: should be greater than titlebar_border_thickness. If _vertical_ value is not specified it is set to the _horizontal_ value. +*disable_titlebar* yes|no. + Remove titlebar. Default is _no_. + *for_window* Whenever a window that matches _criteria_ appears, run list of commands. See *CRITERIA* for more details. diff --git a/sway/tree/container.c b/sway/tree/container.c index 9224b4fb..70a97a7d 100644 --- a/sway/tree/container.c +++ b/sway/tree/container.c @@ -722,6 +722,10 @@ void container_update_representation(struct sway_container *con) { } size_t container_titlebar_height(void) { + if(config->disable_titlebar) { + return 0; + } + return config->font_height + config->titlebar_v_padding * 2; }