Contents of /mcore-src/trunk/mcore-tools/src/xinfo.c
Parent Directory | Revision Log
Revision 2100 -
(show annotations)
(download)
Fri Sep 27 08:40:17 2013 UTC (10 years, 11 months ago) by niro
File MIME type: text/plain
File size: 1033 byte(s)
Fri Sep 27 08:40:17 2013 UTC (10 years, 11 months ago) by niro
File MIME type: text/plain
File size: 1033 byte(s)
-added initial xinfo tool
1 | // code grabbed from: |
2 | // http://surfingtroves.blogspot.de/2011/01/how-to-get-screen-resolution-in-linux-c.html |
3 | |
4 | // ----------------------------------------------------------- |
5 | // Purpose : simply retrieve current X windows information |
6 | // ----------------------------------------------------------- |
7 | #define XLIB_ILLEGAL_ACCESS |
8 | #include <X11/Xlib.h> |
9 | #include <stdio.h> |
10 | |
11 | int main() |
12 | { |
13 | |
14 | Display* pdsp = XOpenDisplay(NULL); |
15 | Window wid = DefaultRootWindow(pdsp); |
16 | |
17 | Screen* pwnd = DefaultScreenOfDisplay(pdsp); |
18 | int sid = DefaultScreen(pdsp); |
19 | |
20 | XWindowAttributes xwAttr; |
21 | XGetWindowAttributes(pdsp,wid,&xwAttr); |
22 | |
23 | /* |
24 | printf(" name : %s\n vendor : %s\n", pdsp->display_name, pdsp->vendor); |
25 | printf(" pos : (%d, %d), width = %d, height = %d \n", |
26 | xwAttr.x, xwAttr.y, xwAttr.width, xwAttr.height); |
27 | */ |
28 | |
29 | //printf("%dx%d\n", xwAttr.width, xwAttr.height); |
30 | printf("xorg_witdh=%d\n", xwAttr.width); |
31 | printf("xorg_height=%d\n", xwAttr.height); |
32 | |
33 | XCloseDisplay( pdsp ); |
34 | |
35 | return 1; |
36 | } |
37 | |
38 | |
39 | /* gcc -o $@ $< -lX11 */ |
40 | /* set ts=4 sts=4 tw=100 sw=4 */ |
41 |