plan 9 kernel history: overview | file list | diff list

1994/0413/port/devmouse.c (diff list | history)

1994/0412/sys/src/9/port/devmouse.c:1,71994/0413/sys/src/9/port/devmouse.c:1,6 (short | long | prev | next)
1993/1006    
#include	"u.h" 
#include	"../port/lib.h" 
#include	<libg.h> 
#include	<gnot.h> 
#include	"mem.h" 
#include	"dat.h" 
#include	"fns.h" 
1994/0412/sys/src/9/port/devmouse.c:57,621994/0413/sys/src/9/port/devmouse.c:56,67
1993/1006    
	int	disable;	/* from being used */ 
1993/1026    
	int	frozen;	/* from being used */ 
1993/1006    
	Rectangle r;		/* location */ 
1994/0413    
 
	int	l; 
	int	tl; 
	int	setop; 
	int	clrop; 
	Rectangle clipr; 
1993/1006    
}; 
 
Mouseinfo	mouse; 
1994/0412/sys/src/9/port/devmouse.c:83,1291994/0413/sys/src/9/port/devmouse.c:88,124
1993/1006    
}; 
 
ulong setbits[16]; 
GBitmap	set = 
1994/0413    
Bitmap	set = 
1993/1006    
{ 
	setbits, 
1994/0413    
	{0, 0, 16, 16}, 
	{0, 0, 16, 16}, 
1993/1006    
	0, 
1994/0413    
	setbits, 
1993/1006    
	1, 
	0, 
	{0, 0, 16, 16}, 
	{0, 0, 16, 16} 
}; 
 
ulong clrbits[16]; 
GBitmap	clr = 
1994/0413    
Bitmap	clr = 
1993/1006    
{ 
	clrbits, 
	0, 
	1, 
	0, 
	{0, 0, 16, 16}, 
	{0, 0, 16, 16} 
}; 
                 
ulong cursorbackbits[16*4]; 
GBitmap cursorback = 
{ 
	cursorbackbits, 
1994/0413    
	{0, 0, 16, 16}, 
1993/1006    
	0, 
1994/0413    
	clrbits, 
1993/1006    
	1, 
	0, 
	{0, 0, 16, 16}, 
	{0, 0, 16, 16} 
}; 
 
1994/0412    
ulong cursorworkbits[16*4]; 
GBitmap cursorwork = 
1994/0413    
ulong backbits[16*5]; 
ulong workbits[16*5]; 
Bitmap cursorwork = 
1994/0412    
{ 
	cursorworkbits, 
1994/0413    
	{0, 0, 16+8, 16}, 
	{0, 0, 16+8, 16}, 
1994/0412    
	0, 
1994/0413    
	workbits, 
1994/0412    
	1, 
	0, 
	{0, 0, 16, 16}, 
	{0, 0, 16, 16} 
}; 
 
1993/1006    
void	Cursortocursor(Cursor*); 
1994/0412/sys/src/9/port/devmouse.c:147,1531994/0413/sys/src/9/port/devmouse.c:142,148
1993/1006    
 
#define	NMOUSE	(sizeof(mousedir)/sizeof(Dirtab)) 
 
extern	GBitmap	gscreen; 
1994/0413    
extern	Bitmap	gscreen; 
1993/1006    
 
void 
mousereset(void) 
1994/0412/sys/src/9/port/devmouse.c:166,1841994/0413/sys/src/9/port/devmouse.c:161,195
1993/1006    
} 
 
void 
1994/0413    
cursorinit(void) 
{ 
	cursorwork.ldepth = gscreen.ldepth; 
	cursorwork.width = ((cursorwork.r.max.x << gscreen.ldepth) + 31) >> 5; 
 
	cursor.l = cursorwork.width*BY2WD; 
 
	if(flipping){ 
		cursor.setop = flipD[S|D]; 
		cursor.clrop = flipD[D&~S]; 
	} else { 
		cursor.setop = S|D; 
		cursor.clrop = D&~S; 
	} 
} 
 
void 
1993/1006    
mouseinit(void) 
{ 
	if(!conf.monitor) 
		return; 
1994/0413    
 
1994/0412    
	if(gscreen.ldepth > 3){ 
1993/1006    
		cursorback.ldepth = 0; 
1994/0412    
		cursorwork.ldepth = 0; 
	}else{ 
1993/1006    
		cursorback.ldepth = gscreen.ldepth; 
		cursorback.width = ((16 << gscreen.ldepth) + 31) >> 5; 
1994/0412    
		cursorwork.ldepth = gscreen.ldepth; 
		cursorwork.width = ((16 << gscreen.ldepth) + 31) >> 5; 
1994/0413    
		print("mouse can't work ldepth > 3"); 
		cursor.disable = 1; 
1993/1006    
	} 
1994/0413    
 
	cursorinit(); 
 
1993/1006    
	cursoron(1); 
} 
 
