aboutsummaryrefslogtreecommitdiffstats
path: root/src/gamma-quartz.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/gamma-quartz.c')
-rw-r--r--src/gamma-quartz.c65
1 files changed, 25 insertions, 40 deletions
diff --git a/src/gamma-quartz.c b/src/gamma-quartz.c
index 74ceaf0..c8e39d6 100644
--- a/src/gamma-quartz.c
+++ b/src/gamma-quartz.c
@@ -15,54 +15,39 @@
along with Redshift. If not, see <http://www.gnu.org/licenses/>.
Copyright (c) 2014-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 <stdio.h>
-#include <stdlib.h>
+#include "common.h"
#include <ApplicationServices/ApplicationServices.h>
-#ifdef ENABLE_NLS
-# include <libintl.h>
-# define _(s) gettext(s)
-#else
-# define _(s) s
-#endif
-
-#include "gamma-quartz.h"
-#include "colorramp.h"
-
-typedef struct {
+struct quartz_display_state {
CGDirectDisplayID display;
uint32_t ramp_size;
float *saved_ramps;
-} quartz_display_state_t;
+};
-typedef struct {
- quartz_display_state_t *displays;
+struct gamma_state {
+ struct quartz_display_state *displays;
uint32_t display_count;
-} quartz_state_t;
+};
static int
-quartz_init(quartz_state_t **state)
+quartz_init(struct gamma_state **state)
{
- *state = malloc(sizeof(quartz_state_t));
+ *state = malloc(sizeof(struct gamma_state));
if (*state == NULL) return -1;
- quartz_state_t *s = *state;
+ struct gamma_state *s = *state;
s->displays = NULL;
return 0;
}
static int
-quartz_start(quartz_state_t *state, program_mode_t mode)
+quartz_start(struct gamma_state *state, program_mode_t mode)
{
CGError error;
uint32_t display_count;
@@ -90,7 +75,7 @@ quartz_start(quartz_state_t *state, program_mode_t mode)
/* Allocate list of display state */
state->displays = malloc(display_count *
- sizeof(quartz_display_state_t));
+ sizeof(struct quartz_display_state));
if (state->displays == NULL) {
perror("malloc");
free(displays);
@@ -147,13 +132,13 @@ quartz_start(quartz_state_t *state, program_mode_t mode)
}
static void
-quartz_restore(quartz_state_t *state)
+quartz_restore(struct gamma_state *state)
{
CGDisplayRestoreColorSyncSettings();
}
static void
-quartz_free(quartz_state_t *state)
+quartz_free(struct gamma_state *state)
{
if (state->displays != NULL) {
for (int i = 0; i < state->display_count; i++) {
@@ -172,7 +157,7 @@ quartz_print_help(FILE *f)
}
static int
-quartz_set_option(quartz_state_t *state, const char *key, const char *value)
+quartz_set_option(struct gamma_state *state, const char *key, const char *value)
{
if (strcasecmp(key, "preserve") == 0) {
fprintf(stderr, _("Parameter `%s` is now always on; "
@@ -189,7 +174,7 @@ quartz_set_option(quartz_state_t *state, const char *key, const char *value)
static void
quartz_set_temperature_for_display(
- quartz_state_t *state, int display_index,
+ struct gamma_state *state, int display_index,
const color_setting_t *setting, int preserve)
{
CGDirectDisplayID display = state->displays[display_index].display;
@@ -236,7 +221,7 @@ quartz_set_temperature_for_display(
static int
quartz_set_temperature(
- quartz_state_t *state, const color_setting_t *setting, int preserve)
+ struct gamma_state *state, const color_setting_t *setting, int preserve)
{
for (int i = 0; i < state->display_count; i++) {
quartz_set_temperature_for_display(
@@ -247,13 +232,13 @@ quartz_set_temperature(
}
-const gamma_method_t quartz_gamma_method = {
+const struct gamma_method quartz_gamma_method = {
"quartz", 1,
- (gamma_method_init_func *)quartz_init,
- (gamma_method_start_func *)quartz_start,
- (gamma_method_free_func *)quartz_free,
- (gamma_method_print_help_func *)quartz_print_help,
- (gamma_method_set_option_func *)quartz_set_option,
- (gamma_method_restore_func *)quartz_restore,
- (gamma_method_set_temperature_func *)quartz_set_temperature
+ &quartz_init,
+ &quartz_start,
+ &quartz_free,
+ &quartz_print_help,
+ &quartz_set_option,
+ &quartz_restore,
+ &quartz_set_temperature
};