diff options
author | Mattias Andrée <m@maandree.se> | 2025-03-05 19:26:58 +0100 |
---|---|---|
committer | Mattias Andrée <m@maandree.se> | 2025-03-05 19:26:58 +0100 |
commit | b42c9662303d1a33ebe038d1895c08945cdbd40f (patch) | |
tree | c05b169b1d28e8d42b111290f9181d2cbad1138b /src/gamma-vidmode.c | |
parent | Merge redshift.h into common.h (diff) | |
download | redshift-ng-b42c9662303d1a33ebe038d1895c08945cdbd40f.tar.gz redshift-ng-b42c9662303d1a33ebe038d1895c08945cdbd40f.tar.bz2 redshift-ng-b42c9662303d1a33ebe038d1895c08945cdbd40f.tar.xz |
Cleanup and style update (avoid typedef)
Signed-off-by: Mattias Andrée <m@maandree.se>
Diffstat (limited to 'src/gamma-vidmode.c')
-rw-r--r-- | src/gamma-vidmode.c | 56 |
1 files changed, 20 insertions, 36 deletions
diff --git a/src/gamma-vidmode.c b/src/gamma-vidmode.c index f718ccc..164437f 100644 --- a/src/gamma-vidmode.c +++ b/src/gamma-vidmode.c @@ -15,45 +15,29 @@ along with Redshift. If not, see <http://www.gnu.org/licenses/>. Copyright (c) 2010-2017 Jon Lund Steffensen <jonlst@gmail.com> + Copyright (c) 2025 Mattias Andrée <m@maandree.se> */ - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include <stdlib.h> -#include <stdio.h> -#include <stdint.h> -#include <string.h> - -#ifdef ENABLE_NLS -# include <libintl.h> -# define _(s) gettext(s) -#else -# define _(s) s -#endif +#include "common.h" #include <X11/Xlib.h> #include <X11/extensions/xf86vmode.h> -#include "common.h" - -typedef struct { +struct gamma_state { Display *display; int screen_num; int ramp_size; uint16_t *saved_ramps; -} vidmode_state_t; +}; static int -vidmode_init(vidmode_state_t **state) +vidmode_init(struct gamma_state **state) { - *state = malloc(sizeof(vidmode_state_t)); + *state = malloc(sizeof(struct gamma_state)); if (*state == NULL) return -1; - vidmode_state_t *s = *state; + struct gamma_state *s = *state; s->screen_num = -1; s->saved_ramps = NULL; @@ -68,7 +52,7 @@ vidmode_init(vidmode_state_t **state) } static int -vidmode_start(vidmode_state_t *state, program_mode_t mode) +vidmode_start(struct gamma_state *state, enum program_mode mode) { int r; int screen_num = state->screen_num; @@ -125,7 +109,7 @@ vidmode_start(vidmode_state_t *state, program_mode_t mode) } static void -vidmode_free(vidmode_state_t *state) +vidmode_free(struct gamma_state *state) { /* Free saved ramps */ free(state->saved_ramps); @@ -150,7 +134,7 @@ vidmode_print_help(FILE *f) } static int -vidmode_set_option(vidmode_state_t *state, const char *key, const char *value) +vidmode_set_option(struct gamma_state *state, const char *key, const char *value) { if (strcasecmp(key, "screen") == 0) { state->screen_num = atoi(value); @@ -168,7 +152,7 @@ vidmode_set_option(vidmode_state_t *state, const char *key, const char *value) } static void -vidmode_restore(vidmode_state_t *state) +vidmode_restore(struct gamma_state *state) { uint16_t *gamma_r = &state->saved_ramps[0*state->ramp_size]; uint16_t *gamma_g = &state->saved_ramps[1*state->ramp_size]; @@ -186,7 +170,7 @@ vidmode_restore(vidmode_state_t *state) static int vidmode_set_temperature( - vidmode_state_t *state, const color_setting_t *setting, int preserve) + struct gamma_state *state, const struct color_setting *setting, int preserve) { int r; @@ -236,13 +220,13 @@ vidmode_set_temperature( } -const gamma_method_t vidmode_gamma_method = { +const struct gamma_method vidmode_gamma_method = { "vidmode", 1, - (gamma_method_init_func *)vidmode_init, - (gamma_method_start_func *)vidmode_start, - (gamma_method_free_func *)vidmode_free, - (gamma_method_print_help_func *)vidmode_print_help, - (gamma_method_set_option_func *)vidmode_set_option, - (gamma_method_restore_func *)vidmode_restore, - (gamma_method_set_temperature_func *)vidmode_set_temperature + &vidmode_init, + &vidmode_start, + &vidmode_free, + &vidmode_print_help, + &vidmode_set_option, + &vidmode_restore, + &vidmode_set_temperature }; |