/** Add a client to the task bar. */ void AddClientToTaskBar(ClientNode *np) { TaskEntry *tp = NULL; ClientEntry *cp = Allocate(sizeof(ClientEntry)); cp->client = np; if(np->className && settings.groupTasks) { for(tp = taskEntries; tp; tp = tp->next) { const char *className = tp->clients->client->className; if(className && !strcmp(np->className, className)) { break; } } } if(tp == NULL) { tp = Allocate(sizeof(TaskEntry)); tp->clients = NULL; tp->next = NULL; tp->prev = taskEntriesTail; if(taskEntriesTail) { taskEntriesTail->next = tp; } else { taskEntries = tp; } taskEntriesTail = tp; } cp->next = tp->clients; if(tp->clients) { tp->clients->prev = cp; } cp->prev = NULL; tp->clients = cp; RequireTaskUpdate(); UpdateNetClientList(); }
/** Remove a client from the task bar. */ void RemoveClientFromTaskBar(ClientNode *np) { TaskEntry *tp; for(tp = taskEntries; tp; tp = tp->next) { ClientEntry *cp; for(cp = tp->clients; cp; cp = cp->next) { if(cp->client == np) { if(cp->prev) { cp->prev->next = cp->next; } else { tp->clients = cp->next; } if(cp->next) { cp->next->prev = cp->prev; } Release(cp); if(!tp->clients) { if(tp->prev) { tp->prev->next = tp->next; } else { taskEntries = tp->next; } if(tp->next) { tp->next->prev = tp->prev; } else { taskEntriesTail = tp->prev; } Release(tp); } RequireTaskUpdate(); UpdateNetClientList(); return; } } } }
/** Restack the clients according the way we want them. */ void RestackClients(void) { TrayType *tp; ClientNode *np; unsigned int layer, index; int trayCount; Window *stack; Window fw; if(JUNLIKELY(shouldExit)) { return; } /* Allocate memory for restacking. */ trayCount = GetTrayCount(); stack = AllocateStack((clientCount + trayCount) * sizeof(Window)); /* Prepare the stacking array. */ fw = None; index = 0; if(activeClient && (activeClient->state.status & STAT_FULLSCREEN)) { fw = activeClient->window; for(np = nodes[activeClient->state.layer]; np; np = np->next) { if(np->owner == fw) { if(np->parent != None) { stack[index] = np->parent; } else { stack[index] = np->window; } index += 1; } } if(activeClient->parent != None) { stack[index] = activeClient->parent; } else { stack[index] = activeClient->window; } index += 1; } layer = LAST_LAYER; for(;;) { for(np = nodes[layer]; np; np = np->next) { if( (np->state.status & (STAT_MAPPED | STAT_SHADED)) && !(np->state.status & STAT_HIDDEN)) { if(fw != None && (np->window == fw || np->owner == fw)) { continue; } if(np->parent != None) { stack[index] = np->parent; } else { stack[index] = np->window; } index += 1; } } for(tp = GetTrays(); tp; tp = tp->next) { if(layer == tp->layer) { stack[index] = tp->window; index += 1; } } if(layer == FIRST_LAYER) { break; } layer -= 1; } JXRestackWindows(display, stack, index); ReleaseStack(stack); UpdateNetClientList(); RequirePagerUpdate(); }