diff options
Diffstat (limited to 'src/gamma-coopgamma.c')
-rw-r--r-- | src/gamma-coopgamma.c | 36 |
1 files changed, 14 insertions, 22 deletions
diff --git a/src/gamma-coopgamma.c b/src/gamma-coopgamma.c index 2f2b0d0..a4e08ef 100644 --- a/src/gamma-coopgamma.c +++ b/src/gamma-coopgamma.c @@ -115,14 +115,14 @@ print_error(struct gamma_state *state) static int -coopgamma_init(struct gamma_state **state) +coopgamma_create(struct gamma_state **state_out) { - struct gamma_state *s; + struct gamma_state *state; struct signal_blockage signal_blockage; - s = *state = ecalloc(1, sizeof(**state)); + state = *state_out = ecalloc(1, sizeof(**state_out)); - if (libcoopgamma_context_initialise(&s->ctx)) { + if (libcoopgamma_context_initialise(&state->ctx)) { weprintf("libcoopgamma_context_initialise:"); return -1; } @@ -130,8 +130,8 @@ coopgamma_init(struct gamma_state **state) /* This is done this early to check if coopgamma is available */ if (unblocked_signal(SIGCHLD, &signal_blockage) < 0) return -1; - s->methods = libcoopgamma_get_methods(); - if (s->methods == NULL) { + state->methods = libcoopgamma_get_methods(); + if (state->methods == NULL) { weprintf("libcoopgamma_get_methods:"); if (restore_signal_blockage(SIGCHLD, &signal_blockage) < 0) exit(1); @@ -140,13 +140,13 @@ coopgamma_init(struct gamma_state **state) if (restore_signal_blockage(SIGCHLD, &signal_blockage) < 0) return -1; - s->priority = 0x0800000000000000LL; + state->priority = 0x0800000000000000LL; return 0; } static int -coopgamma_start(struct gamma_state *state, enum program_mode mode) +coopgamma_start(struct gamma_state *state) { struct signal_blockage signal_blockage; libcoopgamma_lifespan_t lifespan; @@ -160,14 +160,15 @@ coopgamma_start(struct gamma_state *state, enum program_mode mode) lifespan = LIBCOOPGAMMA_REMOVE; break; case PROGRAM_MODE_ONE_SHOT: - case PROGRAM_MODE_MANUAL: lifespan = LIBCOOPGAMMA_UNTIL_REMOVAL; break; case PROGRAM_MODE_CONTINUAL: - case PROGRAM_MODE_PRINT: /* TODO ? */ - default: lifespan = LIBCOOPGAMMA_UNTIL_DEATH; break; + default: + case PROGRAM_MODE_PRINT: + abort(); + break; } free(state->methods); @@ -472,7 +473,7 @@ coopgamma_restore(struct gamma_state *state) } static int -coopgamma_set_temperature(struct gamma_state *state, const struct colour_setting *setting, int perserve) +coopgamma_apply(struct gamma_state *state, const struct colour_setting *setting, int perserve) { libcoopgamma_filter_t *filter; libcoopgamma_filter_t *last_filter = NULL; @@ -516,13 +517,4 @@ coopgamma_set_temperature(struct gamma_state *state, const struct colour_setting } -const struct gamma_method coopgamma_gamma_method = { - "coopgamma", 1, - &coopgamma_init, - &coopgamma_start, - &coopgamma_free, - &coopgamma_print_help, - &coopgamma_set_option, - &coopgamma_restore, - &coopgamma_set_temperature -}; +const struct gamma_method coopgamma_gamma_method = GAMMA_METHOD_INIT("coopgamma", 1, coopgamma); |