static void SetupWindowStateWithEventMask (ClientData *pCD, int newState, Time setTime, unsigned int event_mask) { int currentState; #ifdef WSM int wsI, iplace; WmWorkspaceData *pWS_i; #else /* WSM */ WmWorkspaceData *pWS = PSD_FOR_CLIENT(pCD)->pActiveWS; #endif /* WSM */ WmScreenData *pSD = PSD_FOR_CLIENT(pCD); currentState = pCD->clientState; /* * A transient window is not restored or maximized if the transient leader * is minimized. */ if (newState == NORMAL_STATE) { if (pCD->maxConfig == True) { /* * The configuration function uses maxConfig to determine * what the current configuration is (and then resets * maxConfig) and uses the state paramenter to determine * what the new configuration is. */ ConfigureNewState (pCD); } } else /* MAXIMIZED_STATE */ { if (pCD->maxConfig == False) { ConfigureNewState (pCD); } } if (currentState == MINIMIZED_STATE) { Boolean clearIconFocus; /* * give up keyboard focus */ if ((wmGD.keyboardFocus == pCD) || (wmGD.nextKeyboardFocus == pCD)) { Do_Focus_Key (NULL, setTime, ALWAYS_SET_FOCUS | WORKSPACE_IF_NULL); } if (wmGD.keyboardFocus == pCD) { clearIconFocus = True; } else { clearIconFocus = False; } /* * The wm icon frame window and the client icon window * (if it is being used) are mapped and the client window and * client frame are unmapped. */ if (ICON_FRAME_WIN(pCD)) { if (pSD->useIconBox && P_ICON_BOX(pCD) && !(pCD->clientFlags & ICON_BOX)) { ShowClientIconState(pCD, newState); } else { Boolean doGrab = False; if (event_mask) doGrab = (Success == XGrabPointer (DISPLAY, DefaultRootWindow(DISPLAY), False, event_mask, GrabModeAsync, GrabModeAsync, None, None, CurrentTime)); XUnmapWindow (DISPLAY, ICON_FRAME_WIN(pCD)); if (pCD->iconWindow) { XUnmapWindow (DISPLAY, pCD->iconWindow); } if (event_mask && doGrab) { XEvent event; XMaskEvent(DISPLAY, event_mask, &event); XUngrabPointer(DISPLAY,CurrentTime); } #ifdef WSM if (wmGD.iconAutoPlace) { for (wsI = 0; wsI < pCD->numInhabited; wsI++) { iplace = pCD->pWsList[wsI].iconPlace; if (iplace != NO_ICON_PLACE) { pWS_i = GetWorkspaceData (pCD->pSD, pCD->pWsList[wsI].wsID); pWS_i->IPData.placeList[iplace].pCD = NULL; } } } #else /* WSM */ if ((wmGD.iconAutoPlace) && (ICON_PLACE(pCD) != NO_ICON_PLACE)) { pWS->IPData.placeList[ICON_PLACE(pCD)].pCD = NULL; } #endif /* WSM */ } if (clearIconFocus) { ClearFocusIndication (pCD, False /*no refresh*/); wmGD.keyboardFocus = NULL; } } } if ((currentState != NORMAL_STATE) && (currentState != MAXIMIZED_STATE)) { /* * Note that maximized state is considered a NormalState in * the ICCC. SetClientWMState also sets the state in the * client data. */ if (currentState == MINIMIZED_STATE) { /* * Raise the window(s) when they are deiconified. */ pCD->clientState = newState; #ifdef WSM wmGD.bSuspendSecondaryRestack = True; #endif /* WSM */ F_Raise (NULL, pCD, NULL); #ifdef WSM wmGD.bSuspendSecondaryRestack = False; #endif /* WSM */ } if ( (!(pCD->clientFlags & ICON_BOX)) || ((pCD->clientFlags & ICON_BOX) && (!(firstTime))) ) { #ifdef PANELIST if ((currentState == WITHDRAWN_STATE) && (pCD->dtwmBehaviors & DtWM_BEHAVIOR_SUBPANEL) && !(pCD->transientChildren)) { if (pCD->dtwmBehaviors & DtWM_BEHAVIOR_SUB_RESTORED) { pCD->dtwmBehaviors &= ~DtWM_BEHAVIOR_SUB_RESTORED; pCD->dtwmBehaviors &= ~DtWM_BEHAVIOR_SUBPANEL; XMapWindow (DISPLAY, pCD->client); XMapWindow (DISPLAY, pCD->clientFrameWin); } else { SlideWindowOut (pCD); } } else #endif /* PANELIST */ MapClientWindows (pCD); } /* * Set the WM_STATE property of the window and any associated * transients, along with the clientState value. The call * is made with an indication of NORMAL_STATE to insure * that transient window clientState values are setup * correctly. The top-level window clientState is set later. */ SetClientWMState (pCD, NormalState, NORMAL_STATE); } pCD->clientState = newState; if ((wmGD.keyboardFocusPolicy == KEYBOARD_FOCUS_EXPLICIT) && (currentState == MINIMIZED_STATE) && wmGD.deiconifyKeyFocus) { ClientData *pcdFocus; pcdFocus = FindTransientFocus (pCD); if (pcdFocus) { Do_Focus_Key (pcdFocus, setTime, ALWAYS_SET_FOCUS); } } if ( pSD->useIconBox && P_ICON_BOX(pCD) && (!(pCD->clientFlags & ICON_BOX)) && (ICON_FRAME_WIN(pCD))) { /* * force icon appearance in icon box to change */ IconExposureProc (pCD, True); } } /* END OF FUNCTION SetupWindowStateWithEventMask */
void SetKeyboardFocus (ClientData *pCD, long focusFlags) { ClientData *currentFocus; /* * Don't set the keyboard input focus if it is already set to * the client window. */ if (wmGD.keyboardFocus == pCD) { return; } currentFocus = wmGD.keyboardFocus; ACTIVE_PSD->focusPriority++; /* * If the keyboard input focus policy is "explicit" then reset the * selection button event handling. */ if (wmGD.keyboardFocusPolicy == KEYBOARD_FOCUS_EXPLICIT) { /* * Reset explicit focus selection event tracking on the last focus * window (reset the passive grab on the focus button). */ if (currentFocus) { ResetExplicitSelectHandling (currentFocus); wmGD.keyboardFocus = NULL; } if (pCD && ((pCD->clientState == NORMAL_STATE) || (pCD->clientState == MAXIMIZED_STATE))) { /* * The focus is to be set to a client window (not the root). * Stop explicit focus selection event tracking on the new focus * window. */ if (removeSelectGrab) { WmUngrabButton (DISPLAY, FOCUS_SELECT_BUTTON, 0, pCD->clientBaseWin); } } } wmGD.keyboardFocus = pCD; /* * Do focus auto raise if specified. */ if (pCD && pCD->focusAutoRaise) { if (wmGD.autoRaiseDelay && (wmGD.keyboardFocusPolicy == KEYBOARD_FOCUS_POINTER)) { AddWmTimer (TIMER_RAISE, (unsigned long)wmGD.autoRaiseDelay, pCD); } else { Boolean sameScreen; if (((wmGD.keyboardFocusPolicy == KEYBOARD_FOCUS_EXPLICIT) && (!pCD->focusAutoRaiseDisabled)) || ((wmGD.keyboardFocusPolicy == KEYBOARD_FOCUS_POINTER) && (pCD == GetClientUnderPointer (&sameScreen)))) { Do_Raise (pCD, (ClientListEntry *)NULL, STACK_NORMAL); } } } /* * Clear the focus indication if it is set for a client window or icon. */ if (currentFocus) { ClearFocusIndication (currentFocus, ((focusFlags & REFRESH_LAST_FOCUS) ? True : False)); } /* * Install the client window colormap if the colormap focus policy is * "keyboard". */ if ((wmGD.colormapFocusPolicy == CMAP_FOCUS_KEYBOARD) && (!(focusFlags & SCREEN_SWITCH_FOCUS))) { SetColormapFocus (ACTIVE_PSD, pCD); } /* * Set the focus window or icon visual indication. */ if (pCD) { pCD->focusPriority = ACTIVE_PSD->focusPriority; SetFocusIndication (pCD); } } /* END OF FUNCTION SetKeyboardFocus */