changeset: 2048:c92e1b77e641
tag: tip
user: Kris Maglione <jg_AT_suckless.org>
date: Fri Mar 30 01:15:36 2007 -0400
summary: Tread nil a bit more specially.
diff -r 906bd4fd971d -r c92e1b77e641 cmd/wmii/area.c
--- a/cmd/wmii/area.c Fri Mar 30 00:26:35 2007 -0400
+++ b/cmd/wmii/area.c Fri Mar 30 01:15:36 2007 -0400
@@ -14,7 +14,7 @@ static void place_frame(Frame *f);
static void place_frame(Frame *f);
Client *
-sel_client_of_area(Area *a) {
+area_selclient(Area *a) {
if(a && a->sel)
return a->sel->client;
return nil;
@@ -23,31 +23,36 @@ Area *
Area *
create_area(View *v, Area *pos, uint w) {
static ushort id = 1;
- uint area_num, col_num, i;
- uint min_width;
+ uint areanum, colnum, i;
+ uint minwidth;
Area *a, **p;
- min_width = screen->rect.width/NCOL;
- p = pos ? &pos->next : &v->area;
-
- area_num = 0;
- i = 0;
- for(a = v->area; a != *p; a = a->next)
- area_num++, i++;
- for(; a; a = a->next) area_num++;
-
- col_num = max((area_num - 1), 0);
+ minwidth = screen->rect.width/NCOL;
+
+ p = &v->area;
+ if(pos)
+ p = &pos->next;
+
+ i = areanum = 0;
+ a = v->area;
+ for(; a != *p; a = a->next)
+ areanum++, i++;
+ for(; a; a = a->next)
+ areanum++;
+
+ colnum = max((areanum - 1), 0);
if(w == 0) {
- if(col_num) {
- w = newcolw_of_view(v);
+ if(colnum) {
+ w = newcolw_of_view(v, max(i-1, 0));
if (w == 0)
- w = screen->rect.width / (col_num + 1);
+ w = screen->rect.width / (colnum + 1);
}
else w = screen->rect.width;
}
- if(w < min_width)
- w = min_width;
- if(col_num && (col_num * min_width + w) > screen->rect.width)
+
+ if(w < minwidth)
+ w = minwidth;
+ if(colnum && (colnum * minwidth + w) > screen->rect.width)
return nil;
if(pos)
scale_view(v, screen->rect.width - w);
diff -r 906bd4fd971d -r c92e1b77e641 cmd/wmii/client.c
--- a/cmd/wmii/client.c Fri Mar 30 00:26:35 2007 -0400
+++ b/cmd/wmii/client.c Fri Mar 30 01:15:36 2007 -0400
@@ -163,7 +163,7 @@ manage_client(Client *c) {
}
Client *
-sel_client() {
+selclient() {
if(screen->sel && screen->sel->sel->sel)
return screen->sel->sel->sel->client;
return nil;
@@ -229,7 +229,7 @@ update_client_grab(Client *c) {
update_client_grab(Client *c) {
Frame *f;
f = c->sel;
- if((f->client != sel_client())
+ if((f->client != selclient())
|| (f->area->floating && f != f->area->stack)) {
if(verbose)
fprintf(stderr, "update_client_grab(%p) AnyButton => %s\n", c, str_nil(c->name));
diff -r 906bd4fd971d -r c92e1b77e641 cmd/wmii/event.c
--- a/cmd/wmii/event.c Fri Mar 30 00:26:35 2007 -0400
+++ b/cmd/wmii/event.c Fri Mar 30 01:15:36 2007 -0400
@@ -85,7 +85,7 @@ buttonpress(XEvent *e) {
else if(!ev->subwindow && !ptinrect(ev->x, ev->y, &f->titlebar))
do_mouse_resize(f->client, False, quadrant(&f->rect, ev->x_root, ev->y_root));
- if(f->client != sel_client())
+ if(f->client != selclient())
focus(f->client, True);
}
if(ev->subwindow)
@@ -403,7 +403,7 @@ mapnotify(XEvent *e) {
ev = &e->xmap;
if((c = client_of_win(ev->window)))
- if(c == sel_client())
+ if(c == selclient())
focus_client(c);
}
diff -r 906bd4fd971d -r c92e1b77e641 cmd/wmii/fns.h
--- a/cmd/wmii/fns.h Fri Mar 30 00:26:35 2007 -0400
+++ b/cmd/wmii/fns.h Fri Mar 30 01:15:36 2007 -0400
@@ -14,7 +14,7 @@ void send_to_area(Area *to, Frame *f);
void send_to_area(Area *to, Frame *f);
void attach_to_area(Area *a, Frame *f, Bool send);
void detach_from_area(Frame *f);
-Client *sel_client_of_area(Area *a);
+Client *area_selclient(Area *a);
/* bar.c */
Bar *create_bar(Bar **b_link, char *name);
@@ -47,7 +47,7 @@ char * message_client(Client *c, char *m
char * message_client(Client *c, char *message);
void move_client(Client *c, char *arg);
void size_client(Client *c, char *arg);
-Client *sel_client();
+Client *selclient();
Frame *frame_of_win(Window w);
Client *client_of_win(Window w);
void update_client_grab(Client *c);
@@ -150,13 +150,13 @@ View *view_of_id(ushort id);
View *view_of_id(ushort id);
void select_view(const char *arg);
void attach_to_view(View *v, Frame *f);
-Client *sel_client_of_view(View *v);
+Client *view_selclient(View *v);
char *message_view(View *v, char *message);
void restack_view(View *v);
uchar *view_index(View *v);
void destroy_view(View *v);
void update_views();
-uint newcolw_of_view(View *v);
+uint newcolw_of_view(View *v, int i);
/* wm.c */
int wmii_error_handler(Display *dpy, XErrorEvent *error);
diff -r 906bd4fd971d -r c92e1b77e641 cmd/wmii/fs.c
--- a/cmd/wmii/fs.c Fri Mar 30 00:26:35 2007 -0400
+++ b/cmd/wmii/fs.c Fri Mar 30 01:15:36 2007 -0400
@@ -386,7 +386,7 @@ lookup_file(FileId *parent, char *name)
switch(parent->tab.type) {
case FsDClients:
if(!name || !strcmp(name, "sel")) {
- if((c = sel_client())) {
+ if((c = selclient())) {
file = get_file();
*last = file;
last = &file->next;
diff -r 906bd4fd971d -r c92e1b77e641 cmd/wmii/view.c
--- a/cmd/wmii/view.c Fri Mar 30 00:26:35 2007 -0400
+++ b/cmd/wmii/view.c Fri Mar 30 01:15:36 2007 -0400
@@ -38,7 +38,7 @@ assign_sel_view(View *v) {
}
Client *
-sel_client_of_view(View *v) {
+view_selclient(View *v) {
return v->sel && v->sel->sel ? v->sel->sel->client : nil;
}
@@ -331,7 +331,7 @@ client_of_message(View *v, char *message
if(!strncmp(message, "sel ", 4)) {
*next = 4;
- return sel_client_of_view(v);
+ return view_selclient(v);
}
sscanf(message, "0x%lx %n", &id, next);
if(!id)
@@ -412,41 +412,44 @@ void
void
update_views() {
View *n, *v, *old;
+ Bool found;
old = screen->sel;
for(v=view; v; v=v->next)
update_frame_selectors(v);
+ found = False;
for(v=view; v; v=n) {
n=v->next;
- if((v != old) && is_empty(v))
- destroy_view(v);
- }
-
- focus_view(screen, old);
+ if(v != old) {
+ found = True;
+ if(is_empty(v))
+ destroy_view(v);
+ }
+ }
+
+ if(found && !strcmp(old->name, "nil"))
+ destroy_view(old);
+ focus_view(screen, screen->sel);
}
uint
-newcolw_of_view(View *v) {
+newcolw_of_view(View *v, int num) {
+ regmatch_t regm;
Rule *r;
- Area *a;
- uint i, n;
- regmatch_t tmpregm;
-
- for(r=def.colrules.rule; r; r=r->next) {
- if(!regexec(&r->regex, v->name, 1, &tmpregm, 0)) {
- char buf[256];
+ uint n;
+
+ for(r=def.colrules.rule; r; r=r->next)
+ if(!regexec(&r->regex, v->name, 1, ®m, 0)) {
+ char buf[sizeof r->value];
char *toks[16];
+
strncpy(buf, r->value, sizeof(buf));
n = tokenize(toks, 16, buf, '+');
- for(a=v->area, i=0; a; a=a->next)
- i++;
- if(n && n >= i) {
- if(sscanf(toks[i - 1], "%u", &n) == 1)
- return (screen->rect.width * n) / 100;
- }
+ if(n > num)
+ if(sscanf(toks[num], "%u", &n) == 1)
+ return screen->rect.width * ((double)n / 100);
break;
}
- }
return 0;
}
Received on Fri Mar 30 2007 - 07:16:31 UTC
This archive was generated by hypermail 2.2.0 : Sun Jul 13 2008 - 15:56:30 UTC