Esempio n. 1
0
void actions_run_acts(GSList *acts,
                      ObUserAction uact,
                      guint state,
                      gint x,
                      gint y,
                      gint button,
                      ObFrameContext con,
                      struct _ObClient *client)
{
    GSList *it;

    /* Don't allow saving the initial state when running things from the
       menu */
	syslog(LOG_INFO,"gslist len -> %d",g_slist_length(acts));
    if (uact == OB_USER_ACTION_MENU_SELECTION)
        state = 0;
    /* If x and y are < 0 then use the current pointer position */
    if (x < 0 && y < 0)
        screen_pointer_pos(&x, &y);

    for (it = acts; it; it = g_slist_next(it)) {
        ObActionsData data;
        ObActionsAct *act = it->data;
        gboolean ok = TRUE;
		syslog(LOG_INFO,"action ->%s",act->def->name);
        actions_setup_data(&data, uact, state, x, y, button, con, client);

        /* if they have the same run function, then we'll assume they are
           cooperating and not cancel eachother out */
        if (!interactive_act || interactive_act->def->run != act->def->run) {
            if (actions_act_is_interactive(act)) {
                /* cancel the old one */
                if (interactive_act)
                    actions_interactive_cancel_act();
                ok = actions_interactive_begin_act(act, state);
            }
        }

        /* fire the action's run function with this data */
        if (ok) {
            if (!act->def->run(&data, act->options)) {
                if (actions_act_is_interactive(act))
                    actions_interactive_end_act();
            } else {
                /* make sure its interactive if it returned TRUE */
                g_assert(act->def->i_cancel && act->def->i_input);

                /* no actions are run after the interactive one */
                break;
            }
        }
    }
}
Esempio n. 2
0
void actions_run_acts(GSList *acts,
                      ObUserAction uact,
                      guint state,
                      gint x,
                      gint y,
                      gint button,
                      ObFrameContext con,
                      struct _ObClient *client)
{
    GSList *it;
    gboolean update_user_time;

    /* Don't allow saving the initial state when running things from the
       menu */
    if (uact == OB_USER_ACTION_MENU_SELECTION)
        state = 0;
    /* If x and y are < 0 then use the current pointer position */
    if (x < 0 && y < 0)
        screen_pointer_pos(&x, &y);

    update_user_time = FALSE;
    for (it = acts; it; it = g_slist_next(it)) {
        ObActionsData data;
        ObActionsAct *act = it->data;
        gboolean ok = TRUE;

        actions_setup_data(&data, uact, state, x, y, button, con, client);

        /* if they have the same run function, then we'll assume they are
           cooperating and not cancel eachother out */
        if (!interactive_act || interactive_act->def->run != act->def->run) {
            if (actions_act_is_interactive(act)) {
                /* cancel the old one */
                if (interactive_act)
                    actions_interactive_cancel_act();
                if (act->i_pre)
                    if (!act->i_pre(state, act->options))
                        act->i_input = NULL; /* remove the interactivity */
            }
            /* check again cuz it might have been cancelled */
            if (actions_act_is_interactive(act))
                ok = actions_interactive_begin_act(act, state);
        }

        /* fire the action's run function with this data */
        if (ok) {
            if (!act->def->run(&data, act->options)) {
                if (actions_act_is_interactive(act))
                    actions_interactive_end_act();
                if (client && client == focus_client &&
                        act->def->modifies_focused_window)
                {
                    update_user_time = TRUE;
                }
            } else {
                /* make sure its interactive if it returned TRUE */
                g_assert(act->i_input);

                /* no actions are run after the interactive one */
                break;
            }
        }
    }
    if (update_user_time)
        event_update_user_time();
}