Пример #1
0
static void propagate_up(Data_Obj *dp,uint32_t flagbit)
{
	if( dp->dt_parent != NULL ){
		xfer_cuda_flag(dp->dt_parent,dp,flagbit);
		propagate_up(dp->dt_parent,flagbit);
	}
}
Пример #2
0
static void propagate_up(Data_Obj *dp,uint32_t flagbit)
{
	if( dp->dt_parent != NULL ){
		xfer_dobj_flag(dp->dt_parent,dp,flagbit);
		propagate_up(dp->dt_parent,flagbit);
		// Do we need to propagate down from parent,
		// to get the siblings?
		// That could lead to an infinite regress if
		// we don't somehow mark the objects...
		// But then we would have to clear the marks!?
	}
}
Пример #3
0
void propagate_flag(Data_Obj *dp,uint32_t flagbit)
{
	propagate_up(dp,flagbit);
	propagate_down(dp,flagbit);
}
Пример #4
0
/******************************************************************************\
 Handle an SDL event. Does not allow multiple keys or mouse buttons to be
 pressed at the same time.
\******************************************************************************/
void I_dispatch(const SDL_Event *ev)
{
        SDLMod mod;
        i_event_t event;

        /* Update modifiers */
        mod = SDL_GetModState();
        i_key_shift = mod & KMOD_SHIFT;
        i_key_alt = mod & KMOD_ALT;
        i_key_ctrl = mod & KMOD_CTRL;

        /* Before dispatch */
        switch (ev->type) {
        case SDL_ACTIVEEVENT:

                /* If the mouse focus was lost, reset the cursor position */
                if (!ev->active.gain &&
                    (ev->active.state & SDL_APPMOUSEFOCUS))
                        i_mouse = C_vec2(-1.f, -1.f);

                return;
        case SDL_KEYDOWN:
                event = I_EV_KEY_DOWN;
                i_key = ev->key.keysym.sym;
                i_key_unicode = ev->key.keysym.unicode;
                if (i_debug.value.n > 0)
                        C_trace("SDL_KEYDOWN (%s%s)",
                                (i_key_shift ? "shift + " : ""),
                                I_key_string(i_key_unicode));
                if (!i_key) {
                        C_warning("SDL sent zero keysym");
                        return;
                }
                break;
        case SDL_KEYUP:
                event = I_EV_KEY_UP;
                i_key = ev->key.keysym.sym;
                if (i_debug.value.n > 0)
                        C_trace("SDL_KEYUP (%s%s)",
                                (i_key_shift ? "shift + " : ""),
                                I_key_string(i_key_unicode));
                break;
        case SDL_MOUSEMOTION:
                event = I_EV_MOUSE_MOVE;
                i_mouse.x = ev->motion.x / r_scale_2d;
                i_mouse.y = ev->motion.y / r_scale_2d;
                find_focus();
                break;
        case SDL_MOUSEBUTTONDOWN:
                event = I_EV_MOUSE_DOWN;
                i_mouse_button = ev->button.button;
                if (i_debug.value.n > 0)
                        C_trace("SDL_MOUSEBUTTONDOWN (%d)", i_mouse_button);
                check_mouse_focus(mouse_focus);
                break;
        case SDL_MOUSEBUTTONUP:
                event = I_EV_MOUSE_UP;
                i_mouse_button = ev->button.button;
                if (i_debug.value.n > 0)
                        C_trace("SDL_MOUSEBUTTONUP (%d)", i_mouse_button);
                check_mouse_focus(mouse_focus);
                break;
        default:
                return;
        }

        /* Update focus widgets for this event */
        i_key_focus = key_focus;
        i_mouse_focus = mouse_focus;

        /* Key and mouse down events are propagated back from the focused
           widget up the hierarchy */
        if (event == I_EV_KEY_DOWN) {
                I_global_key();
                if (i_key_focus) {
                        i_key_focus->event_func(i_key_focus, event);
                        propagate_up(i_key_focus->parent, event);
                }
        } else if (event == I_EV_MOUSE_DOWN || event == I_EV_MOUSE_MOVE)
                propagate_up(mouse_focus, event);

        /* Normal event propagation up from the root widget */
        else
                I_widget_event(&i_root, event);

        /* After dispatch */
        switch (ev->type) {
        case SDL_MOUSEBUTTONUP:
                i_mouse_button = 0;
                break;
        case SDL_KEYUP:
                i_key = 0;
                break;
        default:
                break;
        }
}