/* standard lib imports */ #include #include /* Xorg imports */ #include #include /* This doesn't really do anything but allows the same output as the DisplayModeLister */ #define BIT_DEPTH_MULTI -1 /* * xrandr-lsmodes -- binary to prove that the XRandr calls Java makes to list available display * modes are working ok. * * Screen mode listing code located in Java 7 / Icedtea * http://icedtea.classpath.org/hg/openjdk/file/ce9dde984c21/j2se/src/solaris/native/sun/awt/awt_GraphicsEnv.c * function: Java_sun_awt_X11GraphicsDevice_enumDisplayModes(...) */ int main(/* int argc, char *argv[] */) { Display *display; int screen_num; XRRScreenConfiguration *config; XRRScreenSize *sizes; int nsizes, i; char *display_name = getenv("DISPLAY"); /* address of X display */ display = XOpenDisplay(display_name); if (NULL == display) { fprintf(stderr, "Cannot connection to X server %s\n", display_name); exit(-1); } screen_num = DefaultScreen(display); config = XRRGetScreenInfo(display, RootWindow(display, screen_num)); if (NULL == config) { fprintf(stderr, "Could not retrieve screen configuration\n"); exit(-1); } sizes = XRRConfigSizes(config, &nsizes); if (NULL == sizes) { fprintf(stderr, "Could not retrieve list of sizes\n"); exit(-1); } for (i = 0; i < nsizes; ++i) { int nrates, j; XRRScreenSize size = sizes[i]; short *rates = XRRConfigRates(config, i, &nrates); for (j = 0; j < nrates; ++j) { printf("%3d: %4d x%4d @ %dHz %dbit\n", i+1, size.width, size.height, rates[j], BIT_DEPTH_MULTI); } } XRRFreeScreenConfigInfo(config); XCloseDisplay(display); return 0; }