-
Notifications
You must be signed in to change notification settings - Fork 0
/
X11window.c
104 lines (83 loc) · 4.03 KB
/
X11window.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
/*
********************************************************************
* USB stack and host controller driver for SGI IRIX 6.5 *
* *
* Programmed by BSDero *
* bsdero at gmail dot com *
* 2011/2012 *
* *
* *
* File: X11window.c *
* Description: X11 windows basic functions code *
********************************************************************
*******************************************************************************************************
* FIXLIST (latest at top) *
*-----------------------------------------------------------------------------------------------------*
* Author MM-DD-YYYY Description *
*-----------------------------------------------------------------------------------------------------*
* BSDero 09-10-2012 -Initial version *
* *
*******************************************************************************************************
*/
#include "X11window.h"
#include <string.h>
int X11_window_init( X11_display_t *display, X11_window_t *window){
memset( (void *) window, 0, sizeof( X11_window_t));
window->display = display;
window->cl_border = display->cl_border;
window->cl_background = display->cl_background;
return(0);
}
int X11_window_set_geometry( X11_window_t *window, int width, int height, int posx, int posy, int border_width){
window->posx = posx;
window->posy = posy;
window->width = width;
window->height = height;
window->sz_border = border_width;
return(0);
}
int X11_window_set_colors( X11_window_t *window, unsigned long cl_border, unsigned long int cl_background){
window->cl_border = cl_border;
window->cl_background = cl_background;
return(0);
}
int X11_window_set_mask( X11_window_t *window, unsigned long mask){
window->event_mask = mask;
return(0);
}
int X11_window_display( X11_window_t *window){
window->win = XCreateSimpleWindow( window->display->dpy, DefaultRootWindow( window->display->dpy), /* display, parent */
window->posx, window->posy, /* x, y: the window manager will place the window elsewhere */
window->width, window->height, /* width, height */
window->sz_border, window->cl_border, /* border width & colour, unless you have a window manager */
window->cl_background); /* background colour */
/* tell the display server what kind of events we would like to see */
XSelectInput( window->display->dpy, window->win, window->event_mask );
/* okay, put the window on the screen, please */
XMapWindow( window->display->dpy, window->win);
XMoveWindow( window->display->dpy, window->win, window->posx, window->posy);
XFlush( window->display->dpy);
return(0);
}
int X11_window_close( X11_window_t *window){
XUnmapWindow( window->display->dpy , window->win);
return(0);
}
int X11_window_destroy( X11_window_t *window){
XDestroyWindow( window->display->dpy , window->win);
return(0);
}
unsigned long int X11_window_get_next_event( X11_window_t *window){
XNextEvent( window->display->dpy, &window->ev);
return( window->ev.type);
}
int X11_window_set_wm_name( X11_window_t *window, char *window_title){
XSizeHints xsh; /* Size hints for window manager */
xsh.flags = (PPosition|PSize);
xsh.height = window->height;
xsh.width = window->width;
xsh.x = window->posx;
xsh.y = window->posy;
XSetStandardProperties(window->display->dpy, window->win, window_title, window_title, None, NULL, 0, &xsh);
return(0);
}