+ old = focus_client;
+
+ /* unfocus any focused clients.. they can be focused by Pointer events
+ and such, and then when I try focus them, I won't get a FocusIn event
+ at all for them.
+ */
+ focus_set_client(NULL);
+
+ if (!(type == Fallback_Desktop ?
+ config_focus_last_on_desktop : config_focus_last)) {
+ if (config_focus_follow) focus_under_pointer();
+ return;
+ }
+
+ if (type == Fallback_Unfocusing && old) {
+ /* try for transient relations */
+ if (old->transient_for) {
+ if (old->transient_for == TRAN_GROUP) {
+ for (it = focus_order[screen_desktop]; it; it = it->next) {
+ GSList *sit;
+
+ for (sit = old->group->members; sit; sit = sit->next)
+ if (sit->data == it->data)
+ if (focus_fallback_transient(sit->data, old))
+ return;
+ }
+ } else {
+ if (focus_fallback_transient(old->transient_for, old))
+ return;
+ }
+ }
+
+ /* try for group relations */
+ if (old->group) {
+ GSList *sit;
+
+ for (it = focus_order[screen_desktop]; it != NULL; it = it->next)
+ for (sit = old->group->members; sit; sit = sit->next)
+ if (sit->data == it->data)
+ if (sit->data != old && client_normal(sit->data))
+ if (client_focus(sit->data))
+ return;
+ }
+ }
+
+ for (it = focus_order[screen_desktop]; it != NULL; it = it->next)
+ if (type != Fallback_Unfocusing || it->data != old)
+ if (client_normal(it->data) &&
+ /* dont fall back to 'anonymous' fullscreen windows. theres no
+ checks for this is in transient/group fallbacks. */
+ !((Client*)it->data)->fullscreen &&
+ client_focus(it->data))
+ return;
+
+ /* nothing to focus */
+ focus_set_client(NULL);
+}
+
+static void popup_cycle(Client *c, gboolean show)
+{
+ if (!show) {
+ popup_hide(focus_cycle_popup);