Add no_titlebars command

This commit is contained in:
James Pike 2020-12-20 16:33:25 +08:00
parent 5f1fe33d36
commit f802346abe
9 changed files with 40 additions and 1 deletions

View file

@ -160,6 +160,7 @@ sway_cmd cmd_opacity;
sway_cmd cmd_new_float; sway_cmd cmd_new_float;
sway_cmd cmd_new_window; sway_cmd cmd_new_window;
sway_cmd cmd_no_focus; sway_cmd cmd_no_focus;
sway_cmd cmd_no_titlebars;
sway_cmd cmd_output; sway_cmd cmd_output;
sway_cmd cmd_permit; sway_cmd cmd_permit;
sway_cmd cmd_popup_during_fullscreen; sway_cmd cmd_popup_during_fullscreen;

View file

@ -511,6 +511,7 @@ struct sway_config {
bool tiling_drag; bool tiling_drag;
int tiling_drag_threshold; int tiling_drag_threshold;
bool no_titlebars;
bool smart_gaps; bool smart_gaps;
int gaps_inner; int gaps_inner;

View file

@ -78,6 +78,7 @@ static struct cmd_handler handlers[] = {
{ "new_float", cmd_new_float }, { "new_float", cmd_new_float },
{ "new_window", cmd_new_window }, { "new_window", cmd_new_window },
{ "no_focus", cmd_no_focus }, { "no_focus", cmd_no_focus },
{ "no_titlebars", cmd_no_titlebars },
{ "output", cmd_output }, { "output", cmd_output },
{ "popup_during_fullscreen", cmd_popup_during_fullscreen }, { "popup_during_fullscreen", cmd_popup_during_fullscreen },
{ "seat", cmd_seat }, { "seat", cmd_seat },

View file

@ -0,0 +1,24 @@
#include <string.h>
#include "sway/commands.h"
#include "sway/config.h"
#include "sway/tree/arrange.h"
#include "sway/tree/view.h"
#include "sway/tree/container.h"
#include "log.h"
#include "stringop.h"
#include "util.h"
struct cmd_results *cmd_no_titlebars(int argc, char **argv) {
struct cmd_results *error = checkarg(argc, "no_titlebars", EXPECTED_EQUAL_TO, 1);
if (error) {
return error;
}
config->no_titlebars = parse_boolean(argv[0], config->no_titlebars);
arrange_root();
return cmd_results_new(CMD_SUCCESS, NULL);
}

View file

@ -266,6 +266,7 @@ static void config_defaults(struct sway_config *config) {
config->title_align = ALIGN_LEFT; config->title_align = ALIGN_LEFT;
config->tiling_drag = true; config->tiling_drag = true;
config->tiling_drag_threshold = 9; config->tiling_drag_threshold = 9;
config->no_titlebars = false;
config->smart_gaps = false; config->smart_gaps = false;
config->gaps_inner = 0; config->gaps_inner = 0;

View file

@ -659,6 +659,9 @@ static void render_titlebar(struct sway_output *output,
static void render_top_border(struct sway_output *output, static void render_top_border(struct sway_output *output,
pixman_region32_t *output_damage, struct sway_container *con, pixman_region32_t *output_damage, struct sway_container *con,
struct border_colors *colors) { struct border_colors *colors) {
if (config->no_titlebars) {
return;
}
struct sway_container_state *state = &con->current; struct sway_container_state *state = &con->current;
if (!state->border_top) { if (!state->border_top) {
return; return;

View file

@ -79,6 +79,7 @@ sway_sources = files(
'commands/new_float.c', 'commands/new_float.c',
'commands/new_window.c', 'commands/new_window.c',
'commands/no_focus.c', 'commands/no_focus.c',
'commands/no_titlebars.c',
'commands/nop.c', 'commands/nop.c',
'commands/output.c', 'commands/output.c',
'commands/popup_during_fullscreen.c', 'commands/popup_during_fullscreen.c',

View file

@ -639,6 +639,9 @@ The default colors are:
may make it unnecessarily hard to tell which window originally raised the may make it unnecessarily hard to tell which window originally raised the
event. This option allows to set a _timeout_ in ms to delay the urgency hint reset. event. This option allows to set a _timeout_ in ms to delay the urgency hint reset.
*no_titlebars* enable|disable|toggle
Do not render titlebars
*titlebar_border_thickness* <thickness> *titlebar_border_thickness* <thickness>
Thickness of the titlebar border in pixels Thickness of the titlebar border in pixels

View file

@ -617,7 +617,11 @@ void container_update_representation(struct sway_container *con) {
} }
size_t container_titlebar_height(void) { size_t container_titlebar_height(void) {
if (config->no_titlebars) {
return 0;
} else {
return config->font_height + config->titlebar_v_padding * 2; return config->font_height + config->titlebar_v_padding * 2;
}
} }
void floating_calculate_constraints(int *min_width, int *max_width, void floating_calculate_constraints(int *min_width, int *max_width,