diff --git a/src/config.h b/src/config.h index c839b95..0c10e19 100644 --- a/src/config.h +++ b/src/config.h @@ -83,7 +83,8 @@ static const struct { char *name; void (*func)(Uicb cmd); } uicb_list[] = { "client_tab_next_opened", uicb_client_tab_next_opened }, /* Status */ - { "status" , uicb_status }, + { "status" , uicb_status }, + { "status_surface", uicb_status_surface }, /* Mouse */ { "mouse_resize", uicb_mouse_resize }, diff --git a/src/event.c b/src/event.c index 3676945..bc41670 100644 --- a/src/event.c +++ b/src/event.c @@ -29,6 +29,7 @@ event_buttonpress(XEvent *e) struct barwin *b; screen_update_sel(); + status_flush_surface(); SLIST_FOREACH(b, &W->h.barwin, next) if(b->win == ev->window) @@ -325,6 +326,7 @@ event_keypress(XEvent *e) struct keybind *k; screen_update_sel(); + status_flush_surface(); SLIST_FOREACH(k, &W->h.keybind, next) if(k->keysym == keysym && KEYPRESS_MASK(k->mod) == KEYPRESS_MASK(ev->state)) diff --git a/src/mouse.c b/src/mouse.c index a6e79f1..544b4fa 100644 --- a/src/mouse.c +++ b/src/mouse.c @@ -26,7 +26,7 @@ mouse_resize(struct client *c) int d, u, ox, oy, ix, iy; int mx, my; - XQueryPointer(W->dpy, W->root, &w, &w, &ox, &oy, &d, &d, (uint *)&u); + XQueryPointer(W->dpy, W->root, &w, &w, &ox, &oy, &d, &d, (unsigned int *)&u); XGrabServer(W->dpy); if(c->flags & CLIENT_FREE) diff --git a/src/status.c b/src/status.c index 44241aa..d85a17d 100644 --- a/src/status.c +++ b/src/status.c @@ -528,6 +528,68 @@ status_manage(struct status_ctx *ctx) status_copy_mousebind(ctx); } +void +status_flush_surface(void) +{ + struct barwin *b; + + while(!SLIST_EMPTY(&W->h.vbarwin)) + { + b = SLIST_FIRST(&W->h.vbarwin); + SLIST_REMOVE_HEAD(&W->h.vbarwin, vnext); + barwin_remove(b); + } +} + +static void +status_surface(int w, int h, Color bg, char *status) +{ + struct barwin *b; + struct status_ctx ctx; + int d, x, y; + + if(!status) + return; + + XQueryPointer(W->dpy, W->root, (Window*)&d, (Window*)&d, &x, &y, &d, &d, (unsigned int *)&d); + + b = barwin_new(W->root, x, y, w, h, 0, bg, false); + barwin_map(b); + + ctx = status_new_ctx(b, SLIST_FIRST(&W->h.theme)); + ctx.status = xstrdup(status); + + SLIST_INSERT_HEAD(&W->h.vbarwin, b, vnext); + + status_manage(&ctx); + status_free_ctx(&ctx); +} + +void +uicb_status_surface(Uicb cmd) +{ + char *p, *ccmd = xstrdup(cmd); + int w, h; + Color bg; + + if(!ccmd || !(p = strchr(ccmd, ' '))) + return; + + if(sscanf(ccmd, "%d,%d,#%x", &w, &h, &bg) != 3 + || !w || !h) + { + free(ccmd); + return; + } + + *p = '\0'; + ++p; + + status_surface(w, h, bg, p); + + free(ccmd); +} + /* Syntax: " " */ void uicb_status(Uicb cmd) diff --git a/src/status.h b/src/status.h index ada712a..24acdeb 100644 --- a/src/status.h +++ b/src/status.h @@ -16,6 +16,8 @@ void status_copy_mousebind(struct status_ctx *ctx); void status_parse(struct status_ctx *ctx); void status_render(struct status_ctx *ctx); void status_manage(struct status_ctx *ctx); +void status_flush_surface(void); void uicb_status(Uicb cmd); +void uicb_status_surface(Uicb cmd); #endif /* STATUS_H */ diff --git a/src/util.c b/src/util.c index e20c684..07a8d9d 100644 --- a/src/util.c +++ b/src/util.c @@ -149,7 +149,7 @@ parse_args(char *str, char delim, char end, int narg, char *args[]) int i = 0; for(args[0] = str; *str && (*str != end || *(str - 1) == '\\') && i < narg; ++str) - if(*str == delim) + if(*str == delim && i < narg - 1) { *str = '\0'; args[++i] = ++str; diff --git a/src/wmfs.c b/src/wmfs.c index 51d6adf..39682e1 100644 --- a/src/wmfs.c +++ b/src/wmfs.c @@ -160,6 +160,7 @@ wmfs_xinit(void) * Barwin linked list */ SLIST_INIT(&W->h.barwin); + SLIST_INIT(&W->h.vbarwin); /* * Optional dep init diff --git a/src/wmfs.h b/src/wmfs.h index 9a689bf..84d25f9 100644 --- a/src/wmfs.h +++ b/src/wmfs.h @@ -95,6 +95,7 @@ struct barwin SLIST_HEAD(, mousebind) statusmousebinds; SLIST_ENTRY(barwin) next; /* global barwin */ SLIST_ENTRY(barwin) enext; /* element barwin */ + SLIST_ENTRY(barwin) vnext; /* volatile barwin */ }; struct status_seq @@ -363,6 +364,7 @@ struct wmfs SLIST_HEAD(, rule) rule; SLIST_HEAD(, mousebind) mousebind; SLIST_HEAD(, launcher) launcher; + SLIST_HEAD(, barwin) vbarwin; } h; /*