aboutsummaryrefslogtreecommitdiffstats
path: root/src/gamma-vidmode.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/gamma-vidmode.c')
-rw-r--r--src/gamma-vidmode.c34
1 files changed, 10 insertions, 24 deletions
diff --git a/src/gamma-vidmode.c b/src/gamma-vidmode.c
index 042f90c..a855914 100644
--- a/src/gamma-vidmode.c
+++ b/src/gamma-vidmode.c
@@ -31,18 +31,16 @@ struct gamma_state {
static int
-vidmode_init(struct gamma_state **state)
+vidmode_create(struct gamma_state **state_out)
{
- struct gamma_state *s;
+ struct gamma_state *state;
- s = *state = emalloc(sizeof(struct gamma_state));
+ state = *state_out = emalloc(sizeof(**state_out));
+ state->screen_num = -1;
+ state->saved_ramps = NULL;
- s->screen_num = -1;
- s->saved_ramps = NULL;
-
- /* Open display */
- s->display = XOpenDisplay(NULL);
- if (!s->display) {
+ state->display = XOpenDisplay(NULL);
+ if (!state->display) {
weprintf(_("X request failed: %s"), "XOpenDisplay");
return -1;
}
@@ -51,15 +49,13 @@ vidmode_init(struct gamma_state **state)
}
static int
-vidmode_start(struct gamma_state *state, enum program_mode mode)
+vidmode_start(struct gamma_state *state)
{
int r;
int screen_num = state->screen_num;
int major, minor;
uint16_t *gamma_r, *gamma_g, *gamma_b;
- (void) mode;
-
if (screen_num < 0)
screen_num = DefaultScreen(state->display);
state->screen_num = screen_num;
@@ -151,8 +147,7 @@ vidmode_restore(struct gamma_state *state)
}
static int
-vidmode_set_temperature(
- struct gamma_state *state, const struct colour_setting *setting, int preserve)
+vidmode_apply(struct gamma_state *state, const struct colour_setting *setting, int preserve)
{
uint16_t value, *gamma_ramps, *gamma_r, *gamma_g, *gamma_b;
int r, i;
@@ -194,13 +189,4 @@ vidmode_set_temperature(
}
-const struct gamma_method vidmode_gamma_method = {
- "vidmode", 1,
- &vidmode_init,
- &vidmode_start,
- &vidmode_free,
- &vidmode_print_help,
- &vidmode_set_option,
- &vidmode_restore,
- &vidmode_set_temperature
-};
+const struct gamma_method vidmode_gamma_method = GAMMA_METHOD_INIT("vidmode", 1, vidmode);