#ifndef WH_LX_H_155b8c89_ #define WH_LX_H_155b8c89_ #include typedef unsigned int LX_XID; /* * Ideally, I'd like to set things up so that (to pick an example) * LX_WCLASS is the type of a window class, with values such as * LX_WCLASS_InputOutput and LX_WCLASS_InputOnly, and we get strict * typechecking from the compiler, so that passing a non-LX_WCLASS_* * value as an LX_WCLASS argument produces a type mismatch error. But * I also want LX_WCLASS_InputOutput and LX_WCLASS_InputOnly to be * compile-time constants, so they are suitable for use in switches. * * I have not come up with a way to get both. The compromise I'm * picking is to use compile-time constant values and back off to * run-time typechecking, by using values such that (for example) * LX_WCLASS_InputOutput does not equal LX_BACKINGSTORE_WhenMapped, * even though they have the same representation in the protocol, so, * while it won't be a compile-time error to pass * LX_BACKINGSTORE_WhenMapped as a window class, it will be a run-time * error. * * This is especially relevant for values that are a set of fixed * alternatives or an X ID, such as the input focus window (which is a * window ID or None or PointerRoot). * * We can pick values which are known to be disjoint from X IDs because * X IDs never have any of the 0xe0000000 bits set. */ typedef unsigned int LX_IMAGE_BYTE_ORDER; #define LX_IBO_LSBFirst 0x20000001 #define LX_IBO_MSBFirst 0x20000002 typedef unsigned int LX_BITMAP_BIT_ORDER; #define LX_BBO_LeastSignificant 0x20000003 #define LX_BBO_MostSignificant 0x20000004 typedef unsigned int LX_WINDOW_CLASS; #define LX_WCLASS_InputOutput 0x20000005 #define LX_WCLASS_InputOnly 0x20000006 #define LX_WCLASS_CopyFromParent 0x20000007 #define LX__WCLASS_Error 0x20000019 typedef unsigned int LX_GRAVITY; #define LX_GRAVITY_NorthWest 0x2000000d #define LX_GRAVITY_North 0x2000000e #define LX_GRAVITY_NorthEast 0x2000000f #define LX_GRAVITY_West 0x20000010 #define LX_GRAVITY_Center 0x20000011 #define LX_GRAVITY_East 0x20000012 #define LX_GRAVITY_SouthWest 0x20000013 #define LX_GRAVITY_South 0x20000014 #define LX_GRAVITY_SouthEast 0x20000015 #define LX_GRAVITY_Static 0x20000016 #define LX_GRAVITY_Forget 0x20000017 #define LX_GRAVITY_Unmap 0x20000018 #define LX__GRAVITY_Error 0x20000022 typedef unsigned int LX_BACKINGSTORE; #define LX_BACKINGSTORE_NotUseful 0x2000001d #define LX_BACKINGSTORE_WhenMapped 0x2000001e #define LX_BACKINGSTORE_Always 0x2000001f #define LX__BACKINGSTORE_Error 0x20000023 typedef unsigned int LX_GCFUNCTION; #define LX_GCFUNCTION__base 0x20000030 #define LX_GCFUNCTION__mask 0x0000000f #define LX_GCFUNCTION__src 0x00000003 #define LX_GCFUNCTION__dst 0x00000005 #define LX_GCFUNCTION_norm(x) (((x) & LX_GCFUNCTION__mask) | LX_GCFUNCTION__base) #define LX_GCFUNCTION_Clear 0x20000030 #define LX_GCFUNCTION_And 0x20000031 #define LX_GCFUNCTION_AndReverse 0x20000032 #define LX_GCFUNCTION_Copy 0x20000033 #define LX_GCFUNCTION_AndInverted 0x20000034 #define LX_GCFUNCTION_NoOp 0x20000035 #define LX_GCFUNCTION_Xor 0x20000036 #define LX_GCFUNCTION_Or 0x20000037 #define LX_GCFUNCTION_Nor 0x20000038 #define LX_GCFUNCTION_Equiv 0x20000039 #define LX_GCFUNCTION_Invert 0x2000003a #define LX_GCFUNCTION_OrReverse 0x2000003b #define LX_GCFUNCTION_CopyInverted 0x2000003c #define LX_GCFUNCTION_OrInverted 0x2000003d #define LX_GCFUNCTION_Nand 0x2000003e #define LX_GCFUNCTION_Set 0x2000003f #define LX__GCFUNCTION_Error 0x2000002c typedef unsigned int LX_GCLINESTYLE; #define LX_GCLINESTYLE_Solid 0x2000002d #define LX_GCLINESTYLE_OnOffDash 0x2000002e #define LX_GCLINESTYLE_DoubleDash 0x2000002f #define LX__GCLINESTYLE_Error 0x20000040 typedef unsigned int LX_GCCAPSTYLE; #define LX_GCCAPSTYLE_NotLast 0x20000041 #define LX_GCCAPSTYLE_Butt 0x20000042 #define LX_GCCAPSTYLE_Round 0x20000043 #define LX_GCCAPSTYLE_Projecting 0x20000044 #define LX__GCCAPSTYLE_Error 0x20000045 typedef unsigned int LX_GCJOINSTYLE; #define LX_GCJOINSTYLE_Miter 0x20000046 #define LX_GCJOINSTYLE_Round 0x20000047 #define LX_GCJOINSTYLE_Bevel 0x20000048 #define LX__GCJOINSTYLE_Error 0x20000049 typedef unsigned int LX_GCFILLSTYLE; #define LX_GCFILLSTYLE_Solid 0x2000004a #define LX_GCFILLSTYLE_Tiled 0x2000004b #define LX_GCFILLSTYLE_Stippled 0x2000004c #define LX_GCFILLSTYLE_OpaqueStippled 0x2000004d #define LX__GCFILLSTYLE_Error 0x2000004e typedef unsigned int LX_GCFILLRULE; #define LX_GCFILLRULE_EvenOdd 0x2000004f #define LX_GCFILLRULE_Winding 0x20000050 #define LX__GCFILLRULE_Error 0x20000051 typedef unsigned int LX_GCSUBWINDOWMODE; #define LX_GCSUBWINDOWMODE_ClipByChildren 0x20000052 #define LX_GCSUBWINDOWMODE_IncludeInferiors 0x20000053 #define LX__GCSUBWINDOWMODE_Error 0x20000054 typedef unsigned int LX_GCARCMODE; #define LX_GCARCMODE_Chord 0x20000055 #define LX_GCARCMODE_PieSlice 0x20000056 #define LX__GCARCMODE_Error 0x20000057 typedef unsigned int LX_OPEN_STATUS; #define LX_OPENSTATUS_failed 0x20000028 #define LX_OPENSTATUS_worked 0x20000029 typedef unsigned int LX_COORDMODE; #define LX_COORDMODE_Origin 0x20000058 #define LX_COORDMODE_Previous 0x20000059 typedef unsigned int LX_MAPSTATE; #define LX_MAPSTATE_Unmapped 0x2000005a #define LX_MAPSTATE_Unviewable 0x2000005b #define LX_MAPSTATE_Viewable 0x2000005c #define LX__MAPSTATE_Error 0x2000005d /* * LX_CONN and LX_OP are opaque to application code. */ typedef struct lx_conn LX_CONN; typedef struct lx_op LX_OP; /* * Library types which are _not_ opaque. */ // Used to represent a line segment for, eg, lx_PolySegment. typedef struct lx_segment LX_SEGMENT; struct lx_segment { int x1; int y1; int x2; int y2; } ; // Used to represent a point for, eg, lx_PolyPoint. typedef struct lx_point LX_POINT; struct lx_point { int x; int y; } ; typedef struct lx_window_attributes LX_WINDOW_ATTRIBUTES; struct lx_window_attributes { unsigned int backing_store; LX_XID visual; unsigned int class; LX_GRAVITY bit_gravity; LX_GRAVITY win_gravity; unsigned int backing_planes; unsigned int backing_pixel; int save_under; int cmap_installed; LX_MAPSTATE map_state; int override_redirect; LX_XID colormap; unsigned int all_events; unsigned int our_events; unsigned int dont_propagate; } ; /* * An X error. See below about error handling. */ typedef enum { LXXE_Request = 1, LXXE_Value, LXXE_Window, LXXE_Pixmap, LXXE_Atom, LXXE_Cursor, LXXE_Font, LXXE_Match, LXXE_Drawable, LXXE_Access, LXXE_Alloc, LXXE_Colormap, LXXE_GContext, LXXE_IDChoice, LXXE_Name, LXXE_Length, LXXE_Implementation, LXXE_Other, } LX_X_ERR_TYPE; typedef struct lx_X_err LX_X_ERR; struct lx_X_err { LX_X_ERR_TYPE type; union { struct { unsigned int seq; unsigned int opc_major; unsigned int opc_minor; } request; // if LXXE_Request struct { unsigned int seq; unsigned int value; unsigned int opc_major; unsigned int opc_minor; } value; // if LXXE_Value struct { unsigned int seq; unsigned int id; unsigned int opc_major; unsigned int opc_minor; } window; // if LXXE_Window struct { unsigned int seq; unsigned int id; unsigned int opc_major; unsigned int opc_minor; } pixmap; // if LXXE_Pixmap struct { unsigned int seq; unsigned int id; unsigned int opc_major; unsigned int opc_minor; } atom; // if LXXE_Atom struct { unsigned int seq; unsigned int id; unsigned int opc_major; unsigned int opc_minor; } cursor; // if LXXE_Cursor struct { unsigned int seq; unsigned int id; unsigned int opc_major; unsigned int opc_minor; } font; // if LXXE_Font struct { unsigned int seq; unsigned int opc_major; unsigned int opc_minor; } match; // if LXXE_Match struct { unsigned int seq; unsigned int id; unsigned int opc_major; unsigned int opc_minor; } drawable; // if LXXE_Drawable struct { unsigned int seq; unsigned int opc_major; unsigned int opc_minor; } access; // if LXXE_Access struct { unsigned int seq; unsigned int opc_major; unsigned int opc_minor; } alloc; // if LXXE_Alloc struct { unsigned int seq; unsigned int id; unsigned int opc_major; unsigned int opc_minor; } colormap; // if LXXE_Colormap struct { unsigned int seq; unsigned int id; unsigned int opc_major; unsigned int opc_minor; } gcontext; // if LXXE_GContext struct { unsigned int seq; unsigned int id; unsigned int opc_major; unsigned int opc_minor; } idchoice; // if LXXE_IDChoice; struct { unsigned int seq; unsigned int opc_major; unsigned int opc_minor; } name; // if LXXE_Name struct { unsigned int seq; unsigned int opc_major; unsigned int opc_minor; } length; // if LXXE_Length struct { unsigned int seq; unsigned int opc_major; unsigned int opc_minor; } implementation; // if LXXE_Implementation struct { unsigned int type; unsigned int seq; unsigned int opc_major; unsigned int opc_minor; } other; // if LXXE_Other } u; } ; /* * A library-internal error. See below about error handling. * * LXLE_NOMEM * Out of memory (eg, malloc() failed). * LXLE_SYSERR * Error from a syscall, with errno. * LXLE_OSLIBERR * Error from an OS library call, potentially with message. * LXLE_BAD_CALL * Some API function was called incorrectly. This is an * application failure. u.bad_call.fn is the name of the * incorrectly-called API function. * LXLE_NO_DISPLAY * lx_open was passed no display string and thre was no $DISPLAY * in the environment. * LXLE_BAD_DISPLAY * The display string to lx_open (either passed in or from * $DISPLAY) was erroneous in some way. * LXLE_UNX_EOF * The library got an unexpected EOF on the X connection. * LXLE_ALL_FAIL * lx_open ran out of addresses to try without getting a * connection. u.all_fail.msg may have a helpful message. * LXLE_PROTO_ERR * The library got an X protocol error. u.proto_err.msg briefly * states the error. * LXLE_REJECTED * The X server rejected the connection. u.rejected.msg is the * message the server returned. */ typedef enum { LXLE_NOMEM = 1, LXLE_SYSERR, LXLE_OSLIBERR, LXLE_BAD_CALL, LXLE_NO_DISPLAY, LXLE_BAD_DISPLAY, LXLE_UNX_EOF, LXLE_ALL_FAIL, LXLE_PROTO_ERR, LXLE_REJECTED, } LX_LIB_ERR_TYPE; typedef struct lx_lib_err LX_LIB_ERR; struct lx_lib_err { LX_LIB_ERR_TYPE type; union { // nothing for LXLE_NOMEM struct { // syscall which returned error const char *call; // errno returned int err; } syserr; // for LXLE_SYSERR struct { // library call which returned error const char *call; // message, nil if none const char *msg; } osliberr; // for LXLE_OSLIBERR struct { // API function which was called wrong const char *fn; } bad_call; // for LXLE_BAD_CALL // nothing for LXLE_NO_DISPLAY // nothing for LXLE_BAD_DISPLAY // nothing for LXLE_UNX_EOF struct { const char *msg; } all_fail; // for LXLE_ALL_FAIL struct { const char *msg; } proto_err; // for LXLE_PROTO_ERR struct { const char *msg; } rejected; // for LXLE_REJECTED } u; } ; /* * Error handling (the bane of many APIs). We deal with errors via * callbacks. Each connection has two error callbacks, an X error * callback and a library error callback. * * The X error callback is called when an X error is received. It gets * the relevant LX_CONN * and an LX_X_ERR *, which is a discriminated * union holding the unpacked X error packet. It must return an * LX_X_ERR_ACTION, one of * * LX_X_ERR_IGNORE * Ignore the X error event. Carry on as though it had * not been received at all. * * LX_X_ERR_CRASH * Print a description of the error to stderr and exit(1). * * If no X error callback is set, it is as if one were which did * nothing but return LX_X_ERR_CRASH. * * The library error callback is called when a locally-detected error * is discovered by the library. This can be anything from a * can't-happen tset firing to an I/O error to an incorrect * application call. The library error callback gets the relevant * LX_CONN * and an LX_LIB_ERR value describing the error. (lx_open * has its own, different, error handling mechanisms, because it can * encounter errors when it doesn't have an LX_CONN * at all.) It * returns void; if it returns, the library unwinds far enough to * return to the application, but in most cases the LX_CONN is no * longer usable and there is nothing useful to do but lx_close it. * There is one exception; if an LXLE_BAD_CALL handler returns, the * bad call is ignored, as if it had not been made at all. * * If no library error callback is set, the library supplies one which * prints a message to stderr and exits with code 1. * * Error handlers must never throw out. Doing so may leave things in * an inconsistent state, leading to indeterminate later trouble. * * In all cases, the LX_X_ERR or LX_LIB_ERR object pointed to (and * anything it in turn points to) may go invalid as soon as the * handler returns. Any data to be saved from it must be copied * within the handler. * * When a connection is first created, its error handlers are unset. * They can be set with lx_err_set_X() and lx_err_set_lib(), each of * which returns the previously set handler. Passing in a nil pointer * is equivalent to passing in the original library-provided default * function pointer. */ typedef enum { LX_X_ERR_IGNORE = 1, LX_X_ERR_CRASH, } LX_X_ERR_ACTION; extern LX_X_ERR_ACTION (*lx_err_set_X(LX_CONN *, LX_X_ERR_ACTION (*)(LX_CONN *, const LX_X_ERR *)))(LX_CONN *, const LX_X_ERR *); extern void (*lx_err_set_lib(LX_CONN *, void (*)(LX_CONN *, const LX_LIB_ERR *)))(LX_CONN *, const LX_LIB_ERR *); /* * There are various internal functions prototyped here as well, * typically because they are part of the implementation behind a * macro. Any name lx__* or LX__* should be considered an internal * interface, not part of the interface contract and not to be used * directly. */ /* * Open a new connection. Arglist: * * const char *dispname, * void (*err)(const LX_LIB_ERR *, void *), * void (*done)(LX_CONN *, void *), * AIO_LOOP *loop, * void *cbarg, * unsigned int flags * * dispname is a string is of the form * lhs:rhs * where lhs is one of * hostname * numeric-v4-address * [address-literal] * the four-character string "unix" * the zero-length string * and rhs is one of * D * D.S * (D and S are decimal integers) * * err is a function which is called on error. It gets passed an * LX_LIB_ERR pointer and the cbarg value (see below). This pointer * may be nil, in which case the library provides a default which * prints a suitable message to stderr and exits with status 1. As * for calls to the library error handler (see above), the LX_LIB_ERR * pointer must be considered invalid once the handler returns. * * done is a function which is called on success. It gets the * resulting LX_CONN pointer and the cbarg value (see below). * * loop is the AIO_LOOP the library is to use for this connection. * This may be nil, in which case the library uses the global loop. * * cbarg is a pointer, opaque to the library, which is passaed to err * or done, whichever gets called. * * flags is zero or more of the LX_OPENF_* flag bits: * * LX_OPENF_NO_PREAMBLE * By default, the library automatically does some initial * protocol exchanges (such as querying and, if supported, * enabling BIG_REQUESTS) as part of the connection open. * Specifying this suppresses these; the only protocol * done as part of open is then just the strict minimum. * LX_OPENF_DEBUG * Turns on internal debugging code. What there is and * what it does is not documented here; it is there to * help debug the library, so UTSL. * * Note that err and done may be called from within lx_open(); it is an * error to assume that they will not be called until later. */ extern void lx_open( const char *, void (*)(const LX_LIB_ERR *, void *), void (*)(LX_CONN *, void *), AIO_LOOP *, void *, unsigned int ); #define LX_OPENF_NO_PREAMBLE 0x00000001 #define LX_OPENF_DEBUG 0x00000002 /* * lx_close closes an X connection. This implies lx_op_drop on all * pending LX_OPs on it. */ extern void lx_close(LX_CONN *); /* * User data. Each LX_CONN has a void * user data pointer. This is * set to nil when the connection is created and can be set by * lx_set_udata and get by lx_get_udata, but is otherwise not used by * the library at all. */ extern void lx_set_udata(LX_CONN *, void *); extern void *lx_get_udata(LX_CONN *); /* * There are two general paradigms for requests: open-loop and * response-expected. An example of an open-loop request might be * CreateWindow; an example of a response-expected request might be * GetWindowAttributes. * * For open-loop requests, the call (eg, lx_CreateWindow) returns the * results, if any, immediately (eg, an LX_XID for lx_CreateWindow, or * nothing for lx_Bell) and there is no way to tell when it has * completed, except indirectly, such as by a later response-expected * request's response arriving. * * For response-expected requests, the call returns an LX_OP pointer, * which can be passed to various calls, such as lx_op_callback, to do * useful things with the pending request. */ // conn, percent extern void lx_Bell(LX_CONN *, int); // conn, focusp, revertp extern LX_OP *lx_GetInputFocus(LX_CONN *, LX_XID *, LX_XID *); // conn, parent, x, y, w, h, bw, dp, class, vis, ... extern LX_XID lx_CreateWindow(LX_CONN *, LX_XID, int, int, unsigned int, unsigned int, unsigned int, int, LX_WINDOW_CLASS, LX_XID, ...); #define LX_CWV_BackPixmap(pm) LX__CWV_BackPixmap, lx__cvt_LX_XID((pm)) #define LX_CWV_BackPixel(pix) LX__CWV_BackPixel, lx__cvt_pixel((pix)) #define LX_CWV_BorderPixmap(pm) LX__CWV_BorderPixmap, lx__cvt_LX_XID((pm)) #define LX_CWV_BorderPixel(pix) LX__CWV_BorderPixel, lx__cvt_pixel((pix)) #define LX_CWV_BitGravity(g) LX__CWV_BitGravity, lx__cvt_LX_XID((g)) #define LX_CWV_WinGravity(g) LX__CWV_WinGravity, lx__cvt_LX_XID((g)) #define LX_CWV_BackingStore(bs) LX__CWV_BackingStore, lx__cvt_LX_XID((bs)) #define LX_CWV_BackingPlanes(bp) LX__CWV_BackingPlanes, lx__cvt_pixel((bp)) #define LX_CWV_BackingPixel(bp) LX__CWV_BackingPixel, lx__cvt_pixel((bp)) #define LX_CWV_OverrideRedirect(or) LX__CWV_OverrideRedirect, lx__cvt_bool((or)) #define LX_CWV_SaveUnder(su) LX__CWV_SaveUnder, lx__cvt_bool((su)) #define LX_CWV_EventMask(em) LX__CWV_EventMask, lx__cvt_mask((em)) #define LX_CWV_DontPropagate(dp) LX__CWV_DontPropagate, lx__cvt_eventmask((dp)) #define LX_CWV_Colormap(cmap) LX__CWV_Colormap, lx__cvt_LX_XID((cmap)) #define LX_CWV_Cursor(curs) LX__CWV_Cursor, lx__cvt_LX_XID((curs)) #define LX_CWV_END LX__CWV_END // conn, visual, window, alloc extern LX_XID lx_CreateColormap(LX_CONN *, LX_XID, LX_XID, LX_XID); // conn, window extern void lx_MapWindow(LX_CONN *, LX_XID); // conn, cmap, r, g, b, pix, actr, actg, actb extern LX_OP *lx_AllocColor(LX_CONN *, LX_XID, unsigned int, unsigned int, unsigned int, unsigned int *, unsigned int *, unsigned int *, unsigned int *); // conn, drawable, ... extern LX_XID lx_CreateGC(LX_CONN *, LX_XID, ...); #define LX_GCV_Function(f) LX__GCV_Function, lx__cvt_LX_XID((f)) #define LX_GCV_PlaneMask(pm) LX__GCV_PlaneMask, lx__cvt_mask((pm)) #define LX_GCV_Foreground(pix) LX__GCV_Foreground, lx__cvt_pixel((pix)) #define LX_GCV_Background(pix) LX__GCV_Background, lx__cvt_pixel((pix)) #define LX_GCV_LineWidth(w) LX__GCV_LineWidth, lx__cvt_uint((w)) #define LX_GCV_LineStyle(ls) LX__GCV_LineStyle, lx__cvt_LX_XID((ls)) #define LX_GCV_CapStyle(cs) LX__GCV_CapStyle, lx__cvt_LX_XID((cs)) #define LX_GCV_JoinStyle(js) LX__GCV_JoinStyle, lx__cvt_LX_XID((js)) #define LX_GCV_FillStyle(fs) LX__GCV_FillStyle, lx__cvt_LX_XID((fs)) #define LX_GCV_FillRule(fr) LX__GCV_FillRule, lx__cvt_LX_XID((fr)) #define LX_GCV_Tile(pm) LX__GCV_Tile, lx__cvt_LX_XID((pm)) #define LX_GCV_Stipple(pm) LX__GCV_Stipple, lx__cvt_LX_XID((pm)) #define LX_GCV_TileStipXOrigin(xo) LX__GCV_TileStipXOrigin, lx__cvt_int((xo)) #define LX_GCV_TileStipYOrigin(yo) LX__GCV_TileStipYOrigin, lx__cvt_int((yo)) #define LX_GCV_Font(f) LX__GCV_Font, lx__cvt_LX_XID((f)) #define LX_GCV_SubwindowMode(sm) LX__GCV_SubwindowMode, lx__cvt_LX_XID((sm)) #define LX_GCV_GraphicsExposures(gx) LX__GCV_GraphicsExposures, lx__cvt_bool((gx)) #define LX_GCV_ClipXOrigin(cxo) LX__GCV_ClipXOrigin, lx__cvt_int((cxo)) #define LX_GCV_ClipYOrigin(cyo) LX__GCV_ClipYOrigin, lx__cvt_int((cyo)) #define LX_GCV_ClipMask(pm) LX__GCV_ClipMask, lx__cvt_LX_XID((pm)) #define LX_GCV_DashOffset(do) LX__GCV_DashOffset, lx__cvt_uint((do)) #define LX_GCV_Dashes(dl) LX__GCV_DashList, lx__cvt_uint((dl)) #define LX_GCV_ArcMode(am) LX__GCV_ArcMode, lx__cvt_LX_XID((am)) #define LX_GCV_END LX__GCV_END // conn, drawable, gc, nseg, segments extern void lx_PolySegment(LX_CONN *, LX_XID, LX_XID, int, const LX_SEGMENT *); // conn, gc, ... // varargs are the same as for lx_CreateGC extern void lx_ChangeGC(LX_CONN *, LX_XID, ...); // conn, drawable, depth, width, height extern LX_XID lx_CreatePixmap(LX_CONN *, LX_XID, unsigned int, unsigned int, unsigned int); // conn, drawable, gc, coord-mode, npts, points extern void lx_PolyPoint(LX_CONN *, LX_XID, LX_XID, LX_COORDMODE, int, const LX_POINT *); // conn, window, ... // varargs are the same as for lx_CreateWindow extern void lx_ChangeWindowAttributes(LX_CONN *, LX_XID, ...); // conn, window, attrs extern LX_OP *lx_GetWindowAttributes(LX_CONN *, LX_XID, LX_WINDOW_ATTRIBUTES *); /* * There are also a few functions which are conceptually like requests * but which are handled entirely within the library. */ // return number of screens // conn extern int lx_nscreens(LX_CONN *); // return root window of screen N (LX_WINDOW_None if error) // conn, N extern LX_XID lx_root(LX_CONN *, int); // return depth of root window of screen N (-1 if error) // conn, N extern int lx_root_depth(LX_CONN *, int); // return visual of root window of screen N (LX_VISUAL_None if error) // conn, N extern LX_XID lx_root_visual(LX_CONN *, int); // Distinguished values for input focus #define LX_FOCUS_None 0x20000008 #define LX_FOCUS_PointerRoot 0x20000009 #define LX_FOCUS_Parent 0x2000000a // Distinguished values for window IDs #define LX_WINDOW_None 0x2000000b // Distinguished values for pixmap IDs #define LX_PIXMAP_None 0x2000001a #define LX_PIXMAP_ParentRelative 0x2000001b #define LX_PIXMAP_CopyFromParent 0x2000001c // Distinguished values for visual IDs #define LX_VISUAL_None 0x2000000c #define LX_VISUAL_CopyFromParent 0x20000024 // Distinguished values for colormap IDs #define LX_COLORMAP_CopyFromParent 0x20000020 #define LX_COLORMAP_None 0x20000027 // Distinguished values for cursor IDs #define LX_CURSOR_None 0x20000021 // Distinguished values for CreateColormap alloc #define LX_AllocNone 0x20000025 #define LX_AllocAll 0x20000026 // Distinguished values for GC IDs #define LX_GC_None 0x2000002a // Distinguished values for GC clip-mask #define LX_GCCLIPMASK_None 0x2000002b /* * Handling for operations in progress. As outlined above, such * operations return LX_OP pointers. Every LX_OP pointer must * eventually be disposed of by one of: * * - Passing it to lx_op_drop. * - Passing it to lx_op_callback without the LX_OP_KEEP flag. * - Calling lx_close on its XCONN pointer. * * The calls are: * * void lx_op_callback(LX_OP *op, void (*cb)(void *), void *arg, unsigned int flags) * Sets a callback and argument to be called when op completes. * See below for flags. Note that using lx_op_callback without * LX_OP_KEEP means that the LX_OP will become invalid without any * notice to the application beyond the calling of the callback * (and not even that, if it's already completed, which can be * detected by calling lx_op_test). * * int lx_op_test(LX_OP *op) * Tests whether the request has completed, returning 0 if it has * not completed or 1 if it has. * * void lx_op_drop(LX_OP *op) * Indicates that the application no longer cares when op * completes. This also revokes any lx_op_callback on this op. * The LX_OP must not be passed to any lx_op_* functions, * including another lx_op_drop, after this call returns. * * void lx_op_set_udata(LX_OP *op, void *udata) * Sets op's user data pointer to udata. * * void *lx_op_udata(LX_OP *op) * Returns op's user data pointer. * * For lx_op_await and lx_op_callback, the flags argument selects * optional behaviour: * * LX_OP_KEEP * By default, these calls perform the equivalent of * lx_op_drop on the LX_OP once it completes. If * LX_OP_KEEP is set in the flags word, the LX_OP remains * valid. (To dispose of an LX_OP that is done but which * was kept this way, use lx_op_drop() - or lx_op_await() * without LX_OP_KEEP.) */ #define LX_OP_KEEP 0x00000001 extern void lx_op_await(LX_OP *, unsigned int); extern void lx_op_callback(LX_OP *, void (*)(void *), void *, unsigned int); extern int lx_op_test(LX_OP *); extern void lx_op_drop(LX_OP *); extern void lx_op_set_udata(LX_OP *, void *); extern void *lx_op_udata(LX_OP *); /* * lx_abort() is a somewhat odd case. It is an interface which lx * calls but the user will, optionally, provide. It is called in a * few circumstances that should never happen, such as when the * application has misused an API or when the library bugchecks. If * the application defines lx_abort(), the library will call it in * these circumstances. Otherwise, it will call a version of its own * which calls abort(). * * lx_abort() normally should not return. If it ever does, the library * tries to do something reasonable, but no promises are made about * precisely what. */ extern void lx_abort(void); /* * Implementation support for the LX_OPEN_* macros. */ #define LX__OPEN_END (-1700) #define LX__OPEN_ERR (-1701) #define LX__OPEN_CB (-1702) #define LX__OPEN_USE_LOOP (-1703) #define LX__OPEN_NO_PREAMBLE (-1704) #define LX__OPEN_DEBUG (-1705) /* * Implementation support for the LX_CWV_* macros. */ #define LX__CWV_BackPixmap (-1750) #define LX__CWV_BackPixel (-1751) #define LX__CWV_BorderPixmap (-1752) #define LX__CWV_BorderPixel (-1753) #define LX__CWV_BitGravity (-1754) #define LX__CWV_WinGravity (-1755) #define LX__CWV_BackingStore (-1756) #define LX__CWV_BackingPlanes (-1757) #define LX__CWV_BackingPixel (-1758) #define LX__CWV_OverrideRedirect (-1759) #define LX__CWV_SaveUnder (-1760) #define LX__CWV_EventMask (-1761) #define LX__CWV_DontPropagate (-1762) #define LX__CWV_Colormap (-1763) #define LX__CWV_Cursor (-1764) #define LX__CWV_END (-1765) /* * Implementation support for the LX_GCV_* macros. */ #define LX__GCV_Function (-1800) #define LX__GCV_PlaneMask (-1801) #define LX__GCV_Foreground (-1802) #define LX__GCV_Background (-1803) #define LX__GCV_LineWidth (-1804) #define LX__GCV_LineStyle (-1805) #define LX__GCV_CapStyle (-1806) #define LX__GCV_JoinStyle (-1807) #define LX__GCV_FillStyle (-1808) #define LX__GCV_FillRule (-1809) #define LX__GCV_Tile (-1810) #define LX__GCV_Stipple (-1811) #define LX__GCV_TileStipXOrigin (-1812) #define LX__GCV_TileStipYOrigin (-1813) #define LX__GCV_Font (-1814) #define LX__GCV_SubwindowMode (-1815) #define LX__GCV_GraphicsExposures (-1816) #define LX__GCV_ClipXOrigin (-1817) #define LX__GCV_ClipYOrigin (-1818) #define LX__GCV_ClipMask (-1819) #define LX__GCV_DashOffset (-1820) #define LX__GCV_Dashes (-1821) #define LX__GCV_ArcMode (-1822) #define LX__GCV_END (-1823) /* * Arglist converters. */ #ifndef LX__EXTERN_INLINE #define LX__EXTERN_INLINE extern inline #endif extern char **lx__cvt_char_p_p(char **); LX__EXTERN_INLINE char **lx__cvt_char_p_p(char **arg) { return(arg); } extern void (*lx__cvt_fn_opencbarg(void (*)(void *, LX_OPEN_STATUS)))(void *, LX_OPEN_STATUS); LX__EXTERN_INLINE void (*lx__cvt_fn_opencbarg(void (*arg)(void *, LX_OPEN_STATUS)))(void *, LX_OPEN_STATUS) { return(arg); } extern void *lx__cvt_void_p(void *); LX__EXTERN_INLINE void *lx__cvt_void_p(void *arg) { return(arg); } extern int lx__cvt_int(int); LX__EXTERN_INLINE int lx__cvt_int(int arg) { return(arg); } extern AIO_LOOP *lx__cvt_AIO_LOOP_p(AIO_LOOP *); LX__EXTERN_INLINE AIO_LOOP *lx__cvt_AIO_LOOP_p(AIO_LOOP *arg) { return(arg); } extern unsigned long int lx__cvt_LX_XID(LX_XID); LX__EXTERN_INLINE unsigned long int lx__cvt_LX_XID(LX_XID arg) { return(arg); } extern int lx__cvt_bool(int); LX__EXTERN_INLINE int lx__cvt_bool(int arg) { return(arg); } extern unsigned int lx__cvt_mask(unsigned int); LX__EXTERN_INLINE unsigned int lx__cvt_mask(unsigned int arg) { return(arg); } extern unsigned int lx__cvt_pixel(unsigned int); LX__EXTERN_INLINE unsigned int lx__cvt_pixel(unsigned int arg) { return(arg); } /* * Reverse mapping for 0x20000000-and-up values. This is here to serve * as a registry, to make it harder to accidentally allocate the same * value to multiple names. * 0x20000001 LX_IBO_LSBFirst 0x20000002 LX_IBO_MSBFirst 0x20000003 LX_BBO_LeastSignificant 0x20000004 LX_BBO_MostSignificant 0x20000005 LX_WCLASS_InputOutput 0x20000006 LX_WCLASS_InputOnly 0x20000007 LX_WCLASS_CopyFromParent 0x20000008 LX_FOCUS_None 0x20000009 LX_FOCUS_PointerRoot 0x2000000a LX_FOCUS_Parent 0x2000000b LX_WINDOW_None 0x2000000c LX_VISUAL_None 0x2000000d LX_GRAVITY_NorthWest 0x2000000e LX_GRAVITY_North 0x2000000f LX_GRAVITY_NorthEast 0x20000010 LX_GRAVITY_West 0x20000011 LX_GRAVITY_Center 0x20000012 LX_GRAVITY_East 0x20000013 LX_GRAVITY_SouthWest 0x20000014 LX_GRAVITY_South 0x20000015 LX_GRAVITY_SouthEast 0x20000016 LX_GRAVITY_Static 0x20000017 LX_GRAVITY_Forget 0x20000018 LX_GRAVITY_Unmap 0x20000019 LX__WCLASS_Error 0x2000001a LX_PIXMAP_None 0x2000001b LX_PIXMAP_ParentRelative 0x2000001c LX_PIXMAP_CopyFromParent 0x2000001d LX_BACKINGSTORE_NotUseful 0x2000001e LX_BACKINGSTORE_WhenMapped 0x2000001f LX_BACKINGSTORE_Always 0x20000020 LX_COLORMAP_CopyFromParent 0x20000021 LX_CURSOR_None 0x20000022 LX__GRAVITY_Error 0x20000023 LX__BACKINGSTORE_Error 0x20000024 LX_VISUAL_CopyFromParent 0x20000025 LX_AllocNone 0x20000026 LX_AllocAll 0x20000027 LX_COLORMAP_None 0x20000028 LX_OPENSTATUS_failed 0x20000029 LX_OPENSTATUS_worked 0x2000002a LX_GC_None 0x2000002b LX_GCCLIPMASK_None 0x2000002c LX__GCFUNCTION_Error 0x2000002d LX_GCLINESTYLE_Solid 0x2000002e LX_GCLINESTYLE_OnOffDash 0x2000002f LX_GCLINESTYLE_DoubleDash 0x20000030 LX_GCFUNCTION_Clear 0x20000031 LX_GCFUNCTION_And 0x20000032 LX_GCFUNCTION_AndReverse 0x20000033 LX_GCFUNCTION_Copy 0x20000034 LX_GCFUNCTION_AndInverted 0x20000035 LX_GCFUNCTION_NoOp 0x20000036 LX_GCFUNCTION_Xor 0x20000037 LX_GCFUNCTION_Or 0x20000038 LX_GCFUNCTION_Nor 0x20000039 LX_GCFUNCTION_Equiv 0x2000003a LX_GCFUNCTION_Invert 0x2000003b LX_GCFUNCTION_OrReverse 0x2000003c LX_GCFUNCTION_CopyInverted 0x2000003d LX_GCFUNCTION_OrInverted 0x2000003e LX_GCFUNCTION_Nand 0x2000003f LX_GCFUNCTION_Set 0x20000040 LX__GCLINESTYLE_Error 0x20000041 LX_GCCAPSTYLE_NotLast 0x20000042 LX_GCCAPSTYLE_Butt 0x20000043 LX_GCCAPSTYLE_Round 0x20000044 LX_GCCAPSTYLE_Projecting 0x20000045 LX__GCCAPSTYLE_Error 0x20000046 LX_GCJOINSTYLE_Miter 0x20000047 LX_GCJOINSTYLE_Round 0x20000048 LX_GCJOINSTYLE_Bevel 0x20000049 LX__GCJOINSTYLE_Error 0x2000004a LX_GCFILLSTYLE_Solid 0x2000004b LX_GCFILLSTYLE_Tiled 0x2000004c LX_GCFILLSTYLE_Stippled 0x2000004d LX_GCFILLSTYLE_OpaqueStippled 0x2000004e LX__GCFILLSTYLE_Error 0x2000004f LX_GCFILLRULE_EvenOdd 0x20000050 LX_GCFILLRULE_Winding 0x20000051 LX__GCFILLRULE_Error 0x20000052 LX_GCSUBWINDOWMODE_ClipByChildren 0x20000053 LX_GCSUBWINDOWMODE_IncludeInferiors 0x20000054 LX__GCSUBWINDOWMODE_Error 0x20000055 LX_GCARCMODE_Chord 0x20000056 LX_GCARCMODE_PieSlice 0x20000057 LX__GCARCMODE_Error 0x20000058 LX_COORDMODE_Origin 0x20000059 LX_COORDMODE_Previous 0x2000005a LX_MAPSTATE_Unmapped 0x2000005b LX_MAPSTATE_Unviewable 0x2000005c LX_MAPSTATE_Viewable 0x2000005d LX__MAPSTATE_Error */ #endif