- if (type == Fallback_Unfocusing && old && old->transient_for) {
- if (old->transient_for == TRAN_GROUP) {
- for (it = focus_order[screen_desktop]; it != NULL; it = it->next) {
- GSList *sit;
-
- for (sit = old->group->members; sit; sit = sit->next)
- if (sit->data == it->data && client_focus(sit->data))
- return;
- }
- } else {
- if (client_normal(old->transient_for))
- if (client_focus(old->transient_for))
- return;
- }
+ /* nothing is focused, update the colormap and _the root property_ */
+ focus_set_client(NULL);
+
+ /* if there is a grab going on, then we need to cancel it. if we move
+ focus during the grab, applications will get NotifyWhileGrabbed events
+ and ignore them !
+
+ actions should not rely on being able to move focus during an
+ interactive grab.
+ */
+ if (keyboard_interactively_grabbed())
+ keyboard_interactive_cancel();
+
+ /* when nothing will be focused, send focus to the backup target */
+ XSetInputFocus(ob_display, screen_support_win, RevertToPointerRoot,
+ event_curtime);
+}
+
+void focus_order_add_new(ObClient *c)
+{
+ if (c->iconic)
+ focus_order_to_top(c);
+ else {
+ g_assert(!g_list_find(focus_order, c));
+ /* if there are any iconic windows, put this above them in the order,
+ but if there are not, then put it under the currently focused one */
+ if (focus_order && ((ObClient*)focus_order->data)->iconic)
+ focus_order = g_list_insert(focus_order, c, 0);
+ else
+ focus_order = g_list_insert(focus_order, c, 1);