#if RANDR_MAJOR > 1 || (RANDR_MAJOR == 1 && RANDR_MINOR >= 5)
XRRMonitorInfo *rr_monitors;
+#ifdef USE_XCB
+ xcb_get_atom_name_cookie_t *atom_name_cookies;
+ xcb_get_atom_name_reply_t *reply;
+ xcb_generic_error_t *error;
+ int length;
+#endif
/* If RandR 1.5 or later is available, use that instead, as some
video drivers don't report correct dimensions via other versions
goto fallback;
monitors = xzalloc (n_monitors * sizeof *monitors);
+#ifdef USE_XCB
+ atom_name_cookies = alloca (n_monitors * sizeof *atom_name_cookies);
+#endif
for (int i = 0; i < n_monitors; ++i)
{
monitors[i].mm_width = rr_monitors[i].mwidth;
monitors[i].mm_height = rr_monitors[i].mheight;
+#ifndef USE_XCB
name = XGetAtomName (dpyinfo->display, rr_monitors[i].name);
if (name)
{
}
else
monitors[i].name = xstrdup ("Unknown Monitor");
+#else
+ atom_name_cookies[i]
+ = xcb_get_atom_name (dpyinfo->xcb_connection,
+ (xcb_atom_t) rr_monitors[i].name);
+#endif
if (rr_monitors[i].primary)
primary = i;
monitors[i].work = monitors[i].geom;
}
+#ifdef USE_XCB
+ for (int i = 0; i < n_monitors; ++i)
+ {
+ reply = xcb_get_atom_name_reply (dpyinfo->xcb_connection,
+ atom_name_cookies[i], &error);
+
+ if (!reply)
+ {
+ monitors[i].name = xstrdup ("Unknown monitor");
+ free (error);
+ }
+ else
+ {
+ length = xcb_get_atom_name_name_length (reply);
+ name = xmalloc (length + 1);
+ memcpy (name, xcb_get_atom_name_name (reply), length);
+ name[length] = '\0';
+ monitors[i].name = name;
+ free (reply);
+ }
+ }
+#endif
+
XRRFreeMonitors (rr_monitors);
randr15_p = true;
goto out;