From 1f0f42420ce08eb03a51f4e97d5528c1a25f96c7 Mon Sep 17 00:00:00 2001 From: "Anselm R. Garbe" Date: Sun, 21 May 2006 19:21:37 +0200 Subject: [PATCH] added newcol action for client ctls (takes next/prev argument), I didn't changed move --- TODO.wmii-4 | 20 -------------------- cmd/wm/area.c | 6 +++--- cmd/wm/client.c | 38 +++++++++++++++++++++++++++++--------- cmd/wm/column.c | 24 ++++-------------------- cmd/wm/fs.c | 12 +++++++----- cmd/wm/view.c | 4 ++-- cmd/wm/wm.h | 10 ++++------ rc/wmiirc | 10 +++++----- 8 files changed, 54 insertions(+), 70 deletions(-) diff --git a/TODO.wmii-4 b/TODO.wmii-4 index a3885206..5a4d1a61 100644 --- a/TODO.wmii-4 +++ b/TODO.wmii-4 @@ -38,23 +38,3 @@ - partial EWMH support - libixp: idea from PoP: implement a va_args method similiar to printf for marshalling 9P messages, might reduce LOC drastically - - -23:55 <@garbeam> I currently think of something different I haven't done so far, but -which might make some sense -23:55 <@garbeam> I think of reporting an error if a specific command cannot be -performed -23:55 <@garbeam> (a write error with wmiir write) -23:56 <@garbeam> e.g. if you do move next, and there is no next column, an error -could be reported, thus one could add newcol next/prev instead -23:56 <@garbeam> s/add/perform/ -23:57 <@garbeam> thiswould allow keeping the current behavior, but allowing your -behavior as well, without screwing up things as they are -23:57 <@garbeam> a column move command is a different question -23:58 < John-Galt> that sounds reasonable -Day changed to 20 May 2006 -00:00 <@garbeam> ie, if `xwrite /view/sel/sel/ctl move next` then xwrite -/view/sel/sel/ctl newcol next; fi -00:02 <@garbeam> I think moving columns is not necessary at all, it won't be used -that often -00:02 <@garbeam> John-Galt: what resolution do you got that you consider column diff --git a/cmd/wm/area.c b/cmd/wm/area.c index 5cd09af3..d2060aed 100644 --- a/cmd/wm/area.c +++ b/cmd/wm/area.c @@ -15,7 +15,7 @@ vector_of_areas(AreaVector *av) } Area * -create_area(View *v) +create_area(View *v, unsigned int pos) { static unsigned short id = 1; unsigned int w; @@ -44,8 +44,8 @@ create_area(View *v) a->rect.height = rect.height - brect.height; a->mode = def.colmode; a->rect.width = w; - cext_vattach(vector_of_areas(&v->area), a); - v->sel = v->area.size - 1; + cext_vattachat(vector_of_areas(&v->area), a, pos); + v->sel = pos; return a; } diff --git a/cmd/wm/client.c b/cmd/wm/client.c index 45126aa3..0017fea2 100644 --- a/cmd/wm/client.c +++ b/cmd/wm/client.c @@ -569,7 +569,31 @@ select_client(Client *c, char *arg) } void -send_client_to(Client *c, char *arg) +newcol_client(Client *c, char *arg) +{ + Frame *f = c->frame.data[c->sel]; + Area *to, *a = f->area; + View *v = a->view; + int i = idx_of_area(a); + + if(i < 1) + return; + + if(!strncmp(arg, "prev", 5)) { + to = new_column(v, i); + send_to_area(to, a, c); + } + else if(!strncmp(arg, "next", 5)) { + to = new_column(v, i + 1); + send_to_area(to, a, c); + } + else + return; + flush_masked_events(EnterWindowMask); +} + +void +move_client(Client *c, char *arg) { const char *errstr; Frame *f = c->frame.data[c->sel]; @@ -583,10 +607,8 @@ send_client_to(Client *c, char *arg) if(i && !strncmp(arg, "prev", 5)) { if(i > 1) to = v->area.data[i - 1]; - else if(a->frame.size > 1) { - if(!(to = new_left_column(v))) - return; - } + else if(a->frame.size > 1) + to = new_column(v, 1); else return; send_to_area(to, a, c); @@ -594,10 +616,8 @@ send_client_to(Client *c, char *arg) else if(i && !strncmp(arg, "next", 5)) { if(i < v->area.size - 1) to = v->area.data[i + 1]; - else if(a->frame.size > 1) { - if(!(to = new_right_column(v))) - return; - } + else if(a->frame.size > 1) + to = new_column(v, v->area.size); else return; send_to_area(to, a, c); diff --git a/cmd/wm/column.c b/cmd/wm/column.c index 610dd8ff..072ea2cb 100644 --- a/cmd/wm/column.c +++ b/cmd/wm/column.c @@ -366,13 +366,13 @@ drop_move(Frame *f, XRectangle *new, XPoint *pt) int x = new->x + (new->width / 2); if(x < 0) { if(src->frame.size > 1 || idx_of_area(src) != 1) { - tgt = new_left_column(v); + tgt = new_column(v, 0); send_to_area(tgt, src, f->client); } } else if(x > rect.width) { if(src->frame.size > 1 || idx_of_area(src) != v->area.size - 1) { - tgt = new_right_column(v); + tgt = new_column(v, v->area.size); send_to_area(tgt, src, f->client); } } @@ -424,25 +424,9 @@ resize_column(Client *c, XRectangle *r, XPoint *pt) } Area * -new_left_column(View *v) { - Area *a, *p, *n; - unsigned int i; - if(!(a = p = create_area(v))) - return nil; - for(i = 1; i < v->area.size; i++) { - n = v->area.data[i]; - v->area.data[i] = p; - p = n; - } - arrange_view(v); - return a; -} - -Area * -new_right_column(View *v) -{ +new_column(View *v, unsigned int pos) { Area *a; - if(!(a = create_area(v))) + if(!(a = create_area(v, pos))) return nil; arrange_view(v); return a; diff --git a/cmd/wm/fs.c b/cmd/wm/fs.c index d62f39d0..064a06d2 100644 --- a/cmd/wm/fs.c +++ b/cmd/wm/fs.c @@ -1336,17 +1336,19 @@ xwrite(IXPConn *c, Fcall *fcall) break; case FsDarea: if(!strncmp(buf, "select ", 7)) { - Area *a = view.data[i1]->area.data[i2]; - if(a->frame.size) - select_client(a->frame.data[a->sel]->client, &buf[7]); + Area *a = view.data[i1]->area.data[i2]; + if(a->frame.size) + select_client(a->frame.data[a->sel]->client, &buf[7]); } break; case FsDclient: f = view.data[i1]->area.data[i2]->frame.data[i3]; if(!strncmp(buf, "kill", 5)) kill_client(f->client); - else if(!strncmp(buf, "sendto ", 7)) - send_client_to(f->client, &buf[7]); + else if(!strncmp(buf, "newcol ", 7)) + newcol_client(f->client, &buf[7]); + else if(!strncmp(buf, "move ", 5)) + move_client(f->client, &buf[5]); break; case FsDGclient: if(!strncmp(buf, "kill", 5)) diff --git a/cmd/wm/view.c b/cmd/wm/view.c index 5a5605c6..1be300ee 100644 --- a/cmd/wm/view.c +++ b/cmd/wm/view.c @@ -30,8 +30,8 @@ create_view(char *name) v->id = id++; cext_strlcpy(v->name, name, sizeof(v->name)); - create_area(v); - create_area(v); + create_area(v, v->area.size); + create_area(v, v->area.size); cext_vattach(vector_of_views(&view), v); qsort(view.data, view.size, sizeof(View *), comp_view_name); return v; diff --git a/cmd/wm/wm.h b/cmd/wm/wm.h index ea2c77e0..b4733f7f 100644 --- a/cmd/wm/wm.h +++ b/cmd/wm/wm.h @@ -197,7 +197,7 @@ unsigned int valid_mask; unsigned int num_lock_mask; /* area.c */ -Area *create_area(View *t); +Area *create_area(View *v, unsigned int pos); void destroy_area(Area *a); int idx_of_area(Area *a); int idx_of_area_id(View *t, unsigned short id); @@ -235,7 +235,8 @@ void focus_client(Client *c, Bool restack); void focus(Client *c, Bool restack); void resize_client(Client *c, XRectangle *r, Bool ignore_xcall); void select_client(Client *c, char *arg); -void send_client_to(Client *c, char *arg); +void move_client(Client *c, char *arg); +void newcol_client(Client *c, char *arg); void resize_all_clients(); Client *sel_client(); int idx_of_client_id(unsigned short id); @@ -249,8 +250,7 @@ void scale_column(Area *a, float h); void resize_column(Client *c, XRectangle *r, XPoint *pt); int column_mode_of_str(char *arg); char *str_of_column_mode(int mode); -Area *new_left_column(View *v); -Area *new_right_column(View *v); +Area *new_column(View *v, unsigned int pos); /* event.c */ void init_x_event_handler(); @@ -264,8 +264,6 @@ void destroy_frame(Frame *f); int idx_of_frame_id(Area *a, unsigned short id); int idx_of_frame(Frame *f); Client *frame_of_win(Window w); -void insert_before_idx(FrameVector *fv, Frame *f, unsigned int idx); -void insert_after_idx(FrameVector *fv, Frame *f, unsigned int idx); /* fs.c */ unsigned long long pack_qpath(unsigned char type, unsigned short i1, diff --git a/rc/wmiirc b/rc/wmiirc index 9e4eb17a..fd824bea 100644 --- a/rc/wmiirc +++ b/rc/wmiirc @@ -144,15 +144,15 @@ do $MODKEY-Return) xterm &;; $MODKEY-Shift-$LEFT) - xwrite /view/sel/sel/ctl sendto prev;; + xwrite /view/sel/sel/ctl move prev;; $MODKEY-Shift-$RIGHT) - xwrite /view/sel/sel/ctl sendto next;; + xwrite /view/sel/sel/ctl move next;; $MODKEY-Shift-$DOWN) - xwrite /view/sel/sel/ctl sendto down;; + xwrite /view/sel/sel/ctl move down;; $MODKEY-Shift-$UP) - xwrite /view/sel/sel/ctl sendto up;; + xwrite /view/sel/sel/ctl move up;; $MODKEY-Shift-space) - xwrite /view/sel/sel/ctl sendto toggle;; + xwrite /view/sel/sel/ctl move toggle;; $MODKEY-Shift-c) xwrite /view/sel/sel/ctl kill;; $MODKEY-Shift-t)