mirror of
https://cagebreak.project-repo.co/cagebreak.git
synced 2026-08-23 14:04:19 +02:00
Fix output configuration
This commit is contained in:
parent
41e32aa23c
commit
1365fc8d54
3 changed files with 25 additions and 15 deletions
16
keybinding.c
16
keybinding.c
|
|
@ -825,6 +825,19 @@ keybinding_move_view_to_workspace(struct cg_server *server, uint32_t ws) {
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
keybinding_configure_output(struct cg_server *server, struct cg_output_config *cfg) {
|
||||
struct cg_output_config *it,*tmp;
|
||||
wl_list_for_each_safe(it, tmp, &server->output_config,
|
||||
link) {
|
||||
if(strcmp(cfg->output_name,it->output_name) == 0) {
|
||||
wl_list_remove(&it->link);
|
||||
free(it->output_name);
|
||||
}
|
||||
}
|
||||
wl_list_insert(&server->output_config, &cfg->link);
|
||||
}
|
||||
|
||||
/* Hint: see keybinding.h for details on "data" */
|
||||
int
|
||||
run_action(enum keybinding_action action, struct cg_server *server,
|
||||
|
|
@ -947,6 +960,9 @@ run_action(enum keybinding_action action, struct cg_server *server,
|
|||
case KEYBINDING_WORKSPACES:
|
||||
keybinding_set_nws(server, data.i);
|
||||
break;
|
||||
case KEYBINDING_CONFIGURE_OUTPUT:
|
||||
keybinding_configure_output(server, data.o_cfg);
|
||||
break;
|
||||
default: {
|
||||
wlr_log(WLR_ERROR,
|
||||
"run_action was called with a value not present in \"enum "
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ enum keybinding_action {
|
|||
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_QUIT,
|
||||
KEYBINDING_NOOP,
|
||||
KEYBINDING_SWITCH_WORKSPACE, // data.u is the desired workspace
|
||||
|
|
@ -57,6 +58,7 @@ union keybinding_params {
|
|||
bool b;
|
||||
float color[3];
|
||||
struct keybinding *kb;
|
||||
struct cg_output_config *o_cfg;
|
||||
};
|
||||
|
||||
struct keybinding {
|
||||
|
|
|
|||
22
parse.c
22
parse.c
|
|
@ -261,9 +261,8 @@ parse_float(char **saveptr, const char *delim) {
|
|||
}
|
||||
}
|
||||
|
||||
int
|
||||
parse_output_config(struct wl_list *config_list, char **saveptr,
|
||||
char **errstr) {
|
||||
struct cg_output_config *
|
||||
parse_output_config(char **saveptr, char **errstr) {
|
||||
struct cg_output_config *cfg = malloc(sizeof(struct cg_output_config));
|
||||
if(cfg == NULL) {
|
||||
*errstr =
|
||||
|
|
@ -340,23 +339,14 @@ parse_output_config(struct wl_list *config_list, char **saveptr,
|
|||
goto error;
|
||||
}
|
||||
|
||||
#if CG_HAS_FANALYZE
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wanalyzer-malloc-leak"
|
||||
#endif
|
||||
cfg->output_name = strdup(name);
|
||||
wl_list_insert(config_list, &cfg->link);
|
||||
return 0;
|
||||
#if CG_HAS_FANALYZE
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
|
||||
return cfg;
|
||||
error:
|
||||
free(cfg);
|
||||
wlr_log(WLR_ERROR,
|
||||
"Output configuration must be of the form \"output <name> pos <x> "
|
||||
"<y> res <width>x<height> rate <refresh_rate>");
|
||||
return -1;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int
|
||||
|
|
@ -546,7 +536,9 @@ parse_command(struct cg_server *server, struct keybinding *keybinding,
|
|||
return -1;
|
||||
}
|
||||
} else if(strcmp(action, "output") == 0) {
|
||||
if(parse_output_config(&server->output_config, &saveptr, errstr) != 0) {
|
||||
keybinding->action = KEYBINDING_CONFIGURE_OUTPUT;
|
||||
keybinding->data.o_cfg=parse_output_config(&saveptr,errstr);
|
||||
if(keybinding->data.o_cfg == NULL) {
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue