From 4908e4b183d85ecfe6a82bb063c6cfaef763ec71 Mon Sep 17 00:00:00 2001 From: Martin Duquesnoy Date: Mon, 29 Aug 2011 14:04:32 +0200 Subject: [PATCH] Fix warning with -Wall --- wmfs2/src/barwin.c | 20 ++++++++++++++++++++ wmfs2/src/barwin.h | 1 + wmfs2/src/config.h | 5 +++-- wmfs2/src/infobar.c | 9 ++++----- wmfs2/src/wmfs.c | 19 +++++++++++++++++++ wmfs2/src/wmfs.h | 4 +++- 6 files changed, 50 insertions(+), 8 deletions(-) diff --git a/wmfs2/src/barwin.c b/wmfs2/src/barwin.c index 288301c..c697560 100755 --- a/wmfs2/src/barwin.c +++ b/wmfs2/src/barwin.c @@ -45,6 +45,8 @@ barwin_new(Window parent, int x, int y, int w, int h, Color fg, Color bg, bool e b->bg = bg; b->fg = fg; + SLIST_INIT(&b->mousebinds); + /* Attach */ SLIST_INSERT_HEAD(&W->h.barwin, b, next); @@ -63,6 +65,9 @@ barwin_remove(Barwin *b) XDestroyWindow(W->dpy, b->win); XFreePixmap(W->dpy, b->dr); + /* Free mousebinds */ + FREE_LIST(b->mousebinds, Mousebind); + free(b); } @@ -85,6 +90,21 @@ barwin_resize(Barwin *b, int w, int h) XResizeWindow(W->dpy, b->win, w, h); } +void +barwin_mousebind_new(Barwin *b, unsigned int button, bool u, Geo a, void (*func)(Uicb), Uicb cmd) +{ + Mousebind *m; + + m = xcalloc(1, sizeof(Mousebind)); + + m->button = button; + m->use_area = u; + m->area = a; + m->func = func; + m->cmd = cmd; + + SLIST_INSERT_HEAD(&b->mousebinds, m, next): +} /** Refresh the Barwin Color * \param bw Barwin pointer diff --git a/wmfs2/src/barwin.h b/wmfs2/src/barwin.h index de03d88..974145f 100755 --- a/wmfs2/src/barwin.h +++ b/wmfs2/src/barwin.h @@ -26,6 +26,7 @@ Barwin* barwin_new(Window parent, int x, int y, int w, int h, Color fg, Color bg, bool entermask); void barwin_remove(Barwin *b); void barwin_resize(Barwin *b, int w, int h); +void barwin_mousebind_new(Barwin *b, unsigned int button, bool u, Geo a, void (*func)(Uicb), Uicb cmd) void barwin_refresh_color(Barwin *b); #endif /* BARWIN_H */ diff --git a/wmfs2/src/config.h b/wmfs2/src/config.h index 42f6a40..1de5c25 100755 --- a/wmfs2/src/config.h +++ b/wmfs2/src/config.h @@ -17,8 +17,9 @@ static const struct { char *name; void (*func)(Uicb cmd); } uicb_list[] = { /* Sys */ - { "spawn", uicb_spawn }, - { "quit", uicb_quit }, + { "spawn", uicb_spawn }, + { "quit", uicb_quit }, + { "reload", uicb_reload }, /* Tag */ { "tag_set", uicb_tag_set }, diff --git a/wmfs2/src/infobar.c b/wmfs2/src/infobar.c index d8d6a92..fc00732 100755 --- a/wmfs2/src/infobar.c +++ b/wmfs2/src/infobar.c @@ -110,6 +110,8 @@ infobar_elem_init(Infobar *i) Element *e; int n, j; + TAILQ_INIT(&i->elements); + for(n = 0; n < strlen(i->elemorder); ++n) { for(j = 0; j < LEN(elem_funcs); ++j) @@ -170,7 +172,6 @@ infobar_init(void) i->screen = s; i->elemorder = xstrdup(ELEM_DEFAULT_ORDER); - TAILQ_INIT(&i->elements); /* Positions TODO: geo = infobar_position(Position {Top,Bottom,Hidden}) */ i->geo = s->geo; @@ -184,7 +185,9 @@ infobar_init(void) barwin_map_subwin(i->bar); barwin_refresh_color(i->bar); + /* Elements */ infobar_elem_init(i); + infobar_refresh(i); SLIST_INSERT_HEAD(&s->infobars, i, next); @@ -194,10 +197,6 @@ infobar_init(void) void infobar_refresh(Infobar *i) { - draw_text(i->bar->dr, 0, TEXTY(INFOBAR_DEF_W), 0x005500, "|"); - - i->elemupdate |= FLAGINT(ElemTag); - infobar_elem_update(i); barwin_refresh(i->bar); diff --git a/wmfs2/src/wmfs.c b/wmfs2/src/wmfs.c index 543a02c..81c3fb0 100755 --- a/wmfs2/src/wmfs.c +++ b/wmfs2/src/wmfs.c @@ -245,6 +245,7 @@ wmfs_quit(void) XCloseDisplay(W->dpy); free(W->net_atom); + free(W->argv); free(W); /* Conf stuffs */ @@ -253,6 +254,22 @@ wmfs_quit(void) W->running = false; } +/** Reload WMFS binary +*/ +void +uicb_reload(Uicb cmd) +{ + (void)cmd; + char *command = xstrdup(W->argv[0]); + char **argv = W->argv; + + wmfs_quit(); + + for(; command[0] && command[0] == ' '; ++command[0]); + + execvp(command, argv); +} + void uicb_quit(Uicb cmd) { @@ -265,6 +282,8 @@ main(int argc, char **argv) { W = (struct Wmfs*)xcalloc(1, sizeof(struct Wmfs)); + W->argv = argv; + /* Get X display */ if(!(W->dpy = XOpenDisplay(NULL))) { diff --git a/wmfs2/src/wmfs.h b/wmfs2/src/wmfs.h index 8791fee..eedaaea 100755 --- a/wmfs2/src/wmfs.h +++ b/wmfs2/src/wmfs.h @@ -58,7 +58,7 @@ struct Barwin Geo geo; Flags flags; void *ptr; /* Special cases */ - SLIST_HEAD(, MouseBind) mousebinds; + SLIST_HEAD(, Mousebind) mousebinds; SLIST_ENTRY(Barwin) next; }; @@ -161,6 +161,7 @@ struct Wmfs Flags numlockmask; GC gc; Atom *net_atom; + char **argv; bool running; struct @@ -190,6 +191,7 @@ int wmfs_error_handler(Display *d, XErrorEvent *event); int wmfs_error_handler_dummy(Display *d, XErrorEvent *event); void wmfs_grab_keys(void); void wmfs_quit(void); +void uicb_reload(Uicb cmd); void uicb_quit(Uicb cmd);