diff options
author | Mattias Andrée <maandree@operamail.com> | 2014-04-16 01:52:34 +0200 |
---|---|---|
committer | Mattias Andrée <maandree@operamail.com> | 2014-04-16 01:52:34 +0200 |
commit | 30ea51476b71d015f339ccac5fa8ffbb28359292 (patch) | |
tree | d223dc8a5255f7a0b4d5790a30df3a0534c9c18a /src | |
parent | missed to read gamma ramp size (diff) | |
download | blueshift-30ea51476b71d015f339ccac5fa8ffbb28359292.tar.gz blueshift-30ea51476b71d015f339ccac5fa8ffbb28359292.tar.bz2 blueshift-30ea51476b71d015f339ccac5fa8ffbb28359292.tar.xz |
fix logical errors
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/blueshift_quartz_c.c | 2 | ||||
-rw-r--r-- | src/fake_quartz.c | 24 |
2 files changed, 18 insertions, 8 deletions
diff --git a/src/blueshift_quartz_c.c b/src/blueshift_quartz_c.c index 19ffbe9..07432bd 100644 --- a/src/blueshift_quartz_c.c +++ b/src/blueshift_quartz_c.c @@ -183,7 +183,7 @@ uint16_t* blueshift_quartz_read(int use_crtc) rc += gamma_size; for (i = 0; i < gamma_size; i++) { - int32_t v = blue[i] * UINT16_MAX; + int32_t v = green[i] * UINT16_MAX; rc[i] = (uint16_t)(v < 0 ? 0 : v > UINT16_MAX ? UINT16_MAX : v); } rc += gamma_size; diff --git a/src/fake_quartz.c b/src/fake_quartz.c index 840f5b1..7ba2d2f 100644 --- a/src/fake_quartz.c +++ b/src/fake_quartz.c @@ -90,9 +90,13 @@ CGError CGGetOnlineDisplayList(uint32_t max_size, CGDirectDisplayID* displays_ou return ~kCGErrorSuccess; } - memcpy(original_ramps + (0 + 3 * i) * 256, xcb_randr_get_crtc_gamma_red(gamma_reply), 256); - memcpy(original_ramps + (1 + 3 * i) * 256, xcb_randr_get_crtc_gamma_green(gamma_reply), 256); - memcpy(original_ramps + (2 + 3 * i) * 256, xcb_randr_get_crtc_gamma_blue(gamma_reply), 256); +#define __DEST(C) original_ramps + (C + 3 * i) * 256 +#define __SRC(C) xcb_randr_get_crtc_gamma_##C(gamma_reply) + memcpy(__DEST(0), __SRC(red), 256 * sizeof(uint16_t)); + memcpy(__DEST(1), __SRC(green), 256 * sizeof(uint16_t)); + memcpy(__DEST(2), __SRC(blue), 256 * sizeof(uint16_t)); +#undef __SRC +#undef __DEST free(gamma_reply); } @@ -185,13 +189,19 @@ CGError CGGetDisplayTransferByTable(CGDirectDisplayID display, uint32_t gamma_si void CGDisplayRestoreColorSyncSettings(void) { + xcb_generic_error_t* error; + xcb_void_cookie_t gamma_cookie; uint32_t i; + for (i = 0; i < crtc_count; i++) { - xcb_randr_set_crtc_gamma(conn, crtcs[i], 255, - original_ramps + (0 + 3 * i) * 256, - original_ramps + (1 + 3 * i) * 256, - original_ramps + (2 + 3 * i) * 256); + gamma_cookie = xcb_randr_set_crtc_gamma_checked(conn, crtcs[i], 256, + original_ramps + (0 + 3 * i) * 256, + original_ramps + (1 + 3 * i) * 256, + original_ramps + (2 + 3 * i) * 256); + error = xcb_request_check(conn, gamma_cookie); + if (error) + fprintf(stderr, "Quartz gamma reset emulation with RandR returned %i\n", error->error_code); } } |