mirror of
https://github.com/0intro/wmii
synced 2025-02-16 22:35:20 +03:00
Made lbar functional
This commit is contained in:
parent
71b81b54ff
commit
68e5ceae90
@ -76,15 +76,18 @@ destroy_area(Area *a)
|
||||
free(a);
|
||||
}
|
||||
|
||||
void
|
||||
char *
|
||||
select_area(Area *a, char *arg)
|
||||
{
|
||||
Area *new;
|
||||
unsigned int i;
|
||||
View *v = a->view;
|
||||
Frame *f = a->sel, *p;
|
||||
Frame *p, *f;
|
||||
View *v;
|
||||
static char Ebadvalue[] = "bad value";
|
||||
|
||||
v = a->view;
|
||||
v->revert = a;
|
||||
f = a->sel;
|
||||
|
||||
if(!strncmp(arg, "toggle", 7)) {
|
||||
if(a != v->area)
|
||||
@ -93,40 +96,42 @@ select_area(Area *a, char *arg)
|
||||
new = v->revert;
|
||||
else
|
||||
new = v->area->next;
|
||||
} else if(!strncmp(arg, "prev", 5)) {
|
||||
} else if(!strncmp(arg, "left", 5)) {
|
||||
if(a == v->area)
|
||||
return;
|
||||
return Ebadvalue;
|
||||
for(new=v->area->next;
|
||||
new && new->next != a;
|
||||
new=new->next);
|
||||
if(!new)
|
||||
new=v->area->next;
|
||||
} else if(!strncmp(arg, "next", 5)) {
|
||||
} else if(!strncmp(arg, "right", 5)) {
|
||||
if(a == v->area)
|
||||
return;
|
||||
return Ebadvalue;
|
||||
new = a->next ? a->next : a;
|
||||
}
|
||||
else if(!strncmp(arg, "up", 3)) {
|
||||
for(p=a->frame; p->anext && p->anext != f; p=p->anext);
|
||||
for(p=a->frame; p->anext; p=p->anext)
|
||||
if(p->anext == f) break;
|
||||
focus_client(p->client, True);
|
||||
flush_masked_events(EnterWindowMask);
|
||||
return;
|
||||
return nil;
|
||||
}
|
||||
else if(!strncmp(arg, "down", 5)) {
|
||||
p = f->anext ? f->anext : a->frame;
|
||||
focus_client(p->client, True);
|
||||
flush_masked_events(EnterWindowMask);
|
||||
return;
|
||||
return nil;
|
||||
}
|
||||
else {
|
||||
if(sscanf(arg, "%d", &i) != 1)
|
||||
return;
|
||||
return Ebadvalue;
|
||||
for(new=view->area; i && new->next; new=new->next, i--);
|
||||
}
|
||||
if(new->sel)
|
||||
focus_client(new->sel->client, True);
|
||||
v->sel = new;
|
||||
draw_clients();
|
||||
return nil;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -587,22 +587,23 @@ size_client(Client *c, char *arg)
|
||||
char *
|
||||
send_client(Frame *f, char *arg)
|
||||
{
|
||||
static char Ebadvalue[] = "bad value";
|
||||
Area *to, *a;
|
||||
Client *c;
|
||||
Frame *tf;
|
||||
View *v;
|
||||
int i, j;
|
||||
|
||||
a = f->area;
|
||||
v = a->view;
|
||||
c = f->client;
|
||||
i = idx_of_area(a);
|
||||
j = idx_of_frame(f);
|
||||
static char Ebadvalue[] = "bad value";
|
||||
|
||||
if((i == -1) || (j == -1))
|
||||
return 0;
|
||||
|
||||
if(i && !strncmp(arg, "prev", 5)) {
|
||||
if(i && !strncmp(arg, "left", 5)) {
|
||||
if(a == v->area)
|
||||
return Ebadvalue;
|
||||
for(to=v->area->next; to && a != to->next; to=to->next);
|
||||
@ -612,7 +613,7 @@ send_client(Frame *f, char *arg)
|
||||
return Ebadvalue;
|
||||
send_to_area(to, a, c);
|
||||
}
|
||||
else if(i && !strncmp(arg, "next", 5)) {
|
||||
else if(i && !strncmp(arg, "right", 5)) {
|
||||
if(a == v->area)
|
||||
return Ebadvalue;
|
||||
if(!(to = a->next) && (f->anext || f!= a->frame))
|
||||
@ -716,12 +717,6 @@ client_of_win(Window w)
|
||||
return c;
|
||||
}
|
||||
|
||||
Client *
|
||||
selected_client()
|
||||
{
|
||||
return sel && sel->sel->sel ? sel->sel->sel->client : nil;
|
||||
}
|
||||
|
||||
void
|
||||
draw_clients()
|
||||
{
|
||||
|
92
cmd/wm/fs.c
92
cmd/wm/fs.c
@ -534,33 +534,6 @@ fs_freefid(Fid *f) {
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
fs_clunk(Req *r) {
|
||||
Client *c;
|
||||
FileId *f = r->fid->aux;
|
||||
|
||||
switch(f->tab.type) {
|
||||
case FsFTagRules:
|
||||
update_rules(&f->rule->rule, f->rule->string);
|
||||
/* no break */
|
||||
case FsFColRules:
|
||||
for(c=client; c; c=c->next)
|
||||
apply_rules(c);
|
||||
update_views();
|
||||
break;
|
||||
case FsFKeys:
|
||||
def.keys[def.keyssz] = '\0';
|
||||
update_keys();
|
||||
break;
|
||||
case FsFCtags:
|
||||
apply_tags(f->client, f->client->tags);
|
||||
update_views();
|
||||
draw_frame(f->client->sel);
|
||||
break;
|
||||
}
|
||||
respond(r, nil);
|
||||
}
|
||||
|
||||
/* This should be moved to libixp */
|
||||
void
|
||||
write_to_buf(Req *r, void *buf, unsigned int *len, unsigned int max) {
|
||||
@ -603,15 +576,21 @@ data_to_cstring(Req *r) {
|
||||
}
|
||||
|
||||
/* This should be moved to liblitz */
|
||||
int
|
||||
char *
|
||||
parse_colors(char **buf, int *buflen, BlitzColor *col) {
|
||||
unsigned int i;
|
||||
if(*buflen < 23 || 3 != sscanf(*buf, "#%06x #%06x #%06x", &i,&i,&i))
|
||||
return 0;
|
||||
return Ebadvalue;
|
||||
(*buflen) -= 23;
|
||||
bcopy(*buf, col->colstr, 23);
|
||||
blitz_loadcolor(col);
|
||||
return 1;
|
||||
|
||||
(*buf) += 23;
|
||||
if(**buf == '\n' || **buf == ' ') {
|
||||
(*buf)++;
|
||||
(*buflen)--;
|
||||
}
|
||||
return nil;
|
||||
}
|
||||
|
||||
/* This function needs to be seriously cleaned up */
|
||||
@ -665,8 +644,8 @@ fs_write(Req *r) {
|
||||
data_to_cstring(r);
|
||||
buf = (char *)r->ifcall.data;
|
||||
i = r->ifcall.count;
|
||||
if(!parse_colors((char **)&buf, (int *)&i, f->col))
|
||||
return respond(r, Ebadvalue);
|
||||
if((errstr = parse_colors((char **)&buf, (int *)&i, f->col)))
|
||||
return respond(r, errstr);
|
||||
draw_clients();
|
||||
r->ofcall.count = r->ifcall.count - i;
|
||||
return respond(r, nil);
|
||||
@ -713,6 +692,44 @@ fs_write(Req *r) {
|
||||
respond(r, Enoperm);
|
||||
}
|
||||
|
||||
void
|
||||
fs_clunk(Req *r) {
|
||||
Client *c;
|
||||
char *buf;
|
||||
int i;
|
||||
FileId *f = r->fid->aux;
|
||||
|
||||
switch(f->tab.type) {
|
||||
case FsFTagRules:
|
||||
update_rules(&f->rule->rule, f->rule->string);
|
||||
/* no break */
|
||||
case FsFColRules:
|
||||
for(c=client; c; c=c->next)
|
||||
apply_rules(c);
|
||||
update_views();
|
||||
break;
|
||||
case FsFKeys:
|
||||
def.keys[def.keyssz] = '\0';
|
||||
update_keys();
|
||||
break;
|
||||
case FsFCtags:
|
||||
apply_tags(f->client, f->client->tags);
|
||||
update_views();
|
||||
draw_frame(f->client->sel);
|
||||
break;
|
||||
case FsFBar:
|
||||
buf = f->bar->buf;
|
||||
i = strlen(f->bar->buf);
|
||||
parse_colors(&buf, &i, &f->bar->color);
|
||||
while(buf[i - 1] == '\n')
|
||||
buf[--i] = '\0';
|
||||
strncpy(f->bar->data, buf, 255);
|
||||
draw_bar();
|
||||
break;
|
||||
}
|
||||
respond(r, nil);
|
||||
}
|
||||
|
||||
void
|
||||
fs_flush(Req *r) {
|
||||
Req **t;
|
||||
@ -750,7 +767,16 @@ fs_create(Req *r) {
|
||||
|
||||
void
|
||||
fs_remove(Req *r) {
|
||||
respond(r, "not implemented");
|
||||
FileId *f = r->fid->aux;
|
||||
switch(f->tab.type) {
|
||||
default:
|
||||
/* XXX: This should be taken care of by the library */
|
||||
return respond(r, Enoperm);
|
||||
case FsFBar:
|
||||
destroy_bar(f->bar);
|
||||
respond(r, nil);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -73,11 +73,12 @@ update_frame_selectors(View *v)
|
||||
Frame *f;
|
||||
|
||||
/* select correct frames of clients */
|
||||
for(c=client; c; c=c->next) {
|
||||
for(f=c->frame; f && f->area->view != v; f=f->cnext);
|
||||
if(f)
|
||||
c->sel = f;
|
||||
}
|
||||
for(c=client; c; c=c->next)
|
||||
for(f=c->frame; f; f=f->cnext)
|
||||
if(f->area->view == v) {
|
||||
c->sel = f;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
@ -101,11 +102,10 @@ focus_view(View *v)
|
||||
resize_client(c, &f->rect, False);
|
||||
}
|
||||
else
|
||||
XMoveWindow(dpy, c->framewin,
|
||||
2 * rect.width + f->rect.x, f->rect.y);
|
||||
XMoveWindow(dpy, c->framewin, 2 * rect.width + f->rect.x, f->rect.y);
|
||||
}
|
||||
|
||||
if((c = selected_client()))
|
||||
if((c = sel_client()))
|
||||
focus_client(c, True);
|
||||
|
||||
draw_clients();
|
||||
@ -224,7 +224,8 @@ restack_view(View *v)
|
||||
for(a=v->area; a; a=a->next) {
|
||||
if(a->frame) {
|
||||
wins[n++] = a->sel->client->framewin;
|
||||
for(f=a->frame; f; f=f->anext, f != a->sel && n++);
|
||||
for(f=a->frame; f; f=f->anext)
|
||||
if(f != a->sel) n++;
|
||||
i=n;
|
||||
for(f=a->frame; f; f=f->anext) {
|
||||
Client *c = f->client;
|
||||
@ -370,7 +371,7 @@ view_index(View *v) {
|
||||
|
||||
Client *
|
||||
client_of_message(char *message, unsigned int *next)
|
||||
{
|
||||
{
|
||||
unsigned int i;
|
||||
Client *c;
|
||||
|
||||
@ -386,13 +387,13 @@ client_of_message(char *message, unsigned int *next)
|
||||
|
||||
Frame *
|
||||
clientframe_of_view(View *v, Client *c)
|
||||
{
|
||||
{
|
||||
Frame *f;
|
||||
for(f=c->frame; f; f=f->cnext)
|
||||
if(f->area->view == v)
|
||||
break;
|
||||
return f;
|
||||
}
|
||||
}
|
||||
|
||||
/* XXX: This will need cleanup too */
|
||||
char *
|
||||
@ -410,11 +411,13 @@ message_view(View *v, char *message) {
|
||||
return Ebadvalue;
|
||||
return send_client(f, &message[n]);
|
||||
}
|
||||
else if(!strncmp(message, "select ", 7)) {
|
||||
if(!strncmp(message, "select ", 7)) {
|
||||
message += 7;
|
||||
select_area(v->sel, message);
|
||||
if(v->sel->sel)
|
||||
return select_area(v->sel, message);
|
||||
return Ebadvalue;
|
||||
}
|
||||
return nil;
|
||||
return Ebadvalue;
|
||||
}
|
||||
|
||||
static Bool
|
||||
@ -442,11 +445,9 @@ update_views()
|
||||
if(is_view_of(c, v)) {
|
||||
if(!is_of_view(v, c))
|
||||
attach_to_view(v, c);
|
||||
}
|
||||
else {
|
||||
}else
|
||||
if(is_of_view(v, c))
|
||||
detach_from_view(v, c);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -212,7 +212,7 @@ void (*handler[LASTEvent]) (XEvent *);
|
||||
Area *create_area(View *v, Area *pos, unsigned int w);
|
||||
void destroy_area(Area *a);
|
||||
Area *area_of_id(View *t, unsigned short id);
|
||||
void select_area(Area *a, char *arg);
|
||||
char *select_area(Area *a, char *arg);
|
||||
void send_to_area(Area *to, Area *from, Client *c);
|
||||
void attach_to_area(Area *a, Client *c, Bool send);
|
||||
void detach_from_area(Area *a, Client *c);
|
||||
@ -243,9 +243,9 @@ void manage_client(Client *c);
|
||||
void focus_client(Client *c, Bool restack);
|
||||
void focus(Client *c, Bool restack);
|
||||
void resize_client(Client *c, XRectangle *r, Bool ignore_xcall);
|
||||
Client *selected_client();
|
||||
void match_sizehints(Client *c, XRectangle *r, Bool floating, BlitzAlign sticky);
|
||||
char *send_client(Frame *f, char *arg);
|
||||
char * message_client(Client *c, char *message);
|
||||
void move_client(Client *c, char *arg);
|
||||
void size_client(Client *c, char *arg);
|
||||
void newcol_client(Client *c, char *arg);
|
||||
@ -259,7 +259,6 @@ void draw_clients();
|
||||
void update_client_grab(Client *c, Bool is_sel);
|
||||
void apply_rules(Client *c);
|
||||
void apply_tags(Client *c, const char *tags);
|
||||
char *message_client(Client *c, char *message);
|
||||
|
||||
/* column.c */
|
||||
void arrange_column(Area *a, Bool dirty);
|
||||
|
@ -6,9 +6,9 @@ xwrite() {
|
||||
echo -n "$@" | wmiir write "$file"
|
||||
}
|
||||
|
||||
wmiir remove /bar/status 2>/dev/null && sleep 2
|
||||
wmiir create /bar/status
|
||||
while xwrite /bar/status/data `date` `uptime | sed 's/.*://; s/,//g'`
|
||||
wmiir remove /lbar/status 2>/dev/null && sleep 2
|
||||
wmiir create /lbar/status
|
||||
while xwrite /lbar/status "$WMII_NORMCOLORS" `date` `uptime | sed 's/.*://; s/,//g'`
|
||||
do
|
||||
sleep 1
|
||||
done
|
||||
|
15
rc/wmiirc
15
rc/wmiirc
@ -43,7 +43,7 @@ wmiir write /colrules <<EOF
|
||||
EOF
|
||||
|
||||
# TAGGING RULES
|
||||
wmiir write /tagrules <<EOF
|
||||
wmiir write /def/tagrules <<EOF
|
||||
/XMMS.*/ -> ~
|
||||
/Gimp.*/ -> ~
|
||||
/MPlayer.*/ -> ~
|
||||
@ -135,9 +135,9 @@ do
|
||||
Key)
|
||||
case "$1" in
|
||||
$MODKEY-$LEFT)
|
||||
xwrite /tag/sel/ctl select prev;;
|
||||
xwrite /tag/sel/ctl select left;;
|
||||
$MODKEY-$RIGHT)
|
||||
xwrite /tag/sel/ctl select next;;
|
||||
xwrite /tag/sel/ctl select right;;
|
||||
$MODKEY-$DOWN)
|
||||
xwrite /tag/sel/ctl select down;;
|
||||
$MODKEY-$UP)
|
||||
@ -163,9 +163,9 @@ do
|
||||
$MODKEY-Return)
|
||||
PATH="$OLD_PATH" xterm &;;
|
||||
$MODKEY-Shift-$LEFT)
|
||||
xwrite /tag/sel/ctl send sel prev;;
|
||||
xwrite /tag/sel/ctl send sel left;;
|
||||
$MODKEY-Shift-$RIGHT)
|
||||
xwrite /tag/sel/ctl send sel next;;
|
||||
xwrite /tag/sel/ctl send sel right;;
|
||||
$MODKEY-Shift-$DOWN)
|
||||
xwrite /tag/sel/ctl send sel down;;
|
||||
$MODKEY-Shift-$UP)
|
||||
@ -173,9 +173,10 @@ do
|
||||
$MODKEY-Shift-space)
|
||||
xwrite /tag/sel/ctl send sel toggle;;
|
||||
$MODKEY-Shift-c)
|
||||
xwrite /client/sel/ctl kill;;
|
||||
xwrite /client/sel kill;;
|
||||
$MODKEY-Shift-t)
|
||||
xwrite /client/sel/tags "`wmiir ls /tag | sed 's,/,,; /^sel$/d' | wmiimenu`" &;;
|
||||
xwrite /client/`wmiir read /client/sel/index`/tags \
|
||||
"`wmiir ls /tag | sed 's,/,,; /^sel$/d' | wmiimenu`" &;;
|
||||
$MODKEY-Shift-[0-9])
|
||||
xwrite /client/sel/tags `echo $1 | sed 's/.*-//'`;;
|
||||
esac;;
|
||||
|
Loading…
x
Reference in New Issue
Block a user