X-Git-Url: https://git.brokenzipper.com/gitweb?a=blobdiff_plain;f=openbox%2Factions%2Fcyclewindows.c;h=7b4bd11e29e58e3875206afcf2bde4ec2b323612;hb=fe825d1dd274ca1fdafdca333df6d6689ec039c6;hp=3f7388ec061c2ae24ed45bf2a34fec2cf145dcb9;hpb=f227bd994d21d901790d93a962915863914b6c09;p=chaz%2Fopenbox diff --git a/openbox/actions/cyclewindows.c b/openbox/actions/cyclewindows.c index 3f7388ec..7b4bd11e 100644 --- a/openbox/actions/cyclewindows.c +++ b/openbox/actions/cyclewindows.c @@ -14,7 +14,13 @@ typedef struct { GSList *actions; } Options; +static gboolean cycling = FALSE; + static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node); +static gpointer setup_forward_func(ObParseInst *i, xmlDocPtr doc, + xmlNodePtr node); +static gpointer setup_backward_func(ObParseInst *i, xmlDocPtr doc, + xmlNodePtr node); static void free_func(gpointer options); static gboolean run_func(ObActionsData *data, gpointer options); static gboolean i_input_func(guint initial_state, @@ -27,12 +33,10 @@ static void end_cycle(gboolean cancel, guint state, Options *o); void action_cyclewindows_startup() { - actions_register("CycleWindows", - setup_func, - free_func, - run_func, - i_input_func, - i_cancel_func); + actions_register("NextWindow", setup_forward_func, free_func, + run_func, i_input_func, i_cancel_func); + actions_register("PreviousWindow", setup_backward_func, free_func, + run_func, i_input_func, i_cancel_func); } static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node) @@ -43,8 +47,6 @@ static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node) o = g_new0(Options, 1); o->dialog = TRUE; - if ((n = parse_find_node("forward", node))) - o->forward = parse_bool(doc, n); if ((n = parse_find_node("linear", node))) o->linear = parse_bool(doc, n); if ((n = parse_find_node("dialog", node))) @@ -56,7 +58,7 @@ static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node) if ((n = parse_find_node("allDesktops", node))) o->all_desktops = parse_bool(doc, n); - if ((n = parse_find_node("actions", node))) { + if ((n = parse_find_node("finalactions", node))) { xmlNodePtr m; m = parse_find_node("action", n->xmlChildrenNode); @@ -66,6 +68,31 @@ static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node) m = parse_find_node("action", m->next); } } + else { + o->actions = g_slist_prepend(o->actions, + actions_parse_string("Focus")); + o->actions = g_slist_prepend(o->actions, + actions_parse_string("Raise")); + o->actions = g_slist_prepend(o->actions, + actions_parse_string("Unshade")); + } + + return o; +} + +static gpointer setup_forward_func(ObParseInst *i, xmlDocPtr doc, + xmlNodePtr node) +{ + Options *o = setup_func(i, doc, node); + o->forward = TRUE; + return o; +} + +static gpointer setup_backward_func(ObParseInst *i, xmlDocPtr doc, + xmlNodePtr node) +{ + Options *o = setup_func(i, doc, node); + o->forward = FALSE; return o; } @@ -73,6 +100,11 @@ static void free_func(gpointer options) { Options *o = options; + while (o->actions) { + actions_act_unref(o->actions->data); + o->actions = g_slist_delete_link(o->actions, o->actions); + } + g_free(o); } @@ -80,10 +112,6 @@ static gboolean run_func(ObActionsData *data, gpointer options) { Options *o = options; - /* if using focus_delay, stop the timer now so that focus doesn't go moving - on us */ - event_halt_focus_delay(); - focus_cycle(o->forward, o->all_desktops, o->dock_windows, @@ -92,6 +120,7 @@ static gboolean run_func(ObActionsData *data, gpointer options) TRUE, o->dialog, FALSE, FALSE); + cycling = TRUE; return TRUE; } @@ -129,7 +158,10 @@ static gboolean i_input_func(guint initial_state, static void i_cancel_func(gpointer options) { - end_cycle(TRUE, 0, options); + /* we get cancelled when we move focus, but we're not cycling anymore, so + just ignore that */ + if (cycling) + end_cycle(TRUE, 0, options); } static void end_cycle(gboolean cancel, guint state, Options *o) @@ -144,6 +176,7 @@ static void end_cycle(gboolean cancel, guint state, Options *o) TRUE, o->dialog, TRUE, cancel); + cycling = FALSE; if (ft) { actions_run_acts(o->actions, OB_USER_ACTION_KEYBOARD_KEY,