aboutsummaryrefslogtreecommitdiffstats
path: root/src/gamma-w32gdi.c
diff options
context:
space:
mode:
authorJon Lund Steffensen <jonlst@gmail.com>2017-10-13 19:08:55 -0700
committerJon Lund Steffensen <jonlst@gmail.com>2017-10-13 19:08:57 -0700
commite075444663c854fde18f8d20c1bececc96a5c4ff (patch)
treed7c94df10b1d1680f2254f7cb47d9c70329578f2 /src/gamma-w32gdi.c
parentMerge pull request #535 from jonls/cleanup (diff)
downloadredshift-ng-e075444663c854fde18f8d20c1bececc96a5c4ff.tar.gz
redshift-ng-e075444663c854fde18f8d20c1bececc96a5c4ff.tar.bz2
redshift-ng-e075444663c854fde18f8d20c1bececc96a5c4ff.tar.xz
Change preserve option to command line switch
Changes each adjustment method to take a preserve parameter when setting the temperature instead of parsing the preserve option from the command line/configuration file. This helps resolve the issues around #513: - This allows the preserve option to be implemented as a command-line switch (-P). This switch _disables_ the preservation of existing gamma ramps. Having a command-line switch makes it easier to use directly with manual or one-shot mode. - The preserve options is on by default, so continual mode as well as other modes will default to applying the color adjustment on top of the current gamma ramps. - Preserve is always disabled in reset mode so resetting works as expected again.
Diffstat (limited to 'src/gamma-w32gdi.c')
-rw-r--r--src/gamma-w32gdi.c20
1 files changed, 7 insertions, 13 deletions
diff --git a/src/gamma-w32gdi.c b/src/gamma-w32gdi.c
index 298528b..de34bb6 100644
--- a/src/gamma-w32gdi.c
+++ b/src/gamma-w32gdi.c
@@ -42,7 +42,6 @@
typedef struct {
WORD *saved_ramps;
- int preserve;
} w32gdi_state_t;
@@ -54,7 +53,6 @@ w32gdi_init(w32gdi_state_t **state)
w32gdi_state_t *s = *state;
s->saved_ramps = NULL;
- s->preserve = 1;
return 0;
}
@@ -116,20 +114,16 @@ w32gdi_print_help(FILE *f)
{
fputs(_("Adjust gamma ramps with the Windows GDI.\n"), f);
fputs("\n", f);
-
- /* TRANSLATORS: Windows GDI help output
- left column must not be translated */
- fputs(_(" preserve={0,1}\tWhether existing gamma should be"
- " preserved\n"),
- f);
- fputs("\n", f);
}
static int
w32gdi_set_option(w32gdi_state_t *state, const char *key, const char *value)
{
if (strcasecmp(key, "preserve") == 0) {
- state->preserve = atoi(value);
+ fprintf(stderr, _("Parameter `%s` is now always on; "
+ " Use the `%s` command-line option"
+ " to disable.\n"),
+ key, "-P");
} else {
fprintf(stderr, _("Unknown method parameter: `%s'.\n"), key);
return -1;
@@ -163,8 +157,8 @@ w32gdi_restore(w32gdi_state_t *state)
}
static int
-w32gdi_set_temperature(w32gdi_state_t *state,
- const color_setting_t *setting)
+w32gdi_set_temperature(
+ w32gdi_state_t *state, const color_setting_t *setting, int preserve)
{
BOOL r;
@@ -187,7 +181,7 @@ w32gdi_set_temperature(w32gdi_state_t *state,
WORD *gamma_g = &gamma_ramps[1*GAMMA_RAMP_SIZE];
WORD *gamma_b = &gamma_ramps[2*GAMMA_RAMP_SIZE];
- if (state->preserve) {
+ if (preserve) {
/* Initialize gamma ramps from saved state */
memcpy(gamma_ramps, state->saved_ramps,
3*GAMMA_RAMP_SIZE*sizeof(WORD));