/* When a window is unmapped (or destroyed) this function takes care of * adjusting the focus window appropriately. */ void restore_focus_after_unmap( FvwmWindow *tmp_win, Bool do_skip_marked_transients) { extern FvwmWindow *colormap_win; FvwmWindow *t = NULL; FvwmWindow *set_focus_to = NULL; if (tmp_win == get_focus_window()) { if (tmp_win->transientfor != None && tmp_win->transientfor != Scr.Root) { for (t = Scr.FvwmRoot.next; t != NULL; t = t->next) { if (t->w == tmp_win->transientfor && t->Desk == tmp_win->Desk && (!do_skip_marked_transients || !IS_IN_TRANSIENT_SUBTREE(t))) { set_focus_to = t; break; } } } if (!set_focus_to && (HAS_CLICK_FOCUS(tmp_win) || HAS_SLOPPY_FOCUS(tmp_win))) { for (t = tmp_win->next; t != NULL; t = t->next) { if (t->Desk == tmp_win->Desk && !DO_SKIP_CIRCULATE(t) && !(IS_ICONIFIED(t) && ( DO_SKIP_ICON_CIRCULATE(t) || IS_ICON_SUPPRESSED(t))) && (!do_skip_marked_transients || !IS_IN_TRANSIENT_SUBTREE(t))) { /* If it is on a different desk we have to look for another window */ set_focus_to = t; break; } } } if (set_focus_to && set_focus_to != tmp_win && set_focus_to->Desk == tmp_win->Desk) { /* Don't transfer focus to windows on other desks */ SetFocusWindow(set_focus_to, 1); } if (tmp_win == get_focus_window()) { DeleteFocus(1); } } if (tmp_win == Scr.pushed_window) Scr.pushed_window = NULL; if (tmp_win == colormap_win) { InstallWindowColormaps(set_focus_to); } return; }
static FvwmWindow *__restore_focus_after_unmap( const FvwmWindow *fw, Bool do_skip_marked_transients) { FvwmWindow *t = NULL; FvwmWindow *set_focus_to = NULL; t = get_transientfor_fvwmwindow(fw); if (t != NULL && FP_DO_RELEASE_FOCUS_TRANSIENT(FW_FOCUS_POLICY(fw)) && !FP_DO_OVERRIDE_RELEASE_FOCUS(FW_FOCUS_POLICY(t)) && t->Desk == fw->Desk && (!do_skip_marked_transients || !IS_IN_TRANSIENT_SUBTREE(t))) { set_focus_to = t; } else if (t == NULL && FP_DO_RELEASE_FOCUS(FW_FOCUS_POLICY(fw))) { for (t = fw->next; t != NULL && set_focus_to == NULL; t = t->next) { if (!FP_DO_OVERRIDE_RELEASE_FOCUS( FW_FOCUS_POLICY(t)) && t->Desk == fw->Desk && !DO_SKIP_CIRCULATE(t) && !(IS_ICONIFIED(t) && (DO_SKIP_ICON_CIRCULATE(t) || IS_ICON_SUPPRESSED(t))) && (!do_skip_marked_transients || !IS_IN_TRANSIENT_SUBTREE(t))) { /* If it is on a different desk we have to look * for another window */ set_focus_to = t; } } } if (set_focus_to && set_focus_to != fw && set_focus_to->Desk == fw->Desk) { /* Don't transfer focus to windows on other desks */ SetFocusWindow(set_focus_to, True, FOCUS_SET_FORCE); } if (focus_is_focused(fw)) { DeleteFocus(True); } return set_focus_to; }