Mercurial > MadButterfly
changeset 1011:02d52058d352 refine_backend_if
Make functions of X_supp.c static and fill fields of backend.
- Make most functions in X_supp.c static
- fill fields of backend variable.
author | Thinker K.F. Li <thinker@codemud.net> |
---|---|
date | Mon, 22 Nov 2010 00:42:30 +0800 |
parents | feea3784b7ff |
children | 914add76c210 |
files | include/mb_X_supp.h include/mb_backend.h src/X_supp.c |
diffstat | 3 files changed, 32 insertions(+), 33 deletions(-) [+] |
line wrap: on
line diff
--- a/include/mb_X_supp.h Mon Nov 22 00:42:30 2010 +0800 +++ b/include/mb_X_supp.h Mon Nov 22 00:42:30 2010 +0800 @@ -25,18 +25,7 @@ typedef struct _X_MB_runtime X_MB_runtime_t; -extern void X_MB_handle_connection(void *rt); -extern void *X_MB_new(const char *display_name, int w, int h); -extern void *X_MB_new_with_win(Display *display, Window win); -extern void X_MB_free(void *xmb_rt); -extern void X_MB_free_keep_win(void *rt); - -extern subject_t *X_MB_kbevents(void *xmb_rt); -extern redraw_man_t *X_MB_rdman(void *xmb_rt); -extern mb_tman_t *X_MB_tman(void *xmb_rt); -extern ob_factory_t *X_MB_ob_factory(void *xmb_rt); -extern mb_img_ldr_t *X_MB_img_ldr(void *xmb_rt); - -#define MB_WINDOW Window +typedef Window MB_WINDOW; +typedef Display *MB_DISPLAY; #endif
--- 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 @@ -24,6 +24,10 @@ typedef struct _mb_IO_factory mb_IO_factory_t; typedef enum _MB_IO_TYPE MB_IO_TYPE; +/*! \brief Function signature of callback functions for IO requests. + */ +typedef void (*mb_IO_cb_t)(int hdl, int fd, MB_IO_TYPE type, void *data); + /*! \brief The backend engine mb_backend_t is used to define the * interface to realize the MB. * @@ -39,7 +43,7 @@ */ typedef struct { mb_rt_t *(*new)(const char *display, int w,int h); - mb_rt_t *(*new_with_win)(const char *display, MB_WINDOW win, int w,int h); + mb_rt_t *(*new_with_win)(MB_DISPLAY display, MB_WINDOW win); void (*free)(mb_rt_t *rt); /*! \brief Request the backend to start monitoring a file descriptor. @@ -47,7 +51,7 @@ * This is used only when the backend is responsible for event loop. */ int (*add_event)(mb_rt_t *rt, int fd, MB_IO_TYPE type, - mb_eventcb_t f,void *arg); + mb_IO_cb_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. @@ -81,10 +85,6 @@ */ enum _MB_IO_TYPE {MB_IO_DUMMY, MB_IO_R, MB_IO_W, MB_IO_RW}; -/*! \brief Function signature of callback functions for IO requests. - */ -typedef void (*mb_IO_cb_t)(int hdl, int fd, MB_IO_TYPE type, void *data); - /*! \brief IO Manager */ struct _mb_IO_man {
--- 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 @@ -1075,7 +1075,8 @@ xmb_rt->win = win; } -void *X_MB_new(const char *display_name, int w, int h) { +static mb_rt_t * +X_MB_new(const char *display_name, int w, int h) { X_MB_runtime_t *rt; int r; @@ -1097,7 +1098,8 @@ * The object returned by this function must be free with * X_MB_free_keep_win() to prevent the window from closed. */ -void *X_MB_new_with_win(Display *display, Window win) { +static mb_rt_t * +X_MB_new_with_win(MB_DISPLAY display, MB_WINDOW win) { X_MB_runtime_t *rt; int r; @@ -1114,35 +1116,40 @@ return rt; } -void X_MB_free(void *rt) { +static void +X_MB_free(void *rt) { X_MB_destroy((X_MB_runtime_t *) rt); free(rt); } /*! \brief Free runtime created with X_MB_new_with_win(). */ -void +static void X_MB_free_keep_win(void *rt) { X_MB_destroy_keep_win((X_MB_runtime_t *) rt); free(rt); } -subject_t *X_MB_kbevents(void *rt) { +static subject_t * +X_MB_kbevents(void *rt) { X_MB_runtime_t *xmb_rt = (X_MB_runtime_t *) rt; return xmb_rt->kbinfo.kbevents; } -redraw_man_t *X_MB_rdman(void *rt) { +static redraw_man_t * +X_MB_rdman(void *rt) { X_MB_runtime_t *xmb_rt = (X_MB_runtime_t *) rt; return xmb_rt->rdman; } -mb_timer_man_t *X_MB_timer_man(void *rt) { +static mb_timer_man_t * +X_MB_timer_man(void *rt) { X_MB_runtime_t *xmb_rt = (X_MB_runtime_t *) rt; return xmb_rt->timer_man; } -ob_factory_t *X_MB_ob_factory(void *rt) { +static ob_factory_t * +X_MB_ob_factory(void *rt) { X_MB_runtime_t *xmb_rt = (X_MB_runtime_t *) rt; ob_factory_t *factory; @@ -1150,7 +1157,8 @@ return factory; } -mb_img_ldr_t *X_MB_img_ldr(void *rt) { +static mb_img_ldr_t * +X_MB_img_ldr(void *rt) { X_MB_runtime_t *xmb_rt = (X_MB_runtime_t *) rt; mb_img_ldr_t *img_ldr; @@ -1159,8 +1167,9 @@ return img_ldr; } -int X_MB_add_event(void *rt, int fd, MB_IO_TYPE type, - mb_IO_cb_t cb, void *data) +static int +X_MB_add_event(mb_rt_t *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; mb_IO_man_t *io_man = xmb_rt->io_man; @@ -1170,7 +1179,8 @@ return hdl; } -void X_MB_remove_event(void *rt, int hdl) +static void +X_MB_remove_event(mb_rt_t *rt, int hdl) { X_MB_runtime_t *xmb_rt = (X_MB_runtime_t *) rt; mb_IO_man_t *io_man = xmb_rt->io_man; @@ -1184,11 +1194,11 @@ X_MB_free, X_MB_add_event, X_MB_remove_event, - X_MB_handle_connection, + _x_mb_event_loop, X_MB_kbevents, X_MB_rdman, - X_MB_tman, + X_MB_timer_man, X_MB_ob_factory, X_MB_img_ldr };