📄 srvnet.c
字号:
{ nxArcAngleReq *req = r; GrArcAngle(req->drawid, req->gcid, req->x, req->y, req->rx, req->ry, req->angle1, req->angle2, req->type);}static voidGrSetGCForegroundWrapper(void *r){ nxSetGCForegroundReq *req = r; GrSetGCForeground(req->gcid, req->color);}static voidGrSetGCBackgroundWrapper(void *r){ nxSetGCBackgroundReq *req = r; GrSetGCBackground(req->gcid, req->color);}static voidGrSetGCUseBackgroundWrapper(void *r){ nxSetGCUseBackgroundReq *req = r; GrSetGCUseBackground(req->gcid, req->flag);}static voidGrSetGCModeWrapper(void *r){ nxSetGCModeReq *req = r; GrSetGCMode(req->gcid, req->mode);}static voidGrCreateFontWrapper(void *r){ nxCreateFontReq *req = r; GR_FONT_ID fontid; if(req->lf_used) fontid = GrCreateFont(NULL, 0, &req->lf); else fontid = GrCreateFont(req->lf.lfFaceName, req->height, NULL); GsWriteType(current_fd,GrNumCreateFont); GsWrite(current_fd, &fontid, sizeof(fontid));}static voidGrSetFontSizeWrapper(void *r){ nxSetFontSizeReq *req = r; GrSetFontSize(req->fontid, req->fontsize);}static voidGrSetFontRotationWrapper(void *r){ nxSetFontRotationReq *req = r; GrSetFontRotation(req->fontid, req->tenthdegrees);}static voidGrSetFontAttrWrapper(void *r){ nxSetFontAttrReq *req = r; GrSetFontAttr(req->fontid, req->setflags, req->clrflags);}static voidGrDestroyFontWrapper(void *r){ nxDestroyFontReq *req = r; GrDestroyFont(req->fontid);}static voidGrSetGCFontWrapper(void *r){ nxSetGCFontReq *req = r; GrSetGCFont(req->gcid, req->fontid);}static voidGrGetGCTextSizeWrapper(void *r){ nxGetGCTextSizeReq *req = r; GR_SIZE retwidth, retheight, retbase; GrGetGCTextSize(req->gcid, GetReqData(req), GetReqVarLen(req), req->flags, &retwidth, &retheight, &retbase); GsWriteType(current_fd,GrNumGetGCTextSize); GsWrite(current_fd, &retwidth, sizeof(retwidth)); GsWrite(current_fd, &retheight, sizeof(retheight)); GsWrite(current_fd, &retbase, sizeof(retbase));}/* FIXME: fails with size > 64k if sizeof(int) == 2*/static voidGsReadAreaWrapper(void *r){ nxReadAreaReq *req = r; int size; GR_PIXELVAL * area; /* FIXME: optimize for smaller pixelvals*/ size = req->width * req->height * sizeof(GR_PIXELVAL); if(!(area = malloc(size))) { /*GsPutCh(current_fd, GrRetENoMem);*/ /* FIXME*/ /*return;*/ } GrReadArea(req->drawid, req->x, req->y, req->width, req->height, area); GsWriteType(current_fd,GrNumReadArea); GsWrite(current_fd, area, size); free(area);}/* FIXME: fails with size > 64k if sizeof(int) == 2*/static voidGrAreaWrapper(void *r){ nxAreaReq *req = r; GrArea(req->drawid, req->gcid, req->x, req->y, req->width, req->height, GetReqData(req), req->pixtype);}/* FIXME: fails with bitmapsize > 64k if sizeof(int) == 2*/static voidGrBitmapWrapper(void *r){ nxBitmapReq *req = r; GrBitmap(req->drawid, req->gcid, req->x, req->y, req->width, req->height, GetReqData(req));}static voidGrDrawImageBitsWrapper(void *r){ nxDrawImageBitsReq *req = r; char * addr; int imagesize; GR_IMAGE_HDR hdr; hdr.width = req->width; hdr.height = req->height; hdr.planes = req->planes; hdr.bpp = req->bpp; hdr.pitch = req->pitch; hdr.bytesperpixel = req->bytesperpixel; hdr.compression = req->compression; hdr.palsize = req->palsize; hdr.transcolor = req->transcolor; addr = GetReqData(req); hdr.imagebits = (MWUCHAR *)addr; imagesize = hdr.pitch * hdr.height; hdr.palette = (MWPALENTRY *)(addr + imagesize); GrDrawImageBits(req->drawid, req->gcid, req->x, req->y, &hdr);}static voidGrCopyAreaWrapper(void *r){ nxCopyAreaReq *req = r; GrCopyArea(req->drawid, req->gcid, req->x, req->y, req->width, req->height, req->srcid, req->srcx, req->srcy, req->op);}static voidGrTextWrapper(void *r){ nxTextReq *req = r; GrText(req->drawid, req->gcid, req->x, req->y, GetReqData(req), req->count, req->flags);}static voidGrNewCursorWrapper(void *r){ nxNewCursorReq *req = r; int varlen; char * bitmap; GR_CURSOR_ID cursorid; varlen = GetReqVarLen(req); bitmap = GetReqData(req); cursorid = GrNewCursor(req->width, req->height, req->hotx, req->hoty, req->fgcolor, req->bgcolor, (GR_BITMAP *)bitmap, (GR_BITMAP *)(bitmap+varlen/2)); GsWriteType(current_fd, GrNumNewCursor); GsWrite(current_fd, &cursorid, sizeof(cursorid));}static voidGrMoveCursorWrapper(void *r){ nxMoveCursorReq *req = r; GrMoveCursor(req->x, req->y);}static voidGrGetSystemPaletteWrapper(void *r){ GR_PALETTE pal; GrGetSystemPalette(&pal); GsWriteType(current_fd,GrNumGetSystemPalette); GsWrite(current_fd, &pal, sizeof(pal));}static voidGrSetSystemPaletteWrapper(void *r){ nxSetSystemPaletteReq *req = r; GR_PALETTE pal; pal.count = req->count; memcpy(pal.palette, req->palette, sizeof(pal.palette)); GrSetSystemPalette(req->first, &pal);}static voidGrFindColorWrapper(void *r){ nxFindColorReq *req = r; GR_PIXELVAL pixel; GrFindColor(req->color, &pixel); GsWriteType(current_fd,GrNumFindColor); GsWrite(current_fd, &pixel, sizeof(pixel));}static voidGrInjectEventWrapper(void *r){ nxInjectEventReq *req = r; switch(req->event_type) { case GR_INJECT_EVENT_POINTER: GrInjectPointerEvent(req->event.pointer.x, req->event.pointer.y, req->event.pointer.button, req->event.pointer.visible); break; case GR_INJECT_EVENT_KEYBOARD: GrInjectKeyboardEvent(req->event.keyboard.wid, req->event.keyboard.keyvalue, req->event.keyboard.modifier, req->event.keyboard.scancode, req->event.keyboard.pressed); break; }}static voidGrSetWMPropertiesWrapper(void *r){ nxSetWMPropertiesReq *req = r; GR_WM_PROPERTIES *props = GetReqData(req); if(GetReqVarLen(req) - sizeof(GR_WM_PROPERTIES)) props->title = (char *)props + sizeof(GR_WM_PROPERTIES); else props->title = NULL; GrSetWMProperties(req->windowid, props);}static voidGrGetWMPropertiesWrapper(void *r){ nxGetWMPropertiesReq *req = r; UINT16 textlen; GR_WM_PROPERTIES props; GrGetWMProperties(req->windowid, &props); if(props.title) textlen = strlen(props.title) + 1; else textlen = 0; GsWriteType(current_fd,GrNumGetWMProperties); GsWrite(current_fd, &props, sizeof(props)); GsWrite(current_fd, &textlen, sizeof(textlen)); if(textlen) GsWrite(current_fd, props.title, textlen);}static voidGrCloseWindowWrapper(void *r){ nxCloseWindowReq *req = r; GrCloseWindow(req->windowid);}static voidGrKillWindowWrapper(void *r){ nxKillWindowReq *req = r; GrKillWindow(req->windowid);}static voidGrDrawImageFromFileWrapper(void *r){ nxDrawImageFromFileReq *req = r; GrDrawImageFromFile(req->drawid, req->gcid, req->x, req->y, req->width, req->height, GetReqData(req), req->flags);}static voidGrLoadImageFromFileWrapper(void *r){ nxLoadImageFromFileReq *req = r; GR_IMAGE_ID id; id = GrLoadImageFromFile(GetReqData(req), req->flags); GsWriteType(current_fd, GrNumLoadImageFromFile); GsWrite(current_fd, &id, sizeof(id));}static voidGrDrawImageToFitWrapper(void *r){ nxDrawImageToFitReq *req = r; GrDrawImageToFit(req->drawid, req->gcid, req->x, req->y, req->width, req->height, req->imageid);}static voidGrFreeImageWrapper(void *r){ nxFreeImageReq *req = r; GrFreeImage(req->id);}static voidGrGetImageInfoWrapper(void *r){ nxGetImageInfoReq *req = r; GR_IMAGE_INFO info; GrGetImageInfo(req->id, &info); GsWriteType(current_fd, GrNumGetImageInfo); GsWrite(current_fd, &info, sizeof(info));}static voidGrSetScreenSaverTimeoutWrapper(void *r){ nxSetScreenSaverTimeoutReq *req = r; GrSetScreenSaverTimeout(req->timeout);}static voidGrSetSelectionOwnerWrapper(void *r){ nxSetSelectionOwnerReq *req = r; GrSetSelectionOwner(req->wid, GetReqData(req));}static voidGrGetSelectionOwnerWrapper(void *r){ GR_CHAR *typelist; GR_WINDOW_ID wid; unsigned short len; wid = GrGetSelectionOwner(&typelist); GsWriteType(current_fd, GrNumGetSelectionOwner); GsWrite(current_fd, &wid, sizeof(wid)); if(wid) { len = strlen(typelist) + 1; GsWrite(current_fd, &len, sizeof(len)); GsWrite(current_fd, typelist, len); }}static voidGrRequestClientDataWrapper(void *r){ nxRequestClientDataReq *req = r; GrRequestClientData(req->wid, req->rid, req->serial, req->mimetype);}static voidGrSendClientDataWrapper(void *r){ nxSendClientDataReq *req = r; GrSendClientData(req->wid, req->did, req->serial, req->len, GetReqVarLen(req), GetReqData(req));}static voidGrBellWrapper(void *r){ GrBell();}static voidGrSetBackgroundPixmapWrapper(void *r){ nxSetBackgroundPixmapReq *req = r; GrSetBackgroundPixmap(req->wid, req->pixmap, req->flags);}static voidGrDestroyCursorWrapper(void *r){ nxDestroyCursorReq *req = r; GrDestroyCursor(req->cursorid);}static voidGrQueryTreeWrapper(void *r){ nxQueryTreeReq *req = r; GR_WINDOW_ID parentid; GR_WINDOW_ID * children; GR_COUNT nchildren; GrQueryTree(req->windowid, &parentid, &children, &nchildren); GsWriteType(current_fd, GrNumQueryTree); GsWrite(current_fd, &parentid, sizeof(parentid)); GsWrite(current_fd, &nchildren, sizeof(nchildren)); if (nchildren) { GsWrite(current_fd, children, nchildren * sizeof(GR_WINDOW_ID)); free(children); }}static voidGrCreateTimerWrapper(void *r){ nxCreateTimerReq *req = r; GR_TIMER_ID timerid; timerid = GrCreateTimer(req->wid, req->period); GsWriteType(current_fd, GrNumCreateTimer); GsWrite(current_fd, &timerid, sizeof (timerid));}typedef struct image_list { void *data; int id; int size; int offset; struct image_list *next;} imagelist_t;static imagelist_t *imageListHead = 0;static imagelist_t *imageListTail = 0;static int imageListId = 0;static void freeImageBuffer(imagelist_t *buffer) { imagelist_t *prev = 0; imagelist_t *ptr = imageListHead; while(ptr) { if (ptr == buffer) { if (prev) prev->next = buffer->next; else imageListHead = buffer->next; if (!imageListHead) imageListTail = 0; free(buffer->data); free(buffer); return; } prev = ptr; ptr = ptr->next; } }static void GrImageBufferAllocWrapper(void *r) { nxImageBufferAllocReq *req = r; /* Add a new buffer to the end of the list */ if (!imageListTail) { imageListHead = imageListTail = (imagelist_t *) malloc(sizeof(imagelist_t)); } else { imageListTail->next = (imagelist_t *) malloc(sizeof(imagelist_t)); imageListTail = imageListTail->next; } imageListTail->id = ++imageListId; imageListTail->data = (void *) malloc(req->size); imageListTail->size = req->size; imageListTail->offset = 0; imageListTail->next = 0; GsWriteType(current_fd,GrNumImageBufferAlloc); GsWrite(current_fd, &imageListTail->id, sizeof(int));}static void GrImageBufferSendWrapper(void *r) { int csize = 0; imagelist_t *buffer = 0; nxImageBufferSendReq *req = r; for(buffer = imageListHead; buffer; buffer = buffer->next) if (buffer->id == req->buffer_id) break; if (!buffer) return; if (buffer->offset + req->size >= buffer->size) csize = buffer->size - buffer->offset; else csize = req->size; if (!csize) return; memcpy((void *) (buffer->data + buffer->offset), GetReqData(req), csize); buffer->offset += csize;}void GrLoadImageFromBufferWrapper(void *r) { GR_IMAGE_ID id; imagelist_t *buffer = 0; nxLoadImageFromBufferReq *req = r; for(buffer = imageListHead; buffer; buffer = buffer->next) if (buffer->id == req->buffer) break; if (!buffer) return; id = GrLoadImageFromBuffer(buffer->data, buffer->size, req->flags); GsWriteType(current_fd, GrNumLoadImageFromBuffer); GsWrite(current_fd, &id, sizeof(id)); freeImageBuffer(buffer);}void GrDrawImageFromBufferWrapper(void *r) { imagelist_t *buffer = 0; nxDrawImageFromBufferReq *req = r; for(buffer = imageListHead; buffer; buffer = buffer->next) if (buffer->id == req->buffer) break; if (!buffer) return; GrDrawImageFromBuffer(req->drawid, req->gcid, req->x, req->y, req->width, req->height, buffer->data, buffer->size, req->flags); freeImageBuffer(buffer);} static voidGrDestroyTimerWrapper(void *r){ nxDestroyTimerReq *req = r; GrDestroyTimer(req->timerid);}static voidGrSetPortraitModeWrapper(void *r){ nxSetPortraitModeReq *req = r; GrSetPortraitMode(req->portraitmode);}/* * This function makes the Nano-X server set up a shared memory segment * that the client can use when feeding the Nano-X server with requests. * There is a corresponding GrShmCmdsFlush function that will make the * server execute the batched commands. */#define SHMKEY_BASE 1000000#define SHMKEY_MAX 256voidGrReqShmCmdsWrapper(void *r){#if HAVE_SHAREDMEM_SUPPORT nxReqShmCmdsReq *req = r; int key, shmid; char *tmp; if ( curclient->shm_cmds != 0 ) goto bad;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -