summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/blueshift_quartz_c.c2
-rw-r--r--src/fake_quartz.c24
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);
}
}