diff options
Diffstat (limited to 'src/gamma-randr.c')
-rw-r--r-- | src/gamma-randr.c | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/src/gamma-randr.c b/src/gamma-randr.c index 66d5c48..8781e92 100644 --- a/src/gamma-randr.c +++ b/src/gamma-randr.c @@ -62,9 +62,12 @@ randr_init(randr_state_t *state) xcb_randr_query_version_reply_t *ver_reply = xcb_randr_query_version_reply(state->conn, ver_cookie, &error); - if (error) { + /* TODO What does it mean when both error and ver_reply is NULL? + Apparently, we have to check both to avoid seg faults. */ + if (error || ver_reply == NULL) { + int ec = (error != 0) ? error->error_code : -1; fprintf(stderr, _("`%s' returned error %d\n"), - "RANDR Query Version", error->error_code); + "RANDR Query Version", ec); xcb_disconnect(state->conn); return -1; } @@ -298,7 +301,7 @@ randr_set_option(randr_state_t *state, const char *key, const char *value) static int randr_set_temperature_for_crtc(randr_state_t *state, int crtc_num, int temp, - float gamma[3]) + float brightness, float gamma[3]) { xcb_generic_error_t *error; @@ -330,7 +333,7 @@ randr_set_temperature_for_crtc(randr_state_t *state, int crtc_num, int temp, uint16_t *gamma_b = &gamma_ramps[2*ramp_size]; colorramp_fill(gamma_r, gamma_g, gamma_b, ramp_size, - temp, gamma); + temp, brightness, gamma); /* Set new gamma ramps */ xcb_void_cookie_t gamma_set_cookie = @@ -352,7 +355,8 @@ randr_set_temperature_for_crtc(randr_state_t *state, int crtc_num, int temp, } int -randr_set_temperature(randr_state_t *state, int temp, float gamma[3]) +randr_set_temperature(randr_state_t *state, int temp, float brightness, + float gamma[3]) { int r; @@ -361,12 +365,13 @@ randr_set_temperature(randr_state_t *state, int temp, float gamma[3]) if (state->crtc_num < 0) { for (int i = 0; i < state->crtc_count; i++) { r = randr_set_temperature_for_crtc(state, i, - temp, gamma); + temp, brightness, + gamma); if (r < 0) return -1; } } else { return randr_set_temperature_for_crtc(state, state->crtc_num, - temp, gamma); + temp, brightness, gamma); } return 0; |