aboutsummaryrefslogtreecommitdiffstats
path: root/src/gamma-coopgamma.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/gamma-coopgamma.c')
-rw-r--r--src/gamma-coopgamma.c77
1 files changed, 29 insertions, 48 deletions
diff --git a/src/gamma-coopgamma.c b/src/gamma-coopgamma.c
index d389e34..5b18c95 100644
--- a/src/gamma-coopgamma.c
+++ b/src/gamma-coopgamma.c
@@ -16,56 +16,35 @@
Copyright (c) 2016, 2025 Mattias Andrée <m@maandree.se>
*/
-
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#else
-# define PACKAGE "redshift-ng"
-#endif
-
-#include <errno.h>
-#include <inttypes.h>
-#include <signal.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#ifdef ENABLE_NLS
-# include <libintl.h>
-# define _(s) gettext(s)
-#else
-# define _(s) s
-#endif
-
#include "common.h"
#include <libcoopgamma.h>
-typedef struct {
+struct coopgamma_output_id {
char *edid;
size_t index;
-} coopgamma_output_id_t;
+};
-typedef struct {
+struct coopgamma_crtc_state {
libcoopgamma_filter_t filter;
libcoopgamma_ramps_t plain_ramps;
size_t rampsize;
-} coopgamma_crtc_state_t;
+};
-typedef struct {
+struct gamma_state {
libcoopgamma_context_t ctx;
- coopgamma_crtc_state_t *crtcs;
+ struct coopgamma_crtc_state *crtcs;
size_t n_crtcs;
char **methods;
char *method;
char *site;
int64_t priority;
int list_outputs;
- coopgamma_output_id_t *outputs;
+ struct coopgamma_output_id *outputs;
size_t n_outputs;
size_t a_outputs;
-} coopgamma_state_t;
+};
struct signal_blockage {
@@ -88,7 +67,7 @@ restore_signal_blockage(int signo, const struct signal_blockage *blockage)
static int
-update(coopgamma_state_t *state)
+update(struct gamma_state *state)
{
for (size_t i = 0; i < state->n_crtcs; i++)
libcoopgamma_set_gamma_sync(&state->crtcs[i].filter, &state->ctx);
@@ -97,7 +76,7 @@ update(coopgamma_state_t *state)
static void
-print_error(coopgamma_state_t *state)
+print_error(struct gamma_state *state)
{
const char* side = state->ctx.error.server_side ? _("server-side") : _("client-side");
if (state->ctx.error.custom) {
@@ -119,12 +98,12 @@ print_error(coopgamma_state_t *state)
static int
-coopgamma_init(coopgamma_state_t **state)
+coopgamma_init(struct gamma_state **state)
{
- *state = malloc(sizeof(coopgamma_state_t));
+ *state = malloc(sizeof(struct gamma_state));
if (*state == NULL) return -1;
- coopgamma_state_t *s = *state;
+ struct gamma_state *s = *state;
struct signal_blockage signal_blockage;
memset(s, 0, sizeof(*s));
@@ -152,7 +131,7 @@ coopgamma_init(coopgamma_state_t **state)
}
static int
-coopgamma_start(coopgamma_state_t *state, program_mode_t mode)
+coopgamma_start(struct gamma_state *state, enum program_mode mode)
{
struct signal_blockage signal_blockage;
libcoopgamma_lifespan_t lifespan;
@@ -261,7 +240,7 @@ coopgamma_start(coopgamma_state_t *state, program_mode_t mode)
}
for (i = 0; i < state->n_outputs; i++) {
libcoopgamma_crtc_info_t info;
- coopgamma_crtc_state_t *crtc = state->crtcs + state->n_crtcs;
+ struct coopgamma_crtc_state *crtc = state->crtcs + state->n_crtcs;
crtc->filter.priority = state->priority;
crtc->filter.crtc = state->outputs[i].edid;
@@ -367,7 +346,7 @@ coopgamma_start(coopgamma_state_t *state, program_mode_t mode)
}
static void
-coopgamma_free(coopgamma_state_t *state)
+coopgamma_free(struct gamma_state *state)
{
free(state->methods);
state->methods = NULL;
@@ -414,7 +393,7 @@ coopgamma_print_help(FILE *f)
}
static int
-coopgamma_set_option(coopgamma_state_t *state, const char *key, const char *value)
+coopgamma_set_option(struct gamma_state *state, const char *key, const char *value)
{
size_t i;
char *end;
@@ -505,7 +484,7 @@ coopgamma_set_option(coopgamma_state_t *state, const char *key, const char *valu
}
static void
-coopgamma_restore(coopgamma_state_t *state)
+coopgamma_restore(struct gamma_state *state)
{
size_t i;
for (i = 0; i < state->n_crtcs; i++)
@@ -516,12 +495,14 @@ coopgamma_restore(coopgamma_state_t *state)
}
static int
-coopgamma_set_temperature(coopgamma_state_t *state, const color_setting_t *setting)
+coopgamma_set_temperature(struct gamma_state *state, const struct color_setting *setting, int perserve)
{
libcoopgamma_filter_t *filter;
libcoopgamma_filter_t *last_filter = NULL;
size_t i;
+ (void) perserve;
+
for (i = 0; i < state->n_crtcs; i++, last_filter = filter) {
filter = &state->crtcs[i].filter;
@@ -560,13 +541,13 @@ coopgamma_set_temperature(coopgamma_state_t *state, const color_setting_t *setti
}
-const gamma_method_t coopgamma_gamma_method = {
+const struct gamma_method coopgamma_gamma_method = {
"coopgamma", 1,
- (gamma_method_init_func *)coopgamma_init,
- (gamma_method_start_func *)coopgamma_start,
- (gamma_method_free_func *)coopgamma_free,
- (gamma_method_print_help_func *)coopgamma_print_help,
- (gamma_method_set_option_func *)coopgamma_set_option,
- (gamma_method_restore_func *)coopgamma_restore,
- (gamma_method_set_temperature_func *)coopgamma_set_temperature
+ &coopgamma_init,
+ &coopgamma_start,
+ &coopgamma_free,
+ &coopgamma_print_help,
+ &coopgamma_set_option,
+ &coopgamma_restore,
+ &coopgamma_set_temperature
};