void SetClientStateWithEventMask (ClientData *pCD, int newState, Time setTime, unsigned int event_mask) { ClientData *pcdLeader; int currentState; WmScreenData *pSD = PSD_FOR_CLIENT(pCD); #ifdef WSM Boolean notShowing = (newState & UNSEEN_STATE); #endif /* WSM */ currentState = pCD->clientState; if (currentState == newState) { /* no change in state */ return; } /* * Undo the old state and setup the new state. If this is a transient * window then insure that it is put in a state that is compatible * with its transient leader (e.g., it cannot be minimized separately). */ pcdLeader = (pCD->transientLeader) ? FindTransientTreeLeader (pCD) : pCD; #ifdef WSM SetClientWsIndex (pCD); #endif /* WSM */ if (pCD->transientLeader) { if ((pcdLeader->clientState == MINIMIZED_STATE) && (newState != WITHDRAWN_STATE)) { newState = MINIMIZED_STATE; #ifdef WSM if (notShowing) { newState |= UNSEEN_STATE; } #endif /* WSM */ } else if ((newState == MINIMIZED_STATE) && (pcdLeader->clientState != MINIMIZED_STATE)) { if (currentState == WITHDRAWN_STATE) { newState = NORMAL_STATE; #ifdef WSM if (notShowing) { newState |= UNSEEN_STATE; } #endif /* WSM */ } else { newState = currentState; #ifdef WSM if (notShowing) { newState |= UNSEEN_STATE; } #endif /* WSM */ } } if (newState == currentState) { return; } } switch (newState) { #ifdef WSM case UNSEEN_STATE | WITHDRAWN_STATE: #else case WITHDRAWN_STATE: #endif /* WSM */ { /* * Free window manager resources (frame and icon). The * WM_STATE property is set in WithdrawWindow. */ UnManageWindow (pCD); break; } case NORMAL_STATE: case MAXIMIZED_STATE: { SetupWindowStateWithEventMask (pCD, newState, setTime, event_mask); #ifdef WSM XMapWindow (DISPLAY, pCD->client); XMapWindow (DISPLAY, pCD->clientFrameWin); #if defined(PANELIST) WmStopWaiting(); /* in WmIPC.c */ #endif /* PANELIST */ #endif /* WSM */ break; } case MINIMIZED_STATE: { Boolean clientHasFocus; /* * Transient windows are minimized with the rest of the transient * tree, including the transient leader. */ if ((pCD->clientState == NORMAL_STATE) || (pCD->clientState == MAXIMIZED_STATE)) { if ((wmGD.keyboardFocus == pCD) || (pCD->transientChildren && wmGD.keyboardFocus && (pCD == FindTransientTreeLeader (wmGD.keyboardFocus)))) { clientHasFocus = True; } else { clientHasFocus = False; } if (clientHasFocus || ((wmGD.nextKeyboardFocus == pCD) || (pCD->transientChildren && wmGD.keyboardFocus && (pCD == FindTransientTreeLeader (wmGD.nextKeyboardFocus))))) { /* * Give up the keyboard focus when minimized (including * the case in which an associated transient window has * the focus). Immediately remove the focus indication * from the window being minimized. */ if (wmGD.autoKeyFocus && (wmGD.keyboardFocusPolicy == KEYBOARD_FOCUS_EXPLICIT)) { AutoResetKeyFocus (pcdLeader, setTime); } else { Do_Focus_Key (NULL, setTime, ALWAYS_SET_FOCUS | WORKSPACE_IF_NULL); } if (clientHasFocus) { SetKeyboardFocus (NULL, 0); } } /* unmap main client and all transients */ UnmapClients (pCD, event_mask); } /* * Display the icon for the minimized client. */ if (ICON_FRAME_WIN(pCD)) { #ifdef WSM if (pCD->clientState & UNSEEN_STATE) { if (pCD->iconWindow) { XMapWindow (DISPLAY, pCD->iconWindow); } XMapWindow (DISPLAY, ICON_FRAME_WIN(pCD)); } ShowAllIconsForMinimizedClient (pCD); #else /* WSM */ ShowIconForMinimizedClient (pSD->pActiveWS, pCD); #endif /* WSM */ } SetClientWMState (pCD, IconicState, MINIMIZED_STATE); if ((pSD->useIconBox) && P_ICON_BOX(pCD)) { if ((pCD->clientFlags & ICON_BOX) && ACTIVE_ICON_TEXT_WIN) { /* * Hide active icon text window and reparent it to * root */ HideActiveIconText((WmScreenData *)NULL); pSD->activeLabelParent = ACTIVE_ROOT; XReparentWindow(DISPLAY, ACTIVE_ICON_TEXT_WIN , ACTIVE_ROOT, 0, 0 ); } if (ICON_FRAME_WIN(pCD)) { /* * force icon appearance in icon box to change */ IconExposureProc (pCD, True); } } break; } #ifdef WSM case UNSEEN_STATE | NORMAL_STATE: case UNSEEN_STATE | MAXIMIZED_STATE: case UNSEEN_STATE | MINIMIZED_STATE: { if (wmGD.keyboardFocus == pCD) { /* * Give up the keyboard focus */ Do_Focus_Key ((ClientData *)NULL, CurrentTime, ALWAYS_SET_FOCUS); SetKeyboardFocus (NULL, 0); } if (!(pCD->clientState & UNSEEN_STATE) && (((pCD->clientState & ~UNSEEN_STATE) == NORMAL_STATE) || ((pCD->clientState & ~UNSEEN_STATE) == MAXIMIZED_STATE))) { /* unmap main client and all transients */ UnmapClients (pcdLeader, event_mask); } if (pCD->clientFrameWin) { if (!P_ICON_BOX(pCD)) { if (ICON_FRAME_WIN(pCD)) { XUnmapWindow (DISPLAY, ICON_FRAME_WIN(pCD)); } if (pCD->iconWindow) XUnmapWindow (DISPLAY, pCD->iconWindow); } } switch (newState & ~UNSEEN_STATE) { case MINIMIZED_STATE: SetClientWMState (pCD, IconicState, newState); break; case NORMAL_STATE: case MAXIMIZED_STATE: default: SetClientWMState (pCD, NormalState, newState); break; } } break; #endif /* WSM */ } } /* END OF FUNCTION SetClientStateWithEventMask */
void EmbeddedClientRegister (ControlData * control_data, Boolean install) { char * client_name; Window client_window; int i, j; WmFpEmbeddedClientList embedded_client_list = (WmFpEmbeddedClientList) panel.embedded_client_list; WmFpEmbeddedClientData * embedded_client = NULL; if ((char) control_data-> element_values[CONTROL_TYPE].parsed_value != CONTROL_CLIENT) return; /* If this is a control installation, increase the list size, if */ /* needed, and initialize the embedded client structure. If it is */ /* a removal, find the control in the list and remove it by sliding */ /* each subsequent structure down one element in array. */ client_name = (char *) control_data->element_values[CONTROL_CLIENT_NAME].parsed_value; if (client_name == NULL) client_name = (char *) control_data->element_values[CONTROL_LABEL].parsed_value; if (install) { /* First see if this is an update to an already installed */ /* embedded client. If so, simply update the icon field */ for (i = 0; i < panel.embedded_client_count; i++) { if (strcmp (client_name, embedded_client_list[i].pchResName) == 0) { embedded_client_list[i].wControl = control_data->icon; break; } } if (i >= panel.embedded_client_count) { if (panel.embedded_client_count == panel.max_embedded_client_count) { panel.max_embedded_client_count += 10; embedded_client_list = (WmFpEmbeddedClientList) XtRealloc ((char *) embedded_client_list, sizeof (WmFpEmbeddedClientData) * panel.max_embedded_client_count); panel.embedded_client_list = (XtPointer) embedded_client_list; } embedded_client = &embedded_client_list[panel.embedded_client_count]; panel.embedded_client_count++; embedded_client->pchResName = XtNewString (client_name); embedded_client->wControl = control_data->icon; embedded_client->winParent = None; embedded_client->pCD = NULL; } for (i = 0; i < panel.embedded_client_count - 1; i++) { embedded_client = &embedded_client_list[i]; if (embedded_client->pCD != NULL) embedded_client->pCD->pECD = (void *) embedded_client; } } else { for (i = 0; i < panel.embedded_client_count; i++) { if (embedded_client_list[i].wControl == control_data->icon) { Position remove_y; Dimension adjust_y; /* This block will reparent the client window, move it */ /* to a new window location, and remap the window. */ if (embedded_client_list[i].pCD != NULL) { client_window = embedded_client_list[i].pCD->client; UnManageWindow (embedded_client_list[i].pCD); XSync (XtDisplay (panel.shell), False); XMoveWindow (XtDisplay (panel.shell), client_window, 0, 0); XMapWindow (XtDisplay (panel.shell), client_window); } remove_y = embedded_client_list[i].y; /* deleted control height plus 5 pixels of form offset */ adjust_y = XtHeight (control_data->icon) + 5; panel.embedded_client_count--; XtFree (embedded_client_list[i].pchResName); for (j = i; j < panel.embedded_client_count; j++) { embedded_client_list[j] = embedded_client_list[j + 1]; embedded_client = &embedded_client_list[j]; if (embedded_client_list[i].pCD != NULL) { embedded_client->pCD->pECD = (void *) embedded_client; if (XtParent(control_data->icon) == XtParent(embedded_client->wControl) && remove_y < embedded_client->y) { embedded_client->y -= adjust_y; XMoveWindow(XtDisplay(panel.shell), embedded_client->pCD->client, embedded_client->x, embedded_client->y); } } } break; } } } /* Set the embedded client list and count into the window manager's */ /* screen global data. */ EmbeddedClientSetData (); }