forked from ISSAE/nsy103
-
Notifications
You must be signed in to change notification settings - Fork 0
/
connect.c
40 lines (27 loc) · 1.06 KB
/
connect.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/*n Linux compile with gcc connect.c -L/usr/X11R6/lib -lX11
*/
#include<X11/Xlib.h>
#include<X11/Xutil.h>
#include<stdio.h>
int main(){
Display *display_name;
int depth,screen,connection;
/*Opening display and setting defaults*/
display_name = XOpenDisplay(NULL);
screen = DefaultScreen(display_name);
depth = DefaultDepth(display_name,screen);
connection = ConnectionNumber(display_name);
/*Displaying the info gathered*/
printf("The display is::%s\n",XDisplayName((char*)display_name));
printf("Width::%d\tHeight::%d\n",
DisplayWidth(display_name,screen),
DisplayHeight(display_name,screen));
printf("Connection number is %d\n",connection);
if(depth == 1)
printf("You live in prehistoric times\n");
else
printf("You've got a coloured monitor with depth of %d\n",
depth);
/*Closing the display*/
XCloseDisplay(display_name);
}