Skip to content

Commit

Permalink
introduce hide_edge_borders lone_tab
Browse files Browse the repository at this point in the history
Behaves same as _both_ in i3wm with regards to tabbed/stacked containers. If
there is only one tabbed/stacked container child, title bar is hidden.

Related issues and merge requests: swaywm#3031, swaywm#3002, swaywm#2912, swaywm#2987.
  • Loading branch information
thejan2009 committed Feb 24, 2019
1 parent d4b1e71 commit bc12841
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 11 deletions.
1 change: 1 addition & 0 deletions include/sway/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,7 @@ enum edge_border_types {
E_BOTH, /**< hide vertical and horizontal edge borders */
E_SMART, /**< hide both if precisely one window is present in workspace */
E_SMART_NO_GAPS, /**< hide both if one window and gaps to edge is zero */
E_LONE_TAB, /**< E_BOTH, that also applies to tabbed/stacked 1-child cons */
};

enum sway_popup_during_fullscreen {
Expand Down
4 changes: 3 additions & 1 deletion sway/commands/hide_edge_borders.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@ struct cmd_results *cmd_hide_edge_borders(int argc, char **argv) {
config->hide_edge_borders = E_SMART;
} else if (strcmp(argv[0], "smart_no_gaps") == 0) {
config->hide_edge_borders = E_SMART_NO_GAPS;
} else if (strcmp(argv[0], "lone_tab") == 0) {
config->hide_edge_borders = E_LONE_TAB;
} else {
return cmd_results_new(CMD_INVALID, "Expected 'hide_edge_borders "
"<none|vertical|horizontal|both|smart|smart_no_gaps>'");
"<none|vertical|horizontal|both|smart|smart_no_gaps|lone_tab>'");
}
config->saved_edge_borders = config->hide_edge_borders;

Expand Down
9 changes: 9 additions & 0 deletions sway/desktop/render.c
Original file line number Diff line number Diff line change
Expand Up @@ -841,6 +841,15 @@ static void render_containers_stacked(struct sway_output *output,

static void render_containers(struct sway_output *output,
pixman_region32_t *damage, struct parent_data *parent) {
if (config->hide_edge_borders == E_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) {
case L_NONE:
case L_HORIZ:
Expand Down
5 changes: 3 additions & 2 deletions sway/sway.5.scd
Original file line number Diff line number Diff line change
Expand Up @@ -493,8 +493,9 @@ The default colors are:
This affects new workspaces only, and is used when the workspace doesn't
have its own gaps settings (see: workspace <ws> gaps ...).

*hide_edge_borders* none|vertical|horizontal|both|smart|smart_no_gaps
Hides window borders adjacent to the screen edges. Default is _none_.
*hide_edge_borders* none|vertical|horizontal|both|smart|smart_no_gaps|lone_tab
Hides window borders adjacent to the screen edges. Default is _none_. The
_lone_tab_ option is same as _both_ in i3 with regards to tabbed containers.

*input* <input_device> <input-subcommands...>
For details on input subcommands, see *sway-input*(5).
Expand Down
20 changes: 12 additions & 8 deletions sway/tree/view.c
Original file line number Diff line number Diff line change
Expand Up @@ -246,14 +246,18 @@ void view_autoconfigure(struct sway_view *view) {
// 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,
// bar, and disable any top border because we'll always have the title bar.
enum sway_container_layout layout = container_parent_layout(con);
if (layout == L_TABBED && !container_is_floating(con)) {
y_offset = container_titlebar_height();
con->border_top = false;
} else if (layout == L_STACKED && !container_is_floating(con)) {
list_t *siblings = container_get_siblings(con);
y_offset = container_titlebar_height() * siblings->length;
con->border_top = false;
list_t *siblings = container_get_siblings(con);
bool show_titlebar = config->hide_edge_borders != E_LONE_TAB ||
(config->hide_edge_borders == E_LONE_TAB && siblings->length > 1);
if (show_titlebar && !container_is_floating(con)) {
enum sway_container_layout layout = container_parent_layout(con);
if (layout == L_TABBED) {
y_offset = container_titlebar_height();
con->border_top = false;
} else if (layout == L_STACKED) {
y_offset = container_titlebar_height() * siblings->length;
con->border_top = false;
}
}

double x, y, width, height;
Expand Down

0 comments on commit bc12841

Please sign in to comment.