Skip to content

Commit

Permalink
fixup: switch case magic ...
Browse files Browse the repository at this point in the history
  • Loading branch information
columbarius committed Apr 1, 2021
1 parent cb3baa6 commit c863b74
Showing 1 changed file with 10 additions and 14 deletions.
24 changes: 10 additions & 14 deletions src/screencast/wlr_screencast.c
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,6 @@ static bool wlr_output_chooser(struct xdpw_output_chooser *chooser,
struct xdpw_wlr_output *out;
size_t name_size = 0;
char *name = NULL;
FILE *f = NULL;
*output = NULL;

int chooser_in[2]; //p -> c
Expand All @@ -381,8 +380,8 @@ static bool wlr_output_chooser(struct xdpw_output_chooser *chooser,
}

switch (chooser->type) {
case XDPW_CHOOSER_DMENU:
f = fdopen(chooser_in[1], "w");
case XDPW_CHOOSER_DMENU:;
FILE *f = fdopen(chooser_in[1], "w");
if (f == NULL) {
perror("fdopen pipe chooser_in");
logprint(ERROR, "Failed to create stream writing to pipe chooser_in");
Expand All @@ -402,7 +401,7 @@ static bool wlr_output_chooser(struct xdpw_output_chooser *chooser,
goto end;
}

f = fdopen(chooser_out[0], "r");
FILE *f = fdopen(chooser_out[0], "r");
if (f == NULL) {
perror("fdopen pipe chooser_out");
logprint(ERROR, "Failed to create stream reading from pipe chooser_out");
Expand Down Expand Up @@ -475,20 +474,18 @@ 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) {
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;
return wlr_output_chooser_default(&ctx->output_list);
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);
return 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 xdpw_wlr_output_first(&ctx->output_list);
}
break;
case XDPW_CHOOSER_DMENU:
case XDPW_CHOOSER_SIMPLE:
case XDPW_CHOOSER_SIMPLE:;
struct xdpw_wlr_output *output = NULL;
if (!ctx->state->config->screencast_conf.chooser_cmd) {
logprint(ERROR, "wlroots: no output chooser given");
goto end;
Expand All @@ -501,18 +498,17 @@ struct xdpw_wlr_output *xdpw_wlr_output_chooser(struct xdpw_screencast_context *
bool ret = wlr_output_chooser(&chooser, &ctx->output_list, &output);
if (!ret) {
logprint(ERROR, "wlroots: output chooser %s failed", chooser.cmd);
output = NULL;
goto end;
}
if (output) {
logprint(DEBUG, "wlroots: output chooser selects %s", output->name);
} else {
logprint(DEBUG, "wlroots: output chooser canceled");
}
break;
return output;
}
end:
return output;
return NULL;
}

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

0 comments on commit c863b74

Please sign in to comment.