1994/0412/sys/src/9/port/devmouse.c:187,1921994/0413/sys/src/9/port/devmouse.c:198,204
1993/1006    
{ 
	if(!conf.monitor) 
		error(Egreg); 
1994/0413    
	cursorinit(); 
1993/1006    
	return devattach('m', spec); 
} 
 
1994/0412/sys/src/9/port/devmouse.c:437,4451994/0413/sys/src/9/port/devmouse.c:449,472
1993/1006    
	unlock(&cursor); 
} 
 
1994/0413    
typedef struct 
{ 
	Bitmap *dm; 
	Point p; 
	Bitmap *sm; 
	Rectangle r; 
	Fcode f; 
} XXX; 
 
1993/1006    
void 
cursoron(int dolock) 
{ 
1994/0413    
	int off; 
	Rectangle r; 
	uchar *a; 
	XXX x; 
	extern int graphicssubtile(uchar*, int, int, Rectangle, Rectangle, uchar**); 
 
1993/1006    
	if(cursor.disable) 
		return; 
	if(dolock) 
1994/0412/sys/src/9/port/devmouse.c:451,4651994/0413/sys/src/9/port/devmouse.c:478,513
1993/1006    
			cursor.r.min = mouse.xy; 
			cursor.r.max = add(mouse.xy, Pt(16, 16)); 
			cursor.r = raddp(cursor.r, cursor.offset); 
1994/0412    
			screenunload(cursor.r, (uchar*)cursorworkbits, 
				(16>>3) << gscreen.ldepth, cursorwork.width*BY2WD, 0); 
			memmove(cursorbackbits, cursorworkbits, 16*cursorback.width*BY2WD); 
			gbitblt(&cursorwork, cursorwork.r.min, 
1993/1006    
				&clr, Rect(0, 0, 16, 16), flipping? flipD[D&~S] : D&~S); 
1994/0412    
			gbitblt(&cursorwork, cursorwork.r.min, 
1993/1006    
				&set, Rect(0, 0, 16, 16), flipping? flipD[S|D] : S|D); 
1994/0412    
			screenload(cursor.r, (uchar*)cursorworkbits, 
				(16>>3) << gscreen.ldepth, cursorwork.width*BY2WD, 0); 
1994/0413    
 
			/* bit offset into backup area */ 
			off = ((1<<gscreen.ldepth)*cursor.r.min.x) & 7; 
 
			/* clip the cursor rectangle */ 
			x.dm = &cursorwork; 
			x.p = Pt(off, 0); 
			x.sm = &gscreen; 
			x.r = cursor.r; 
			bitbltclip(&x); 
 
			/* tile width */ 
			cursor.tl = graphicssubtile(0, cursor.l, gscreen.ldepth, 
					gscreen.r, x.r, &a); 
			if(cursor.tl > 0){ 
				/* get tile */ 
				screenunload(x.r, (uchar*)workbits, cursor.tl, cursor.l, 0); 
 
				/* save for cursoroff */ 
				memmove(backbits, workbits, cursor.l*16); 
 
				/* add mouse into work area */ 
				r = Rect(0, 0, Dx(x.r), Dy(x.r)); 
				bitblt(&cursorwork, x.p, &clr, r, cursor.clrop); 
				bitblt(&cursorwork, x.p, &set, r, cursor.setop); 
 
				/* put back tile */ 
				cursor.clipr = x.r; 
				screenload(x.r, (uchar*)workbits, cursor.tl, cursor.l, 0); 
			} 
1993/1006    
		} 
	} 
	if(dolock) 
1994/0412/sys/src/9/port/devmouse.c:473,4831994/0413/sys/src/9/port/devmouse.c:521,528
1993/1006    
		return; 
	if(dolock) 
		lock(&cursor); 
	if(--cursor.visible == 0) { 
1994/0412    
		if(!hwcurs) 
			screenload(cursor.r, (uchar*)cursorbackbits, 
				(16>>3) << gscreen.ldepth, cursorback.width*BY2WD, 0); 
1993/1006    
	} 
1994/0413    
	if(--cursor.visible == 0 && !hwcurs && cursor.tl > 0) 
		screenload(cursor.clipr, (uchar*)backbits, cursor.tl, cursor.l, 0); 
1993/1006    
	if(dolock) 
		unlock(&cursor); 
} 


source code copyright © 1990-2005 Lucent Technologies; see license
Plan 9 distribution
comments to russ cox (rsc@swtch.com)