diff options
Diffstat (limited to '')
-rw-r--r-- | src/gamma-vidmode.c (renamed from src/vidmode.c) | 58 |
1 files changed, 52 insertions, 6 deletions
diff --git a/src/vidmode.c b/src/gamma-vidmode.c index 4da1831..e6b9412 100644 --- a/src/vidmode.c +++ b/src/gamma-vidmode.c @@ -1,4 +1,4 @@ -/* vidmode.c -- X VidMode gamma adjustment source +/* gamma-vidmode.c -- X VidMode gamma adjustment source This file is part of Redshift. Redshift is free software: you can redistribute it and/or modify @@ -20,21 +20,27 @@ #include <stdlib.h> #include <stdio.h> #include <stdint.h> +#include <string.h> -#include <libintl.h> -#define _(s) gettext(s) +#ifdef ENABLE_NLS +# include <libintl.h> +# define _(s) gettext(s) +#else +# define _(s) s +#endif #include <X11/Xlib.h> #include <X11/extensions/xf86vmode.h> -#include "vidmode.h" +#include "gamma-vidmode.h" #include "colorramp.h" int -vidmode_init(vidmode_state_t *state, int screen_num) +vidmode_init(vidmode_state_t *state) { - int r; + state->screen_num = -1; + state->saved_ramps = NULL; /* Open display */ state->display = XOpenDisplay(NULL); @@ -44,6 +50,15 @@ vidmode_init(vidmode_state_t *state, int screen_num) return -1; } + return 0; +} + +int +vidmode_start(vidmode_state_t *state) +{ + int r; + int screen_num = state->screen_num; + if (screen_num < 0) screen_num = DefaultScreen(state->display); state->screen_num = screen_num; @@ -111,6 +126,37 @@ vidmode_free(vidmode_state_t *state) } void +vidmode_print_help(FILE *f) +{ + fputs(_("Adjust gamma ramps with the X VidMode extension.\n"), f); + fputs("\n", f); + + /* TRANSLATORS: VidMode help output + left column must not be translated */ + fputs(_(" screen=N\tX screen to apply adjustments to\n"), f); + fputs("\n", f); +} + +int +vidmode_set_option(vidmode_state_t *state, const char *key, const char *value) +{ + if (key == NULL) { + fprintf(stderr, _("Missing value for parameter: `%s'.\n"), + key); + return -1; + } + + if (strcasecmp(key, "screen") == 0) { + state->screen_num = atoi(value); + } else { + fprintf(stderr, _("Unknown method parameter: `%s'.\n"), key); + return -1; + } + + return 0; +} + +void vidmode_restore(vidmode_state_t *state) { uint16_t *gamma_r = &state->saved_ramps[0*state->ramp_size]; |