diff options
author | Mattias Andrée <m@maandree.se> | 2025-03-16 22:36:46 +0100 |
---|---|---|
committer | Mattias Andrée <m@maandree.se> | 2025-03-16 22:36:46 +0100 |
commit | f84a3ba77c61a351e1d7efb67bd40db23a435281 (patch) | |
tree | 83948f9074f2c761913cbb648f8b36bcdae43367 /src/gamma-vidmode.c | |
parent | Major refactoring and some fixes (diff) | |
download | redshift-ng-f84a3ba77c61a351e1d7efb67bd40db23a435281.tar.gz redshift-ng-f84a3ba77c61a351e1d7efb67bd40db23a435281.tar.bz2 redshift-ng-f84a3ba77c61a351e1d7efb67bd40db23a435281.tar.xz |
Refactor
Signed-off-by: Mattias Andrée <m@maandree.se>
Diffstat (limited to 'src/gamma-vidmode.c')
-rw-r--r-- | src/gamma-vidmode.c | 34 |
1 files changed, 10 insertions, 24 deletions
diff --git a/src/gamma-vidmode.c b/src/gamma-vidmode.c index 042f90c..a855914 100644 --- a/src/gamma-vidmode.c +++ b/src/gamma-vidmode.c @@ -31,18 +31,16 @@ struct gamma_state { static int -vidmode_init(struct gamma_state **state) +vidmode_create(struct gamma_state **state_out) { - struct gamma_state *s; + struct gamma_state *state; - s = *state = emalloc(sizeof(struct gamma_state)); + state = *state_out = emalloc(sizeof(**state_out)); + state->screen_num = -1; + state->saved_ramps = NULL; - s->screen_num = -1; - s->saved_ramps = NULL; - - /* Open display */ - s->display = XOpenDisplay(NULL); - if (!s->display) { + state->display = XOpenDisplay(NULL); + if (!state->display) { weprintf(_("X request failed: %s"), "XOpenDisplay"); return -1; } @@ -51,15 +49,13 @@ vidmode_init(struct gamma_state **state) } static int -vidmode_start(struct gamma_state *state, enum program_mode mode) +vidmode_start(struct gamma_state *state) { int r; int screen_num = state->screen_num; int major, minor; uint16_t *gamma_r, *gamma_g, *gamma_b; - (void) mode; - if (screen_num < 0) screen_num = DefaultScreen(state->display); state->screen_num = screen_num; @@ -151,8 +147,7 @@ vidmode_restore(struct gamma_state *state) } static int -vidmode_set_temperature( - struct gamma_state *state, const struct colour_setting *setting, int preserve) +vidmode_apply(struct gamma_state *state, const struct colour_setting *setting, int preserve) { uint16_t value, *gamma_ramps, *gamma_r, *gamma_g, *gamma_b; int r, i; @@ -194,13 +189,4 @@ vidmode_set_temperature( } -const struct gamma_method vidmode_gamma_method = { - "vidmode", 1, - &vidmode_init, - &vidmode_start, - &vidmode_free, - &vidmode_print_help, - &vidmode_set_option, - &vidmode_restore, - &vidmode_set_temperature -}; +const struct gamma_method vidmode_gamma_method = GAMMA_METHOD_INIT("vidmode", 1, vidmode); |