commit 74503fd53bb6f2a6afc80caefb4e115ee209f827
parent c8f0151586430f1e144f07e8a17c5722b75e18e5
Author: Anselm R. Garbe <garbeam@wmii.de>
Date: Thu, 26 Jan 2006 16:24:34 +0200
proceeded with column.c
Diffstat:
| cmd/wm/client.c | | | 61 | ++++++++++++++++++++++++++++++------------------------------- |
| cmd/wm/column.c | | | 545 | +++++++++++++++++++++++++------------------------------------------------------ |
| cmd/wm/event.c | | | 4 | ++-- |
| cmd/wm/page.c | | | 67 | ++++++++++++++++++++++++++++++++++--------------------------------- |
| cmd/wm/wm.c | | | 66 | +++++++++++++++++++++++++++++++++--------------------------------- |
| cmd/wm/wm.h | | | 31 | ++++++++++++++++--------------- |
6 files changed, 285 insertions(+), 489 deletions(-)
diff --git a/cmd/wm/client.c b/cmd/wm/client.c
@@ -113,7 +113,7 @@ alloc_client(Window w, XWindowAttributes *wa)
c->frame.gc = XCreateGC(dpy, c->frame.win, 0, 0);
XSync(dpy, False);
- attach_client_to_array(c, clients, &clientssz);
+ attach_client_to_array(c, client, &clientsz);
return c;
}
@@ -132,22 +132,22 @@ set_client_state(Client * c, int state)
void
focus_client(Client *c)
{
- Page *p = pages ? pages[sel_page] : nil;
+ Page *p = page ? page[sel_page] : nil;
size_t i, j;
Client *old = sel_client();
/* setup indexes */
if(c->page != p)
focus_page(c->page);
- p->is_managed = c->managed;
- if(p->is_managed) {
- for(i = 0; (i < p->managedsz) && p->managed[i]; i++) {
- Column *col = p->managed[i];
- for(j = 0; (j < col->clientssz) && col->clients[j] && (c != col->clients[j]); j++);
- if((j < col->clientssz) && col->clients[j]) {
- p->sel_managed = i;
+ p->is_column = c->column != nil;
+ if(p->is_column) {
+ for(i = 0; (i < p->columnsz) && p->column[i]; i++) {
+ Column *col = p->column[i];
+ for(j = 0; (j < col->clientsz) && col->client[j] && (c != col->client[j]); j++);
+ if((j < col->clientsz) && col->client[j]) {
+ p->sel_column = i;
col->sel = j;
- p->file[P_SEL_MANAGED_CLIENT]->content = c->file[P_PREFIX]->content;
+ p->file[P_SEL_COLUMN_CLIENT]->content = c->file[P_PREFIX]->content;
break;
}
}
@@ -414,21 +414,20 @@ void
attach_client(Client *c)
{
Page *p;
- if(!pages)
+ if(!page)
alloc_page();
- p = pages[sel_page];
+ p = page[sel_page];
/* XXX: do we need */ resize_client(c, &c->rect, 0);
reparent_client(c, c->frame.win, c->rect.x, c->rect.y);
c->page = p;
- c->managed = p->is_managed;
- if(c->managed)
+ if(p->is_column)
attach_column(c);
- else {
+ else
attach_client_to_array(c, p->floating, &p->floatingsz);
- map_client(c);
- }
+ map_client(c);
+ focus_client(c);
invoke_wm_event(def[WM_EVENT_PAGE_UPDATE]);
}
@@ -436,7 +435,7 @@ attach_client(Client *c)
void
detach_client(Client *c, Bool unmap)
{
- if(c->managed)
+ if(c->column)
detach_column(c);
else {
detach_client_from_array(c, c->page->floating);
@@ -453,17 +452,17 @@ detach_client(Client *c, Bool unmap)
c->page = nil;
if(c->destroyed)
destroy_client(c);
- focus_page(pages[sel_page]);
+ focus_page(page[sel_page]);
}
Client *
sel_client()
{
- Page *p = pages ? pages[sel_page] : nil;
+ Page *p = page ? page[sel_page] : nil;
if(p) {
- if(p->is_managed) {
- Column *col = p->managed[p->sel_managed];
- return (col && col->clients) ? col->clients[col->sel] : nil;
+ if(p->is_column) {
+ Column *col = p->column[p->sel_column];
+ return (col && col->client) ? col->client[col->sel] : nil;
}
else
return p->floating ? p->floating[p->sel_float] : nil;
@@ -476,9 +475,9 @@ win_to_frame(Window w)
{
size_t i;
- for(i = 0; clients && clients[i]; i++)
- if(clients[i]->frame.win == w)
- return clients[i];
+ for(i = 0; client && client[i]; i++)
+ if(client[i]->frame.win == w)
+ return client[i];
return nil;
}
@@ -544,7 +543,7 @@ resize_client(Client *c, XRectangle *r, XPoint *pt)
unsigned int tabh = tab_height(c);
unsigned int bw = border_width(c);
- if(c->managed)
+ if(c->column)
resize_column(c, r, pt);
/* resize if client requests special size */
@@ -571,8 +570,8 @@ handle_before_read_client(IXPServer * s, File *file)
size_t i;
char buf[32];
- for(i = 0; (i < clientssz) && clients[i]; i++) {
- Client *c = clients[i];
+ for(i = 0; (i < clientsz) && client[i]; i++) {
+ Client *c = client[i];
if(file == c->file[C_GEOMETRY]) {
snprintf(buf, sizeof(buf), "%d %d %d %d", c->frame.rect.x, c->frame.rect.y,
c->frame.rect.width, c->frame.rect.height);
@@ -597,8 +596,8 @@ handle_after_write_client(IXPServer *s, File *file)
{
size_t i;
- for(i = 0; (i < clientssz) && clients[i]; i++) {
- Client *c = clients[i];
+ for(i = 0; (i < clientsz) && client[i]; i++) {
+ Client *c = client[i];
if(file == c->file[C_TAB] || file == c->file[C_BORDER]
|| file == c->file[C_HANDLE_INC])
{
diff --git a/cmd/wm/column.c b/cmd/wm/column.c
@@ -5,453 +5,247 @@
#include <stdlib.h>
#include <string.h>
-#include <math.h>
#include "wm.h"
-#include "layoutdef.h"
-
-typedef struct Acme Acme;
-typedef struct Column Column;
-typedef struct Cell Cell;
-
-struct Acme {
- Column *sel;
- Column *columns;
- size_t ncolumns;
- Frame *frames;
- size_t nframes;
-};
-
-struct Cell {
- Frame *frame;
- Cell *next;
- Cell *prev;
- Column *column;
-};
-
-struct Column {
- Cell *sel;
- Cell *cells;
- size_t ncells;
- XRectangle rect;
- Column *prev;
- Column *next;
-};
-
-static void init_column(Layout *l, Client * clients);
-static Client *deinit_column(Layout *l);
-static void arrange_column(Layout *l);
-static Bool attach_column(Layout *l, Client * c);
-static void detach_column(Layout *l, Client * c, Bool unmap);
-static void resize_column(Frame * f, XRectangle * new, XPoint * pt);
-static void focus_column(Layout *l, Client *c, Bool raise);
-static Frame *frames_column(Layout *l);
-static Client *sel_column(Layout *l);
-static Action *actions_column(Layout *l);
-
-static void select_frame(void *obj, char *arg);
-static void max_frame(void *obj, char *arg);
-static void swap_frame(void *obj, char *arg);
-static void new_column(void *obj, char *arg);
-
-static Action lcol_acttbl[] = {
- {"select", select_frame},
- {"swap", swap_frame},
- {"new", new_column},
- {"max", max_frame},
- {0, 0}
-};
-
-void
-init_layout_column()
-{
- LayoutDef *lp, *l = cext_emallocz(sizeof(LayoutDef));
- l->name = "column";
- l->init = init_column;
- l->deinit = deinit_column;
- l->arrange = arrange_column;
- l->attach = attach_column;
- l->detach = detach_column;
- l->resize = resize_column;
- l->focus = focus_column;
- l->frames = frames_column;
- l->sel = sel_column;
- l->actions = actions_column;
-
- for(lp = layouts; lp && lp->next; lp = lp->next);
- if(lp)
- lp->next = l;
- else
- layouts = l;
-}
-
-static void
-xarrange_column(Column * column)
-{
- Cell *cell;
- unsigned int i = 0, h = layout_rect.height / column->ncells;
- for(cell = column->cells; cell; cell = cell->next) {
- Frame *f = cell->frame;
- f->rect = column->rect;
- f->rect.y = layout_rect.y + i * h;
- if(!cell->next)
- f->rect.height = layout_rect.height - f->rect.y + layout_rect.y;
- else
- f->rect.height = h;
- resize_frame(f, &f->rect, 0);
- i++;
- }
-}
static void
-arrange_column(Layout *l)
+attach_column_to_array(Column *col, Column **array, size_t *size)
{
- Acme *acme = l->aux;
- Column *column;
- for(column = acme->columns; column; column = column->next)
- xarrange_column(column);
- XSync(dpy, False);
+ size_t i;
+ if(!array) {
+ *size = 2;
+ array = cext_emallocz(sizeof(Column *) * (*size));
+ }
+ for(i = 0; (i < (*size)) && array[i]; i++);
+ if(i >= (*size)) {
+ Column **tmp = array;
+ (*size) *= 2;
+ array = cext_emallocz(sizeof(Column *) * (*size));
+ for(i = 0; tmp[i]; i++)
+ array[i] = tmp[i];
+ free(tmp);
+ }
+ array[i] = col;
}
static void
-init_column(Layout *l, Client * clients)
+detach_column_from_array(Column *col, Column **array)
{
- Client *n, *c = clients;
-
- l->aux = cext_emallocz(sizeof(Acme));
- while(c) {
- n = c->next;
- attach_column(l, c);
- c = n;
- }
+ size_t i;
+ for(i = 0; array[i] != col; i++);
+ for(; array[i + 1]; i++)
+ array[i] = array[i + 1];
+ array[i] = nil;
}
static void
-attach_frame(Layout *l, Column * column, Frame * new)
+xarrange_column(Page *p, Column *col)
{
- Acme *acme = l->aux;
- Cell *c, *cell = cext_emallocz(sizeof(Cell));
- Frame *f;
-
- cell->frame = new;
- cell->column = column;
- new->aux = cell;
- for(c = column->cells; c && c->next; c = c->next);
- if(!c)
- column->cells = cell;
- else {
- c->next = cell;
- cell->prev = c;
- }
- column->ncells++;
-
- for(f = acme->frames; f && f->next; f = f->next);
- if(!f)
- acme->frames = new;
- else {
- f->next = new;
- new->prev = f;
- }
- attach_frame_to_layout(l, new);
- acme->nframes++;
+ size_t i, nc;
+ unsigned int h;
+
+ for(nc = 0; (nc < col->clientsz) && col->client[nc]; nc++);
+ h = col->rect.height;
+ if(nc)
+ h /= nc;
+ for(i = 0; (i < col->clientsz) && col->client[i]; i++) {
+ Client *c = col->client[i];
+ c->frame.rect = col->rect;
+ c->frame.rect.y = p->rect_column.y + i * h;
+ if(col->client[i + 1])
+ c->frame.rect.height =
+ p->rect_column.height - c->frame.rect.y + p->rect_column.y;
+ else
+ c->frame.rect.height = h;
+ resize_client(c, &c->frame.rect, 0);
+ }
}
-static void
-detach_frame(Layout *l, Frame * old)
+void
+arrange_column(Page *p)
{
- Acme *acme = l->aux;
- Cell *cell = old->aux;
- Column *column = cell->column;
-
- if(cell->prev)
- cell->prev->next = cell->next;
- else
- column->cells = cell->next;
- if(cell->next)
- cell->next->prev = cell->prev;
-
- if(column->sel == cell)
- column->sel = column->cells;
-
- free(cell);
- column->ncells--;
-
- if(old->prev)
- old->prev->next = old->next;
- else
- acme->frames = old->next;
- if(old->next)
- old->next->prev = old->prev;
- old->prev = old->next = nil;
- old->aux = nil;
- detach_frame_from_layout(old);
- acme->nframes--;
+ size_t i;
+ for(i = 0; (i < p->columnsz) && p->column[i]; i++)
+ xarrange_column(p, p->column[i]);
}
-static Client *
-deinit_column(Layout *l)
-{
- Acme *acme = l->aux;
- Frame *f;
- Client *cl, *res = nil, *c = nil;
- Column *column = acme->columns;
-
- while((f = acme->frames)) {
- cl = f->client;
- detach_client_from_frame(cl, False);
- cl->prev = cl->next = 0;
- if(!c)
- res = c = cl;
- else {
- c->next = cl;
- cl->prev = c;
- c = cl;
- }
- detach_frame(l, f);
- destroy_frame(f);
- }
- while((column = acme->columns)) {
- acme->columns = column->next;
- free(column);
- }
- free(acme);
- l->aux = 0;
- return res;
-}
-
-static Bool
-attach_column(Layout *l, Client * c)
+void
+attach_column(Client *c)
{
- Acme *acme = l->aux;
- Column *column = acme->sel;
- Frame *f = nil;
-
- if(!column) {
- column = cext_emallocz(sizeof(Column));
- column->rect = layout_rect;
- acme->columns = acme->sel = column;
- acme->ncolumns++;
+ Page *p = page[sel_page];
+ Column *col = p->columnsz ? p->column[p->sel_column] : nil;
+
+ if(!col) {
+ col = cext_emallocz(sizeof(Column));
+ col->rect = p->rect_column;
+ attach_column_to_array(col, p->column, &p->columnsz);
+ p->sel_column = 0;
}
- f = alloc_frame(&c->rect);
- attach_frame(l, column, f);
- attach_client_to_frame(f, c);
- xarrange_column(column);
- if(l->page == selpage)
- XMapWindow(dpy, f->win);
- focus_column(l, c, True);
- return True;
+ c->column = col;
+ attach_client_to_array(c, col->client, &col->clientsz);
+ xarrange_column(p, col);
}
static void
-update_column_width(Layout *l)
+update_column_width(Page *p)
{
- Acme *acme = l->aux;
- unsigned int i = 0, width;
- Column *column;
-
- if(!acme->ncolumns)
- return;
-
- width = layout_rect.width / acme->ncolumns;
- for(column = acme->columns; column; column = column->next) {
- column->rect = layout_rect;
- column->rect.x = i * width;
- column->rect.width = width;
- i++;
+ size_t i;
+ unsigned int width;
+
+ for(i = 0; (i < p->columnsz) && p->column[i]; i++);
+ if(!i)
+ return;
+
+ width = p->rect_column.width / i;
+ for(i = 0; (i < p->columnsz) && p->column[i]; i++) {
+ p->column[i]->rect = p->rect_column;
+ p->column[i]->rect.x = i * width;
+ p->column[i]->rect.width = width;
}
- arrange_column(l);
+ arrange_column(p);
}
-static void
-detach_column(Layout *l, Client * c, Bool unmap)
+void
+detach_column(Client *c)
{
- Acme *acme = l->aux;
- Frame *f = c->frame;
- Cell *old = f->aux;
- Column *column = old->column;
-
- detach_client_from_frame(c, unmap);
- detach_frame(l, f);
- destroy_frame(f);
- if(column->cells) {
- if(column->sel == old)
- column->sel = column->cells;
- xarrange_column(column);
+ Page *p = c->page;
+ Column *col = c->column;
+
+ detach_client_from_array(c, col->client);
+ if(!col->client[0]) {
+ detach_column_from_array(col, p->column);
+ free(col);
+ update_column_width(p);
}
- else {
- if(acme->sel == column) {
- if(column->prev)
- acme->sel = column->prev;
- else
- acme->sel = nil;
- }
- if(column->prev)
- column->prev->next = column->next;
- else
- acme->columns = column->next;
- if(column->next)
- column->next->prev = column->prev;
- if(!acme->sel)
- acme->sel = acme->columns;
- acme->ncolumns--;
- free(column);
- update_column_width(l);
- }
-}
+ else
+ xarrange_column(p, col);
+}
static void
-match_frame_horiz(Column * column, XRectangle * r)
+match_horiz(Column *col, XRectangle *r)
{
- Cell *cell;
- for(cell = column->cells; cell; cell = cell->next) {
- Frame *f = cell->frame;
- f->rect.x = r->x;
- f->rect.width = r->width;
- resize_frame(f, &f->rect, nil);
+ size_t i;
+
+ for(i = 0; (i < col->clientsz) && col->client[i]; i++) {
+ Client *c = col->client[i];
+ c->frame.rect.x = r->x;
+ c->frame.rect.width = r->width;
+ resize_client(c, &c->frame.rect, nil);
}
}
static void
-drop_resize(Frame * f, XRectangle * new)
+drop_resize(Client *c, XRectangle *new)
{
- Column *west = nil, *east = nil, *column = nil;
- Cell *north = nil, *south = nil;
- Cell *cell = f->aux;
+ Page *p = c->page;
+ Column *west = nil, *east = nil, *col = c->column;
+ Client *north = nil, *south = nil;
+ size_t i;
- column = cell->column;
- west = column->prev;
- east = column->next;
- north = cell->prev;
- south = cell->next;
+ for(i = 0; (i < p->columnsz) && p->column[i] && (p->column[i] != col); i++);
+ west = i ? p->column[i - 1] : nil;
+ east = (i < p->columnsz) && p->column[i + 1] ? p->column[i + 1] : nil;
+
+ for(i = 0; (i < col->clientsz) && col->client[i] && (col->client[i] != c); i++);
+ north = i ? col->client[i - 1] : nil;
+ south = (i < col->clientsz) && col->client[i + 1] ? col->client[i + 1] : nil;
/* horizontal resize */
- if(west && (new->x != f->rect.x)) {
+ if(west && (new->x != c->frame.rect.x)) {
west->rect.width = new->x - west->rect.x;
- column->rect.width += f->rect.x - new->x;
- column->rect.x = new->x;
- match_frame_horiz(west, &west->rect);
- match_frame_horiz(column, &column->rect);
+ col->rect.width += c->frame.rect.x - new->x;
+ col->rect.x = new->x;
+ match_horiz(west, &west->rect);
+ match_horiz(col, &col->rect);
}
- if(east && (new->x + new->width != f->rect.x + f->rect.width)) {
+ if(east && (new->x + new->width != c->frame.rect.x + c->frame.rect.width)) {
east->rect.width -= new->x + new->width - east->rect.x;
east->rect.x = new->x + new->width;
- column->rect.x = new->x;
- column->rect.width = new->width;
- match_frame_horiz(column, &column->rect);
- match_frame_horiz(east, &east->rect);
+ col->rect.x = new->x;
+ col->rect.width = new->width;
+ match_horiz(col, &col->rect);
+ match_horiz(east, &east->rect);
}
/* vertical resize */
- if(north && (new->y != f->rect.y)) {
- north->frame->rect.height = new->y - north->frame->rect.y;
- f->rect.height += f->rect.y - new->y;
- f->rect.y = new->y;
- resize_frame(north->frame, &north->frame->rect, nil);
- resize_frame(f, &f->rect, nil);
+ if(north && (new->y != c->frame.rect.y)) {
+ north->frame.rect.height = new->y - north->frame.rect.y;
+ c->frame.rect.height += c->frame.rect.y - new->y;
+ c->frame.rect.y = new->y;
+ resize_client(north, &north->frame.rect, nil);
+ resize_client(c, &c->frame.rect, nil);
}
- if(south && (new->y + new->height != f->rect.y + f->rect.height)) {
- south->frame->rect.height -=
- new->y + new->height - south->frame->rect.y;
- south->frame->rect.y = new->y + new->height;
- f->rect.y = new->y;
- f->rect.height = new->height;
- resize_frame(f, &f->rect, nil);
- resize_frame(south->frame, &south->frame->rect, nil);
+ if(south && (new->y + new->height != c->frame.rect.y + c->frame.rect.height)) {
+ south->frame.rect.height -= new->y + new->height - south->frame.rect.y;
+ south->frame.rect.y = new->y + new->height;
+ c->frame.rect.y = new->y;
+ c->frame.rect.height = new->height;
+ resize_client(c, &c->frame.rect, nil);
+ resize_client(south, &south->frame.rect, nil);
}
}
static void
-drop_moving(Frame * f, XRectangle * new, XPoint * pt)
+drop_moving(Client *c, XRectangle *new, XPoint * pt)
{
- Layout *l = f->layout;
- Cell *cell = f->aux;
- Column *src = cell->column, *tgt = 0;
- Acme *acme = l->aux;
+ Page *p = c->page;
+ Column *tgt = nil, *src = c->column;
+ size_t i;
if(!pt)
return;
- for(tgt = acme->columns;
- tgt && !blitz_ispointinrect(pt->x, pt->y, &tgt->rect);
- tgt = tgt->next);
+ for(i = 0; (i < p->columnsz) && p->column[i] &&
+ !blitz_ispointinrect(pt->x, pt->y, &p->column[i]->rect); i++);
+ tgt = (i < p->columnsz) ? p->column[i] : nil;
if(tgt) {
if(tgt != src) {
- if(src->ncells < 2)
- return;
- detach_frame(l, f);
- attach_frame(l, tgt, f);
- xarrange_column(src);
- xarrange_column(tgt);
- focus_column(l, f->sel, True);
+ if(src->clientsz <= 1 || !src->client[1])
+ return;
+ detach_client_from_array(c, src->client);
+ attach_client_to_array(c, tgt->client, &tgt->clientsz);
+ xarrange_column(p, src);
+ xarrange_column(p, tgt);
} else {
- Cell *c;
- for(c = src->cells;
- c && !blitz_ispointinrect(pt->x, pt->y, &c->frame->rect);
- c = c->next);
- if(c && c != cell) {
- Frame *tmp = c->frame;
- c->frame = f;
- cell->frame = tmp;
- xarrange_column(src);
- focus_column(l, f->sel, True);
+ for(i = 0; (i < src->clientsz) && src->client[i] &&
+ !blitz_ispointinrect(pt->x, pt->y, &src->client[i]->frame.rect); i++);
+ if((i < src->clientsz) && src->client[i] && (c != src->client[i])) {
+ size_t j;
+ for(j = 0; (j < src->clientsz) && src->client[j] && (src->client[j] != c); j++);
+ src->client[j] = src->client[i];
+ src->client[i] = c;
+ xarrange_column(p, src);
}
}
+ focus_client(c);
}
}
-static void
-resize_column(Frame * f, XRectangle * new, XPoint * pt)
+void
+resize_column(Client *c, XRectangle *r, XPoint *pt)
{
- if((f->rect.width == new->width)
- && (f->rect.height == new->height))
- drop_moving(f, new, pt);
+ if((c->frame.rect.width == r->width)
+ && (c->frame.rect.height == r->height))
+ drop_moving(c, r, pt);
else
- drop_resize(f, new);
+ drop_resize(c, r);
}
-static void
-focus_column(Layout *l, Client *c, Bool raise)
-{
- Acme *acme = l->aux;
- Cell *cell = c->frame->aux;
- Client *old = sel_client();
-
- c->frame->sel = c;
- acme->sel = cell->column;
- cell->column->sel = cell;
- l->file[L_SEL_FRAME]->content = c->frame->file[F_PREFIX]->content;
-
- if(raise)
- XWarpPointer(dpy, None, c->win, 0, 0, 0, 0,
- c->rect.width / 2, c->rect.height / 2);
-
- focus_client(c, old);
-}
-
-static Frame *
-frames_column(Layout *l)
-{
- Acme *acme = l->aux;
- return acme->frames;
-}
-
-static Client *
-sel_column(Layout *l)
-{
- Acme *acme = l->aux;
- Column *column = acme->sel;
+/*
+static void select_frame(void *obj, char *arg);
+static void max_frame(void *obj, char *arg);
+static void swap_frame(void *obj, char *arg);
+static void new_column(void *obj, char *arg);
- if(column && column->sel)
- return column->sel->frame->sel;
- return nil;
-}
+static Action lcol_acttbl[] = {
+ {"select", select_frame},
+ {"swap", swap_frame},
+ {"new", new_column},
+ {"max", max_frame},
+ {0, 0}
+};
-static Action *
-actions_column(Layout *l)
-{
- return lcol_acttbl;
-}
static void
max_frame(void *obj, char *arg)
@@ -632,3 +426,4 @@ new_column(void *obj, char *arg)
update_column_width(l);
focus_column(l, f->sel, True);
}
+*/
diff --git a/cmd/wm/event.c b/cmd/wm/event.c
@@ -215,7 +215,7 @@ handle_maprequest(XEvent * e)
detach_page_from_array(aqueue[0], aqueue);
}
- /* there're clients which send map requests twice */
+ /* there're client which send map requests twice */
c = win_to_client(ev->window);
if(!c)
c = alloc_client(ev->window, &wa);
@@ -269,7 +269,7 @@ static void handle_clientmessage(XEvent *e)
if (ev->message_type == net_atoms[NET_NUMBER_OF_DESKTOPS] && ev->format == 32)
return; /* ignore */
else if (ev->message_type == net_atoms[NET_CURRENT_DESKTOP] && ev->format == 32) {
- focus_page(pages[ev->data.l[0]]);
+ focus_page(page[ev->data.l[0]]);
return;
}
}
diff --git a/cmd/wm/page.c b/cmd/wm/page.c
@@ -67,25 +67,26 @@ alloc_page()
new->file[P_NAME] = wmii_create_ixpfile(ixps, buf, buf2);
snprintf(buf, sizeof(buf), "/%d/floating/", id);
new->file[P_FLOATING_PREFIX] = ixp_create(ixps, buf);
- snprintf(buf, sizeof(buf), "/%d/managed/", id);
- new->file[P_MANAGED_PREFIX] = ixp_create(ixps, buf);
+ snprintf(buf, sizeof(buf), "/%d/column/", id);
+ new->file[P_COLUMN_PREFIX] = ixp_create(ixps, buf);
snprintf(buf, sizeof(buf), "/%d/sel/", id);
new->file[P_SEL_PREFIX] = ixp_create(ixps, buf);
new->file[P_SEL_PREFIX]->bind = 1; /* mount point */
snprintf(buf, sizeof(buf), "/%d/floating/sel", id);
new->file[P_SEL_FLOATING_CLIENT] = ixp_create(ixps, buf);
new->file[P_SEL_FLOATING_CLIENT]->bind = 1;
- snprintf(buf, sizeof(buf), "/%d/managed/sel", id);
- new->file[P_SEL_MANAGED_CLIENT] = ixp_create(ixps, buf);
- new->file[P_SEL_MANAGED_CLIENT]->bind = 1;
+ snprintf(buf, sizeof(buf), "/%d/column/sel", id);
+ new->file[P_SEL_COLUMN_CLIENT] = ixp_create(ixps, buf);
+ new->file[P_SEL_COLUMN_CLIENT]->bind = 1;
snprintf(buf, sizeof(buf), "/%d/ctl", id);
new->file[P_CTL] = ixp_create(ixps, buf);
new->file[P_CTL]->after_write = handle_after_write_page;
def[WM_SEL_PAGE]->content = new->file[P_PREFIX]->content;
invoke_wm_event(def[WM_EVENT_PAGE_UPDATE]);
id++;
- attach_page_to_array(p, pages, &pagessz);
- for(np = 0; (np < pagessz) && pages[np]; np++);
+ p->rect_column = rect;
+ attach_page_to_array(p, page, &pagesz);
+ for(np = 0; (np < pagesz) && page[np]; np++);
focus_page(new);
XChangeProperty(dpy, root, net_atoms[NET_NUMBER_OF_DESKTOPS], XA_CARDINAL,
32, PropModeReplace, (unsigned char *) &np, 1);
@@ -104,11 +105,11 @@ destroy_page(Page *p)
for(i = 0; i < naqueue; i++)
detach_page_from_array(p, aqueue);
- for(i = 0; (i < clientssz) && clients[i]; i++)
- if(clients[i]->page == p)
- detach_client(clients[i], False);
+ for(i = 0; (i < clientsz) && client[i]; i++)
+ if(client[i]->page == p)
+ detach_client(client[i], False);
- for(i = 0; (i < pagessz) && pages[i] && (p != pages[i]); i++);
+ for(i = 0; (i < pagesz) && page[i] && (p != page[i]); i++);
if(sel_page && (sel_page == i))
sel_page--;
@@ -116,13 +117,13 @@ destroy_page(Page *p)
ixp_remove_file(ixps, p->file[P_PREFIX]);
free(p);
- for(i = 0; (i < pagessz) && pages[i]; i++);
+ for(i = 0; (i < pagesz) && page[i]; i++);
XChangeProperty(dpy, root, net_atoms[NET_NUMBER_OF_DESKTOPS], XA_CARDINAL,
32, PropModeReplace, (unsigned char *) &i, 1);
/* determine what to focus and do that */
- if(pages[sel_page])
- focus_page(pages[sel_page]);
+ if(page[sel_page])
+ focus_page(page[sel_page]);
else {
invoke_wm_event(def[WM_EVENT_CLIENT_UPDATE]);
invoke_wm_event(def[WM_EVENT_PAGE_UPDATE]);
@@ -134,27 +135,27 @@ void
focus_page(Page *p)
{
unsigned int i, j;
- Page *old = pages ? pages[sel_page] : nil;
+ Page *old = page ? page[sel_page] : nil;
- if(!pages)
+ if(!page)
return;
- for(i = 0; (i < pagessz) && pages[i]; i++);
+ for(i = 0; (i < pagesz) && page[i]; i++);
if(i == sel_page)
return;
sel_page = i;
- for(j = 0; (j < clientssz) && clients[j]; j++) {
- if(clients[j]->page == old)
- XMoveWindow(dpy, clients[j]->frame.win, 2 * rect.width, 2 * rect.height);
- else if(clients[j]->page == p)
- XMoveWindow(dpy, clients[j]->frame.win,
- clients[j]->frame.rect.x, clients[j]->frame.rect.y);
+ for(j = 0; (j < clientsz) && client[j]; j++) {
+ if(client[j]->page == old)
+ XMoveWindow(dpy, client[j]->frame.win, 2 * rect.width, 2 * rect.height);
+ else if(client[j]->page == p)
+ XMoveWindow(dpy, client[j]->frame.win,
+ client[j]->frame.rect.x, client[j]->frame.rect.y);
}
def[WM_SEL_PAGE]->content = p->file[P_PREFIX]->content;
- if(p->is_managed)
- p->file[P_SEL_PREFIX]->content = p->file[P_MANAGED_PREFIX]->content;
+ if(p->is_column)
+ p->file[P_SEL_PREFIX]->content = p->file[P_COLUMN_PREFIX]->content;
else
p->file[P_SEL_PREFIX]->content = p->file[P_FLOATING_PREFIX]->content;
@@ -199,9 +200,9 @@ handle_after_write_page(IXPServer *s, File *file)
{
size_t i;
- for(i = 0; (i < pagessz) && pages[i]; i++) {
- if(file == pages[i]->file[P_CTL]) {
- run_action(file, pages[i], page_acttbl);
+ for(i = 0; (i < pagesz) && page[i]; i++) {
+ if(file == page[i]->file[P_CTL]) {
+ run_action(file, page[i], page_acttbl);
return;
}
}
@@ -219,11 +220,11 @@ toggle_layout(void *obj, char *arg)
{
Page *p = obj;
- p->is_managed = !p->is_managed;
- if(p->is_managed) {
- Column *col = p->managed[p->sel_managed];
- if(col && col->clientssz && col->clients[col->sel])
- focus_client(col->clients[col->sel]);
+ p->is_column = !p->is_column;
+ if(p->is_column) {
+ Column *col = p->column[p->sel_column];
+ if(col && col->clientsz && col->client[col->sel])
+ focus_client(col->client[col->sel]);
}
else if(p->floating && p->floatingsz && p->floating[p->sel_float])
focus_client(p->floating[p->sel_float]);
diff --git a/cmd/wm/wm.c b/cmd/wm/wm.c
@@ -28,7 +28,7 @@ static void xattach_client(void *obj, char *arg);
static void xdetach_client(void *obj, char *arg);
static void xclose_client(void *obj, char *arg);
static void pager(void *obj, char *arg);
-static void detached_clients(void *obj, char *arg);
+static void detached_client(void *obj, char *arg);
/* action table for /ctl namespace */
Action wm_acttbl[] = {
@@ -40,7 +40,7 @@ Action wm_acttbl[] = {
{"close", xclose_client},
{"quit", quit},
{"pager", pager},
- {"detclients", detached_clients},
+ {"detclient", detached_client},
{0, 0}
};
@@ -154,13 +154,13 @@ draw_pager_page(size_t idx, Draw *d)
blitz_drawlabel(dpy, d);
XSync(dpy, False);
- for(i = 0; (i < pages[idx]->managedsz) && pages[idx]->managed[i]; i++) {
- Column *col = pages[idx]->managed[i];
- for(j = 0; (i < col->clientssz) && col->clients[j]; j++)
- draw_pager_client(col->clients[j], d);
+ for(i = 0; (i < page[idx]->columnsz) && page[idx]->column[i]; i++) {
+ Column *col = page[idx]->column[i];
+ for(j = 0; (i < col->clientsz) && col->client[j]; j++)
+ draw_pager_client(col->client[j], d);
}
- for(i = 0; (i < pages[idx]->floatingsz) && pages[idx]->floating[i]; i++)
- draw_pager_client(pages[idx]->floating[i], d);
+ for(i = 0; (i < page[idx]->floatingsz) && page[idx]->floating[i]; i++)
+ draw_pager_client(page[idx]->floating[i], d);
}
static void
@@ -170,7 +170,7 @@ draw_pager()
unsigned int i, ic, ir, tw, th, rows, cols;
int dx;
- for(i = 0; (i < pagessz) && pages[i]; i++);
+ for(i = 0; (i < pagesz) && page[i]; i++);
blitz_getbasegeometry(i, &cols, &rows);
dx = (cols - 1) * GAP; /* GAPpx space */
tw = (rect.width - dx) / cols;
@@ -189,7 +189,7 @@ draw_pager()
d.rect.y = ir * (rect.height - th) / (rows - 1);
d.rect.height = th;
draw_pager_page(i++, &d);
- if(!pages[i])
+ if(!page[i])
return;
}
}
@@ -202,7 +202,7 @@ xy_to_pager_page(int x, int y)
int dx;
XRectangle r;
- for(i = 0; (i < pagessz) && pages[i]; i++);
+ for(i = 0; (i < pagesz) && page[i]; i++);
blitz_getbasegeometry(i, &cols, &rows);
dx = (cols - 1) * GAP; /* GAPpx space */
tw = (rect.width - dx) / cols;
@@ -221,7 +221,7 @@ xy_to_pager_page(int x, int y)
if(blitz_ispointinrect(x, y, &r))
return i;
i++;
- if(!pages[i])
+ if(!page[i])
return -1;
}
}
@@ -250,10 +250,10 @@ pager(void *obj, char *arg)
int i;
size_t j;
- if(!pages)
+ if(!page)
return;
- for(j = 0; (j < pagessz) && pages[j]; j++);
+ for(j = 0; (j < pagesz) && page[j]; j++);
XClearWindow(dpy, transient);
XMapRaised(dpy, transient);
@@ -281,7 +281,7 @@ pager(void *obj, char *arg)
XUnmapWindow(dpy, transient);
if((i = handle_kpress(&ev.xkey)) != -1)
if(i < j)
- focus_page(pages[i]);
+ focus_page(page[i]);
XUngrabKeyboard(dpy, CurrentTime);
XUngrabPointer(dpy, CurrentTime /* ev.xbutton.time */ );
return;
@@ -289,7 +289,7 @@ pager(void *obj, char *arg)
case ButtonPress:
XUnmapWindow(dpy, transient);
if(ev.xbutton.button == Button1)
- focus_page(pages[xy_to_pager_page(ev.xbutton.x, ev.xbutton.y)]);
+ focus_page(page[xy_to_pager_page(ev.xbutton.x, ev.xbutton.y)]);
XUngrabKeyboard(dpy, CurrentTime);
XUngrabPointer(dpy, CurrentTime /* ev.xbutton.time */ );
return;
@@ -299,7 +299,7 @@ pager(void *obj, char *arg)
}
static void
-map_detached_clients()
+map_detached_client()
{
unsigned int i, ic, ir, tw, th, rows, cols;
int dx, dy;
@@ -336,7 +336,7 @@ map_detached_clients()
}
static void
-detached_clients(void *obj, char *arg)
+detached_client(void *obj, char *arg)
{
XEvent ev;
int n;
@@ -348,7 +348,7 @@ detached_clients(void *obj, char *arg)
return;
XClearWindow(dpy, transient);
XMapRaised(dpy, transient);
- map_detached_clients();
+ map_detached_client();
while(XGrabKeyboard
(dpy, transient, True, GrabModeAsync, GrabModeAsync,
CurrentTime) != GrabSuccess)
@@ -421,15 +421,15 @@ xselect_page(void *obj, char *arg)
{
size_t np, new = sel_page;
- for(np = 0; (np < pagessz) && pages[np]; np++);
+ for(np = 0; (np < pagesz) && page[np]; np++);
if(!np || !arg)
return;
if(!strncmp(arg, "prev", 5)) {
if(new > 0)
- for(new = 0; pages[new]; new++);
+ for(new = 0; page[new]; new++);
new--;
} else if(!strncmp(arg, "next", 5)) {
- if(pages[new + 1])
+ if(page[new + 1])
new++;
else
new = 0;
@@ -438,13 +438,13 @@ xselect_page(void *obj, char *arg)
if(idx < np)
new = idx;
}
- focus_page(pages[new]);
+ focus_page(page[new]);
}
static void
xdestroy_page(void *obj, char *arg)
{
- destroy_page(pages[sel_page]);
+ destroy_page(page[sel_page]);
}
static void
@@ -458,9 +458,9 @@ win_to_client(Window w)
{
size_t i;
- for(i = 0; clients && clients[i]; i++)
- if(clients[i]->win == w)
- return clients[i];
+ for(i = 0; client && client[i]; i++)
+ if(client[i]->win == w)
+ return client[i];
return nil;
}
@@ -607,7 +607,7 @@ init_default()
wmii_create_ixpfile(ixps, "/default/transcolor",
BLITZ_SEL_FG_COLOR);
def[WM_TRANS_COLOR]->after_write = handle_after_write;
- def[WM_MANAGED_GEOMETRY] = wmii_create_ixpfile(ixps, "/default/geometry", BLITZ_SEL_FG_COLOR);
+ def[WM_COLUMN_GEOMETRY] = wmii_create_ixpfile(ixps, "/default/geometry", BLITZ_SEL_FG_COLOR);
def[WM_SEL_BG_COLOR] =
wmii_create_ixpfile(ixps, "/default/sstyle/bgcolor",
BLITZ_SEL_BG_COLOR);
@@ -719,8 +719,8 @@ cleanup()
{
size_t i;
Client *c;
- for(i = 0; clients && clients[i]; i++) {
- c = clients[i];
+ for(i = 0; client && client[i]; i++) {
+ c = client[i];
reparent_client(c, root, c->frame.rect.x + c->rect.x, c->frame.rect.y + c->rect.y);
}
XSetInputFocus(dpy, PointerRoot, RevertToPointerRoot, CurrentTime);
@@ -794,9 +794,9 @@ main(int argc, char *argv[])
}
def[WM_CTL]->after_write = handle_after_write;
- aqueuesz = detachedsz = pagessz = clientssz = sel_page = 0;
- pages = nil;
- clients = detached = nil;
+ aqueuesz = detachedsz = pagesz = clientsz = sel_page = 0;
+ page = nil;
+ client = detached = nil;
aqueue = nil;
init_atoms();
diff --git a/cmd/wm/wm.h b/cmd/wm/wm.h
@@ -13,10 +13,10 @@
enum {
P_PREFIX,
P_NAME,
- P_MANAGED_PREFIX,
+ P_COLUMN_PREFIX,
P_FLOATING_PREFIX,
P_SEL_PREFIX,
- P_SEL_MANAGED_CLIENT,
+ P_SEL_COLUMN_CLIENT,
P_SEL_FLOATING_CLIENT,
P_CTL,
P_LAST
@@ -37,7 +37,7 @@ enum {
enum {
WM_CTL,
WM_TRANS_COLOR,
- WM_MANAGED_GEOMETRY,
+ WM_COLUMN_GEOMETRY,
WM_SEL_BG_COLOR,
WM_SEL_BORDER_COLOR,
WM_SEL_FG_COLOR,
@@ -82,20 +82,21 @@ typedef struct Page Page;
typedef struct Client Client;
struct Column {
- Client **clients;
- size_t clientssz;
+ Client **client;
+ size_t clientsz;
size_t sel;
+ XRectangle rect;
};
struct Page {
Client **floating;
- Column **managed;
+ Column **column;
size_t floatingsz;
- size_t managedsz;
+ size_t columnsz;
size_t sel_float;
- size_t sel_managed;
- Bool is_managed;
- XRectangle rect_managed;
+ size_t sel_column;
+ Bool is_column;
+ XRectangle rect_column;
File *file[P_LAST];
};
@@ -107,7 +108,7 @@ struct Client {
Bool destroyed;
Bool maximized;
Bool attached;
- Bool managed;
+ Column *column;
Window win;
Window trans;
XRectangle rect;
@@ -124,15 +125,15 @@ struct Client {
};
/* global variables */
-Page **pages;
-size_t pagessz;
+Page **page;
+size_t pagesz;
size_t sel_page;
Page **aqueue;
size_t aqueuesz;
Client **detached;
size_t detachedsz;
-Client **clients;
-size_t clientssz;
+Client **client;
+size_t clientsz;
Display *dpy;
IXPServer *ixps;