Contents of /mcore-src/tags/mcore-tools-1_0_5/src/xinfo.c
Parent Directory | Revision Log
Revision 2911 -
(show annotations)
(download)
Fri Sep 15 09:55:18 2023 UTC (12 months, 1 week ago) by niro
File MIME type: text/plain
File size: 1052 byte(s)
Fri Sep 15 09:55:18 2023 UTC (12 months, 1 week ago) by niro
File MIME type: text/plain
File size: 1052 byte(s)
tagged 'mcore-tools-1_0_5'
1 | // original 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 | if (! pdsp) { |
16 | printf("No display found!\n"); |
17 | return 1; |
18 | } |
19 | Window wid = DefaultRootWindow(pdsp); |
20 | |
21 | Screen* pwnd = DefaultScreenOfDisplay(pdsp); |
22 | int sid = DefaultScreen(pdsp); |
23 | |
24 | XWindowAttributes xwAttr; |
25 | XGetWindowAttributes(pdsp,wid,&xwAttr); |
26 | |
27 | /* |
28 | printf(" name : %s\n vendor : %s\n", pdsp->display_name, pdsp->vendor); |
29 | printf(" pos : (%d, %d), width = %d, height = %d \n", |
30 | xwAttr.x, xwAttr.y, xwAttr.width, xwAttr.height); |
31 | */ |
32 | |
33 | printf("xorg_width=%d\n", xwAttr.width); |
34 | printf("xorg_height=%d\n", xwAttr.height); |
35 | |
36 | XCloseDisplay( pdsp ); |
37 | |
38 | return 0; |
39 | } |
40 | |
41 | /* gcc -o $@ $< -lX11 */ |
42 | /* set ts=4 sts=4 tw=100 sw=4 */ |