Skip to content

Instantly share code, notes, and snippets.

@phillipberndt
Created June 24, 2015 13:18
Show Gist options
  • Save phillipberndt/9f2e4b29c6c500b2f0bb to your computer and use it in GitHub Desktop.
Save phillipberndt/9f2e4b29c6c500b2f0bb to your computer and use it in GitHub Desktop.
test if fakexrandr supports xcb
/* compile with
gcc -oxcbtest xcbtest.c -lxcb -lxcb-randr -lX11 -lXrandr
*/
#include <xcb/xcb.h>
#include <xcb/randr.h>
#include <X11/extensions/Xrandr.h>
#include <X11/Xlibint.h>
#include <stdio.h>
int main() {
xcb_connection_t *connection = xcb_connect(NULL, NULL);
const xcb_setup_t *setup = xcb_get_setup (connection);
xcb_screen_iterator_t iter = xcb_setup_roots_iterator (setup);
xcb_screen_t *screen = iter.data;
xcb_randr_get_screen_resources_cookie_t screen_res_c = xcb_randr_get_screen_resources(connection, screen->root);
xcb_randr_get_screen_resources_reply_t *screen_res_r = xcb_randr_get_screen_resources_reply(connection, screen_res_c, NULL);
Display *dpl = XOpenDisplay(":0");
XRRScreenResources *res = XRRGetScreenResources(dpl, XDefaultRootWindow(dpl));
printf("num outputs from xlib: %d\n", res->noutput);
printf("num outputs from xcb: %d\n", screen_res_r->num_outputs);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment