From 015c05fbf6c64a7e008ba483bdb1cf9a65ecae80 Mon Sep 17 00:00:00 2001 From: Giovanni Campagna Date: Sun, 18 Aug 2013 11:44:45 +0200 Subject: [PATCH] MonitorXrandr: fix setting gamma ramps The value passed to XRRCrtcSetGamma must be allocated with XRRAllocGamma (because it relies on the locations of green and blue), otherwise garbage is sent on the wire. https://bugzilla.gnome.org/show_bug.cgi?id=706231 --- src/core/monitor-xrandr.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/core/monitor-xrandr.c b/src/core/monitor-xrandr.c index ec9a6bed8..51e480a77 100644 --- a/src/core/monitor-xrandr.c +++ b/src/core/monitor-xrandr.c @@ -921,14 +921,16 @@ meta_monitor_manager_xrandr_set_crtc_gamma (MetaMonitorManager *manager, unsigned short *blue) { MetaMonitorManagerXrandr *manager_xrandr = META_MONITOR_MANAGER_XRANDR (manager); - XRRCrtcGamma gamma; + XRRCrtcGamma *gamma; - gamma.size = size; - gamma.red = red; - gamma.green = green; - gamma.blue = blue; + gamma = XRRAllocGamma (size); + memcpy (gamma->red, red, sizeof (unsigned short) * size); + memcpy (gamma->green, green, sizeof (unsigned short) * size); + memcpy (gamma->blue, blue, sizeof (unsigned short) * size); - XRRSetCrtcGamma (manager_xrandr->xdisplay, (XID)crtc->crtc_id, &gamma); + XRRSetCrtcGamma (manager_xrandr->xdisplay, (XID)crtc->crtc_id, gamma); + + XRRFreeGamma (gamma); } static gboolean