Ejemplo n.º 1
0
/*
 *  called at interrupt level to update the structure and
 *  awaken any waiting procs.
 */
void
mousetrack(int x, int y, int b, int msec)
{
	int lastb;

	if(x < mouserect.min.x)
		x = mouserect.min.x;
	if(x >= mouserect.max.x)
		x = mouserect.max.x;
	if(y < mouserect.min.y)
		y = mouserect.min.y;
	if(y >= mouserect.max.y)
		y = mouserect.max.y;

	lastb = mouse.mstate.buttons;
	mouse.mstate.xy = Pt(x, y);
	mouse.mstate.buttons = b;
	mouse.redraw = 1;
	mouse.mstate.counter++;
	mouse.mstate.msec = msec;

	/*
	 * if the queue fills, we discard the entire queue and don't
	 * queue any more events until a reader polls the mouse.
	 */
	if(!mouse.qfull && lastb != b) {	/* add to ring */
		mouse.queue[mouse.wi] = mouse.mstate;
		if(++mouse.wi == nelem(mouse.queue))
			mouse.wi = 0;
		if(mouse.wi == mouse.ri)
			mouse.qfull = 1;
	}
	wakeup(&mouse.r);
	drawactive(1);
}
Ejemplo n.º 2
0
/*
 * called by any source of pointer data
 */
void
mousetrack(int b, int x, int y, int isdelta)
{
	int lastb;
	ulong msec;
	Pointer e;

	if(isdelta){
		x += mouse.x;
		y += mouse.y;
	}
	msec = TK2MS(MACHP(0)->ticks);
	if(b && (mouse.b ^ b)&0x1f){
		if(msec - mouse.msec < 300 && mouse.lastb == b
		   && abs(mouse.x - x) < 12 && abs(mouse.y - y) < 12)
			b |= 1<<8;
		mouse.lastb = b & 0x1f;
		mouse.msec = msec;
	}
	if(x == mouse.x && y == mouse.y && mouse.b == b)
		return;
	lastb = mouse.b;
	mouse.x = x;
	mouse.y = y;
	mouse.b = b;
	mouse.msec = msec;
	if(!ptrq.full && lastb != b){
		e = mouse.Pointer;
		ptrq.clicks[ptrq.wr] = e;
		if(++ptrq.wr >= Nevent)
			ptrq.wr = 0;
		if(ptrq.wr == ptrq.rd)
			ptrq.full = 1;
	}
	mouse.modify = 1;
	ptrq.put++;
	wakeup(&ptrq.r);
	drawactive(1);
	/* TO DO: cursor update */
}
Ejemplo n.º 3
0
static void
blanktimer(void)
{
	drawactive(0);
}