Fix SIGCHLD signal handling, remove fifo from master
This commit is contained in:
parent
5e3c44824d
commit
acc66f62ab
@ -17,7 +17,6 @@ SRCS= \
|
|||||||
src/screen.c \
|
src/screen.c \
|
||||||
src/tag.c \
|
src/tag.c \
|
||||||
src/util.c \
|
src/util.c \
|
||||||
src/fifo.c \
|
|
||||||
src/status.c \
|
src/status.c \
|
||||||
src/systray.c \
|
src/systray.c \
|
||||||
src/mouse.c \
|
src/mouse.c \
|
||||||
|
|||||||
@ -133,7 +133,7 @@ client_gb_frame(Window w)
|
|||||||
struct client*
|
struct client*
|
||||||
client_gb_pos(struct tag *t, int x, int y)
|
client_gb_pos(struct tag *t, int x, int y)
|
||||||
{
|
{
|
||||||
struct client *c = SLIST_FIRST(&t->clients);
|
struct client *c;
|
||||||
|
|
||||||
FOREACH_NFCLIENT(c, &t->clients, tnext)
|
FOREACH_NFCLIENT(c, &t->clients, tnext)
|
||||||
if(INAREA(x, y, c->geo))
|
if(INAREA(x, y, c->geo))
|
||||||
|
|||||||
13
src/event.c
13
src/event.c
@ -16,10 +16,10 @@
|
|||||||
|
|
||||||
#define EVDPY(e) (e)->xany.display
|
#define EVDPY(e) (e)->xany.display
|
||||||
|
|
||||||
#define MOUSE_CHECK_BIND(m) \
|
#define MOUSE_DO_BIND(m) \
|
||||||
if(m->button == ev->button) \
|
if(m->button == ev->button) \
|
||||||
if(!m->use_area || (m->use_area && INAREA(ev->x, ev->y, m->area))) \
|
if(!m->use_area || (m->use_area && INAREA(ev->x, ev->y, m->area))) \
|
||||||
if(m->func) \
|
if(m->func) \
|
||||||
m->func(m->cmd);
|
m->func(m->cmd);
|
||||||
static void
|
static void
|
||||||
event_buttonpress(XEvent *e)
|
event_buttonpress(XEvent *e)
|
||||||
@ -36,10 +36,10 @@ event_buttonpress(XEvent *e)
|
|||||||
W->last_clicked_barwin = b;
|
W->last_clicked_barwin = b;
|
||||||
|
|
||||||
SLIST_FOREACH(m, &b->mousebinds, next)
|
SLIST_FOREACH(m, &b->mousebinds, next)
|
||||||
MOUSE_CHECK_BIND(m);
|
MOUSE_DO_BIND(m);
|
||||||
|
|
||||||
SLIST_FOREACH(m, &b->statusmousebinds, next)
|
SLIST_FOREACH(m, &b->statusmousebinds, next)
|
||||||
MOUSE_CHECK_BIND(m);
|
MOUSE_DO_BIND(m);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -98,7 +98,6 @@ event_clientmessageevent(XEvent *e)
|
|||||||
if((sy = systray_find(ev->data.l[2])))
|
if((sy = systray_find(ev->data.l[2])))
|
||||||
ewmh_send_message(sy->win, sy->win, "_XEMBED", XEMBED_FOCUS_IN,
|
ewmh_send_message(sy->win, sy->win, "_XEMBED", XEMBED_FOCUS_IN,
|
||||||
XEMBED_FOCUS_CURRENT, 0, 0, 0);
|
XEMBED_FOCUS_CURRENT, 0, 0, 0);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(ev->window == W->root)
|
else if(ev->window == W->root)
|
||||||
|
|||||||
75
src/fifo.c
75
src/fifo.c
@ -1,75 +0,0 @@
|
|||||||
/*
|
|
||||||
* wmfs2 by Martin Duquesnoy <xorg62@gmail.com> { for(i = 2011; i < 2111; ++i) ©(i); }
|
|
||||||
* File created by David Delassus.
|
|
||||||
* For license, see COPYING.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <sys/stat.h> /* access */
|
|
||||||
|
|
||||||
#include "wmfs.h"
|
|
||||||
#include "util.h"
|
|
||||||
#include "config.h"
|
|
||||||
#include "fifo.h"
|
|
||||||
|
|
||||||
#define READ_SIZE (32768)
|
|
||||||
|
|
||||||
static void
|
|
||||||
fifo_open(void)
|
|
||||||
{
|
|
||||||
if(W->fifo.fd)
|
|
||||||
close(W->fifo.fd);
|
|
||||||
|
|
||||||
if(!(W->fifo.fd = open(W->fifo.path, O_RDONLY | O_NDELAY, 0)))
|
|
||||||
warnxl("Can't open FIFO: %s\n", strerror(errno));
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
fifo_init(void)
|
|
||||||
{
|
|
||||||
xasprintf(&(W->fifo.path), "%s/wmfs-%s.fifo", P_tmpdir, DisplayString(W->dpy));
|
|
||||||
|
|
||||||
/* Check if fifo already exists */
|
|
||||||
if(access(W->fifo.path, F_OK) != -1)
|
|
||||||
unlink(W->fifo.path);
|
|
||||||
|
|
||||||
if(mkfifo(W->fifo.path, 0644) < 0)
|
|
||||||
warnxl("Can't create FIFO: %s\n", strerror(errno));
|
|
||||||
|
|
||||||
fifo_open();
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
fifo_parse(char *cmd)
|
|
||||||
{
|
|
||||||
void (*func)(Uicb);
|
|
||||||
char *p, *arg = NULL;
|
|
||||||
|
|
||||||
/* remove trailing newline */
|
|
||||||
if((p = strchr(cmd, '\n')))
|
|
||||||
*p = '\0';
|
|
||||||
|
|
||||||
/* If an argument is present, delimit function string */
|
|
||||||
if((p = strchr(cmd, ' ')))
|
|
||||||
{
|
|
||||||
*p = '\0';
|
|
||||||
arg = p + 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* call the UICB function, p + 1 is command or NULL */
|
|
||||||
if((func = uicb_name_func(cmd)))
|
|
||||||
func(arg);
|
|
||||||
|
|
||||||
XSync(W->dpy, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
fifo_read(void)
|
|
||||||
{
|
|
||||||
char buf[READ_SIZE] = { 0 };
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
if((ret = read(W->fifo.fd, buf, sizeof(buf) - 1)) > 0)
|
|
||||||
fifo_parse(buf);
|
|
||||||
else if(!ret)
|
|
||||||
fifo_open();
|
|
||||||
}
|
|
||||||
18
src/screen.c
18
src/screen.c
@ -101,10 +101,10 @@ screen_select(struct screen *s)
|
|||||||
void
|
void
|
||||||
uicb_screen_next(Uicb cmd)
|
uicb_screen_next(Uicb cmd)
|
||||||
{
|
{
|
||||||
struct screen *s;
|
struct screen *s = SLIST_NEXT(W->screen, next);
|
||||||
(void)cmd;
|
(void)cmd;
|
||||||
|
|
||||||
if(!(s = SLIST_NEXT(W->screen, next)))
|
if(!s)
|
||||||
s = SLIST_FIRST(&W->h.screen);
|
s = SLIST_FIRST(&W->h.screen);
|
||||||
|
|
||||||
screen_select(s);
|
screen_select(s);
|
||||||
@ -113,23 +113,19 @@ uicb_screen_next(Uicb cmd)
|
|||||||
void
|
void
|
||||||
uicb_screen_prev(Uicb cmd)
|
uicb_screen_prev(Uicb cmd)
|
||||||
{
|
{
|
||||||
struct screen *s;
|
struct screen *s = SLIST_FIRST(&W->h.screen);
|
||||||
(void)cmd;
|
(void)cmd;
|
||||||
|
|
||||||
SLIST_FOREACH(s, &W->h.screen, next)
|
while(SLIST_NEXT(s, next) && SLIST_NEXT(s, next) != s)
|
||||||
if(SLIST_NEXT(W->screen, next) == s)
|
s = SLIST_NEXT(s, next);
|
||||||
{
|
|
||||||
screen_select(s);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
screen_select(SLIST_FIRST(&W->h.screen));
|
screen_select(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
uicb_screen_move_client_next(Uicb cmd)
|
uicb_screen_move_client_next(Uicb cmd)
|
||||||
{
|
{
|
||||||
struct screen *s = SLIST_NEXT(W->screen, next);;
|
struct screen *s = SLIST_NEXT(W->screen, next);
|
||||||
(void)cmd;
|
(void)cmd;
|
||||||
|
|
||||||
if(!s)
|
if(!s)
|
||||||
|
|||||||
52
src/wmfs.c
52
src/wmfs.c
@ -22,7 +22,6 @@
|
|||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "client.h"
|
#include "client.h"
|
||||||
#include "fifo.h"
|
|
||||||
#include "layout.h"
|
#include "layout.h"
|
||||||
|
|
||||||
int
|
int
|
||||||
@ -357,39 +356,26 @@ wmfs_scan(void)
|
|||||||
XSync(W->dpy, false);
|
XSync(W->dpy, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline void
|
||||||
|
wmfs_sigchld(void)
|
||||||
|
{
|
||||||
|
if(W->flags & WMFS_SIGCHLD)
|
||||||
|
{
|
||||||
|
while(waitpid(-1, NULL, WNOHANG) > 0);
|
||||||
|
W->flags ^= WMFS_SIGCHLD;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
wmfs_loop(void)
|
wmfs_loop(void)
|
||||||
{
|
{
|
||||||
XEvent ev;
|
XEvent ev;
|
||||||
int maxfd, fd = ConnectionNumber(W->dpy);
|
|
||||||
fd_set iset;
|
|
||||||
|
|
||||||
while(W->flags & WMFS_RUNNING)
|
while((W->flags & WMFS_RUNNING) && !XNextEvent(W->dpy, &ev))
|
||||||
{
|
{
|
||||||
maxfd = fd + 1;
|
/* Manage SIGCHLD event here, X is not safe with it */
|
||||||
|
wmfs_sigchld();
|
||||||
FD_ZERO(&iset);
|
EVENT_HANDLE(&ev);
|
||||||
FD_SET(fd, &iset);
|
|
||||||
|
|
||||||
if(W->fifo.fd > 0)
|
|
||||||
{
|
|
||||||
maxfd += W->fifo.fd;
|
|
||||||
FD_SET(W->fifo.fd, &iset);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(select(maxfd, &iset, NULL, NULL, NULL) > 0)
|
|
||||||
{
|
|
||||||
if(FD_ISSET(fd, &iset))
|
|
||||||
{
|
|
||||||
while((W->flags & WMFS_RUNNING) && XPending(W->dpy))
|
|
||||||
{
|
|
||||||
XNextEvent(W->dpy, &ev);
|
|
||||||
EVENT_HANDLE(&ev);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if(W->fifo.fd > 0 && FD_ISSET(W->fifo.fd, &iset))
|
|
||||||
fifo_read();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -402,7 +388,6 @@ wmfs_init(void)
|
|||||||
screen_init();
|
screen_init();
|
||||||
event_init();
|
event_init();
|
||||||
config_init();
|
config_init();
|
||||||
fifo_init();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -486,13 +471,6 @@ wmfs_quit(void)
|
|||||||
free(r);
|
free(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* FIFO stuffs */
|
|
||||||
if(W->fifo.fd > 0)
|
|
||||||
{
|
|
||||||
close(W->fifo.fd);
|
|
||||||
unlink(W->fifo.path);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* close log */
|
/* close log */
|
||||||
if(W->log)
|
if(W->log)
|
||||||
fclose(W->log), W->log = NULL;
|
fclose(W->log), W->log = NULL;
|
||||||
@ -554,7 +532,7 @@ signal_handle(int sig)
|
|||||||
W->flags &= ~WMFS_RUNNING;
|
W->flags &= ~WMFS_RUNNING;
|
||||||
break;
|
break;
|
||||||
case SIGCHLD:
|
case SIGCHLD:
|
||||||
while(waitpid(-1, NULL, WNOHANG) > 0);
|
W->flags |= WMFS_SIGCHLD;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -324,6 +324,7 @@ struct wmfs
|
|||||||
#define WMFS_SYSTRAY 0x08
|
#define WMFS_SYSTRAY 0x08
|
||||||
#define WMFS_LOG 0x10
|
#define WMFS_LOG 0x10
|
||||||
#define WMFS_LAUNCHER 0x20
|
#define WMFS_LAUNCHER 0x20
|
||||||
|
#define WMFS_SIGCHLD 0x40
|
||||||
Flags flags;
|
Flags flags;
|
||||||
GC gc, rgc;
|
GC gc, rgc;
|
||||||
Atom *net_atom;
|
Atom *net_atom;
|
||||||
@ -332,13 +333,6 @@ struct wmfs
|
|||||||
struct barwin *last_clicked_barwin;
|
struct barwin *last_clicked_barwin;
|
||||||
struct theme *ctheme;
|
struct theme *ctheme;
|
||||||
|
|
||||||
/* FIFO stuffs */
|
|
||||||
struct
|
|
||||||
{
|
|
||||||
char *path;
|
|
||||||
int fd;
|
|
||||||
} fifo;
|
|
||||||
|
|
||||||
/* Log file */
|
/* Log file */
|
||||||
FILE *log;
|
FILE *log;
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user