Mercurial > MadButterfly
comparison src/X_supp.c @ 1009:595a06fc0157 refine_backend_if
Change X_MB_add/remove_event() to match new mb_backend_t
author | Thinker K.F. Li <thinker@codemud.net> |
---|---|
date | Mon, 22 Nov 2010 00:42:30 +0800 |
parents | 789f67288e1c |
children | feea3784b7ff |
comparison
equal
deleted
inserted
replaced
1008:789f67288e1c | 1009:595a06fc0157 |
---|---|
1157 img_ldr = xmb_rt->img_ldr; | 1157 img_ldr = xmb_rt->img_ldr; |
1158 | 1158 |
1159 return img_ldr; | 1159 return img_ldr; |
1160 } | 1160 } |
1161 | 1161 |
1162 void X_MB_add_event(void *rt, int type, int fd, mb_eventcb_t f,void *arg) | 1162 int X_MB_add_event(void *rt, int fd, MB_IO_TYPE type, |
1163 mb_IO_cb_t cb, void *data) | |
1163 { | 1164 { |
1164 X_MB_runtime_t *xmb_rt = (X_MB_runtime_t *) rt; | 1165 X_MB_runtime_t *xmb_rt = (X_MB_runtime_t *) rt; |
1165 int i; | 1166 mb_IO_man_t *io_man = xmb_rt->io_man; |
1166 | 1167 int hdl; |
1167 for(i=0;i<xmb_rt->n_monitor;i++) { | 1168 |
1168 if (xmb_rt->monitors[i].type == type && xmb_rt->monitors[i].fd == fd) { | 1169 hdl = io_man->reg(io_man, fd, type, cb, data); |
1169 xmb_rt->monitors[i].f = f; | 1170 return hdl; |
1170 xmb_rt->monitors[i].arg = arg; | 1171 } |
1171 return; | 1172 |
1172 } | 1173 void X_MB_remove_event(void *rt, int hdl) |
1173 } | |
1174 for(i=0;i<xmb_rt->n_monitor;i++) { | |
1175 if (xmb_rt->monitors[i].type == 0) { | |
1176 xmb_rt->monitors[i].type = type; | |
1177 xmb_rt->monitors[i].fd = fd; | |
1178 xmb_rt->monitors[i].f = f; | |
1179 xmb_rt->monitors[i].arg = arg; | |
1180 return; | |
1181 } | |
1182 } | |
1183 if (i == MAX_MONITORS) return; | |
1184 xmb_rt->monitors[i].type = type; | |
1185 xmb_rt->monitors[i].fd = fd; | |
1186 xmb_rt->monitors[i].f = f; | |
1187 xmb_rt->monitors[i].arg = arg; | |
1188 i++; | |
1189 xmb_rt->n_monitor=i; | |
1190 } | |
1191 | |
1192 void X_MB_remove_event(void *rt, int type, int fd) | |
1193 { | 1174 { |
1194 X_MB_runtime_t *xmb_rt = (X_MB_runtime_t *) rt; | 1175 X_MB_runtime_t *xmb_rt = (X_MB_runtime_t *) rt; |
1195 int i; | 1176 mb_IO_man_t *io_man = xmb_rt->io_man; |
1196 for(i=0;i<xmb_rt->n_monitor;i++) { | 1177 |
1197 if (xmb_rt->monitors[i].type == type && xmb_rt->monitors[i].fd == fd) { | 1178 io_man->unreg(io_man, hdl); |
1198 xmb_rt->monitors[i].type = 0; | 1179 } |
1199 return; | 1180 |
1200 } | |
1201 } | |
1202 } | |
1203 mb_backend_t backend = { X_MB_new, | 1181 mb_backend_t backend = { X_MB_new, |
1204 X_MB_new_with_window, | 1182 X_MB_new_with_window, |
1205 | 1183 |
1206 X_MB_free, | 1184 X_MB_free, |
1207 X_MB_add_event, | 1185 X_MB_add_event, |