From 2dded1e5102ad9d1aeb73dd05eefe685f705c596 Mon Sep 17 00:00:00 2001 From: "Jasper St. Pierre" Date: Mon, 18 Aug 2014 17:57:33 -0400 Subject: [PATCH] xrandr: Don't use RRQueryOutputProperty to fetch hotplug_mode_update If the property doesn't exist, a BadName error will be generated. This is a terrible API, but it's what we're stuck with. Use RRGetOutputProperty instead. --- .../x11/meta-monitor-manager-xrandr.c | 33 +++++++------------ 1 file changed, 12 insertions(+), 21 deletions(-) diff --git a/src/backends/x11/meta-monitor-manager-xrandr.c b/src/backends/x11/meta-monitor-manager-xrandr.c index eadf3bd8b..f229d6662 100644 --- a/src/backends/x11/meta-monitor-manager-xrandr.c +++ b/src/backends/x11/meta-monitor-manager-xrandr.c @@ -139,8 +139,8 @@ meta_monitor_transform_from_xrandr_all (Rotation rotation) } static gboolean -output_get_presentation_xrandr (MetaMonitorManagerXrandr *manager_xrandr, - MetaOutput *output) +output_get_boolean_property (MetaMonitorManagerXrandr *manager_xrandr, + MetaOutput *output, const char *propname) { gboolean value; Atom atom, actual_type; @@ -148,7 +148,7 @@ output_get_presentation_xrandr (MetaMonitorManagerXrandr *manager_xrandr, unsigned long nitems, bytes_after; unsigned char *buffer; - atom = XInternAtom (manager_xrandr->xdisplay, "_MUTTER_PRESENTATION_OUTPUT", False); + atom = XInternAtom (manager_xrandr->xdisplay, propname, False); XRRGetOutputProperty (manager_xrandr->xdisplay, (XID)output->winsys_id, atom, @@ -166,6 +166,13 @@ output_get_presentation_xrandr (MetaMonitorManagerXrandr *manager_xrandr, return value; } +static gboolean +output_get_presentation_xrandr (MetaMonitorManagerXrandr *manager_xrandr, + MetaOutput *output) +{ + return output_get_boolean_property (manager_xrandr, output, "_MUTTER_PRESENTATION_OUTPUT"); +} + static int normalize_backlight (MetaOutput *output, int hw_value) @@ -314,24 +321,9 @@ static gboolean output_get_hotplug_mode_update (MetaMonitorManagerXrandr *manager_xrandr, XID winsys_id) { - Atom atom; - XRRPropertyInfo *info; - gboolean result = FALSE; - - atom = XInternAtom (manager_xrandr->xdisplay, "hotplug_mode_update", False); - info = XRRQueryOutputProperty (manager_xrandr->xdisplay, winsys_id, - atom); - - if (info) - { - result = TRUE; - XFree (info); - } - - return result; + return output_get_boolean_property (manager_xrandr, output, "hotplug_mode_update"); } - static void meta_monitor_manager_xrandr_read_current (MetaMonitorManager *manager) { @@ -503,8 +495,7 @@ meta_monitor_manager_xrandr_read_current (MetaMonitorManager *manager) meta_output->width_mm = output->mm_width; meta_output->height_mm = output->mm_height; meta_output->subpixel_order = COGL_SUBPIXEL_ORDER_UNKNOWN; - meta_output->hotplug_mode_update = - output_get_hotplug_mode_update (manager_xrandr, meta_output->winsys_id); + meta_output->hotplug_mode_update = output_get_hotplug_mode_update (manager_xrandr, meta_output); meta_output->n_modes = output->nmode; meta_output->modes = g_new0 (MetaMonitorMode *, meta_output->n_modes);