-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathX11display.c
55 lines (45 loc) · 2.51 KB
/
X11display.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/*
********************************************************************
* USB stack and host controller driver for SGI IRIX 6.5 *
* *
* Programmed by BSDero *
* bsdero at gmail dot com *
* 2011/2012 *
* *
* *
* File: X11display.c *
* Description: X11 display basic functions code *
********************************************************************
*******************************************************************************************************
* FIXLIST (latest at top) *
*-----------------------------------------------------------------------------------------------------*
* Author MM-DD-YYYY Description *
*-----------------------------------------------------------------------------------------------------*
* BSDero 09-10-2012 -Initial version *
* *
*******************************************************************************************************
*/
#include <stdio.h>
#include <stdlib.h>
#include "X11display.h"
int X11_display_init( X11_display_t *display){
/* First connect to the display server, as specified in the DISPLAY
environment variable. */
display->dpy = XOpenDisplay(NULL);
if (!display->dpy) {
fprintf(stderr, "unable to connect to display ");
return( -1);
}
/* these are macros that pull useful data out of the display object */
/* we use these bits of info enough to want them in their own variables */
display->screen_num = DefaultScreen(display->dpy);
display->width = DisplayWidth( display->dpy, DefaultScreen( display->dpy));
display->height = DisplayHeight( display->dpy, DefaultScreen( display->dpy));
display->cl_border = WhitePixel( display->dpy, display->screen_num);
display->cl_background = BlackPixel( display->dpy, display->screen_num);
return( 0);
}
int X11_display_close( X11_display_t *display){
XCloseDisplay(display->dpy);
return(0);
}