]> git.lizzy.rs Git - plan9front.git/blob - sys/src/cmd/mothra/libpanel/event.c
exec(2): fix prototypes
[plan9front.git] / sys / src / cmd / mothra / libpanel / event.c
1 #include <u.h>
2 #include <libc.h>
3 #include <draw.h>
4 #include <event.h>
5 #include <panel.h>
6 #include "pldefs.h"
7
8 void plgrabkb(Panel *g){
9         plkbfocus=g;
10 }
11 void plkeyboard(Rune c){
12         if(plkbfocus){
13                 plkbfocus->type(plkbfocus, c);
14                 flushimage(display, 1);
15         }
16 }
17
18 /*
19  * Return the most leafward, highest priority panel containing p
20  */
21 Panel *pl_ptinpanel(Point p, Panel *g){
22         Panel *v;
23         for(;g;g=g->next) if(ptinrect(p, g->r)){
24                 v=pl_ptinpanel(p, g->child);
25                 if(v && v->pri(v, p)>=g->pri(g, p)) return v;
26                 return g;
27         }
28         return 0;
29 }
30 void plmouse(Panel *g, Mouse *m){
31         Panel *hit, *last;
32         if(g->flags&REMOUSE)
33                 hit=g->lastmouse;
34         else{
35                 hit=pl_ptinpanel(m->xy, g);
36                 last=g->lastmouse;
37                 if(last && last!=hit){
38                         m->buttons|=OUT;
39                         last->hit(last, m);
40                         m->buttons&=~OUT;
41                 }
42         }
43         if(hit){
44                 if(hit->hit(hit, m))
45                         g->flags|=REMOUSE;
46                 else
47                         g->flags&=~REMOUSE;
48                 g->lastmouse=hit;
49         }
50         flushimage(display, 1);
51 }