📄 nxproto.h
字号:
/* * Copyright (c) 1999, 2003 Greg Haerr <greg@censoft.com> * Copyright (c) 2000 Alex Holden <alex@linuxhacker.org> * Portions Copyright (c) 2002, 2003 by Koninklijke Philips Electronics N.V. * * Nano-X Core Protocol Header * * These structures define the Nano-X client/server protocol. * Much of this has been modeled after the X11 implementation. * Note that all NX Protocol requests should have all data quantities * properly aligned. This is assured by hand-coding each NX request * structure. Unlike Xlib, fixed size request structs don't have to * be a multiple of 4 bytes, since the length field is a byte count * and GetReq() automatically pads all requests to 4-byte boundaries. * Request structs for variable size data, however, must be hand-padded * to 4-byte alignment, as variable data starts after sizeof(structure). * Also, the hilength/length fields store the unaligned byte count, so * that extra code isn't required to de-crypt extra data size or * big packets. *//* * The following is provided to allow limiting the maximum * request size that will be sent (not received) using this protocol. * The protocol allows for 2^24 byte maximum, but the * server currently allocates the MAXREQUESTSZ in a stack buffer. * Also, the client realloc's the request queue to * the largest size asked for, and currently never reduces it. * * Routines like GrArea will split packets to be <= MAXREQUESTSZ * automatically. * * NOTE: MAXREQUESTSZ must be an _aligned_ multiple of 4, meaning * that MAXREQUESTSZ = (MAXREQUESTSZ + 3) & ~3. */#define MAXREQUESTSZ 30000 /* max request size (65532)*/typedef unsigned char BYTE8; /* 1 byte*/typedef unsigned short UINT16; /* 2 bytes*/typedef short INT16; /* 2 bytes*/typedef unsigned long UINT32; /* 4 bytes*/#if ELKStypedef UINT16 IDTYPE;#define ALIGNSZ 2 /* 2 byte packet alignment*/#elsetypedef UINT32 IDTYPE;#define ALIGNSZ 4 /* 4 byte packet alignment*/#endif/* all requests share this header*/typedef struct { BYTE8 reqType; /* request code*/ BYTE8 hilength; /* upper 24 bits of unaligned length*/ UINT16 length; /* lower 16 bits of unaligned length*/} nxReq;/* Allocate a fixed size request from request buffer*/#define AllocReq(name) \ ((nx##name##Req *)nxAllocReq(GrNum##name,sizeof(nx##name##Req), 0))/* Allocate a request, but allocate n extra bytes*/#define AllocReqExtra(name,n) \ ((nx##name##Req *)nxAllocReq(GrNum##name,sizeof(nx##name##Req), n))/* return pointer to variable length data*/#define GetReqData(req) ((void *)((char *)req + sizeof(* (req))))/* FIXME fails when sizeof(int) == 2*//* get request total valid data length, including header*/#define GetReqLen(req) (((req)->hilength << 16) | (req)->length)/* get request variable data length, not including fixed size structure*/#define GetReqVarLen(req) (GetReqLen(req) - sizeof(* (req)))/* get request total aligned length*/#define GetReqAlignedLen(req) ((GetReqLen(req) + (ALIGNSZ-1)) & ~(ALIGNSZ-1))void * nxAllocReq(int type, long size, long extra);void nxFlushReq(long newsize, int reply_needed);void nxAssignReqbuffer(char *buffer, long size);void nxWriteSocket(char *buf, int todo);int nxCalcStringBytes(void *str, int count, GR_TEXTFLAGS flags);#if notyet/* all replies share this header*/typedef struct { BYTE8 repType; /* reply code*/ BYTE8 hilength; /* upper 24 bits of unaligned length*/ UINT16 length; /* lower 16 bits of unaligned length*/} nxReply;/* reply types if not equal to request type*/#define GrNumErrorReply 255#define GrNumEventReply 254#endif /* notyet*/#define GrNumOpen 0typedef struct { BYTE8 reqType; BYTE8 hilength; UINT16 length; UINT32 pid;} nxOpenReq;#define GrNumClose 1typedef struct { BYTE8 reqType; BYTE8 hilength; UINT16 length;} nxCloseReq;#define GrNumGetScreenInfo 2typedef struct { BYTE8 reqType; BYTE8 hilength; UINT16 length;} nxGetScreenInfoReq;#define GrNumNewWindow 3typedef struct { BYTE8 reqType; BYTE8 hilength; UINT16 length; IDTYPE parentid; INT16 x; INT16 y; INT16 width; INT16 height; UINT32 backgroundcolor; UINT32 bordercolor; INT16 bordersize;} nxNewWindowReq;#define GrNumNewInputWindow 4typedef struct { BYTE8 reqType; BYTE8 hilength; UINT16 length; IDTYPE parentid; INT16 x; INT16 y; INT16 width; INT16 height;} nxNewInputWindowReq;#define GrNumDestroyWindow 5typedef struct { BYTE8 reqType; BYTE8 hilength; UINT16 length; IDTYPE windowid;} nxDestroyWindowReq;#define GrNumNewGC 6typedef struct { BYTE8 reqType; BYTE8 hilength; UINT16 length;} nxNewGCReq;#define GrNumCopyGC 7typedef struct { BYTE8 reqType; BYTE8 hilength; UINT16 length; IDTYPE gcid;} nxCopyGCReq;#define GrNumGetGCInfo 8typedef struct { BYTE8 reqType; BYTE8 hilength; UINT16 length; IDTYPE gcid;} nxGetGCInfoReq;#define GrNumDestroyGC 9typedef struct { BYTE8 reqType; BYTE8 hilength; UINT16 length; IDTYPE gcid;} nxDestroyGCReq;#define GrNumMapWindow 10typedef struct { BYTE8 reqType; BYTE8 hilength; UINT16 length; IDTYPE windowid;} nxMapWindowReq;#define GrNumUnmapWindow 11typedef struct { BYTE8 reqType; BYTE8 hilength; UINT16 length; IDTYPE windowid;} nxUnmapWindowReq;#define GrNumRaiseWindow 12typedef struct { BYTE8 reqType; BYTE8 hilength; UINT16 length; IDTYPE windowid;} nxRaiseWindowReq;#define GrNumLowerWindow 13typedef struct { BYTE8 reqType; BYTE8 hilength; UINT16 length; IDTYPE windowid;} nxLowerWindowReq;#define GrNumMoveWindow 14typedef struct { BYTE8 reqType; BYTE8 hilength; UINT16 length; IDTYPE windowid; INT16 x; INT16 y;} nxMoveWindowReq;#define GrNumResizeWindow 15typedef struct { BYTE8 reqType; BYTE8 hilength; UINT16 length; IDTYPE windowid; INT16 width; INT16 height;} nxResizeWindowReq;#define GrNumGetWindowInfo 16typedef struct { BYTE8 reqType; BYTE8 hilength; UINT16 length; IDTYPE windowid;} nxGetWindowInfoReq;#define GrNumGetFontInfo 17typedef struct { BYTE8 reqType; BYTE8 hilength; UINT16 length; IDTYPE fontid;} nxGetFontInfoReq;#define GrNumSetFocus 18typedef struct { BYTE8 reqType; BYTE8 hilength; UINT16 length; IDTYPE windowid;} nxSetFocusReq;#define GrNumSetWindowCursor 19typedef struct { BYTE8 reqType; BYTE8 hilength; UINT16 length; IDTYPE windowid; IDTYPE cursorid;} nxSetWindowCursorReq;#define GrNumClearArea 20typedef struct { BYTE8 reqType; BYTE8 hilength; UINT16 length; IDTYPE windowid; INT16 x; INT16 y; INT16 width; INT16 height; UINT16 exposeflag;} nxClearAreaReq;#define GrNumSelectEvents 21typedef struct { BYTE8 reqType; BYTE8 hilength; UINT16 length; IDTYPE windowid; UINT32 eventmask;} nxSelectEventsReq;#define GrNumGetNextEvent 22typedef struct { BYTE8 reqType; BYTE8 hilength; UINT16 length;} nxGetNextEventReq;#define GrNumCheckNextEvent 23typedef struct { BYTE8 reqType; BYTE8 hilength; UINT16 length;} nxCheckNextEventReq;#define GrNumPeekEvent 24typedef struct { BYTE8 reqType; BYTE8 hilength; UINT16 length;} nxPeekEventReq;#define GrNumLine 25typedef struct { BYTE8 reqType; BYTE8 hilength; UINT16 length; IDTYPE drawid; IDTYPE gcid; INT16 x1; INT16 y1; INT16 x2; INT16 y2;} nxLineReq;#define GrNumPoint 26typedef struct { BYTE8 reqType; BYTE8 hilength; UINT16 length; IDTYPE drawid; IDTYPE gcid; INT16 x; INT16 y;} nxPointReq;#define GrNumRect 27typedef struct { BYTE8 reqType; BYTE8 hilength; UINT16 length; IDTYPE drawid; IDTYPE gcid; INT16 x; INT16 y; INT16 width; INT16 height;} nxRectReq;#define GrNumFillRect 28typedef struct { BYTE8 reqType; BYTE8 hilength; UINT16 length; IDTYPE drawid; IDTYPE gcid; INT16 x; INT16 y; INT16 width; INT16 height;} nxFillRectReq;#define GrNumPoly 29typedef struct { BYTE8 reqType; BYTE8 hilength; UINT16 length; IDTYPE drawid; IDTYPE gcid; /*INT16 pointtable[];*/} nxPolyReq;#define GrNumFillPoly 30typedef struct { BYTE8 reqType; BYTE8 hilength; UINT16 length; IDTYPE drawid; IDTYPE gcid; /*INT16 pointtable[];*/} nxFillPolyReq;#define GrNumEllipse 31typedef struct { BYTE8 reqType; BYTE8 hilength; UINT16 length; IDTYPE drawid; IDTYPE gcid; INT16 x; INT16 y; INT16 rx; INT16 ry;} nxEllipseReq;#define GrNumFillEllipse 32typedef struct { BYTE8 reqType; BYTE8 hilength; UINT16 length; IDTYPE drawid; IDTYPE gcid; INT16 x; INT16 y; INT16 rx; INT16 ry;} nxFillEllipseReq;#define GrNumSetGCForeground 33typedef struct { BYTE8 reqType; BYTE8 hilength; UINT16 length; IDTYPE gcid; UINT32 color;} nxSetGCForegroundReq;#define GrNumSetGCBackground 34typedef struct { BYTE8 reqType; BYTE8 hilength; UINT16 length; IDTYPE gcid; UINT32 color;} nxSetGCBackgroundReq;#define GrNumSetGCUseBackground 35typedef struct { BYTE8 reqType; BYTE8 hilength; UINT16 length; IDTYPE gcid; UINT16 flag;} nxSetGCUseBackgroundReq;#define GrNumSetGCMode 36typedef struct { BYTE8 reqType; BYTE8 hilength; UINT16 length; IDTYPE gcid; UINT16 mode;} nxSetGCModeReq;#define GrNumSetGCFont 37typedef struct { BYTE8 reqType; BYTE8 hilength; UINT16 length; IDTYPE gcid; IDTYPE fontid;} nxSetGCFontReq;#define GrNumGetGCTextSize 38typedef struct { BYTE8 reqType; BYTE8 hilength; UINT16 length; IDTYPE gcid; UINT32 flags; UINT32 charcount; /*BYTE8 text[];*/} nxGetGCTextSizeReq;#define GrNumReadArea 39typedef struct { BYTE8 reqType; BYTE8 hilength; UINT16 length; IDTYPE drawid; INT16 x; INT16 y; INT16 width; INT16 height;} nxReadAreaReq;#define GrNumArea 40typedef struct { BYTE8 reqType; BYTE8 hilength; UINT16 length; IDTYPE drawid; IDTYPE gcid; INT16 x; INT16 y; INT16 width; INT16 height; INT16 pixtype; INT16 pad; /*UINT32 pixels[];*/} nxAreaReq;#define GrNumBitmap 41typedef struct { BYTE8 reqType; BYTE8 hilength; UINT16 length; IDTYPE drawid; IDTYPE gcid; INT16 x; INT16 y; INT16 width; INT16 height; /*UINT16 bitmaptable[];*/} nxBitmapReq;#define GrNumText 42typedef struct { BYTE8 reqType; BYTE8 hilength; UINT16 length; IDTYPE drawid; IDTYPE gcid; INT16 x; INT16 y; INT16 count; INT16 pad; UINT32 flags; /*BYTE8 text[];*/} nxTextReq;#define GrNumNewCursor 43typedef struct { BYTE8 reqType; BYTE8 hilength; UINT16 length; INT16 width; INT16 height; INT16 hotx; INT16 hoty; UINT32 fgcolor; UINT32 bgcolor; /*UINT16 fgbitmap[];*/ /*UINT16 bgbitmap[];*/} nxNewCursorReq;#define GrNumMoveCursor 44typedef struct { BYTE8 reqType; BYTE8 hilength; UINT16 length; INT16 x; INT16 y;} nxMoveCursorReq;#define GrNumGetSystemPalette 45typedef struct { BYTE8 reqType; BYTE8 hilength; UINT16 length;} nxGetSystemPaletteReq;#define GrNumFindColor 46typedef struct { BYTE8 reqType; BYTE8 hilength; UINT16 length; UINT32 color;} nxFindColorReq;#define GrNumReparentWindow 47typedef struct { BYTE8 reqType; BYTE8 hilength; UINT16 length; IDTYPE windowid; IDTYPE parentid; INT16 x; INT16 y;} nxReparentWindowReq;#define GrNumDrawImageFromFile 48typedef struct { BYTE8 reqType; BYTE8 hilength; UINT16 length; IDTYPE drawid; IDTYPE gcid; INT16 x; INT16 y; INT16 width; INT16 height; IDTYPE flags; /*char path[];*/} nxDrawImageFromFileReq;#define GrNumLoadImageFromFile 49typedef struct { BYTE8 reqType; BYTE8 hilength; UINT16 length; INT16 flags; INT16 pad;} nxLoadImageFromFileReq;#define GrNumNewPixmap 50typedef struct { BYTE8 reqType; BYTE8 hilength; UINT16 length; INT16 width; INT16 height;/* FIXME: Add support for passing shared memory info */} nxNewPixmapReq;#define GrNumCopyArea 51typedef struct { BYTE8 reqType; BYTE8 hilength; UINT16 length; IDTYPE drawid; IDTYPE gcid; INT16 x; INT16 y; INT16 width; INT16 height; IDTYPE srcid; INT16 srcx; INT16 srcy; UINT32 op;} nxCopyAreaReq;#define GrNumSetFontSize 52typedef struct { BYTE8 reqType; BYTE8 hilength; UINT16 length; IDTYPE fontid; INT16 fontsize;} nxSetFontSizeReq;#define GrNumCreateFont 53typedef struct { BYTE8 reqType; BYTE8 hilength; UINT16 length; INT16 height; INT16 padding;} nxCreateFontReq;#define GrNumDestroyFont 54typedef struct { BYTE8 reqType; BYTE8 hilength; UINT16 length; IDTYPE fontid;} nxDestroyFontReq;#define GrNumReqShmCmds 55typedef struct { BYTE8 reqType; BYTE8 hilength; UINT16 length; UINT32 size;} nxReqShmCmdsReq;#define GrNumShmCmdsFlush 56typedef struct { BYTE8 reqType; BYTE8 hilength; UINT16 length; UINT32 size; UINT32 reply;} nxShmCmdsFlushReq;#define GrNumSetFontRotation 57typedef struct { BYTE8 reqType; BYTE8 hilength; UINT16 length; IDTYPE fontid; INT16 tenthdegrees;} nxSetFontRotationReq;#define GrNumSetFontAttr 58typedef struct { BYTE8 reqType; BYTE8 hilength; UINT16 length; IDTYPE fontid; INT16 setflags; INT16 clrflags;} nxSetFontAttrReq;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -