Add clean status_surface. cmd syntax: "w;h;bg <statusline>"
This commit is contained in:
parent
b5764dd0a6
commit
ff269f01b3
@ -83,7 +83,8 @@ static const struct { char *name; void (*func)(Uicb cmd); } uicb_list[] =
|
|||||||
{ "client_tab_next_opened", uicb_client_tab_next_opened },
|
{ "client_tab_next_opened", uicb_client_tab_next_opened },
|
||||||
|
|
||||||
/* Status */
|
/* Status */
|
||||||
{ "status" , uicb_status },
|
{ "status" , uicb_status },
|
||||||
|
{ "status_surface", uicb_status_surface },
|
||||||
|
|
||||||
/* Mouse */
|
/* Mouse */
|
||||||
{ "mouse_resize", uicb_mouse_resize },
|
{ "mouse_resize", uicb_mouse_resize },
|
||||||
|
|||||||
@ -29,6 +29,7 @@ event_buttonpress(XEvent *e)
|
|||||||
struct barwin *b;
|
struct barwin *b;
|
||||||
|
|
||||||
screen_update_sel();
|
screen_update_sel();
|
||||||
|
status_flush_surface();
|
||||||
|
|
||||||
SLIST_FOREACH(b, &W->h.barwin, next)
|
SLIST_FOREACH(b, &W->h.barwin, next)
|
||||||
if(b->win == ev->window)
|
if(b->win == ev->window)
|
||||||
@ -325,6 +326,7 @@ event_keypress(XEvent *e)
|
|||||||
struct keybind *k;
|
struct keybind *k;
|
||||||
|
|
||||||
screen_update_sel();
|
screen_update_sel();
|
||||||
|
status_flush_surface();
|
||||||
|
|
||||||
SLIST_FOREACH(k, &W->h.keybind, next)
|
SLIST_FOREACH(k, &W->h.keybind, next)
|
||||||
if(k->keysym == keysym && KEYPRESS_MASK(k->mod) == KEYPRESS_MASK(ev->state))
|
if(k->keysym == keysym && KEYPRESS_MASK(k->mod) == KEYPRESS_MASK(ev->state))
|
||||||
|
|||||||
@ -26,7 +26,7 @@ mouse_resize(struct client *c)
|
|||||||
int d, u, ox, oy, ix, iy;
|
int d, u, ox, oy, ix, iy;
|
||||||
int mx, my;
|
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);
|
XGrabServer(W->dpy);
|
||||||
|
|
||||||
if(c->flags & CLIENT_FREE)
|
if(c->flags & CLIENT_FREE)
|
||||||
|
|||||||
62
src/status.c
62
src/status.c
@ -528,6 +528,68 @@ status_manage(struct status_ctx *ctx)
|
|||||||
status_copy_mousebind(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: "<infobar name> <status string>" */
|
/* Syntax: "<infobar name> <status string>" */
|
||||||
void
|
void
|
||||||
uicb_status(Uicb cmd)
|
uicb_status(Uicb cmd)
|
||||||
|
|||||||
@ -16,6 +16,8 @@ void status_copy_mousebind(struct status_ctx *ctx);
|
|||||||
void status_parse(struct status_ctx *ctx);
|
void status_parse(struct status_ctx *ctx);
|
||||||
void status_render(struct status_ctx *ctx);
|
void status_render(struct status_ctx *ctx);
|
||||||
void status_manage(struct status_ctx *ctx);
|
void status_manage(struct status_ctx *ctx);
|
||||||
|
void status_flush_surface(void);
|
||||||
void uicb_status(Uicb cmd);
|
void uicb_status(Uicb cmd);
|
||||||
|
void uicb_status_surface(Uicb cmd);
|
||||||
|
|
||||||
#endif /* STATUS_H */
|
#endif /* STATUS_H */
|
||||||
|
|||||||
@ -149,7 +149,7 @@ parse_args(char *str, char delim, char end, int narg, char *args[])
|
|||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
for(args[0] = str; *str && (*str != end || *(str - 1) == '\\') && i < narg; ++str)
|
for(args[0] = str; *str && (*str != end || *(str - 1) == '\\') && i < narg; ++str)
|
||||||
if(*str == delim)
|
if(*str == delim && i < narg - 1)
|
||||||
{
|
{
|
||||||
*str = '\0';
|
*str = '\0';
|
||||||
args[++i] = ++str;
|
args[++i] = ++str;
|
||||||
|
|||||||
@ -160,6 +160,7 @@ wmfs_xinit(void)
|
|||||||
* Barwin linked list
|
* Barwin linked list
|
||||||
*/
|
*/
|
||||||
SLIST_INIT(&W->h.barwin);
|
SLIST_INIT(&W->h.barwin);
|
||||||
|
SLIST_INIT(&W->h.vbarwin);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Optional dep init
|
* Optional dep init
|
||||||
|
|||||||
@ -95,6 +95,7 @@ struct barwin
|
|||||||
SLIST_HEAD(, mousebind) statusmousebinds;
|
SLIST_HEAD(, mousebind) statusmousebinds;
|
||||||
SLIST_ENTRY(barwin) next; /* global barwin */
|
SLIST_ENTRY(barwin) next; /* global barwin */
|
||||||
SLIST_ENTRY(barwin) enext; /* element barwin */
|
SLIST_ENTRY(barwin) enext; /* element barwin */
|
||||||
|
SLIST_ENTRY(barwin) vnext; /* volatile barwin */
|
||||||
};
|
};
|
||||||
|
|
||||||
struct status_seq
|
struct status_seq
|
||||||
@ -363,6 +364,7 @@ struct wmfs
|
|||||||
SLIST_HEAD(, rule) rule;
|
SLIST_HEAD(, rule) rule;
|
||||||
SLIST_HEAD(, mousebind) mousebind;
|
SLIST_HEAD(, mousebind) mousebind;
|
||||||
SLIST_HEAD(, launcher) launcher;
|
SLIST_HEAD(, launcher) launcher;
|
||||||
|
SLIST_HEAD(, barwin) vbarwin;
|
||||||
} h;
|
} h;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user