#include #include "xenon.h" #include "window.h" #include "display.h" #include "damage.h" #include "render.h" #include "draw.h" #include "util.h" Status XAllocColor( Display* display, Colormap colormap, XColor* screen_in_out ) { printf("alloc color ok\n"); } int XCloseDisplay( Display* display ) { printf("close display ok\n"); } GC XCreateGC( Display* display, Drawable d, unsigned long valuemask, XGCValues* values ) { // XXX init hack, remove when the renderer is changed to gallium extern int inhibit_rendering; if (inhibit_rendering) { void* handle; handle = dlopen("/usr/lib64/libX11.so.6", RTLD_LAZY); if (!handle) handle = dlopen("/usr/lib/libX11.so.6", RTLD_LAZY); if (!handle) printf("can't open libX11\n"); typedef GC (* XCreateGCfunc) (Display*, Drawable,unsigned long, XGCValues*); XCreateGCfunc XCreateGCreal = dlsym(handle, "XCreateGC"); return XCreateGCreal(display, d, valuemask, values); } printf("create GC ok\n"); } Pixmap XCreatePixmap( Display* display, Drawable d, unsigned int width, unsigned int height, unsigned int depth ) { printf("create pixmap ok\n"); } Window XCreateSimpleWindow( Display* display, Window parent, int x, int y, unsigned int width, unsigned int height, unsigned int border_width, unsigned long border, unsigned long background ) { Window wid = window_create(); window_resize(wid, width, height); window_move(wid, x, y); printf("simple window ok\n"); return wid; } int XDrawLine( Display* display, Drawable d, GC gc, int x1, int y1, int x2, int y2 ) { } int XDrawPoint( Display* display, Drawable d, GC gc, int x, int y ) { draw_point(gc, x, y); } int XDrawRectangle( Display* display, Drawable d, GC gc, int x, int y, unsigned int width, unsigned int height ) { xenon_rect r = {x,y,width,height}; draw_rectangle(gc, &r); printf("draw rectangle ok\n"); } int XDrawString( Display* display, Drawable d, GC gc, int x, int y, _Xconst char* string, int length ) { printf("draw string ok\n"); } int XFillRectangle( Display* display, Drawable d, GC gc, int x, int y, unsigned int width, unsigned int height ) { printf("fill rectangle ok\n"); } int XFlush( Display* display ) { render_update(damage_current()); damage_clear(); printf("flush ok\n"); } void XFlushGC( Display* display, GC gc ) { XFlush(display); } int XMapWindow( Display* display, Window w ) { printf("map window ok\n"); } int XNextEvent( Display* display, XEvent* event_return ) { printf("event requested\n"); event_return->type = KeyPress; } Display *XOpenDisplay( _Xconst char* name /* display_name */ ) { Display* r = display_find(name); printf("open display ok\n"); return r; } Status XParseColor( Display* display, Colormap colormap, _Xconst char* spec, XColor* exact_def_return ) { unsigned long r,g,b; if (!spec) return BadValue; if (spec[0] == '#') { switch(strlen(spec)) { case 4: r = hexval(spec[1]) << 12; g = hexval(spec[2]) << 12; b = hexval(spec[3]) << 12; break; case 7: r = ( hexval(spec[1]) << 12 ) + ( hexval(spec[2]) << 8 ); g = ( hexval(spec[3]) << 12 ) + ( hexval(spec[4]) << 8 ); b = ( hexval(spec[5]) << 12 ) + ( hexval(spec[6]) << 8 ); break; case 10: r = ( hexval(spec[1]) << 12 ) + ( hexval(spec[2]) << 8 ) + ( hexval(spec[3]) << 4 ); g = ( hexval(spec[4]) << 12 ) + ( hexval(spec[5]) << 8 ) + ( hexval(spec[6]) << 4 ); b = ( hexval(spec[7]) << 12 ) + ( hexval(spec[8]) << 8 ) + ( hexval(spec[9]) << 4 ); break; case 13: r = ( hexval(spec[1]) << 12 ) + ( hexval(spec[2]) << 8 ) + ( hexval(spec[3]) << 4 ) + hexval(spec[4]); g = ( hexval(spec[5]) << 12 ) + ( hexval(spec[6]) << 8 ) + ( hexval(spec[7]) << 4 ) + hexval(spec[8]); b = ( hexval(spec[9]) << 12 ) + ( hexval(spec[10]) << 8 ) + ( hexval(spec[11]) << 4 ) + hexval(spec[12]); break; default: return BadValue; } exact_def_return -> red = r; exact_def_return -> green = g; exact_def_return -> blue = b; exact_def_return -> pixel = (r << 32) | (g << 16) | b; printf("parse color ok %x-%x-%x\n",r>>8,g>>8,b>>8); } else { return BadValue; } } int XPutImage( Display* display, Drawable d, GC gc, XImage* image, int src_x, int src_y, int dest_x, int dest_y, unsigned int width, unsigned int height ) { // XXX init hack, remove when the renderer is changed to gallium extern int inhibit_rendering; if (inhibit_rendering) { void* handle; handle = dlopen("/usr/lib64/libX11.so.6", RTLD_LAZY); if (!handle) handle = dlopen("/usr/lib/libX11.so.6", RTLD_LAZY); if (!handle) printf("can't open libX11\n"); typedef int (* XPutImagefunc) (Display*, Drawable, GC, XImage*, int, int, int, int, unsigned, unsigned); XPutImagefunc XPutImagereal = dlsym(handle, "XPutImage"); return XPutImagereal(display, d, gc, image, src_x, src_y, dest_x, dest_y, width, height); } xenon_rect r = {src_x,src_y,width,height}; draw_image(gc, image, &r, dest_x, dest_y); printf("put image ok\n"); } int XSelectInput( Display* display, Window w, long event_mask ) { printf("select input ok\n"); } int XSetForeground( Display* display, GC gc, unsigned long foreground ) { printf("set foreground ok\n"); }