mirror of
https://github.com/swaywm/sway.git
synced 2024-11-22 16:01:27 +00:00
add --i3 flag to hide_edge_borders
Enables i3-compatible behavior regarding hiding the title bar on tabbed and stacked containers with one child. Related issues and merge requests: #3031, #3002, #2912, #2987.
This commit is contained in:
parent
d4b1e71b91
commit
2510e3df38
|
@ -465,6 +465,7 @@ struct sway_config {
|
||||||
int floating_border_thickness;
|
int floating_border_thickness;
|
||||||
enum edge_border_types hide_edge_borders;
|
enum edge_border_types hide_edge_borders;
|
||||||
enum edge_border_types saved_edge_borders;
|
enum edge_border_types saved_edge_borders;
|
||||||
|
bool hide_lone_tab;
|
||||||
|
|
||||||
// border colors
|
// border colors
|
||||||
struct {
|
struct {
|
||||||
|
|
|
@ -5,10 +5,16 @@
|
||||||
|
|
||||||
struct cmd_results *cmd_hide_edge_borders(int argc, char **argv) {
|
struct cmd_results *cmd_hide_edge_borders(int argc, char **argv) {
|
||||||
struct cmd_results *error = NULL;
|
struct cmd_results *error = NULL;
|
||||||
if ((error = checkarg(argc, "hide_edge_borders", EXPECTED_EQUAL_TO, 1))) {
|
if ((error = checkarg(argc, "hide_edge_borders", EXPECTED_AT_LEAST, 1))) {
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (strcmp(*argv, "--i3") == 0) {
|
||||||
|
config->hide_lone_tab = true;
|
||||||
|
++argv;
|
||||||
|
--argc;
|
||||||
|
}
|
||||||
|
|
||||||
if (strcmp(argv[0], "none") == 0) {
|
if (strcmp(argv[0], "none") == 0) {
|
||||||
config->hide_edge_borders = E_NONE;
|
config->hide_edge_borders = E_NONE;
|
||||||
} else if (strcmp(argv[0], "vertical") == 0) {
|
} else if (strcmp(argv[0], "vertical") == 0) {
|
||||||
|
@ -23,7 +29,7 @@ struct cmd_results *cmd_hide_edge_borders(int argc, char **argv) {
|
||||||
config->hide_edge_borders = E_SMART_NO_GAPS;
|
config->hide_edge_borders = E_SMART_NO_GAPS;
|
||||||
} else {
|
} else {
|
||||||
return cmd_results_new(CMD_INVALID, "Expected 'hide_edge_borders "
|
return cmd_results_new(CMD_INVALID, "Expected 'hide_edge_borders "
|
||||||
"<none|vertical|horizontal|both|smart|smart_no_gaps>'");
|
"[--i3] <none|vertical|horizontal|both|smart|smart_no_gaps>'");
|
||||||
}
|
}
|
||||||
config->saved_edge_borders = config->hide_edge_borders;
|
config->saved_edge_borders = config->hide_edge_borders;
|
||||||
|
|
||||||
|
|
|
@ -261,6 +261,7 @@ static void config_defaults(struct sway_config *config) {
|
||||||
config->floating_border_thickness = 2;
|
config->floating_border_thickness = 2;
|
||||||
config->hide_edge_borders = E_NONE;
|
config->hide_edge_borders = E_NONE;
|
||||||
config->saved_edge_borders = E_NONE;
|
config->saved_edge_borders = E_NONE;
|
||||||
|
config->hide_lone_tab = false;
|
||||||
|
|
||||||
// border colors
|
// border colors
|
||||||
set_color(config->border_colors.focused.border, 0x4C7899);
|
set_color(config->border_colors.focused.border, 0x4C7899);
|
||||||
|
|
|
@ -841,6 +841,14 @@ static void render_containers_stacked(struct sway_output *output,
|
||||||
|
|
||||||
static void render_containers(struct sway_output *output,
|
static void render_containers(struct sway_output *output,
|
||||||
pixman_region32_t *damage, struct parent_data *parent) {
|
pixman_region32_t *damage, struct parent_data *parent) {
|
||||||
|
if (config->hide_lone_tab && parent->children->length == 1) {
|
||||||
|
struct sway_container *child = parent->children->items[0];
|
||||||
|
if (child->view) {
|
||||||
|
render_containers_linear(output,damage, parent);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
switch (parent->layout) {
|
switch (parent->layout) {
|
||||||
case L_NONE:
|
case L_NONE:
|
||||||
case L_HORIZ:
|
case L_HORIZ:
|
||||||
|
|
|
@ -493,8 +493,10 @@ The default colors are:
|
||||||
This affects new workspaces only, and is used when the workspace doesn't
|
This affects new workspaces only, and is used when the workspace doesn't
|
||||||
have its own gaps settings (see: workspace <ws> gaps ...).
|
have its own gaps settings (see: workspace <ws> gaps ...).
|
||||||
|
|
||||||
*hide_edge_borders* none|vertical|horizontal|both|smart|smart_no_gaps
|
*hide_edge_borders* [--i3] none|vertical|horizontal|both|smart|smart_no_gaps
|
||||||
Hides window borders adjacent to the screen edges. Default is _none_.
|
Hides window borders adjacent to the screen edges. Default is _none_. The
|
||||||
|
_--i3_ option enables i3-compatible behavior to hide the title bar on tabbed
|
||||||
|
and stacked containers with one child.
|
||||||
|
|
||||||
*input* <input_device> <input-subcommands...>
|
*input* <input_device> <input-subcommands...>
|
||||||
For details on input subcommands, see *sway-input*(5).
|
For details on input subcommands, see *sway-input*(5).
|
||||||
|
|
|
@ -246,15 +246,18 @@ void view_autoconfigure(struct sway_view *view) {
|
||||||
// In a tabbed or stacked container, the container's y is the top of the
|
// In a tabbed or stacked container, the container's y is the top of the
|
||||||
// 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);
|
||||||
|
bool show_titlebar = siblings->length > 1 || !config->hide_lone_tab;
|
||||||
|
if (show_titlebar && !container_is_floating(con)) {
|
||||||
enum sway_container_layout layout = container_parent_layout(con);
|
enum sway_container_layout layout = container_parent_layout(con);
|
||||||
if (layout == L_TABBED && !container_is_floating(con)) {
|
if (layout == L_TABBED) {
|
||||||
y_offset = container_titlebar_height();
|
y_offset = container_titlebar_height();
|
||||||
con->border_top = false;
|
con->border_top = false;
|
||||||
} else if (layout == L_STACKED && !container_is_floating(con)) {
|
} else if (layout == L_STACKED) {
|
||||||
list_t *siblings = container_get_siblings(con);
|
|
||||||
y_offset = container_titlebar_height() * siblings->length;
|
y_offset = container_titlebar_height() * siblings->length;
|
||||||
con->border_top = false;
|
con->border_top = false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
double x, y, width, height;
|
double x, y, width, height;
|
||||||
switch (con->border) {
|
switch (con->border) {
|
||||||
|
|
Loading…
Reference in a new issue