It's supposed to create, manage, draw, and destroy X11 widgets with a cairo surface to draw.
Additional to subscribe to and handle events.
I decided to put it in the Public Domain, so everyone could do what ever he /she want's with it.
Now, here is the usual "hello world":
Code: Select all
#include "xputty.h"
static void draw_window(void *w_, void* user_data) {
Widget_t *w = (Widget_t*)w_;
cairo_push_group (w->cr);
cairo_set_source_rgb (w->cr, 1, 1, 1);
cairo_paint (w->cr);
cairo_pop_group_to_source (w->cr);
cairo_paint (w->cr);
}
int main (int argc, char ** argv)
{
Display *dpy = XOpenDisplay(0);
XContext context = XUniqueContext();
Widget_t *w;
w = create_window(dpy, DefaultRootWindow(dpy), context, 0, 0, 300, 200);
XStoreName(dpy, w->widget, "Xputty Hello world");
w->func.expose_callback = draw_window;
bool run = true;
loop(w,context,&run);
destroy_widget( w, context);
XCloseDisplay(dpy);
return 0;
}
The repository contain a example folder showing some of the features supported by the layer.
It's a tiny, but powerful abstraction of the X11 low level API to easier the process to create nice GUI's.
Documentation is included in the source code, it's a single header and a single c file.
All together just 654 lines, were most lines taken by documentation.
So, here you go:
https://github.com/brummer10/Xputty