// code grabbed from: // http://surfingtroves.blogspot.de/2011/01/how-to-get-screen-resolution-in-linux-c.html // ----------------------------------------------------------- // Purpose : simply retrieve current X windows information // ----------------------------------------------------------- #define XLIB_ILLEGAL_ACCESS #include #include int main() { Display* pdsp = XOpenDisplay(NULL); Window wid = DefaultRootWindow(pdsp); Screen* pwnd = DefaultScreenOfDisplay(pdsp); int sid = DefaultScreen(pdsp); XWindowAttributes xwAttr; XGetWindowAttributes(pdsp,wid,&xwAttr); /* printf(" name : %s\n vendor : %s\n", pdsp->display_name, pdsp->vendor); printf(" pos : (%d, %d), width = %d, height = %d \n", xwAttr.x, xwAttr.y, xwAttr.width, xwAttr.height); */ //printf("%dx%d\n", xwAttr.width, xwAttr.height); printf("xorg_witdh=%d\n", xwAttr.width); printf("xorg_height=%d\n", xwAttr.height); XCloseDisplay( pdsp ); return 1; } /* gcc -o $@ $< -lX11 */ /* set ts=4 sts=4 tw=100 sw=4 */