Mercurial > MadButterfly
diff src/redraw_man.c @ 231:2637519e2bd7
Move mouse event handler and interpreter to src/mouse.c.
- Also change makefiles of examples with a better configuration.
author | Thinker K.F. Li <thinker@branda.to> |
---|---|
date | Thu, 18 Dec 2008 22:37:15 +0800 |
parents | 29e1b2bffe4c |
children | 65cabbdd5284 |
line wrap: on
line diff
--- a/src/redraw_man.c Wed Dec 17 21:37:39 2008 +0800 +++ b/src/redraw_man.c Thu Dec 18 22:37:15 2008 +0800 @@ -242,99 +242,11 @@ static void mouse_event_root_dummy(event_t *evt, void *arg) { } -static void mouse_event_interpreter(event_t *evt, void *arg) { - mouse_event_t *mevt = (mouse_event_t *)evt; - redraw_man_t *rdman = (redraw_man_t *)arg; - mb_obj_t *obj; - mouse_event_t new_evt; - coord_t *coord; - shape_t *shape; - - ASSERT(evt->type == EVT_MOUSE_MOVE_RAW); - - obj = (mb_obj_t *)subject_get_object(evt->cur_tgt); - if(rdman->last_mouse_over == obj) { - evt->type = EVT_MOUSE_MOVE; - return; - } - - new_evt.x = mevt->x; - new_evt.y = mevt->y; - new_evt.but_state = mevt->but_state; - new_evt.button = mevt->button; - - if(rdman->last_mouse_over != NULL) { - new_evt.event.type = EVT_MOUSE_OUT; - if(IS_MBO_COORD(rdman->last_mouse_over)) { - coord = (coord_t *)rdman->last_mouse_over; - subject_notify(coord->mouse_event, (event_t *)&new_evt); - } else if(IS_MBO_SHAPES(rdman->last_mouse_over)) { - shape = (shape_t *)rdman->last_mouse_over; - ASSERT(shape->geo != NULL); - subject_notify(shape->geo->mouse_event, (event_t *)&new_evt); - } - } - - new_evt.event.type = EVT_MOUSE_OVER; - subject_notify(evt->cur_tgt, (event_t *)&new_evt); - rdman->last_mouse_over = obj; - - evt->flags |= EVTF_STOP_NOTIFY; -} - -static void addrm_monitor_hdlr(event_t *evt, void *arg) { - monitor_event_t *mevt; - redraw_man_t *rdman; - mb_obj_t *obj; - mb_prop_store_t *props; - observer_t *observer; - int cnt = 0; - - mevt = (monitor_event_t *)evt; - rdman = (redraw_man_t *)evt->tgt; - obj = (mb_obj_t *)subject_get_object(mevt->subject); - props = mb_obj_prop_store(obj); - - switch(evt->type) { - case EVT_MONITOR_ADD: - if(!mb_prop_has(props, PROP_MEVT_OB_CNT)) - cnt = 0; - else - cnt = (int)mb_prop_get(props, PROP_MEVT_OB_CNT); - - cnt++; - mb_prop_set(props, PROP_MEVT_OB_CNT, (void *)cnt); - if(cnt == 1) { - observer = - subject_add_event_observer_head(mevt->subject, - EVT_MOUSE_MOVE_RAW, - mouse_event_interpreter, - rdman); - ASSERT(observer != NULL); - mb_prop_set(props, PROP_MEVT_OBSERVER, observer); - } - break; - - case EVT_MONITOR_REMOVE: - cnt = (int)mb_prop_get(props, PROP_MEVT_OB_CNT); - cnt--; - mb_prop_set(props, PROP_MEVT_OB_CNT, (void *)cnt); - if(cnt == 1) { - observer = (observer_t *)mb_prop_get(props, PROP_MEVT_OBSERVER); - subject_remove_observer(mevt->subject, observer); - mb_prop_del(props, PROP_MEVT_OBSERVER); - } - break; - - case EVT_MONITOR_FREE: - break; - } -} - int redraw_man_init(redraw_man_t *rdman, cairo_t *cr, cairo_t *backend) { extern void redraw_man_destroy(redraw_man_t *rdman); extern int _paint_color_size; observer_t *addrm_ob; + extern void addrm_monitor_hdlr(event_t *evt, void *arg); memset(rdman, 0, sizeof(redraw_man_t));