Example #1
0
File: windw.c Project: 8l/inferno
Tk*
tkfindfocus(TkTop *t, int x, int y, int descend)
{
	Point p, q;
	Tk *tk, *f;
	TkWin *tkw;
	p.x = x;
	p.y = y;
	for(f = t->windows; f != nil; f = TKobj(TkWin, f)->next) {
		assert(f->flag&Tkwindow);
		if(f->flag & Tkmapped) {
			tkw = TKobj(TkWin, f);
			q.x = p.x - (tkw->act.x+f->borderwidth);
			q.y = p.y - (tkw->act.y+f->borderwidth);
			tk = tkinwindow(f, q, descend);
			if(tk != nil)
				return tk;
		}
	}
	return nil;
}
Example #2
0
static Tk*
tktdeliver(Tk *tk, TkTitem *i, TkTitem *tagit, int event, void *data, Point deltasv)
{
	Tk *ftk, *dest;
	TkTwind *w;
	TkText *tkt;
	TkTtaginfo *t;
	TkTline *l;
	TkMouse m;
	Point mp, p;
	TkTindex ix;
	int bd;

	dest = nil;
	if(i != nil) {
		tkt = TKobj(TkText, tk);

		if(i->kind == TkTwin) {
			w = i->iwin;
			if(w->sub != nil) {
				if(!(event & TkKey) && (event & TkEmouse)) {
					m = *(TkMouse*)data;
					mp.x = m.x;
					mp.y = m.y;
					ix.item = i;
					ix.pos = 0;
					ix.line = tktitemline(i);
					p = tktitempos(tk, &ix);
					bd = w->sub->borderwidth;
					mp.x = m.x - (deltasv.x + p.x + w->sub->act.x + bd);
					mp.y = m.y - (deltasv.y + p.y + w->sub->act.y + bd);
					ftk = tkinwindow(w->sub, mp, 0);
					if(ftk != w->focus) {
						tkdeliver(w->focus, TkLeave, data);
						tkdeliver(ftk, TkEnter, data);

						w->focus = ftk;
					}
					if(ftk != nil)
						dest = tkdeliver(ftk, event, &m);
				}
				else {
					if ((event & TkLeave) && (w->focus != w->sub)) {
						tkdeliver(w->focus, TkLeave, data);
						w->focus = nil;
						event &= ~TkLeave;
					}
					if (event)
						tkdeliver(w->sub, event, data);
				}
				if(Dx(w->sub->dirty) > 0) {
					l = tktitemline(i);
					tktfixgeom(tk, tktprevwrapline(tk, l), l, 0);
				}
				if(event & TkKey)
					return dest;
			}
		}

		if(tagit != 0) {
			for(t = tkt->tags; t != nil; t = t->next) {
				if(t->binds != nil && tkttagset(tagit, t->id)) {
					if(tksubdeliver(tk, t->binds, event, data, 0) == TkDbreak) {
						return dest;
					}
				}
			}
		}
	}
	return dest;
}