mirror of
https://cagebreak.project-repo.co/cagebreak.git
synced 2026-08-19 12:04:18 +02:00
Apply clang-format
This commit is contained in:
parent
348925e30a
commit
bc22892a06
5 changed files with 68 additions and 59 deletions
18
cagebreak.c
18
cagebreak.c
|
|
@ -307,18 +307,18 @@ main(int argc, char *argv[]) {
|
|||
}
|
||||
|
||||
server.nws = 1;
|
||||
server.message_config.fg_color[0]=0.0;
|
||||
server.message_config.fg_color[1]=0.0;
|
||||
server.message_config.fg_color[2]=0.0;
|
||||
server.message_config.fg_color[3]=1.0;
|
||||
server.message_config.fg_color[0] = 0.0;
|
||||
server.message_config.fg_color[1] = 0.0;
|
||||
server.message_config.fg_color[2] = 0.0;
|
||||
server.message_config.fg_color[3] = 1.0;
|
||||
|
||||
server.message_config.bg_color[0]=0.9;
|
||||
server.message_config.bg_color[1]=0.85;
|
||||
server.message_config.bg_color[2]=0.85;
|
||||
server.message_config.bg_color[3]=1.0;
|
||||
server.message_config.bg_color[0] = 0.9;
|
||||
server.message_config.bg_color[1] = 0.85;
|
||||
server.message_config.bg_color[2] = 0.85;
|
||||
server.message_config.bg_color[3] = 1.0;
|
||||
|
||||
server.message_config.display_time = 2;
|
||||
server.message_config.font=strdup("pango:Monospace 10");
|
||||
server.message_config.font = strdup("pango:Monospace 10");
|
||||
|
||||
event_loop = wl_display_get_event_loop(server.wl_display);
|
||||
sigint_source =
|
||||
|
|
|
|||
33
keybinding.c
33
keybinding.c
|
|
@ -77,7 +77,7 @@ keybinding_free(struct keybinding *keybinding, bool recursive) {
|
|||
free(keybinding->data.o_cfg);
|
||||
break;
|
||||
case KEYBINDING_CONFIGURE_MESSAGE:
|
||||
if(keybinding->data.m_cfg->font!=NULL) {
|
||||
if(keybinding->data.m_cfg->font != NULL) {
|
||||
free(keybinding->data.m_cfg->font);
|
||||
}
|
||||
break;
|
||||
|
|
@ -977,25 +977,26 @@ keybinding_configure_input(struct cg_server *server,
|
|||
}
|
||||
|
||||
void
|
||||
keybinding_configure_message(struct cg_server *server, struct cg_message_config *config) {
|
||||
if(config->font!=NULL) {
|
||||
keybinding_configure_message(struct cg_server *server,
|
||||
struct cg_message_config *config) {
|
||||
if(config->font != NULL) {
|
||||
free(server->message_config.font);
|
||||
server->message_config.font=strdup(config->font);
|
||||
server->message_config.font = strdup(config->font);
|
||||
}
|
||||
if(config->display_time!=-1) {
|
||||
server->message_config.display_time=config->display_time;
|
||||
if(config->display_time != -1) {
|
||||
server->message_config.display_time = config->display_time;
|
||||
}
|
||||
if(config->bg_color[0]!=-1) {
|
||||
server->message_config.bg_color[0]=config->bg_color[0];
|
||||
server->message_config.bg_color[1]=config->bg_color[1];
|
||||
server->message_config.bg_color[2]=config->bg_color[2];
|
||||
server->message_config.bg_color[3]=config->bg_color[3];
|
||||
if(config->bg_color[0] != -1) {
|
||||
server->message_config.bg_color[0] = config->bg_color[0];
|
||||
server->message_config.bg_color[1] = config->bg_color[1];
|
||||
server->message_config.bg_color[2] = config->bg_color[2];
|
||||
server->message_config.bg_color[3] = config->bg_color[3];
|
||||
}
|
||||
if(config->fg_color[0]!=-1) {
|
||||
server->message_config.fg_color[0]=config->fg_color[0];
|
||||
server->message_config.fg_color[1]=config->fg_color[1];
|
||||
server->message_config.fg_color[2]=config->fg_color[2];
|
||||
server->message_config.fg_color[3]=config->fg_color[3];
|
||||
if(config->fg_color[0] != -1) {
|
||||
server->message_config.fg_color[0] = config->fg_color[0];
|
||||
server->message_config.fg_color[1] = config->fg_color[1];
|
||||
server->message_config.fg_color[2] = config->fg_color[2];
|
||||
server->message_config.fg_color[3] = config->fg_color[3];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
14
keybinding.h
14
keybinding.h
|
|
@ -20,14 +20,14 @@ enum keybinding_action {
|
|||
KEYBINDING_SPLIT_HORIZONTAL,
|
||||
KEYBINDING_CHANGE_TTY, // data.u is the desired tty
|
||||
KEYBINDING_LAYOUT_FULLSCREEN,
|
||||
KEYBINDING_CYCLE_VIEWS, // data.b is 0 if forward, 1 if reverse
|
||||
KEYBINDING_CYCLE_TILES, // data.b is 0 if forward, 1 if reverse
|
||||
KEYBINDING_CYCLE_OUTPUT, // data.b is 0 if forward, 1 if reverse
|
||||
KEYBINDING_CONFIGURE_OUTPUT, // data.o_cfg is the desired output
|
||||
// configuration
|
||||
KEYBINDING_CYCLE_VIEWS, // data.b is 0 if forward, 1 if reverse
|
||||
KEYBINDING_CYCLE_TILES, // data.b is 0 if forward, 1 if reverse
|
||||
KEYBINDING_CYCLE_OUTPUT, // data.b is 0 if forward, 1 if reverse
|
||||
KEYBINDING_CONFIGURE_OUTPUT, // data.o_cfg is the desired output
|
||||
// configuration
|
||||
KEYBINDING_CONFIGURE_MESSAGE, // data.m_cfg is the desired config
|
||||
KEYBINDING_CONFIGURE_INPUT, // data.i_cfg is the desired input
|
||||
// configuration
|
||||
KEYBINDING_CONFIGURE_INPUT, // data.i_cfg is the desired input
|
||||
// configuration
|
||||
KEYBINDING_QUIT,
|
||||
KEYBINDING_NOOP,
|
||||
KEYBINDING_SWITCH_OUTPUT, // data.u is the desired output
|
||||
|
|
|
|||
10
message.c
10
message.c
|
|
@ -59,7 +59,8 @@ create_message_texture(const char *string, const struct cg_output *output) {
|
|||
cairo_font_options_set_subpixel_order(
|
||||
fo, to_cairo_subpixel_order(output->wlr_output->subpixel));
|
||||
cairo_set_font_options(c, fo);
|
||||
get_text_size(c, output->server->message_config.font, &width, &height, NULL, scale, "%s", string);
|
||||
get_text_size(c, output->server->message_config.font, &width, &height, NULL,
|
||||
scale, "%s", string);
|
||||
width += 2 * WIDTH_PADDING;
|
||||
height += 2 * HEIGHT_PADDING;
|
||||
cairo_surface_destroy(dummy_surface);
|
||||
|
|
@ -71,18 +72,19 @@ create_message_texture(const char *string, const struct cg_output *output) {
|
|||
cairo_set_antialias(cairo, CAIRO_ANTIALIAS_BEST);
|
||||
cairo_set_font_options(cairo, fo);
|
||||
cairo_font_options_destroy(fo);
|
||||
float *bg_col=output->server->message_config.bg_color;
|
||||
float *bg_col = output->server->message_config.bg_color;
|
||||
cairo_set_source_rgba(cairo, bg_col[0], bg_col[1], bg_col[2], bg_col[3]);
|
||||
cairo_paint(cairo);
|
||||
PangoContext *pango = pango_cairo_create_context(cairo);
|
||||
float *fg_col=output->server->message_config.fg_color;
|
||||
float *fg_col = output->server->message_config.fg_color;
|
||||
cairo_set_source_rgba(cairo, fg_col[0], fg_col[1], fg_col[2], fg_col[3]);
|
||||
cairo_set_line_width(cairo, 2);
|
||||
cairo_rectangle(cairo, 0, 0, width, height);
|
||||
cairo_stroke(cairo);
|
||||
cairo_move_to(cairo, WIDTH_PADDING, HEIGHT_PADDING);
|
||||
|
||||
pango_printf(cairo, output->server->message_config.font, scale, "%s", string);
|
||||
pango_printf(cairo, output->server->message_config.font, scale, "%s",
|
||||
string);
|
||||
|
||||
cairo_surface_flush(surface);
|
||||
unsigned char *data = cairo_image_surface_get_data(surface);
|
||||
|
|
|
|||
46
parse.c
46
parse.c
|
|
@ -628,7 +628,8 @@ error:
|
|||
return NULL;
|
||||
}
|
||||
|
||||
struct cg_message_config *parse_message_config(char **saveptr, char **errstr) {
|
||||
struct cg_message_config *
|
||||
parse_message_config(char **saveptr, char **errstr) {
|
||||
struct cg_message_config *cfg = calloc(1, sizeof(struct cg_message_config));
|
||||
if(cfg == NULL) {
|
||||
*errstr =
|
||||
|
|
@ -636,45 +637,50 @@ struct cg_message_config *parse_message_config(char **saveptr, char **errstr) {
|
|||
goto error;
|
||||
}
|
||||
|
||||
cfg->bg_color[0]=-1;
|
||||
cfg->fg_color[0]=-1;
|
||||
cfg->display_time=-1;
|
||||
cfg->font=NULL;
|
||||
cfg->bg_color[0] = -1;
|
||||
cfg->fg_color[0] = -1;
|
||||
cfg->display_time = -1;
|
||||
cfg->font = NULL;
|
||||
|
||||
char *setting = strtok_r(NULL, " ", saveptr);
|
||||
if(setting == NULL) {
|
||||
*errstr =
|
||||
log_error("Expected setting to be set for message configuration, got none");
|
||||
*errstr = log_error(
|
||||
"Expected setting to be set for message configuration, got none");
|
||||
goto error;
|
||||
}
|
||||
|
||||
if(strcmp(setting, "font") == 0) {
|
||||
cfg->font=strdup(*saveptr);
|
||||
cfg->font = strdup(*saveptr);
|
||||
if(cfg->font == NULL) {
|
||||
*errstr = log_error( "Unable to allocate memory for font descrition in command \"message\"");
|
||||
*errstr = log_error("Unable to allocate memory for font descrition "
|
||||
"in command \"message\"");
|
||||
goto error;
|
||||
}
|
||||
} else if(strcmp(setting, "display_time") == 0) {
|
||||
cfg->display_time=parse_uint(saveptr, " ");
|
||||
if(cfg->display_time<0) {
|
||||
*errstr = log_error("Error parsing command \"configure_message display_time\", expected a non-negative integer");
|
||||
cfg->display_time = parse_uint(saveptr, " ");
|
||||
if(cfg->display_time < 0) {
|
||||
*errstr =
|
||||
log_error("Error parsing command \"configure_message "
|
||||
"display_time\", expected a non-negative integer");
|
||||
goto error;
|
||||
}
|
||||
} else if(strcmp(setting, "bg_color") == 0) {
|
||||
for(int i = 0; i < 4; ++i) {
|
||||
cfg->bg_color[i]=parse_float(saveptr, " ");
|
||||
cfg->bg_color[i] = parse_float(saveptr, " ");
|
||||
if(cfg->bg_color[i] == FLT_MIN) {
|
||||
*errstr =
|
||||
log_error("Error parsing command \"configure_message bg_color\", expected 4 float values separated by spaces");
|
||||
*errstr = log_error(
|
||||
"Error parsing command \"configure_message bg_color\", "
|
||||
"expected 4 float values separated by spaces");
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
} else if(strcmp(setting, "fg_color") == 0) {
|
||||
for(int i = 0; i < 4; ++i) {
|
||||
cfg->fg_color[i]=parse_float(saveptr, " ");
|
||||
cfg->fg_color[i] = parse_float(saveptr, " ");
|
||||
if(cfg->fg_color[i] == FLT_MIN) {
|
||||
*errstr =
|
||||
log_error("Error parsing command \"configure_message bg_color\", expected 4 float values separated by spaces");
|
||||
*errstr = log_error(
|
||||
"Error parsing command \"configure_message bg_color\", "
|
||||
"expected 4 float values separated by spaces");
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
|
|
@ -685,9 +691,9 @@ struct cg_message_config *parse_message_config(char **saveptr, char **errstr) {
|
|||
return cfg;
|
||||
|
||||
error:
|
||||
wlr_log(WLR_ERROR, "Message configuration must be of the form 'configure_message <setting> <value>'");
|
||||
wlr_log(WLR_ERROR, "Message configuration must be of the form "
|
||||
"'configure_message <setting> <value>'");
|
||||
return NULL;
|
||||
|
||||
}
|
||||
|
||||
int
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue