Merge branch 'merging'

This commit is contained in:
Martin Duquesnoy 2011-08-31 20:59:17 +02:00
commit 1acdc0ca01
27 changed files with 88 additions and 0 deletions

0
wmfs2/TODO Executable file → Normal file
View File

0
wmfs2/src/barwin.c Executable file → Normal file
View File

0
wmfs2/src/barwin.h Executable file → Normal file
View File

0
wmfs2/src/client.c Executable file → Normal file
View File

0
wmfs2/src/client.h Executable file → Normal file
View File

0
wmfs2/src/config.c Executable file → Normal file
View File

0
wmfs2/src/config.h Executable file → Normal file
View File

0
wmfs2/src/draw.h Executable file → Normal file
View File

0
wmfs2/src/event.c Executable file → Normal file
View File

0
wmfs2/src/event.h Executable file → Normal file
View File

0
wmfs2/src/ewmh.c Executable file → Normal file
View File

0
wmfs2/src/ewmh.h Executable file → Normal file
View File

53
wmfs2/src/fifo.c Normal file
View File

@ -0,0 +1,53 @@
/*
* wmfs2 by Martin Duquesnoy <xorg62@gmail.com> { for(i = 2011; i < 2111; ++i) ©(i); }
* For license, see COPYING.
*/
#include "wmfs.h"
#include "fifo.h"
#include "config.h"
#define FIFO_DEFAULT_PATH "/tmp/wmfs-fifo"
void
fifo_init(void)
{
W->fifo.path = FIFO_DEFAULT_PATH;
if(mkfifo(W->fifo.path, 0644) < 0 || !(W->fifo.fp = fopen(W->fifo.path, "w+")))
{
warnx("Can't create FIFO: %s\n", strerror(errno));
return;
}
fcntl(fileno(W->fifo.fp), F_SETFL, O_NONBLOCK);
}
static void
fifo_parse(char *cmd)
{
void (*func)(Uicb cmd);
char *uicb = strtok(cmd, " ");
char *arg = strtok(NULL, "\n");
printf ("%s %s\n", uicb, arg);
func = uicb_name_func(uicb);
if(func)
func(arg);
}
void
fifo_read(void)
{
char buf[256] = {0};
/* Don't read it if not open */
if(!(W->fifo.fp)) return;
fread(buf, sizeof(buf) - 1, 1, W->fifo.fp);
if (buf[0])
fifo_parse(buf);
}

17
wmfs2/src/fifo.h Normal file
View File

@ -0,0 +1,17 @@
/*
* wmfs2 by Martin Duquesnoy <xorg62@gmail.com> { for(i = 2011; i < 2111; ++i) ©(i); }
* For license, see COPYING.
*/
#ifndef FIFO_H
#define FIFO_H
#include <fcntl.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/stat.h>
void fifo_init(void);
void fifo_read(void);
#endif /* FIFO_H */

0
wmfs2/src/infobar.c Executable file → Normal file
View File

0
wmfs2/src/infobar.h Executable file → Normal file
View File

0
wmfs2/src/parse.c Executable file → Normal file
View File

0
wmfs2/src/parse.h Executable file → Normal file
View File

0
wmfs2/src/parse_api.c Executable file → Normal file
View File

0
wmfs2/src/screen.c Executable file → Normal file
View File

0
wmfs2/src/screen.h Executable file → Normal file
View File

0
wmfs2/src/tag.c Executable file → Normal file
View File

0
wmfs2/src/tag.h Executable file → Normal file
View File

0
wmfs2/src/util.c Executable file → Normal file
View File

0
wmfs2/src/util.h Executable file → Normal file
View File

11
wmfs2/src/wmfs.c Executable file → Normal file
View File

@ -15,6 +15,7 @@
#include "util.h"
#include "config.h"
#include "client.h"
#include "fifo.h"
int
wmfs_error_handler(Display *d, XErrorEvent *event)
@ -213,8 +214,13 @@ wmfs_loop(void)
XEvent ev;
while(XPending(W->dpy))
{
while(W->running && !XNextEvent(W->dpy, &ev))
{
HANDLE_EVENT(&ev);
fifo_read();
}
}
}
static inline void
@ -225,6 +231,7 @@ wmfs_init(void)
screen_init();
event_init();
config_init();
fifo_init();
}
void
@ -244,6 +251,10 @@ wmfs_quit(void)
FREE_LIST(Keybind, W->h.keybind);
FREE_LIST(Theme, W->h.theme);
/* FIFO stuffs */
fclose(W->fifo.fp);
free(W->fifo.path);
W->running = false;
}

7
wmfs2/src/wmfs.h Executable file → Normal file
View File

@ -213,6 +213,13 @@ struct Wmfs
*/
Scr33n *screen;
/* FIFO */
struct
{
FILE *fp;
char *path;
} fifo;
};
int wmfs_error_handler(Display *d, XErrorEvent *event);