Mercurial > MadButterfly
changeset 757:f43224bf3524
Remove unused variables and refactor to X_MB_init_with_win
author | Thinker K.F. Li <thinker@codemud.net> |
---|---|
date | Thu, 26 Aug 2010 17:54:11 +0800 |
parents | cceac4ba259e |
children | d11b0900f03c |
files | include/mb_redraw_man.h src/X_supp.c src/mbaf/animated_menu.c src/paint.c |
diffstat | 4 files changed, 40 insertions(+), 33 deletions(-) [+] |
line wrap: on
line diff
--- a/include/mb_redraw_man.h Thu Aug 26 14:54:50 2010 +0800 +++ b/include/mb_redraw_man.h Thu Aug 26 17:54:11 2010 +0800 @@ -250,7 +250,7 @@ */ typedef struct { - void *(*init)(char *display,int w,int h); + void *(*init)(const char *display,int w,int h); void (*free)(void *be); void (*add_event)(void *be,int type, int fd, mb_eventcb_t f,void *arg); void (*remove_event)(void *be,int type, int fd);
--- a/src/X_supp.c Thu Aug 26 14:54:50 2010 +0800 +++ b/src/X_supp.c Thu Aug 26 17:54:11 2010 +0800 @@ -591,7 +591,7 @@ } xmb_rt->backend_surface = - mbe_image_surface_create_for_data(ximage->data, + mbe_image_surface_create_for_data((unsigned char *)ximage->data, surf_fmt, xmb_rt->w, xmb_rt->h, @@ -603,22 +603,23 @@ /*! \brief Initialize a MadButterfy runtime for Xlib. * - * It setups a runtime environment to run MadButterfly with Xlib. - * Users should specify width and height of the opening window. + * This one is very like X_MB_init(), except it accepts a + * X_MB_runtime_t object initialized with a display connected to a X + * server and an opened window. + * + * Following field of the X_MB_runtime_t object should be initialized. + * - w, h + * - win + * - display + * - visual */ -static int X_MB_init(const char *display_name, - int w, int h, X_MB_runtime_t *xmb_rt) { +static int +X_MB_init_with_win(X_MB_runtime_t *xmb_rt) { mb_img_ldr_t *img_ldr; - int r; + int w, h; - memset(xmb_rt, 0, sizeof(X_MB_runtime_t)); - - xmb_rt->w = w; - xmb_rt->h = h; - r = X_init_connection(display_name, w, h, &xmb_rt->display, - &xmb_rt->visual, &xmb_rt->win); - if(r != OK) - return ERR; + w = xmb_rt->w; + h = xmb_rt->h; #ifdef XSHM xshm_init(xmb_rt); @@ -648,8 +649,6 @@ // to get the xmb_rt->tman for the animation. We should relocate the tman // to the redraw_man_t instead. xmb_rt->rdman->rt = xmb_rt; - xmb_rt->rdman->w = w; - xmb_rt->rdman->h = h; xmb_rt->tman = mb_tman_new(); @@ -667,6 +666,29 @@ return OK; } +/*! \brief Initialize a MadButterfy runtime for Xlib. + * + * It setups a runtime environment to run MadButterfly with Xlib. + * Users should specify width and height of the opening window. + */ +static int X_MB_init(const char *display_name, + int w, int h, X_MB_runtime_t *xmb_rt) { + int r; + + memset(xmb_rt, 0, sizeof(X_MB_runtime_t)); + + xmb_rt->w = w; + xmb_rt->h = h; + r = X_init_connection(display_name, w, h, &xmb_rt->display, + &xmb_rt->visual, &xmb_rt->win); + if(r != OK) + return ERR; + + r = X_MB_init_with_win(xmb_rt); + + return r; +} + static void X_MB_destroy(X_MB_runtime_t *xmb_rt) { if(xmb_rt->rdman) { redraw_man_destroy(xmb_rt->rdman);
--- a/src/mbaf/animated_menu.c Thu Aug 26 14:54:50 2010 +0800 +++ b/src/mbaf/animated_menu.c Thu Aug 26 17:54:11 2010 +0800 @@ -22,13 +22,8 @@ { int i; coord_t *textgroup; - shape_t *text; coord_t *group; coord_t *lightbar; - int tmp; - mb_timeval_t start, playing, now; - mb_progm_t *progm; - mb_word_t *word; // fill new item for(i=0;i<8;i++) { @@ -63,7 +58,6 @@ { int i; coord_t *textgroup; - shape_t *text; coord_t *group; coord_t *lightbar; int tmp; @@ -123,11 +117,6 @@ static void mb_animated_menu_fillMenuContentDown(mb_animated_menu_t *m) { int i; - coord_t *textgroup; - shape_t *text; - coord_t *group; - coord_t *lightbar; - char name[255]; int tmp; mb_timeval_t start, playing, now; mb_progm_t *progm; @@ -179,7 +168,6 @@ mb_timeval_t start, playing, now; mb_progm_t *progm; mb_word_t *word; - coord_t *group; coord_t *lightbar; m->progm = progm = mb_progm_new(1, MBAF_RDMAN(m->app)); @@ -324,7 +312,7 @@ mb_animated_menu_t *mb_animated_menu_new(mbaf_t *app,mb_sprite_t *sp,char *objnames,char *menus[]) { mb_animated_menu_t *m; - int i,len; + int i; char name[255]; mb_obj_t *l; int ii;
--- a/src/paint.c Thu Aug 26 14:54:50 2010 +0800 +++ b/src/paint.c Thu Aug 26 17:54:11 2010 +0800 @@ -83,8 +83,6 @@ static void paint_linear_prepare(paint_t *paint, mbe_t *cr) { paint_linear_t *linear = (paint_linear_t *)paint; mbe_pattern_t *ptn; - grad_stop_t *stop; - int i; ptn = linear->ptn; if(linear->flags & LIF_DIRTY) { @@ -173,7 +171,6 @@ static void paint_radial_prepare(paint_t *paint, mbe_t *cr) { paint_radial_t *radial = (paint_radial_t *)paint; mbe_pattern_t *ptn; - int i; if(radial->flags & RDF_DIRTY) { ptn = mbe_pattern_create_radial(radial->cx, radial->cy, 0,