⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 srvfunc.c

📁 一个linux下的根文件系统的源码
💻 C
📖 第 1 页 / 共 5 页
字号:
	if (!wp->realized) {		GsError(GR_ERROR_UNMAPPED_FOCUS_WINDOW, wid);		SERVER_UNLOCK();		return;	}	/* Check if window wants focus, if not, ignore call*/	if (wp->props & GR_WM_PROPS_NOFOCUS) {		SERVER_UNLOCK();		return;	}	focusfixed = (wp != rootwp);	GsWpSetFocus(wp);	SERVER_UNLOCK();}/* * Create a new server-based cursor resource. */static int nextcursorid = 1000;GR_CURSOR_IDGrNewCursor(GR_SIZE width, GR_SIZE height, GR_COORD hotx, GR_COORD hoty,	GR_COLOR foreground, GR_COLOR background, GR_BITMAP *fgbitmap,	GR_BITMAP *bgbitmap){	GR_CURSOR	*cp;	int		bytes;	GR_CURSOR_ID id;	SERVER_LOCK();	/*	 * Make sure the size of the bitmap is reasonable.	 */	if (width <= 0 || width > MWMAX_CURSOR_SIZE ||	    height <= 0 || height > MWMAX_CURSOR_SIZE) {		GsError(GR_ERROR_BAD_CURSOR_SIZE, 0);		SERVER_UNLOCK();		return 0;	}	cp = (GR_CURSOR *)malloc(sizeof(GR_CURSOR));	if (cp == NULL) {		GsError(GR_ERROR_MALLOC_FAILED, 0);		SERVER_UNLOCK();		return 0;	}	/* fill in cursor structure*/	cp->cursor.width = width;	cp->cursor.height = height;	cp->cursor.hotx = hotx;	cp->cursor.hoty = hoty;	cp->cursor.fgcolor = foreground;	cp->cursor.bgcolor = background;	bytes = GR_BITMAP_SIZE(width, height) * sizeof(GR_BITMAP);	memcpy(&cp->cursor.image, fgbitmap, bytes);	memcpy(&cp->cursor.mask, bgbitmap, bytes);	cp->id = nextcursorid++;	cp->owner = curclient;	cp->next = listcursorp;	listcursorp = cp;	id = cp->id;		SERVER_UNLOCK();		return id;}/* * Destroy a server-based cursor. */voidGrDestroyCursor(GR_CURSOR_ID cid){	GR_CURSOR	*cursorp;	GR_CURSOR	*prevcursorp;	SERVER_LOCK();	cursorp = GsFindCursor(cid);	if (cursorp == NULL) {		SERVER_UNLOCK();		return;	}	if (listcursorp == cursorp)		listcursorp = cursorp->next;	else {		prevcursorp = listcursorp;		while (prevcursorp->next != cursorp)			prevcursorp = prevcursorp->next;		prevcursorp->next = cursorp->next;	}	if (curcursor == cursorp)		curcursor = NULL;	free(cursorp);	GsCheckCursor();	SERVER_UNLOCK();}/* * Specify a cursor for a window. * This cursor will only be used within that window, and by default * for its new children.  If the cursor is currently within this * window, it will be changed to the new one immediately. * If the new cursor id is 0, revert to the root window cursor. */voidGrSetWindowCursor(GR_WINDOW_ID wid, GR_CURSOR_ID cid){	GR_WINDOW	*wp;	GR_CURSOR	*cp;		/* cursor structure */	SERVER_LOCK();	wp = GsFindWindow(wid);	if (wp == NULL) {		SERVER_UNLOCK();		return;	}	if (cid == 0)		cp = stdcursor;	else {		cp = GsFindCursor(cid);		if (!cp) {			SERVER_UNLOCK();			return;		/* FIXME add server errmsg*/		}	}	wp->cursorid = cid;	/*	 * If this was the current cursor, then draw the new one.	 */	if (cp == curcursor || curcursor == NULL) {		GdMoveCursor(cursorx - cp->cursor.hotx,			cursory - cp->cursor.hoty);		GdSetCursor(&cp->cursor);	}	GsCheckCursor();	SERVER_UNLOCK();}/* * Move the cursor to the specified absolute screen coordinates. * The coordinates are that of the defined hot spot of the cursor. * The cursor's appearance is changed to that defined for the window * in which the cursor is moved to.  In addition, mouse enter, mouse * exit, focus in, and focus out events are generated if necessary. * The current mouse location is also changed. */voidGrMoveCursor(GR_COORD x, GR_COORD y){	SERVER_LOCK();	/*	 * Move the cursor only if necessary, offsetting it to	 * place the hot spot at the specified coordinates.	 */	if (x != cursorx || y != cursory) {		if(curcursor) {			GdMoveCursor(x - curcursor->cursor.hotx,				y - curcursor->cursor.hoty);			GdMoveMouse(x, y);		}		cursorx = x;		cursory = y;	}	/*	 * Now check to see which window the mouse is in, whether or	 * not the cursor shape should be changed, and whether or not	 * the input focus window should be changed.	 */	GsCheckMouseWindow();	GsCheckFocusWindow();	GsCheckCursor();	SERVER_UNLOCK();}/* * Set the foreground color in a graphics context from a passed RGB color value. */voidGrSetGCForeground(GR_GC_ID gc, GR_COLOR foreground){	GR_GC		*gcp;		/* graphics context */	SERVER_LOCK();	gcp = GsFindGC(gc);	if (gcp && ((gcp->foreground != foreground) || gcp->fgispixelval)) {		gcp->foreground = foreground;		gcp->fgispixelval = GR_FALSE;		gcp->changed = GR_TRUE;	}	SERVER_UNLOCK();}/* * Set the background color in a graphics context from a passed RGB color value. */voidGrSetGCBackground(GR_GC_ID gc, GR_COLOR background){	GR_GC		*gcp;		/* graphics context */	SERVER_LOCK();	gcp = GsFindGC(gc);	if (gcp && ((gcp->background != background) || gcp->bgispixelval)) {		gcp->background = background;		gcp->bgispixelval = GR_FALSE;		gcp->changed = GR_TRUE;	}	SERVER_UNLOCK();}/* * Set the foreground color in a graphics context from a passed pixel value. */voidGrSetGCForegroundPixelVal(GR_GC_ID gc, GR_PIXELVAL foreground){	GR_GC *gcp;		/* graphics context */	SERVER_LOCK();	gcp = GsFindGC(gc);	if (gcp && ((gcp->foreground != foreground) || !gcp->fgispixelval)) {		gcp->foreground = foreground;		gcp->fgispixelval = GR_TRUE;		gcp->changed = GR_TRUE;	}	SERVER_UNLOCK();}/* * Set the background color in a graphics context from a passed pixel value. */voidGrSetGCBackgroundPixelVal(GR_GC_ID gc, GR_PIXELVAL background){	GR_GC *gcp;		/* graphics context */	SERVER_LOCK();	gcp = GsFindGC(gc);	if (gcp && ((gcp->background != background) || !gcp->bgispixelval)) {		gcp->background = background;		gcp->bgispixelval = GR_TRUE;		gcp->changed = GR_TRUE;	}	SERVER_UNLOCK();}/* * Set whether or not the background color is drawn in bitmaps and text. */voidGrSetGCUseBackground(GR_GC_ID gc, GR_BOOL flag){	GR_GC		*gcp;		/* graphics context */	SERVER_LOCK();	flag = (flag != 0);	gcp = GsFindGC(gc);	if (gcp && gcp->usebackground != flag) {		gcp->usebackground = flag;		gcp->changed = GR_TRUE;	}	SERVER_UNLOCK();}/* * Set the drawing mode in a graphics context. */voidGrSetGCMode(GR_GC_ID gc, int mode){	GR_GC		*gcp;		/* graphics context */	SERVER_LOCK();	gcp = GsFindGC(gc);	if (!gcp || gcp->mode == mode) {		SERVER_UNLOCK();		return;	}	if ((mode & GR_MODE_DRAWMASK) > GR_MAX_MODE) {		GsError(GR_ERROR_BAD_DRAWING_MODE, gc);		SERVER_UNLOCK();		return;	}	gcp->mode = mode;	gcp->changed = GR_TRUE;	SERVER_UNLOCK();}/*  * Set the attributes of the line.   */voidGrSetGCLineAttributes(GR_GC_ID gc, int linestyle){	GR_GC *gcp;	SERVER_LOCK();	gcp = GsFindGC(gc);	if (!gcp) {		SERVER_UNLOCK();		return;	}	switch (linestyle) {	case GR_LINE_SOLID:	case GR_LINE_ONOFF_DASH:		gcp->linestyle = linestyle;		break;	default:		GsError(GR_ERROR_BAD_LINE_ATTRIBUTE, gc);		SERVER_UNLOCK();		return;	}	gcp->changed = GR_TRUE;	SERVER_UNLOCK();}/* * Set the dash mode  * A series of numbers are passed indicating the on / off state  * for example { 3, 1 } indicates 3 on and 1 off  */voidGrSetGCDash(GR_GC_ID gc, char *dashes, int count){	GR_GC *gcp;	unsigned long dmask = 0;	int dcount = 0;	int onoff = 1;	int i;	SERVER_LOCK();	gcp = GsFindGC(gc);	if (!gcp) {		SERVER_UNLOCK();		return;	}	/* Build the bitmask (up to 32 bits) */	for (i = 0; i < count; i++) {		int b = 0;		for (; b < dashes[i]; b++) {			if (onoff)				dmask |= (1 << dcount);			if ((++dcount) == 32)				break;		}		onoff = (onoff + 1) % 2;		if (dcount == 32)			break;	}	gcp->dashmask = dmask;	gcp->dashcount = dcount;	gcp->changed = GR_TRUE;	SERVER_UNLOCK();}voidGrSetGCFillMode(GR_GC_ID gc, int fillmode){	GR_GC *gcp;	SERVER_LOCK();	gcp = GsFindGC(gc);	if (!gcp) {		SERVER_UNLOCK();		return;	}	switch (fillmode) {	case GR_FILL_SOLID:	case GR_FILL_STIPPLE:	case GR_FILL_OPAQUE_STIPPLE:	case GR_FILL_TILE:		gcp->fillmode = fillmode;		break;	default:		GsError(GR_ERROR_BAD_FILL_MODE, gc);		SERVER_UNLOCK();		return;	}	gcp->changed = GR_TRUE;	SERVER_UNLOCK();}voidGrSetGCStipple(GR_GC_ID gc, GR_BITMAP * bitmap, GR_SIZE width, GR_SIZE height){	GR_GC *gcp;	SERVER_LOCK();	gcp = GsFindGC(gc);	if (!gcp) {		SERVER_UNLOCK();		return;	}	if (gcp->stipple.bitmap)		free(gcp->stipple.bitmap);	if (!bitmap) {		gcp->stipple.bitmap = 0;		gcp->stipple.width = gcp->stipple.height = 0;		gcp->changed = GR_TRUE;		SERVER_UNLOCK();		return;	}	gcp->stipple.bitmap =		malloc(GR_BITMAP_SIZE(width, height) * sizeof(GR_BITMAP));	memcpy(gcp->stipple.bitmap, bitmap,	       GR_BITMAP_SIZE(width, height) * sizeof(GR_BITMAP));	gcp->stipple.width = width;	gcp->stipple.height = height;	gcp->changed = GR_TRUE;	SERVER_UNLOCK();}voidGrSetGCTile(GR_GC_ID gc, GR_WINDOW_ID pixmap, GR_SIZE width, GR_SIZE height){	GR_WINDOW *win;	GR_GC *gcp;	SERVER_LOCK();	gcp = GsFindGC(gc);	if (!gcp) {		SERVER_UNLOCK();		return;	}	if (!pixmap) {		gcp->tile.psd = NULL;		gcp->tile.width = gcp->tile.height = 0;		gcp->changed = GR_TRUE;		SERVER_UNLOCK();		return;	}	win = GsFindWindow(pixmap);	if (win)		gcp->tile.psd = win->psd;	else {		GR_PIXMAP *pix = GsFindPixmap(pixmap);		if (!pix) {			gcp->tile.psd = NULL;			gcp->tile.width = gcp->tile.height = 0;			gcp->changed = GR_TRUE;			SERVER_UNLOCK();			return;		}		gcp->tile.psd = pix->psd;	}	/* FIXME:  Set a size restriction here? */	gcp->tile.width = width;	gcp->tile.height = height;	gcp->changed = GR_TRUE;	SERVER_UNLOCK();}voidGrSetGCTSOffset(GR_GC_ID gc, GR_COORD xoff, GR_COORD yoff){	GR_GC *gcp;	SERVER_LOCK();	gcp = GsFindGC(gc);	if (gcp) {		gcp->ts_offset.x = xoff;		gcp->ts_offset.y = yoff;		gcp->changed = GR_TRUE;	}	SERVER_UNLOCK();}/*  * Boolean that sets if we send EXPOSE events on a GrCopyArea */void GrSetGCGraphicsExposure(GR_GC_ID gc, GR_BOOL exposure){	GR_GC		*gcp;	SERVER_LOCK();	gcp = GsFindGC(gc);	if (gcp) {		gcp->exposure = exposure;		gcp->changed = GR_TRUE;	}	SERVER_UNLOCK();}/* * Set the text font in a graphics context. */voidGrSetGCFont(GR_GC_ID gc, GR_FONT_ID font){	GR_GC		*gcp;	SERVER_LOCK();	gcp = GsFindGC(gc);	if (gcp && gcp->fontid != font) {		gcp->fontid = font;		gcp->changed = GR_TRUE;	}	SERVER_UNLOCK();}/* * Draw a line in the specified drawable using the specified graphics context. */voidGrLine(GR_DRAW_ID id, GR_GC_ID gc, GR_COORD x1, GR_COORD y1, GR_COORD x2,	GR_COORD y2){	GR_DRAWABLE	*dp;	SERVER_LOCK();	switch (GsPrepareDrawing(id, gc, &dp)) {		case GR_DRAW_TYPE_WINDOW:	        case GR_DRAW_TYPE_PIXMAP:			GdLine(dp->psd, dp->x + x1, dp->y + y1,				dp->x + x2, dp->y + y2, TRUE);			break;	}	SERVER_UNLOCK();}/* * Draw the boundary of a rectangle in the specified drawable using the * specified graphics context. * NOTE: this function draws a rectangle 1 pixel wider and higher * than Xlib's XDrawRectangle(). */void GrRect(GR_DRAW_ID id, GR_GC_ID gc, GR_COORD x, GR_COORD y, GR_SIZE width,	GR_SIZE height){	GR_DRAWABLE	*dp;	SERVER_LOCK();	switch (GsPrepareDrawing(id, gc, &dp)) {		case GR_DRAW_TYPE_WINDOW:      	        case GR_DRAW_TYPE_PIXMAP:			GdRect(dp->psd, dp->x + x, dp->y + y, width, height);			break;	}	SERVER_UNLOCK();}/* * Fill a rectangle in the specified drawable using the specified * graphics context. */voidGrFillRect(GR_DRAW_ID id, GR_GC_ID gc, GR_COORD x, GR_COORD y,	GR_SIZE width, GR_SIZE height){	GR_DRAWABLE	*dp;	SERVER_LOCK();	switch (GsPrepareDrawing(id, gc, &dp)) {		case GR_DRAW_TYPE_WINDOW:	        case GR_DRAW_TYPE_PIXMAP:			GdFillRect(dp->psd, dp->x + x, dp->y + y, width,height);			break;	}	SERVER_UNLOCK();}/* * Draw the boundary of an ellipse in the specified drawable with * the specified graphics context.  Integer only. */voidGrEllipse(GR_DRAW_ID id, GR_GC_ID gc, GR_COORD x, GR_COORD y, GR_SIZE rx,	GR_SIZE ry){	GR_DRAWABLE	*dp;	SERVER_LOCK();	switch (GsPrepareDrawing(id, gc, &dp)) {		case GR_DRAW_TYPE_WINDOW:	        case GR_DRAW_TYPE_PIXMAP:

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -