1 |
// code grabbed from: |
// original code grabbed from: |
2 |
// http://surfingtroves.blogspot.de/2011/01/how-to-get-screen-resolution-in-linux-c.html |
// http://surfingtroves.blogspot.de/2011/01/how-to-get-screen-resolution-in-linux-c.html |
3 |
|
|
4 |
// ----------------------------------------------------------- |
// ----------------------------------------------------------- |
12 |
{ |
{ |
13 |
|
|
14 |
Display* pdsp = XOpenDisplay(NULL); |
Display* pdsp = XOpenDisplay(NULL); |
15 |
|
if (! pdsp) { |
16 |
|
printf("No display found!\n"); |
17 |
|
return 1; |
18 |
|
} |
19 |
Window wid = DefaultRootWindow(pdsp); |
Window wid = DefaultRootWindow(pdsp); |
20 |
|
|
21 |
Screen* pwnd = DefaultScreenOfDisplay(pdsp); |
Screen* pwnd = DefaultScreenOfDisplay(pdsp); |
22 |
int sid = DefaultScreen(pdsp); |
int sid = DefaultScreen(pdsp); |
23 |
|
|
24 |
XWindowAttributes xwAttr; |
XWindowAttributes xwAttr; |
25 |
XGetWindowAttributes(pdsp,wid,&xwAttr); |
XGetWindowAttributes(pdsp,wid,&xwAttr); |
26 |
|
|
30 |
xwAttr.x, xwAttr.y, xwAttr.width, xwAttr.height); |
xwAttr.x, xwAttr.y, xwAttr.width, xwAttr.height); |
31 |
*/ |
*/ |
32 |
|
|
33 |
//printf("%dx%d\n", xwAttr.width, xwAttr.height); |
printf("xorg_width=%d\n", xwAttr.width); |
|
printf("xorg_witdh=%d\n", xwAttr.width); |
|
34 |
printf("xorg_height=%d\n", xwAttr.height); |
printf("xorg_height=%d\n", xwAttr.height); |
35 |
|
|
36 |
XCloseDisplay( pdsp ); |
XCloseDisplay( pdsp ); |
|
|
|
|
return 1; |
|
|
} |
|
37 |
|
|
38 |
|
return 0; |
39 |
|
} |
40 |
|
|
41 |
/* gcc -o $@ $< -lX11 */ |
/* gcc -o $@ $< -lX11 */ |
42 |
/* set ts=4 sts=4 tw=100 sw=4 */ |
/* set ts=4 sts=4 tw=100 sw=4 */ |
|
|
|