From f84a3ba77c61a351e1d7efb67bd40db23a435281 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Sun, 16 Mar 2025 22:36:46 +0100 Subject: Refactor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/gamma-quartz.c | 27 ++++++++------------------- 1 file changed, 8 insertions(+), 19 deletions(-) (limited to 'src/gamma-quartz.c') diff --git a/src/gamma-quartz.c b/src/gamma-quartz.c index c708105..d323d33 100644 --- a/src/gamma-quartz.c +++ b/src/gamma-quartz.c @@ -34,15 +34,15 @@ struct gamma_state { static int -quartz_init(struct gamma_state **state) +quartz_create(struct gamma_state **state_out) { - *state = emalloc(sizeof(**state)); - (*state)->displays = NULL; + *state_out = emalloc(sizeof(**state_out)); + (*state_out)->displays = NULL; return 0; } static int -quartz_start(struct gamma_state *state, program_mode_t mode) +quartz_start(struct gamma_state *state) { float *gamma_r, *gamma_g, *gamma_b; uint32_t i, display_count, ramp_size, sample_count; @@ -144,8 +144,7 @@ quartz_set_option(struct gamma_state *state, const char *key, const char *value) } static void -quartz_set_temperature_for_display(struct gamma_state *state, int display_index, - const colour_setting_t *setting, int preserve) +quartz_apply_for_display(struct gamma_state *state, int display_index, const colour_setting_t *setting, int preserve) { float *gamma_ramps, *gamma_r, *gamma_g, *gamma_b, value; CGDirectDisplayID display = state->displays[display_index].display; @@ -185,25 +184,15 @@ quartz_set_temperature_for_display(struct gamma_state *state, int display_index, } static int -quartz_set_temperature( - struct gamma_state *state, const colour_setting_t *setting, int preserve) +quartz_apply(struct gamma_state *state, const colour_setting_t *setting, int preserve) { uint32_t i; for (i = 0; i < state->display_count; i++) - quartz_set_temperature_for_display(state, i, setting, preserve); + quartz_apply_for_display(state, i, setting, preserve); return 0; } -const struct gamma_method quartz_gamma_method = { - "quartz", 1, - &quartz_init, - &quartz_start, - &quartz_free, - &quartz_print_help, - &quartz_set_option, - &quartz_restore, - &quartz_set_temperature -}; +const struct gamma_method quartz_gamma_method = GAMMA_METHOD_INIT("quartz", 1, quartz); -- cgit v1.2.3-70-g09d2