1) Caller has t get a conn: NewConn Myconn;
2) Caller gets one or more windows and one or more GC, graphics contexts.
3) Caller then creates rects within windows and stuffs text into rects. The rect is redrawn, one way or the other, when the caller puts text to rect. Not to difficult, or their is one thing, The caller has a:
DrawRect rect gc; , not shown. But it connects the GC to the rect an draws. The GC stays connect to rect until another DrawRect is made. Very simple, do it from the command line.
The system measures font sozes and sets line height, mostly. The symbol table is fast, but limited to eight character names. The system would make a great interface for font based strategy games of all sorts. When xcb wants a redraw of the screen, Xchars will just go though the symbol list and find rects within the redraw area. Thus it needs to retain the attached gc entry.
The xcb system is a good system, even under Wayland architecture, xcb is a still good interface to a rendering client.
char *t1[] ={"NewConn","Myconn"};
char *t2[] ={"NewWin","Myconn","Mywin"};
char *t3[] ={"NewGC","Myconn", "Mygc"};
char *t4[] ={"SetRGB","Myconn","Mygc","100","101","102"};
char *t5[] ={"NewRect","Mywin","Myrect","20","20","60","70"};
char *t6[] ={"PutStr","Myrect","HelloWorld"};
I used a trick on xcb. I created a structure that held each of the major xcb_thing_t that I might need, froms canning the examples. Then I cutnpaste their example and replace the arguments with: my_xcb_creatcontex_checked(Box * b){}
So in their code when they had something like:
screen = data.iter, which I barely know, I replace with: b->screen=data.iter.
So, though I barely now the details, at least I am making the calls and collecting xcb things, thus learning the sequence of filling up a box of xcb things. Helped a lot, I am keeping it. As the caller makes his calls into Xchars, it is filling its box A caller is fills the xcb box on a per connection basis, so I keep one box per connection. The box will hold the last valid settings of for that connection, up to rect, then wins handle rects. Box don't do rects.
By the way:
Here is an example of redneck programming at its finest. In China they would throw me in gcc jail for pulling this stunt. But there ain't no gcc warning machine beat me. I use he same names in structures as xcb examples, it is almost a search and substitute. But I have done this, gone through these graphics interfaces many times.
typedef union {
unsigned long l;
char * s;
void * vp;
EntryType * entry;
char txt[8];
xcb_font_t font;
xcb_screen_t *screen;
xchars_rect_t *rect;
xcb_window_t win;
xchars_gc_t gc;
xcb_connection_t *conn;
Box * box;
} Val;
No comments:
Post a Comment