Add always_hide_tab command

Titles on tabbed and stacked windows will be hidden if always_hide_tab
is set to 'yes'. With that stacked mode is similar to dwm monocle mode.
This commit is contained in:
shtayerc 2021-10-31 14:16:14 +01:00
parent 38020d157d
commit 52b1faff9a
8 changed files with 40 additions and 2 deletions

View file

@ -104,6 +104,7 @@ sway_cmd cmd_exec_validate;
sway_cmd cmd_exec_process; sway_cmd cmd_exec_process;
sway_cmd cmd_assign; sway_cmd cmd_assign;
sway_cmd cmd_always_hide_tab;
sway_cmd cmd_bar; sway_cmd cmd_bar;
sway_cmd cmd_bindcode; sway_cmd cmd_bindcode;
sway_cmd cmd_bindswitch; sway_cmd cmd_bindswitch;

View file

@ -536,6 +536,7 @@ struct sway_config {
enum edge_border_types hide_edge_borders; enum edge_border_types hide_edge_borders;
enum edge_border_smart_types hide_edge_borders_smart; enum edge_border_smart_types hide_edge_borders_smart;
bool hide_lone_tab; bool hide_lone_tab;
bool always_hide_tab;
// border colors // border colors
struct { struct {

View file

@ -43,6 +43,7 @@ struct cmd_results *checkarg(int argc, const char *name, enum expected_args type
/* Keep alphabetized */ /* Keep alphabetized */
static const struct cmd_handler handlers[] = { static const struct cmd_handler handlers[] = {
{ "always_hide_tab", cmd_always_hide_tab },
{ "assign", cmd_assign }, { "assign", cmd_assign },
{ "bar", cmd_bar }, { "bar", cmd_bar },
{ "bindcode", cmd_bindcode }, { "bindcode", cmd_bindcode },

View file

@ -0,0 +1,29 @@
#include "sway/commands.h"
#include "sway/config.h"
#include "sway/tree/arrange.h"
#include "sway/tree/view.h"
struct cmd_results *cmd_always_hide_tab(int argc, char **argv) {
const char *expected_syntax = "Expected 'always_hide_tab "
"yes|no";
struct cmd_results *error = NULL;
if ((error = checkarg(argc, "always_hide_tab", EXPECTED_AT_LEAST, 1))) {
return error;
}
if (!argc) {
return cmd_results_new(CMD_INVALID, expected_syntax);
}
if (strcmp(argv[0], "yes") == 0) {
config->always_hide_tab = true;
} else if (strcmp(argv[0], "no") == 0) {
config->always_hide_tab = false;
} else {
return cmd_results_new(CMD_INVALID, expected_syntax);
}
arrange_root();
return cmd_results_new(CMD_SUCCESS, NULL);
}

View file

@ -289,6 +289,7 @@ static void config_defaults(struct sway_config *config) {
config->hide_edge_borders = E_NONE; config->hide_edge_borders = E_NONE;
config->hide_edge_borders_smart = ESMART_OFF; config->hide_edge_borders_smart = ESMART_OFF;
config->hide_lone_tab = false; config->hide_lone_tab = false;
config->always_hide_tab = false;
// border colors // border colors
color_to_rgba(config->border_colors.focused.border, 0x4C7899FF); color_to_rgba(config->border_colors.focused.border, 0x4C7899FF);

View file

@ -40,6 +40,7 @@ sway_sources = files(
'config/seat.c', 'config/seat.c',
'config/input.c', 'config/input.c',
'commands/always_hide_tab.c',
'commands/assign.c', 'commands/assign.c',
'commands/bar.c', 'commands/bar.c',
'commands/bind.c', 'commands/bind.c',

View file

@ -369,6 +369,10 @@ set|plus|minus|toggle <amount>
The following commands may be used either in the configuration file or at The following commands may be used either in the configuration file or at
runtime. runtime.
*always_hide_tab* yes|no
If *always_hide_tab* is yes, titles on tabbed and stacked windows will
be hidden.
*assign* <criteria> [→] [workspace] [number] <workspace> *assign* <criteria> [→] [workspace] [number] <workspace>
Assigns views matching _criteria_ (see *CRITERIA* for details) to Assigns views matching _criteria_ (see *CRITERIA* for details) to
_workspace_. The → (U+2192) is optional and cosmetic. This command is _workspace_. The → (U+2192) is optional and cosmetic. This command is

View file

@ -294,8 +294,8 @@ void view_autoconfigure(struct sway_view *view) {
// title area. We have to offset the surface y by the height of the title, // title area. We have to offset the surface y by the height of the title,
// bar, and disable any top border because we'll always have the title bar. // bar, and disable any top border because we'll always have the title bar.
list_t *siblings = container_get_siblings(con); list_t *siblings = container_get_siblings(con);
bool show_titlebar = (siblings && siblings->length > 1) bool show_titlebar = ((siblings && siblings->length > 1)
|| !config->hide_lone_tab; || !config->hide_lone_tab) && !config->always_hide_tab;
if (show_titlebar) { if (show_titlebar) {
enum sway_container_layout layout = container_parent_layout(con); enum sway_container_layout layout = container_parent_layout(con);
if (layout == L_TABBED) { if (layout == L_TABBED) {