- if (!focus_order[screen_desktop])
- goto done_cycle;
-
- if (!first) first = focus_client;
- if (!focus_cycle_target) focus_cycle_target = focus_client;
-
- if (linear) list = client_list;
- else list = focus_order[screen_desktop];
-
- start = it = g_list_find(list, focus_cycle_target);
- if (!start) /* switched desktops or something? */
- start = it = forward ? g_list_last(list) : g_list_first(list);
- if (!start) goto done_cycle;
-
- do {
- if (forward) {
- it = it->next;
- if (it == NULL) it = g_list_first(list);
- } else {
- it = it->prev;
- if (it == NULL) it = g_list_last(list);
- }
- ft = it->data;
- if (valid_focus_target(ft)) {
- if (ft != focus_cycle_target) { /* prevents flicker */
- if (focus_cycle_target)
- frame_adjust_focus(focus_cycle_target->frame, FALSE);
- focus_cycle_target = ft;
- frame_adjust_focus(focus_cycle_target->frame, TRUE);
- }
- popup_cycle(ft, dialog);
- return;
- }
- } while (it != start);
-
-done_cycle:
- if (done && focus_cycle_target)
- client_activate(focus_cycle_target, FALSE);
-
- t = NULL;
- first = NULL;
- focus_cycle_target = NULL;
- g_list_free(order);
- order = NULL;
-
- popup_cycle(ft, FALSE);
-
- return;
-}
-
-void focus_directional_cycle(ObDirection dir,
- gboolean dialog, gboolean done, gboolean cancel)
-{
- static ObClient *first = NULL;
- ObClient *ft = NULL;
-
- if (cancel) {
- if (focus_cycle_target)
- frame_adjust_focus(focus_cycle_target->frame, FALSE);
- if (focus_client)
- frame_adjust_focus(focus_client->frame, TRUE);
- focus_cycle_target = NULL;
- goto done_cycle;
- } else if (done && dialog) {
- goto done_cycle;
- }
-
- if (!focus_order[screen_desktop])
- goto done_cycle;
-
- if (!first) first = focus_client;
- if (!focus_cycle_target) focus_cycle_target = focus_client;
-
- if (focus_cycle_target)
- ft = client_find_directional(focus_cycle_target, dir);
- else {
- GList *it;
-
- for (it = focus_order[screen_desktop]; it; it = g_list_next(it))
- if (valid_focus_target(it->data))
- ft = it->data;
- }
-
- if (ft) {
- if (ft != focus_cycle_target) {/* prevents flicker */
- if (focus_cycle_target)
- frame_adjust_focus(focus_cycle_target->frame, FALSE);
- focus_cycle_target = ft;
- frame_adjust_focus(focus_cycle_target->frame, TRUE);
- }
- }
- if (focus_cycle_target) {
- popup_cycle(focus_cycle_target, dialog);
- if (dialog)
- return;
- }
-
-
-done_cycle:
- if (done && focus_cycle_target)
- client_activate(focus_cycle_target, FALSE);
-
- first = NULL;
- focus_cycle_target = NULL;