[ALL] Improve uicb_spawn function, fix typo..

This commit is contained in:
Martin Duquesnoy 2008-10-05 16:33:57 +02:00
parent 3f5d307045
commit 8a3948b62a
3 changed files with 39 additions and 36 deletions

14
util.c
View File

@ -57,6 +57,10 @@ getcolor(char *color)
void
uicb_spawn(uicb_t cmd)
{
char *sh = NULL;
if(!(sh = getenv("SHELL")))
sh = "/bin/sh";
if(!strlen(cmd))
return;
if(fork() == 0)
@ -66,7 +70,7 @@ uicb_spawn(uicb_t cmd)
if(dpy)
close(ConnectionNumber(dpy));
setsid();
execl(getenv("SHELL"), getenv("SHELL"), "-c", cmd, (char*)NULL);
execl(sh, sh, "-c", cmd, (char*)NULL);
exit(EXIT_FAILURE);
}
exit(EXIT_SUCCESS);
@ -76,12 +80,12 @@ uicb_spawn(uicb_t cmd)
}
void
xprint(Drawable d, int x, int y, char *str,
unsigned int fg,unsigned int bg,
int dec1,int dec2)
xprint(Drawable d, int x, int y,
uint fg, uint bg,
int d1, int d2, char *str)
{
XSetForeground(dpy, gc, bg);
XFillRectangle(dpy, d, gc, x - dec1, 0, TEXTW(str) - dec2, barheight);
XFillRectangle(dpy, d, gc, x - d1, 0, TEXTW(str) - d2, barheight);
XSetForeground(dpy, gc, fg);
XDrawString(dpy, d, gc, x, y, str, strlen(str));

21
wmfs.c
View File

@ -950,20 +950,19 @@ updatebar(void)
taglen[i+1] = taglen[i] + TEXTW(buf[i]);
/* Draw tags */
xprint(dr, taglen[i], fonth, buf[i],
xprint(dr, taglen[i], fonth,
((i+1 == seltag) ? conf.colors.tagselfg : conf.colors.text),
((i+1 == seltag) ? conf.colors.tagselbg : conf.colors.bar), 3, 3);
((i+1 == seltag) ? conf.colors.tagselbg : conf.colors.bar), 3, 3, buf[i]);
}
/* Layout symbol */
xprint(dr, taglen[conf.ntag] - 4,
fonth, tags[seltag].layout.symbol,
conf.colors.layout_fg, conf.colors.layout_bg, 1, -1);
fonth, conf.colors.layout_fg, conf.colors.layout_bg,
1, -1, tags[seltag].layout.symbol);
/* Draw status text */
k = TEXTW(bartext);
xprint(dr, mw-k, fonth - 1, bartext,
conf.colors.text, conf.colors.bar, 0, 0);
xprint(dr, mw-k, fonth - 1, conf.colors.text, conf.colors.bar, 0, 0, bartext);
XDrawLine(dpy, dr, gc, mw-k-5, 0, mw-k-5, barheight);
XCopyArea(dpy, dr, bar, gc, 0, 0, mw, barheight, 0, 0);
@ -1015,16 +1014,16 @@ updatebutton(Bool c)
CWOverrideRedirect | CWBackPixmap | CWEventMask, &at);
XSetWindowBackground(dpy, conf.barbutton[i].win, conf.barbutton[i].bg_color);
XMapRaised(dpy, conf.barbutton[i].win);
xprint(conf.barbutton[i].win, 1, fonth_l, conf.barbutton[i].text,
conf.barbutton[i].fg_color, conf.barbutton[i].bg_color, 0, 0);
xprint(conf.barbutton[i].win, 1, fonth_l, conf.barbutton[i].fg_color,
conf.barbutton[i].bg_color, 0, 0, conf.barbutton[i].text);
}
else
{
if(!conf.barbutton[i].win)
return;
XMoveWindow(dpy, conf.barbutton[i].win, x, y);
xprint(conf.barbutton[i].win, 1, fonth_l, conf.barbutton[i].text,
conf.barbutton[i].fg_color, conf.barbutton[i].bg_color, 0, 0);
xprint(conf.barbutton[i].win, 1, fonth_l, conf.barbutton[i].fg_color,
conf.barbutton[i].bg_color, 0, 0, conf.barbutton[i].text);
}
}
XSync(dpy, False);
@ -1059,7 +1058,7 @@ updatetitle(Client *c)
{
XClearWindow(dpy, c->tbar);
xprint(c->tbar, 3, ((fonth-2) + ((conf.ttbarheight - fonth) / 2)),
c->title, conf.colors.text, conf.colors.bar, 0, 0);
conf.colors.text, conf.colors.bar, 0, 0, c->title);
}
return;
}

40
wmfs.h
View File

@ -210,16 +210,16 @@ void getevent(void);
/* util.c */
void *emalloc(unsigned int elemet, unsigned int size);
unsigned long getcolor(char *color);
void uicb_spawn(uicb_t cmd);
void xprint(Drawable d, int x, int y, char *str,
unsigned int fg, unsigned int bg,
int dec1, int dec2);
void xprint(Drawable d, int x, int y,
uint fg, uint bg,
int d1, int d2, char* str);
void uicb_spawn(uicb_t);
/* tag.c */
void uicb_tag(uicb_t cmd);
void uicb_tag_next(uicb_t cmd);
void uicb_tag_prev(uicb_t cmd);
void uicb_tagtransfert(uicb_t cmd);
void uicb_tag(uicb_t);
void uicb_tag_next(uicb_t);
void uicb_tag_prev(uicb_t);
void uicb_tagtransfert(uicb_t);
/* layout.c */
void freelayout(void);
@ -227,12 +227,12 @@ void layoutswitch(Bool b);
void maxlayout(void);
Client* nexttiled(Client *c);
void tile(void);
void uicb_tile_switch(uicb_t cmd);
void uicb_togglemax(uicb_t cmd);
void uicb_layout_prev(uicb_t cmd);
void uicb_layout_next(uicb_t cmd);
void uicb_set_mwfact(uicb_t cmd);
void uicb_set_nmaster(uicb_t cmd);
void uicb_tile_switch(uicb_t);
void uicb_togglemax(uicb_t);
void uicb_layout_prev(uicb_t);
void uicb_layout_next(uicb_t);
void uicb_set_mwfact(uicb_t);
void uicb_set_nmaster(uicb_t);
/* wmfs.c */
void arrange(void);
@ -269,11 +269,11 @@ void updatebutton(Bool c);
void unmapclient(Client *c);
void updateall(void);
void updatetitle(Client *c);
void uicb_client_prev(uicb_t cmd);
void uicb_client_next(uicb_t cmd);
void uicb_killclient(uicb_t cmd);
void uicb_quit(uicb_t cmd);
void uicb_togglebarpos(uicb_t cmd);
void uicb_client_prev(uicb_t);
void uicb_client_next(uicb_t);
void uicb_killclient(uicb_t);
void uicb_quit(uicb_t);
void uicb_togglebarpos(uicb_t);
/* Variables */
@ -313,7 +313,7 @@ Client *sel;
Client *selbytag[MAXTAG];
/* Other */
unsigned int numlockmask;
uint numlockmask;
#endif /* LOCAL_H */