# HG changeset patch # User Thinker K.F. Li # Date 1290357750 -28800 # Node ID 595a06fc015730e3fd71bd2cb7cf5a3d9726e0a2 # Parent 789f67288e1c7fbbb09fcb62bbc0102e0a97625e Change X_MB_add/remove_event() to match new mb_backend_t diff -r 789f67288e1c -r 595a06fc0157 include/mb_backend.h --- a/include/mb_backend.h Mon Nov 22 00:42:30 2010 +0800 +++ b/include/mb_backend.h Mon Nov 22 00:42:30 2010 +0800 @@ -22,6 +22,7 @@ typedef struct _mb_timer_factory mb_timer_factory_t; typedef struct _mb_IO_man mb_IO_man_t; typedef struct _mb_IO_factory mb_IO_factory_t; +typedef enum _MB_IO_TYPE MB_IO_TYPE; /*! \brief The backend engine mb_backend_t is used to define the * interface to realize the MB. @@ -45,12 +46,13 @@ * * This is used only when the backend is responsible for event loop. */ - void (*add_event)(mb_rt_t *rt,int type, int fd, mb_eventcb_t f,void *arg); + int (*add_event)(mb_rt_t *rt, int fd, MB_IO_TYPE type, + mb_eventcb_t f,void *arg); /*! \brief Request the backend to stop monitoring a file descriptor. * * This is used only when the backend is responsible for event loop. */ - void (*remove_event)(mb_rt_t *rt,int type, int fd); + void (*remove_event)(mb_rt_t *rt, int hdl); /*! \brief Event Loop * * This is called when main application does not handle event @@ -78,7 +80,6 @@ /*! \brief Type of IO that registered with an IO manager. */ enum _MB_IO_TYPE {MB_IO_DUMMY, MB_IO_R, MB_IO_W, MB_IO_RW}; -typedef enum _MB_IO_TYPE MB_IO_TYPE; /*! \brief Function signature of callback functions for IO requests. */ diff -r 789f67288e1c -r 595a06fc0157 src/X_supp.c --- a/src/X_supp.c Mon Nov 22 00:42:30 2010 +0800 +++ b/src/X_supp.c Mon Nov 22 00:42:30 2010 +0800 @@ -1159,47 +1159,25 @@ return img_ldr; } -void X_MB_add_event(void *rt, int type, int fd, mb_eventcb_t f,void *arg) +int X_MB_add_event(void *rt, int fd, MB_IO_TYPE type, + mb_IO_cb_t cb, void *data) { X_MB_runtime_t *xmb_rt = (X_MB_runtime_t *) rt; - int i; + mb_IO_man_t *io_man = xmb_rt->io_man; + int hdl; - for(i=0;in_monitor;i++) { - if (xmb_rt->monitors[i].type == type && xmb_rt->monitors[i].fd == fd) { - xmb_rt->monitors[i].f = f; - xmb_rt->monitors[i].arg = arg; - return; - } - } - for(i=0;in_monitor;i++) { - if (xmb_rt->monitors[i].type == 0) { - xmb_rt->monitors[i].type = type; - xmb_rt->monitors[i].fd = fd; - xmb_rt->monitors[i].f = f; - xmb_rt->monitors[i].arg = arg; - return; - } - } - if (i == MAX_MONITORS) return; - xmb_rt->monitors[i].type = type; - xmb_rt->monitors[i].fd = fd; - xmb_rt->monitors[i].f = f; - xmb_rt->monitors[i].arg = arg; - i++; - xmb_rt->n_monitor=i; + hdl = io_man->reg(io_man, fd, type, cb, data); + return hdl; } -void X_MB_remove_event(void *rt, int type, int fd) +void X_MB_remove_event(void *rt, int hdl) { X_MB_runtime_t *xmb_rt = (X_MB_runtime_t *) rt; - int i; - for(i=0;in_monitor;i++) { - if (xmb_rt->monitors[i].type == type && xmb_rt->monitors[i].fd == fd) { - xmb_rt->monitors[i].type = 0; - return; - } - } + mb_IO_man_t *io_man = xmb_rt->io_man; + + io_man->unreg(io_man, hdl); } + mb_backend_t backend = { X_MB_new, X_MB_new_with_window,