Add working reload (without global replacement)

This commit is contained in:
Martin Duquesnoy 2011-10-29 16:49:05 +02:00
parent a4564543d7
commit 984145243d
4 changed files with 34 additions and 20 deletions

View File

@ -904,7 +904,8 @@ client_remove(struct client *c)
{
XGrabServer(W->dpy);
XSetErrorHandler(wmfs_error_handler_dummy);
XReparentWindow(W->dpy, c->win, W->root, c->geo.x, c->geo.y);
XReparentWindow(W->dpy, c->win, W->root, c->rgeo.x, c->rgeo.y);
WIN_STATE(c->win, Map);
XDestroyWindow(W->dpy, c->frame);
if(c->titlebar)

View File

@ -261,7 +261,7 @@ wmfs_loop(void)
{
if(FD_ISSET(fd, &iset))
{
while(XPending(W->dpy))
while(W->running && XPending(W->dpy))
{
XNextEvent(W->dpy, &ev);
EVENT_HANDLE(&ev);
@ -289,6 +289,7 @@ wmfs_quit(void)
{
struct keybind *k;
struct theme *t;
struct client *c;
/* Will free:
*
@ -298,17 +299,14 @@ wmfs_quit(void)
screen_free();
XFreeGC(W->dpy, W->rgc);
XCloseDisplay(W->dpy);
/* Conf stuffs */
while(!SLIST_EMPTY(&W->h.keybind))
while(!SLIST_EMPTY(&W->h.client))
{
k = SLIST_FIRST(&W->h.keybind);
SLIST_REMOVE_HEAD(&W->h.keybind, next);
free((void*)k->cmd);
free(k);
c = SLIST_FIRST(&W->h.client);
client_remove(c);
}
/* Conf stuffs */
while(!SLIST_EMPTY(&W->h.theme))
{
t = SLIST_FIRST(&W->h.theme);
@ -317,18 +315,24 @@ wmfs_quit(void)
free(t);
}
while(!SLIST_EMPTY(&W->h.keybind))
{
k = SLIST_FIRST(&W->h.keybind);
SLIST_REMOVE_HEAD(&W->h.keybind, next);
free((void*)k->cmd);
free(k);
}
/* FIFO stuffs */
if(W->fifo.fd > 0)
{
close(W->fifo.fd);
unlink(W->fifo.path);
}
free(W->fifo.path);
free(W->net_atom);
free(W);
W->running = false;
XCloseDisplay(W->dpy);
}
/** Reload WMFS binary
@ -337,21 +341,25 @@ void
uicb_reload(Uicb cmd)
{
(void)cmd;
/* TODO */
W->running = false;
W->reload = true;
}
void
uicb_quit(Uicb cmd)
{
(void)cmd;
W->running = false;
}
int
main(int argc, char **argv)
{
W = (struct wmfs*)xcalloc(1, sizeof(struct wmfs));
bool r;
W = (struct wmfs*)xcalloc(1, sizeof(struct wmfs));
/* Get X display */
if(!(W->dpy = XOpenDisplay(NULL)))
@ -380,10 +388,14 @@ main(int argc, char **argv)
/* Core */
wmfs_init();
wmfs_scan();
wmfs_loop();
wmfs_quit();
r = W->reload;
free(W);
if(r)
execvp(argv[0], argv);
return 1;
}

View File

@ -222,7 +222,8 @@ struct wmfs
Flags numlockmask;
GC gc, rgc;
Atom *net_atom;
bool running;
char **argv;
bool running, reload;
/* FIFO stuffs */
struct
@ -258,7 +259,6 @@ void wmfs_quit(void);
void uicb_reload(Uicb cmd);
void uicb_quit(Uicb cmd);
/* Single global variable */
struct wmfs *W;

View File

@ -105,7 +105,8 @@
[keys]
[key] mod = {"Super"} key = "Return" func = "spawn" cmd = "xterm" [/key]
[key] mod = {"Control","Alt"} key = "q" func = "quit" [/key]
[key] mod = {"Control", "Alt"} key = "q" func = "quit" [/key]
[key] mod = {"Control", "Alt"} key = "r" func = " reload" [/key]
[key] mod = {"Super"} key = "1" func = "tag_set" cmd = "1" [/key]
[key] mod = {"Super"} key = "2" func = "tag_set" cmd = "2" [/key]
[key] mod = {"Super"} key = "3" func = "tag_set" cmd = "3" [/key]