From b753f7cf48afcd8c87aced52aa73949e84bb665f Mon Sep 17 00:00:00 2001 From: Martin Duquesnoy Date: Mon, 6 Feb 2012 20:38:26 +0100 Subject: [PATCH] Add possible x,y arg in status_surface (w,h,#color OR x,y,w,h,#color) --- src/status.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/status.c b/src/status.c index d7d9a65..439fafa 100644 --- a/src/status.c +++ b/src/status.c @@ -542,17 +542,19 @@ status_flush_surface(void) } static void -status_surface(int w, int h, Color bg, char *status) +status_surface(int x, int y, int w, int h, Color bg, char *status) { struct barwin *b; struct screen *s; struct status_ctx ctx; - int d, x, y; + int d; if(!status) return; - XQueryPointer(W->dpy, W->root, (Window*)&d, (Window*)&d, &x, &y, &d, &d, (unsigned int *)&d); + if(x + y < 0) + XQueryPointer(W->dpy, W->root, (Window*)&d, (Window*)&d, &x, &y, &d, &d, (unsigned int *)&d); + s = screen_gb_geo(x, y); if(x + w > s->geo.x + s->geo.w) @@ -576,23 +578,23 @@ void uicb_status_surface(Uicb cmd) { char *p, *ccmd = xstrdup(cmd); - int w, h; + int s, d = 0, w, h, x = -1, y = -1; Color bg; if(!ccmd || !(p = strchr(ccmd, ' '))) return; - if(sscanf(ccmd, "%d,%d,#%x", &w, &h, &bg) != 3 - || !w || !h) + *p = '\0'; + ++p; + + if(!(((s = sscanf(ccmd, "%d,%d,#%x", &w, &h, &bg)) == 3) + || (s = sscanf(ccmd, "%d,%d,%d,%d,#%x", &x, &y, &w, &h, &bg)) == 5)) { free(ccmd); return; } - *p = '\0'; - ++p; - - status_surface(w, h, bg, p); + status_surface(x, y, w, h, bg, p); free(ccmd); }