aboutsummaryrefslogtreecommitdiffstats
path: root/xlib-testing.c
diff options
context:
space:
mode:
authorEliteTK <tomasz.kramkowski@gmail.com>2014-05-24 12:58:39 +0100
committerEliteTK <tomasz.kramkowski@gmail.com>2014-05-24 12:58:39 +0100
commit5bbcb1f542c239ce1e9b5a7d3c7214a7bf001d6a (patch)
tree47ef91ea74fc60660d79b87ec00f8f25d6366722 /xlib-testing.c
parent420ef6622d9e8de96ffc1843b9b4c3c3ea87b1c9 (diff)
downloadc-stuff-5bbcb1f542c239ce1e9b5a7d3c7214a7bf001d6a.tar.gz
c-stuff-5bbcb1f542c239ce1e9b5a7d3c7214a7bf001d6a.tar.xz
c-stuff-5bbcb1f542c239ce1e9b5a7d3c7214a7bf001d6a.zip
More random stuff.
Diffstat (limited to 'xlib-testing.c')
-rw-r--r--xlib-testing.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/xlib-testing.c b/xlib-testing.c
new file mode 100644
index 0000000..cfb35c0
--- /dev/null
+++ b/xlib-testing.c
@@ -0,0 +1,40 @@
+#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);
+}