mirror of
https://cagebreak.project-repo.co/cagebreak.git
synced 2026-08-23 22:14:18 +02:00
Fixed indentation
This commit is contained in:
parent
19a3d1c992
commit
7c8cfdc380
6 changed files with 61 additions and 58 deletions
|
|
@ -356,7 +356,7 @@ main(int argc, char *argv[]) {
|
|||
|
||||
server.message_config.display_time = 2;
|
||||
server.message_config.font = strdup("pango:Monospace 10");
|
||||
server.message_config.anchor = CG_MESSAGE_TOP_RIGHT;
|
||||
server.message_config.anchor = CG_MESSAGE_TOP_RIGHT;
|
||||
|
||||
event_loop = wl_display_get_event_loop(server.wl_display);
|
||||
sigint_source =
|
||||
|
|
|
|||
|
|
@ -1620,9 +1620,9 @@ keybinding_configure_message(struct cg_server *server,
|
|||
server->message_config.fg_color[2] = config->fg_color[2];
|
||||
server->message_config.fg_color[3] = config->fg_color[3];
|
||||
}
|
||||
if(config->anchor != CG_MESSAGE_NOPT) {
|
||||
server->message_config.anchor = config->anchor;
|
||||
}
|
||||
if(config->anchor != CG_MESSAGE_NOPT) {
|
||||
server->message_config.anchor = config->anchor;
|
||||
}
|
||||
ipc_send_event(server, "{\"event_name\":\"configure_message\"}");
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -61,8 +61,8 @@ definekey root <key> <command>
|
|||
- fg_color <r> <g> <b> <a> sets RGBA of foreground
|
||||
- bg_color <r> <g> <b> <a> sets RGBA of background
|
||||
- display_time <n> sets display time in seconds
|
||||
- anchor <position> sets the position of the message
|
||||
- <position> may be one of {top,bottom}_{left,center,right} or center
|
||||
- anchor <position> sets the position of the message
|
||||
- <position> may be one of {top,bottom}_{left,center,right} or center
|
||||
|
||||
```
|
||||
# Set font
|
||||
|
|
|
|||
67
message.c
67
message.c
|
|
@ -177,7 +177,7 @@ create_message_texture(const char *string, const struct cg_output *output) {
|
|||
|
||||
#if CG_HAS_FANALYZE
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wanalyzer-malloc-leak" //NOLINT
|
||||
#pragma GCC diagnostic ignored "-Wanalyzer-malloc-leak" // NOLINT
|
||||
#endif
|
||||
void
|
||||
message_set_output(struct cg_output *output, const char *string,
|
||||
|
|
@ -205,23 +205,23 @@ message_set_output(struct cg_output *output, const char *string,
|
|||
message->position->height = height;
|
||||
switch(anchor) {
|
||||
case CG_MESSAGE_TOP_LEFT:
|
||||
message->position->x = 0;
|
||||
message->position->y = 0;
|
||||
break;
|
||||
message->position->x = 0;
|
||||
message->position->y = 0;
|
||||
break;
|
||||
case CG_MESSAGE_TOP_CENTER:
|
||||
message->position->x -= width / 2;
|
||||
message->position->y = 0;
|
||||
break;
|
||||
message->position->x -= width / 2;
|
||||
message->position->y = 0;
|
||||
break;
|
||||
case CG_MESSAGE_TOP_RIGHT:
|
||||
message->position->x -= width;
|
||||
message->position->y = 0;
|
||||
message->position->y = 0;
|
||||
break;
|
||||
case CG_MESSAGE_BOTTOM_LEFT:
|
||||
message->position->x = 0;
|
||||
message->position->x = 0;
|
||||
message->position->y -= height;
|
||||
break;
|
||||
case CG_MESSAGE_BOTTOM_CENTER:
|
||||
message->position->x -= width / 2;
|
||||
message->position->x -= width / 2;
|
||||
message->position->y -= height;
|
||||
break;
|
||||
case CG_MESSAGE_BOTTOM_RIGHT:
|
||||
|
|
@ -274,43 +274,44 @@ message_printf(struct cg_output *output, const char *fmt, ...) {
|
|||
struct wlr_box output_box;
|
||||
wlr_output_layout_get_box(output->server->output_layout, output->wlr_output,
|
||||
&output_box);
|
||||
|
||||
box->width = 0;
|
||||
|
||||
box->width = 0;
|
||||
box->height = 0;
|
||||
switch(output->server->message_config.anchor) {
|
||||
case CG_MESSAGE_TOP_LEFT:
|
||||
box->x = 0;
|
||||
box->y = 0;
|
||||
break;
|
||||
case CG_MESSAGE_TOP_CENTER:
|
||||
box->x = output_box.width /2;
|
||||
box->y = 0;
|
||||
break;
|
||||
box->x = 0;
|
||||
box->y = 0;
|
||||
break;
|
||||
case CG_MESSAGE_TOP_CENTER:
|
||||
box->x = output_box.width / 2;
|
||||
box->y = 0;
|
||||
break;
|
||||
case CG_MESSAGE_TOP_RIGHT:
|
||||
box->x = output_box.width;
|
||||
box->y = 0;
|
||||
box->x = output_box.width;
|
||||
box->y = 0;
|
||||
break;
|
||||
case CG_MESSAGE_BOTTOM_LEFT:
|
||||
box->x = 0;
|
||||
box->y = output_box.height;
|
||||
box->x = 0;
|
||||
box->y = output_box.height;
|
||||
break;
|
||||
case CG_MESSAGE_BOTTOM_CENTER:
|
||||
box->x = output_box.width / 2;
|
||||
box->y = output_box.height;
|
||||
break;
|
||||
case CG_MESSAGE_BOTTOM_CENTER:
|
||||
box->x = output_box.width /2;
|
||||
box->y = output_box.height;
|
||||
break;
|
||||
case CG_MESSAGE_BOTTOM_RIGHT:
|
||||
box->x = output_box.width;
|
||||
box->y = output_box.height;
|
||||
box->x = output_box.width;
|
||||
box->y = output_box.height;
|
||||
break;
|
||||
case CG_MESSAGE_CENTER:
|
||||
box->x = output_box.width / 2;
|
||||
box->y = output_box.height / 2;
|
||||
box->x = output_box.width / 2;
|
||||
box->y = output_box.height / 2;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
message_set_output(output, buffer, box, output->server->message_config.anchor);
|
||||
|
||||
message_set_output(output, buffer, box,
|
||||
output->server->message_config.anchor);
|
||||
free(buffer);
|
||||
alarm(output->server->message_config.display_time);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,13 +13,13 @@ struct wlr_buffer;
|
|||
|
||||
enum cg_message_anchor {
|
||||
CG_MESSAGE_TOP_LEFT,
|
||||
CG_MESSAGE_TOP_CENTER,
|
||||
CG_MESSAGE_TOP_CENTER,
|
||||
CG_MESSAGE_TOP_RIGHT,
|
||||
CG_MESSAGE_BOTTOM_LEFT,
|
||||
CG_MESSAGE_BOTTOM_CENTER,
|
||||
CG_MESSAGE_BOTTOM_CENTER,
|
||||
CG_MESSAGE_BOTTOM_RIGHT,
|
||||
CG_MESSAGE_CENTER,
|
||||
CG_MESSAGE_NOPT
|
||||
CG_MESSAGE_NOPT
|
||||
};
|
||||
|
||||
struct cg_message_config {
|
||||
|
|
@ -27,7 +27,7 @@ struct cg_message_config {
|
|||
int display_time;
|
||||
float bg_color[4];
|
||||
float fg_color[4];
|
||||
enum cg_message_anchor anchor;
|
||||
enum cg_message_anchor anchor;
|
||||
};
|
||||
|
||||
struct cg_message {
|
||||
|
|
|
|||
32
parse.c
32
parse.c
|
|
@ -702,7 +702,7 @@ parse_message_config(char **saveptr, char **errstr) {
|
|||
cfg->fg_color[0] = -1;
|
||||
cfg->display_time = -1;
|
||||
cfg->font = NULL;
|
||||
cfg->anchor = CG_MESSAGE_NOPT;
|
||||
cfg->anchor = CG_MESSAGE_NOPT;
|
||||
|
||||
char *setting = strtok_r(NULL, " ", saveptr);
|
||||
if(setting == NULL) {
|
||||
|
|
@ -747,20 +747,22 @@ parse_message_config(char **saveptr, char **errstr) {
|
|||
}
|
||||
}
|
||||
} else if(strcmp(setting, "anchor") == 0) {
|
||||
char* anchors[] = {"top_left", "top_center", "top_right", "bottom_left", "bottom_center", "bottom_right", "center"};
|
||||
for(int i = 0; i < 7; ++i) {
|
||||
if(strcmp(*saveptr, anchors[i]) == 0) {
|
||||
cfg->anchor = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(cfg->anchor == CG_MESSAGE_NOPT) {
|
||||
*errstr = log_error(
|
||||
"Error parsing command \"configure_message anchor\", "
|
||||
"the given anchor value is not a valid option");
|
||||
goto error;
|
||||
}
|
||||
} else {
|
||||
char *anchors[] = {"top_left", "top_center", "top_right",
|
||||
"bottom_left", "bottom_center", "bottom_right",
|
||||
"center"};
|
||||
for(int i = 0; i < 7; ++i) {
|
||||
if(strcmp(*saveptr, anchors[i]) == 0) {
|
||||
cfg->anchor = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(cfg->anchor == CG_MESSAGE_NOPT) {
|
||||
*errstr =
|
||||
log_error("Error parsing command \"configure_message anchor\", "
|
||||
"the given anchor value is not a valid option");
|
||||
goto error;
|
||||
}
|
||||
} else {
|
||||
*errstr = log_error("Invalid option to command \"configure_message\"");
|
||||
goto error;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue