diff options
author | Jesse Luehrs <doy@tozt.net> | 2014-04-05 00:35:58 -0400 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2014-04-05 00:35:58 -0400 |
commit | 2f1c8d35e6a824544714c7eed274f88121322618 (patch) | |
tree | 7cd0eafb9b436a9aca5a428fe8473d0230bafe7e /xlib.c | |
download | runes-2f1c8d35e6a824544714c7eed274f88121322618.tar.gz runes-2f1c8d35e6a824544714c7eed274f88121322618.zip |
initial commit
Diffstat (limited to 'xlib.c')
-rw-r--r-- | xlib.c | 57 |
1 files changed, 57 insertions, 0 deletions
@@ -0,0 +1,57 @@ +#include <cairo-xlib.h> +#include <stdlib.h> +#include <X11/Xlib.h> + +#include "xlib.h" + +RunesWindow *runes_window_create() +{ + RunesWindow *w; + unsigned long white; + + w = malloc(sizeof(RunesWindow)); + + w->dpy = XOpenDisplay(NULL); + white = WhitePixel(w->dpy, DefaultScreen(w->dpy)); + w->w = XCreateSimpleWindow( + w->dpy, DefaultRootWindow(w->dpy), + 0, 0, 240, 80, 0, white, white + ); + + XSelectInput(w->dpy, w->w, StructureNotifyMask); + XMapWindow(w->dpy, w->w); + w->gc = XCreateGC(w->dpy, w->w, 0, NULL); + XSetForeground(w->dpy, w->gc, white); + + for (;;) { + XEvent e; + + XNextEvent(w->dpy, &e); + if (e.type == MapNotify) { + break; + } + } + + return w; +} + +cairo_surface_t *runes_surface_create(RunesWindow *w) +{ + Visual *vis; + + vis = DefaultVisual(w->dpy, DefaultScreen(w->dpy)); + return cairo_xlib_surface_create(w->dpy, w->w, vis, 240, 80); +} + +void runes_window_flush(RunesWindow *w) +{ + XFlush(w->dpy); +} + +void runes_window_destroy(RunesWindow *w) +{ + XDestroyWindow(w->dpy, w->w); + XCloseDisplay(w->dpy); + + free(w); +} |