Fix fifo code
This commit is contained in:
parent
1642779b8c
commit
d1ec33ed53
@ -528,9 +528,7 @@ client_frame_new(struct client *c)
|
|||||||
struct client*
|
struct client*
|
||||||
client_new(Window w, XWindowAttributes *wa)
|
client_new(Window w, XWindowAttributes *wa)
|
||||||
{
|
{
|
||||||
struct client *c = NULL;
|
struct client *c = xcalloc(1, sizeof(struct client));
|
||||||
|
|
||||||
c = xcalloc(1, sizeof(struct client));
|
|
||||||
|
|
||||||
/* C attributes */
|
/* C attributes */
|
||||||
c->win = w;
|
c->win = w;
|
||||||
@ -794,7 +792,7 @@ client_apply_tgeo(struct tag *t)
|
|||||||
do { \
|
do { \
|
||||||
SLIST_FOREACH(gc, &c->tag->clients, tnext) \
|
SLIST_FOREACH(gc, &c->tag->clients, tnext) \
|
||||||
draw_reversed_rect(W->root, &gc->tgeo); \
|
draw_reversed_rect(W->root, &gc->tgeo); \
|
||||||
draw_reversed_cross(W->root, &c->tag->sel->tgeo); \
|
/* draw_reversed_cross(W->root, &c->tag->sel->tgeo);*/ \
|
||||||
} while(/* CONSTCOND */ 0);
|
} while(/* CONSTCOND */ 0);
|
||||||
void
|
void
|
||||||
client_fac_resize(struct client *c, enum position p, int fac)
|
client_fac_resize(struct client *c, enum position p, int fac)
|
||||||
|
|||||||
40
src/fifo.c
40
src/fifo.c
@ -14,38 +14,30 @@ fifo_init(void)
|
|||||||
{
|
{
|
||||||
xasprintf(&(W->fifo.path), "%s/wmfs-%s.fifo", P_tmpdir, DisplayString(W->dpy));
|
xasprintf(&(W->fifo.path), "%s/wmfs-%s.fifo", P_tmpdir, DisplayString(W->dpy));
|
||||||
|
|
||||||
if(mkfifo(W->fifo.path, 0644) < 0 || !(W->fifo.fd = open(W->fifo.path, O_NONBLOCK, 0)))
|
if(mkfifo(W->fifo.path, 0644) < 0)
|
||||||
warnx("Can't create FIFO: %s\n", strerror(errno));
|
warnx("Can't create FIFO: %s\n", strerror(errno));
|
||||||
|
|
||||||
|
if(!(W->fifo.fd = open(W->fifo.path, O_NONBLOCK, 0)))
|
||||||
|
warnx("Can't open FIFO: %s\n", strerror(errno));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
fifo_parse(char *cmd)
|
fifo_parse(char *cmd)
|
||||||
{
|
{
|
||||||
void (*func)(Uicb);
|
void (*func)(Uicb);
|
||||||
char *uicb = NULL;
|
char *p = NULL;
|
||||||
char *arg = NULL;
|
|
||||||
char *p = NULL;
|
|
||||||
|
|
||||||
/* remove trailing newline */
|
/* remove trailing newline */
|
||||||
if((p = strchr(cmd, '\n')))
|
if((p = strchr(cmd, '\n')))
|
||||||
*p = 0;
|
*p = '\0';
|
||||||
|
|
||||||
/* Check if an argument is present */
|
/* If an argument is present, delimit function string */
|
||||||
if((p = strchr(cmd, ' ')))
|
if((p = strchr(cmd, ' ')))
|
||||||
{
|
*p = '\0';
|
||||||
*p = 0;
|
|
||||||
arg = xstrdup(p + 1);
|
|
||||||
}
|
|
||||||
uicb = xstrdup(cmd);
|
|
||||||
|
|
||||||
/* call the UICB function */
|
/* call the UICB function, p + 1 is command or NULL */
|
||||||
func = uicb_name_func(uicb);
|
if((func = uicb_name_func(cmd)))
|
||||||
if(func)
|
func(p + 1);
|
||||||
func(arg);
|
|
||||||
|
|
||||||
if(arg)
|
|
||||||
free(arg);
|
|
||||||
free(uicb);
|
|
||||||
|
|
||||||
XSync(W->dpy, false);
|
XSync(W->dpy, false);
|
||||||
}
|
}
|
||||||
@ -53,14 +45,8 @@ fifo_parse(char *cmd)
|
|||||||
void
|
void
|
||||||
fifo_read(void)
|
fifo_read(void)
|
||||||
{
|
{
|
||||||
char buf[256] = {0};
|
static char buf[256] = { 0 };
|
||||||
|
|
||||||
/* Don't read it if not open */
|
if(read(W->fifo.fd, buf, sizeof(buf) - 1) > 0)
|
||||||
if(!(W->fifo.fd))
|
|
||||||
return;
|
|
||||||
|
|
||||||
read(W->fifo.fd, buf, sizeof(buf) - 1);
|
|
||||||
|
|
||||||
if(buf[0])
|
|
||||||
fifo_parse(buf);
|
fifo_parse(buf);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user