-
Notifications
You must be signed in to change notification settings - Fork 0
/
xlib-testing.c
50 lines (37 loc) · 1.1 KB
/
xlib-testing.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
/*
* Copyright (C) 2014 Tomasz Kramkowski <[email protected]>
*
* This program is free software. It is licensed under version 3 of the
* GNU General Public License.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see [http://www.gnu.org/licenses/].
*/
#include <X11/Xlib.h>
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char **argv)
{
Display *d = XOpenDisplay(NULL);
if (!d) {
fprintf(stderr, "Could not open display.");
exit(1);
}
unsigned long int black = BlackPixel(d, DefaultScreen(d));
unsigned long int white = WhitePixel(d, DefaultScreen(d));
Window w = XCreateSimpleWindow(d, DefaultRootWindow(d), 0, 0, 300, 300, 0, black, white);
XSelextInput(d, w, StructureNotifyMask);
XMapWindow(d, w);
GC gc = XCreateGC(d, w, 0, NULL);
XSetForeground(d, gc, white);
while(1) {
XEvent e;
XNextEvent(d, &e);
if (e.type == MapNotify)
break;
}
XDrawLine(d, w, gc, 10, 60, 180, 20);
XFlush(d);
sleep(10);
XCloseDisplay(d);
}