From 8da5761ffce40ff0737c49b0a29a5dda4c537a10 Mon Sep 17 00:00:00 2001 From: "Jasper St. Pierre" Date: Sun, 28 Jun 2015 13:25:49 -0700 Subject: [PATCH] x11/xrandr: Use xcb to set properties on outputs It seems that fglrx sometimes gives us absolute junk when requesting the outputs, and if we don't trap errors, we'll just crash when trying to configure a junk output. Use xcb so errors simply get ignored. --- .../x11/meta-monitor-manager-xrandr.c | 55 ++++++++++--------- 1 file changed, 30 insertions(+), 25 deletions(-) diff --git a/src/backends/x11/meta-monitor-manager-xrandr.c b/src/backends/x11/meta-monitor-manager-xrandr.c index 3e52679cc..13010b022 100644 --- a/src/backends/x11/meta-monitor-manager-xrandr.c +++ b/src/backends/x11/meta-monitor-manager-xrandr.c @@ -917,11 +917,12 @@ output_set_presentation_xrandr (MetaMonitorManagerXrandr *manager_xrandr, int value = presentation; atom = XInternAtom (manager_xrandr->xdisplay, "_MUTTER_PRESENTATION_OUTPUT", False); - XRRChangeOutputProperty (manager_xrandr->xdisplay, - (XID)output->winsys_id, - atom, - XA_CARDINAL, 32, PropModeReplace, - (unsigned char*) &value, 1); + + xcb_randr_change_output_property (XGetXCBConnection (manager_xrandr->xdisplay), + (XID)output->winsys_id, + atom, XCB_ATOM_CARDINAL, 32, + XCB_PROP_MODE_REPLACE, + 1, &value); } static void @@ -936,11 +937,12 @@ output_set_underscanning_xrandr (MetaMonitorManagerXrandr *manager_xrandr, value = underscanning ? "on" : "off"; valueatom = XInternAtom (manager_xrandr->xdisplay, value, False); - XRRChangeOutputProperty (manager_xrandr->xdisplay, - (XID)output->winsys_id, - prop, - XA_ATOM, 32, PropModeReplace, - (unsigned char*) &valueatom, 1); + + xcb_randr_change_output_property (XGetXCBConnection (manager_xrandr->xdisplay), + (XID)output->winsys_id, + prop, XCB_ATOM_ATOM, 32, + XCB_PROP_MODE_REPLACE, + 1, &valueatom); /* Configure the border at the same time. Currently, we use a * 5% of the width/height of the mode. In the future, we should @@ -951,19 +953,21 @@ output_set_underscanning_xrandr (MetaMonitorManagerXrandr *manager_xrandr, prop = XInternAtom (manager_xrandr->xdisplay, "underscan hborder", False); border_value = output->crtc->current_mode->width * 0.05; - XRRChangeOutputProperty (manager_xrandr->xdisplay, - (XID)output->winsys_id, - prop, - XA_INTEGER, 32, PropModeReplace, - (unsigned char *) &border_value, 1); + + xcb_randr_change_output_property (XGetXCBConnection (manager_xrandr->xdisplay), + (XID)output->winsys_id, + prop, XCB_ATOM_INTEGER, 32, + XCB_PROP_MODE_REPLACE, + 1, &border_value); prop = XInternAtom (manager_xrandr->xdisplay, "underscan vborder", False); border_value = output->crtc->current_mode->height * 0.05; - XRRChangeOutputProperty (manager_xrandr->xdisplay, - (XID)output->winsys_id, - prop, - XA_INTEGER, 32, PropModeReplace, - (unsigned char *) &border_value, 1); + + xcb_randr_change_output_property (XGetXCBConnection (manager_xrandr->xdisplay), + (XID)output->winsys_id, + prop, XCB_ATOM_INTEGER, 32, + XCB_PROP_MODE_REPLACE, + 1, &border_value); } } @@ -1199,11 +1203,12 @@ meta_monitor_manager_xrandr_change_backlight (MetaMonitorManager *manager, hw_value = round ((double)value / 100.0 * output->backlight_max + output->backlight_min); atom = XInternAtom (manager_xrandr->xdisplay, "Backlight", False); - XRRChangeOutputProperty (manager_xrandr->xdisplay, - (XID)output->winsys_id, - atom, - XA_INTEGER, 32, PropModeReplace, - (unsigned char *) &hw_value, 1); + + xcb_randr_change_output_property (XGetXCBConnection (manager_xrandr->xdisplay), + (XID)output->winsys_id, + atom, XCB_ATOM_INTEGER, 32, + XCB_PROP_MODE_REPLACE, + 1, &hw_value); /* We're not selecting for property notifies, so update the value immediately */ output->backlight = normalize_backlight (output, hw_value);