Status: Use InfoBar* instead of win in StatusMouse struct
This commit is contained in:
parent
8958dbfe70
commit
39080f9952
12
src/draw.c
12
src/draw.c
@ -86,7 +86,7 @@ parse_image_block(Drawable dr, char *str)
|
||||
BarWindow *bw;
|
||||
Geo area;
|
||||
char as, mouse[512] = { 0 };
|
||||
int i = 0, j = 0, k, n;
|
||||
int i = 0, j = 0, k = 0, n;
|
||||
|
||||
for(; i < (int)strlen(str); ++i, ++j)
|
||||
if((n = sscanf(&str[i], "\\i[%d;%d;%d;%d;%512[^];]]%c",
|
||||
@ -97,7 +97,7 @@ parse_image_block(Drawable dr, char *str)
|
||||
{
|
||||
draw_image(dr, im.x - sw, im.y, im.w, im.h, im.name);
|
||||
|
||||
/* Etablish clickable area on image */
|
||||
/* Etablish clickable area on image (on infobar wins only (status mouse bind) */
|
||||
if(n == 7)
|
||||
{
|
||||
area.x = im.x - sw;
|
||||
@ -105,11 +105,11 @@ parse_image_block(Drawable dr, char *str)
|
||||
area.width = im.w;
|
||||
area.height = im.h;
|
||||
|
||||
/* Associate drawable with window; travel barwins */
|
||||
SLIST_FOREACH(bw, &bwhead, next)
|
||||
if(bw->dr == dr)
|
||||
/* Associate drawable with window; travel infobars */
|
||||
for(; k < screen_count(); ++k)
|
||||
if(infobar[k].bar->dr == dr)
|
||||
{
|
||||
statustext_mouse(mouse, area, bw->win);
|
||||
statustext_mouse(mouse, area, &infobar[k]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -161,7 +161,7 @@ buttonpress(XEvent *e)
|
||||
|
||||
/* Status mouse bindings */
|
||||
SLIST_FOREACH(sm, &smhead, next)
|
||||
if(sm->win == ev->window && ev->button == sm->button)
|
||||
if(sm->infobar->bar->win == ev->window && ev->button == sm->button)
|
||||
if(ev->x >= sm->area.x && ev->x <= sm->area.x + sm->area.width
|
||||
&& ev->y >= sm->area.y && ev->y <= sm->area.y + sm->area.height)
|
||||
if(sm->func)
|
||||
|
||||
35
src/status.c
35
src/status.c
@ -39,10 +39,10 @@ static int sw = 0;
|
||||
* --> \<block>[;;;;(button;func;cmd)]\ add a mouse bind on the block object
|
||||
*\param str String
|
||||
*\param area Area of clicking
|
||||
*\param win Win to click
|
||||
*\param infobar Infobar pointer
|
||||
*/
|
||||
void
|
||||
statustext_mouse(char *str, Geo area, Window win)
|
||||
statustext_mouse(char *str, Geo area, InfoBar *infobar)
|
||||
{
|
||||
StatusMouse *sm = NULL;
|
||||
int i = 0, button = 1, n;
|
||||
@ -50,14 +50,14 @@ statustext_mouse(char *str, Geo area, Window win)
|
||||
char func[64] = { 0 };
|
||||
|
||||
for(; i < strlen(str); ++i)
|
||||
if((n = sscanf(&str[i], "(%d;%64[^;];%256[^)])", &button, func, cmd) >= 2) && n <= 3)
|
||||
if((n = sscanf(&str[i], "(%d;%64[^;];%256[^)])", &button, func, cmd) >= 2) && n < 4)
|
||||
{
|
||||
sm = zcalloc(sizeof(StatusMouse));
|
||||
sm->button = button;
|
||||
sm->func = name_to_func((char*)func, func_list);
|
||||
sm->cmd = xstrdup(cmd);
|
||||
sm->area = area;
|
||||
sm->win = win;
|
||||
sm->button = button;
|
||||
sm->func = name_to_func((char*)func, func_list);
|
||||
sm->cmd = xstrdup(cmd);
|
||||
sm->area = area;
|
||||
sm->infobar = infobar;
|
||||
|
||||
SLIST_INSERT_HEAD(&smhead, sm, next);
|
||||
|
||||
@ -91,7 +91,7 @@ statustext_rectangle(InfoBar *ib, char *str)
|
||||
draw_rectangle(ib->bar->dr, r.g.x - sw, r.g.y, r.g.width, r.g.height, r.color);
|
||||
|
||||
if(n == 7)
|
||||
statustext_mouse(mouse, r.g, ib->bar->win);
|
||||
statustext_mouse(mouse, r.g, ib);
|
||||
|
||||
for(++i, --j; str[i] != as || str[i - 1] != ']'; ++i);
|
||||
}
|
||||
@ -182,7 +182,7 @@ statustext_text(InfoBar *ib, char *str)
|
||||
area.x = s.x - sw;
|
||||
area.y = s.y - area.height;
|
||||
|
||||
statustext_mouse(mouse, area, ib->bar->win);
|
||||
statustext_mouse(mouse, area, ib);
|
||||
}
|
||||
|
||||
for(++i, --j; str[i] != as || str[i - 1] != ']'; ++i);
|
||||
@ -267,13 +267,14 @@ statustext_handle(int sc, char *str)
|
||||
return;
|
||||
|
||||
/* Free previous linked list of mouse bind */
|
||||
while(!SLIST_EMPTY(&smhead))
|
||||
{
|
||||
sm = SLIST_FIRST(&smhead);
|
||||
SLIST_REMOVE_HEAD(&smhead, next);
|
||||
free((void*)sm->cmd);
|
||||
free(sm);
|
||||
}
|
||||
if(!sc)
|
||||
while(!SLIST_EMPTY(&smhead))
|
||||
{
|
||||
sm = SLIST_FIRST(&smhead);
|
||||
SLIST_REMOVE_HEAD(&smhead, next);
|
||||
free((void*)sm->cmd);
|
||||
free(sm);
|
||||
}
|
||||
|
||||
if(sc == conf.systray.screen)
|
||||
sw = systray_get_width();
|
||||
|
||||
@ -563,7 +563,7 @@ typedef struct
|
||||
typedef struct StatusMouse
|
||||
{
|
||||
Geo area;
|
||||
Window win;
|
||||
InfoBar *infobar;
|
||||
int button;
|
||||
void (*func)(uicb_t);
|
||||
uicb_t cmd;
|
||||
|
||||
@ -363,7 +363,7 @@ void uicb_screen_prev(uicb_t);
|
||||
void uicb_screen_prev_sel(uicb_t);
|
||||
|
||||
/* status.c */
|
||||
void statustext_mouse(char *str, Geo area, Drawable dr);
|
||||
void statustext_mouse(char *str, Geo area, InfoBar *infobar);
|
||||
void statustext_handle(int sc, char *str);
|
||||
|
||||
/* systray.c */
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user