Mercurial > MadButterfly
comparison src/event.c @ 139:1695a4b02b14
Members of coords are geos instead of shapes, now.
author | Thinker K.F. Li <thinker@branda.to> |
---|---|
date | Mon, 22 Sep 2008 19:22:57 +0800 |
parents | 23bc382d9683 |
children | c1cdd3fcd28f |
comparison
equal
deleted
inserted
replaced
138:9f4fc9ecfd1f | 139:1695a4b02b14 |
---|---|
5 #include "redraw_man.h" | 5 #include "redraw_man.h" |
6 #include "shapes.h" | 6 #include "shapes.h" |
7 | 7 |
8 #define OK 0 | 8 #define OK 0 |
9 #define ERR -1 | 9 #define ERR -1 |
10 | |
11 #define ARRAY_EXT_SZ 64 | |
10 | 12 |
11 | 13 |
12 static int extend_memblk(void **buf, int o_size, int n_size) { | 14 static int extend_memblk(void **buf, int o_size, int n_size) { |
13 void *new_buf; | 15 void *new_buf; |
14 | 16 |
31 static int add_gen_geo(redraw_man_t *rdman, geo_t *geo) { | 33 static int add_gen_geo(redraw_man_t *rdman, geo_t *geo) { |
32 int max_gen_geos; | 34 int max_gen_geos; |
33 int r; | 35 int r; |
34 | 36 |
35 if(rdman->n_gen_geos >= rdman->max_gen_geos) { | 37 if(rdman->n_gen_geos >= rdman->max_gen_geos) { |
36 max_gen_geos = rdman->n_geos; | 38 max_gen_geos = rdman->max_gen_geos + ARRAY_EXT_SZ; |
37 r = extend_memblk((void **)&rdman->gen_geos, | 39 r = extend_memblk((void **)&rdman->gen_geos, |
38 sizeof(geo_t *) * rdman->n_gen_geos, | 40 sizeof(geo_t *) * rdman->n_gen_geos, |
39 sizeof(geo_t *) * max_gen_geos); | 41 sizeof(geo_t *) * max_gen_geos); |
40 if(r != OK) | 42 if(r != OK) |
41 return ERR; | 43 return ERR; |
55 if(r != OK) | 57 if(r != OK) |
56 return ERR; | 58 return ERR; |
57 | 59 |
58 rdman->n_gen_geos = 0; | 60 rdman->n_gen_geos = 0; |
59 | 61 |
60 for(geo = STAILQ_HEAD(rdman->all_geos); | 62 for(geo = rdman_geos(rdman, NULL); |
61 geo != NULL; | 63 geo != NULL; |
62 geo = STAILQ_NEXT(geo_t, next, geo)) { | 64 geo = rdman_geos(rdman, geo)) { |
63 if(geo_pos_is_in(geo, x, y)) { | 65 if(geo_pos_is_in(geo, x, y)) { |
64 r = add_gen_geo(rdman, geo); | 66 r = add_gen_geo(rdman, geo); |
65 if(r != OK) | 67 if(r != OK) |
66 return ERR; | 68 return ERR; |
67 } | 69 } |