void tile(Win *w, int x, int y, unsigned int width, unsigned int height, unsigned int col, unsigned int row) { Win *tmp; List *l; unsigned int len, xi, yi, i; if(!(tmp = w)) return; for(len = 1; win_next(data.tag, NORMAL, &l, &tmp); len++); if(col && row) row = col = 0; if(!col) { if(row) col = ROUND(len / row); else for(col = 0; col <= len; col++) if(col * col >= len) break; } if(!row) row = ROUND(len / col); for(i = 0, yi = 0; w; win_next(data.tag, NORMAL, &l, &w), i++) { if(!(xi = (i % col)) && i) ++yi; w->w = (width / col) - var.gap_win; w->h = (height / row) - var.gap_win; w->x = ((width / col) * xi) + x; w->y = ((height / row) * yi) + y; if((xi + 1) == col || (i + 1) == len) w->w += width - ((w->w + var.gap_win) * (xi + 1)); if((yi + 1) == row || ((yi + 1) * col) >= len) w->h += height - ((w->h + var.gap_win) * (yi + 1)); win_resize(w); } }
void layout_arrange(void) { Win *w; List *l, *ll; Layout *lo; Laydata *ld; unsigned int i, j, len; if(!(lo = layout_get(var.layout))) return; for(l = list_first(data.wins); l; l = l->next) { w = (Win*)l->ptr; if(!(w->tag & data.tag)) XMoveWindow(data.dpy, w->win, w->x, (data.height * 2)); else if(w->type & FULL) return; else if(w->type & FLOAT) XMoveWindow(data.dpy, w->win, w->x, w->y); } j = win_len(data.tag, NORMAL) - 1; if(win_first(data.tag, NORMAL, &l, &w)) for(i = 0; w; win_next(data.tag, NORMAL, &l, &w), i++) { if(!(l = list_nth(lo->data, i))) l = list_last(lo->data); len = list_len(l); j = lo->tile ? MIN(len, j) : j; l = (List*)l->ptr; if(!(ll = list_nth(l, (j - i)))) ll = list_last(l); ld = (Laydata*)ll->ptr; w->w = ((ld->width * data.width) / 100); w->h = ((ld->height * data.height) / 100); w->x = ((ld->x * data.width) / 100); w->x += var.gap_left + ROUND(var.gap_win / 2) - var.border_width; w->y = ((ld->y * data.height) / 100); w->y += var.gap_top + ROUND(var.gap_win / 2) - var.border_width; if(!lo->tile || i != len - 1) { w->w -= var.gap_win; w->h -= var.gap_win; win_resize(w); } else { tile(w, w->x, w->y, w->w, w->h, ld->col, ld->row); break; } } }
static int run_command(uint8_t command, char *data, uint32_t datalen, Client *client, ClientWindow *gfx) { int running=1; printf("Command from packet: %02X\n", command); switch (command) { case PIWM_CMD_OPEN: running = win_open(client,gfx,data,datalen); break; case PIWM_CMD_DRAW: running = draw(client,gfx,data,datalen); break; case PIWM_CMD_CLOSE: running = 0; break; case PIWM_CMD_RESIZE: running = win_resize(client,gfx,data,datalen); break; case PIWM_CMD_VGENABLE: running = enable_openvg(client,gfx,data,datalen); break; case PIWM_CMD_VGDISABLE: running = disable_openvg(client,gfx,data,datalen); break; case PIWM_CMD_RESERVED: case PIWM_CMD_VGCMD: printf("command not implemented\n"); break; default: printf("invalid command byte: %02X\n", command); running=0; break; } return running; }