Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added disable_titlebar option in Sway v1.9 #8023

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions include/sway/commands.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 3 additions & 1 deletion include/sway/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,7 @@ struct sway_config {
int font_height;
int font_baseline;
bool pango_markup;

int titlebar_border_thickness;
int titlebar_h_padding;
int titlebar_v_padding;
Expand All @@ -532,6 +533,7 @@ struct sway_config {
bool validating;
bool auto_back_and_forth;
bool show_marks;
bool disable_titlebar;
enum alignment title_align;
bool primary_selection;

Expand All @@ -541,7 +543,7 @@ struct sway_config {
enum smart_gaps_mode smart_gaps;
int gaps_inner;
struct side_gaps gaps_outer;

list_t *config_chain;
bool user_config_path;
const char *current_config_path;
Expand Down
1 change: 1 addition & 0 deletions sway/commands.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,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 },
Expand Down
14 changes: 14 additions & 0 deletions sway/commands/disable_titlebar.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#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);
}
1 change: 1 addition & 0 deletions sway/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,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;
Expand Down
20 changes: 12 additions & 8 deletions sway/desktop/render.c
Original file line number Diff line number Diff line change
Expand Up @@ -716,7 +716,7 @@ static void render_containers_linear(struct render_context *ctx, struct parent_d
marks_texture = child->marks_unfocused;
}

if (state->border == B_NORMAL) {
if (state->border == B_NORMAL && !config->disable_titlebar) {
render_titlebar(ctx, child, floor(state->x),
floor(state->y), state->width, colors,
title_texture, marks_texture);
Expand Down Expand Up @@ -789,9 +789,11 @@ static void render_containers_tabbed(struct render_context *ctx, struct parent_d
if (i == parent->children->length - 1) {
tab_width = parent->box.width - tab_width * i;
}

render_titlebar(ctx, child, x, parent->box.y, tab_width,
colors, title_texture, marks_texture);

if (!config->disable_titlebar) {
render_titlebar(ctx, child, x, parent->box.y, tab_width,
colors, title_texture, marks_texture);
}

if (child == current) {
current_colors = colors;
Expand Down Expand Up @@ -851,9 +853,11 @@ static void render_containers_stacked(struct render_context *ctx, struct parent_
marks_texture = child->marks_unfocused;
}

int y = parent->box.y + titlebar_height * i;
render_titlebar(ctx, child, parent->box.x, y,
parent->box.width, colors, title_texture, marks_texture);
if (!config->disable_titlebar) {
int y = parent->box.y + titlebar_height * i;
render_titlebar(ctx, child, parent->box.x, y,
parent->box.width, colors, title_texture, marks_texture);
}

if (child == current) {
current_colors = colors;
Expand Down Expand Up @@ -949,7 +953,7 @@ static void render_floating_container(struct render_context *ctx,
marks_texture = con->marks_unfocused;
}

if (con->current.border == B_NORMAL) {
if (con->current.border == B_NORMAL && !config->disable_titlebar) {
render_titlebar(ctx, con, floor(con->current.x),
floor(con->current.y), con->current.width, colors,
title_texture, marks_texture);
Expand Down
1 change: 1 addition & 0 deletions sway/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,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',
Expand Down
6 changes: 5 additions & 1 deletion sway/sway.5.scd
Original file line number Diff line number Diff line change
Expand Up @@ -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* <criteria> <command>
Whenever a window that matches _criteria_ appears, run list of commands.
See *CRITERIA* for more details.
Expand All @@ -747,7 +750,7 @@ The default colors are:
tabbed and stacked containers with one child. The _smart_|_smart_no_gaps_
options are equivalent to setting _smart_borders_ smart|no_gaps and
_hide_edge_borders_ none.

*input* <input_device> <input-subcommands...>
For details on input subcommands, see *sway-input*(5).

Expand Down Expand Up @@ -850,6 +853,7 @@ The default colors are:
to _yes_, the marks will be shown on the _left_ side instead of the
_right_ side.


*unbindswitch* <switch>:<state>
Removes a binding for when <switch> changes to <state>.

Expand Down
4 changes: 4 additions & 0 deletions sway/tree/container.c
Original file line number Diff line number Diff line change
Expand Up @@ -670,6 +670,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;
}

Expand Down