Skip to content

Commit

Permalink
fixup: use switch case for chooser_type
Browse files Browse the repository at this point in the history
  • Loading branch information
columbarius committed Apr 1, 2021
1 parent 6d57585 commit cb3baa6
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions src/screencast/wlr_screencast.c
Original file line number Diff line number Diff line change
Expand Up @@ -475,40 +475,44 @@ static struct xdpw_wlr_output *wlr_output_chooser_default(struct wl_list *output
}

struct xdpw_wlr_output *xdpw_wlr_output_chooser(struct xdpw_screencast_context *ctx) {
if (ctx->state->config->screencast_conf.chooser_type == XDPW_CHOOSER_DEFAULT) {
return wlr_output_chooser_default(&ctx->output_list);
} else if (ctx->state->config->screencast_conf.chooser_type == XDPW_CHOOSER_NONE) {
struct xdpw_wlr_output *output = NULL;
struct xdpw_wlr_output *output = NULL;
switch (ctx->state->config->screencast_conf.chooser_type) {
case XDPW_CHOOSER_DEFAULT:
output = wlr_output_chooser_default(&ctx->output_list);
break;
case XDPW_CHOOSER_NONE:
if (ctx->state->config->screencast_conf.output_name) {
output = xdpw_wlr_output_find_by_name(&ctx->output_list, ctx->state->config->screencast_conf.output_name);
} else {
output = xdpw_wlr_output_first(&ctx->output_list);
}
return output;
} else {
struct xdpw_wlr_output *output = NULL;
break;
case XDPW_CHOOSER_DMENU:
case XDPW_CHOOSER_SIMPLE:
if (!ctx->state->config->screencast_conf.chooser_cmd) {
logprint(ERROR, "wlroots: no output chooser given");
return NULL;
goto end;
}
struct xdpw_output_chooser chooser = {
ctx->state->config->screencast_conf.chooser_type,
ctx->state->config->screencast_conf.chooser_cmd
};
logprint(DEBUG, "wlroots: output chooser %s (%d)", chooser.cmd, chooser.type);
bool ret;
ret = wlr_output_chooser(&chooser, &ctx->output_list, &output);
bool ret = wlr_output_chooser(&chooser, &ctx->output_list, &output);
if (!ret) {
logprint(ERROR, "wlroots: output chooser %s failed", chooser.cmd);
return NULL;
output = NULL;
goto end;
}
if (output) {
logprint(DEBUG, "wlroots: output chooser selects %s", output->name);
} else {
logprint(DEBUG, "wlroots: output chooser canceled");
}
return output;
break;
}
end:
return output;
}

struct xdpw_wlr_output *xdpw_wlr_output_first(struct wl_list *output_list) {
Expand Down

0 comments on commit cb3baa6

Please sign in to comment.