summaryrefslogtreecommitdiffhomepage
path: root/patch/bar_systray.c
diff options
context:
space:
mode:
authorbakkeby <[email protected]>2020-10-24 10:01:19 +0200
committerbakkeby <[email protected]>2020-10-24 10:01:19 +0200
commit5edf4bab172157288985c483009f846cc8b15478 (patch)
tree932a945a6a677be49b834b12c5d71cb046385d42 /patch/bar_systray.c
parentc6c2f0109f69d851792714dbabfd668752f21953 (diff)
downloaddwm-flexipatch-5edf4bab172157288985c483009f846cc8b15478.tar.gz
dwm-flexipatch-5edf4bab172157288985c483009f846cc8b15478.zip
Proposed changes to ensure that systray icons are sized according to font size rather than bar height, ref. #62
Diffstat (limited to 'patch/bar_systray.c')
-rw-r--r--patch/bar_systray.c29
1 files changed, 15 insertions, 14 deletions
diff --git a/patch/bar_systray.c b/patch/bar_systray.c
index d3df37c..4ff7fd9 100644
--- a/patch/bar_systray.c
+++ b/patch/bar_systray.c
@@ -31,15 +31,16 @@ draw_systray(Bar *bar, BarArg *a)
wa.override_redirect = True;
wa.event_mask = ButtonPressMask|ExposureMask;
wa.border_pixel = 0;
+ systray->h = MIN(a->h, drw->fonts->h);
#if BAR_ALPHA_PATCH
wa.background_pixel = 0;
wa.colormap = cmap;
- systray->win = XCreateWindow(dpy, root, bar->bx + a->x + lrpad / 2, bar->by + a->y, MAX(a->w + 40, 1), a->h, 0, depth,
+ systray->win = XCreateWindow(dpy, root, bar->bx + a->x + lrpad / 2, bar->by + a->y + (a->h - systray->h) / 2, MAX(a->w + 40, 1), systray->h, 0, depth,
InputOutput, visual,
CWOverrideRedirect|CWBorderPixel|CWBackPixel|CWColormap|CWEventMask, &wa); // CWBackPixmap
#else
wa.background_pixel = scheme[SchemeNorm][ColBg].pixel;
- systray->win = XCreateSimpleWindow(dpy, root, bar->bx + a->x + lrpad / 2, bar->by + a->y, MIN(a->w, 1), a->h, 0, 0, scheme[SchemeNorm][ColBg].pixel);
+ systray->win = XCreateSimpleWindow(dpy, root, bar->bx + a->x + lrpad / 2, bar->by + a->y + (a->h - systray->h) / 2, MIN(a->w, 1), systray->h, 0, 0, scheme[SchemeNorm][ColBg].pixel);
XChangeWindowAttributes(dpy, systray->win, CWOverrideRedirect|CWBackPixel|CWBorderPixel|CWEventMask, &wa);
#endif // BAR_ALPHA_PATCH
@@ -85,7 +86,7 @@ draw_systray(Bar *bar, BarArg *a)
i->mon = bar->mon;
}
- XMoveResizeWindow(dpy, systray->win, bar->bx + a->x + lrpad / 2, (w ? bar->by + a->y : -bar->by - a->y), MAX(w, 1), a->h);
+ XMoveResizeWindow(dpy, systray->win, bar->bx + a->x + lrpad / 2, (w ? bar->by + a->y + (a->h - systray->h) / 2: -bar->by - a->y), MAX(w, 1), systray->h);
return w;
}
@@ -127,26 +128,26 @@ updatesystrayicongeom(Client *i, int w, int h)
if (!systray)
return;
- int bar_height = systray->bar->bh - 2 * systray->bar->borderpx;
+ int icon_height = systray->h;
if (i) {
- i->h = bar_height;
+ i->h = icon_height;
if (w == h)
- i->w = bar_height;
- else if (h == bar_height)
+ i->w = icon_height;
+ else if (h == icon_height)
i->w = w;
else
- i->w = (int) ((float)bar_height * ((float)w / (float)h));
+ i->w = (int) ((float)icon_height * ((float)w / (float)h));
applysizehints(i, &(i->x), &(i->y), &(i->w), &(i->h), False);
/* force icons into the systray dimensions if they don't want to */
- if (i->h > bar_height) {
+ if (i->h > icon_height) {
if (i->w == i->h)
- i->w = bar_height;
+ i->w = icon_height;
else
- i->w = (int) ((float)bar_height * ((float)i->w / (float)i->h));
- i->h = bar_height;
+ i->w = (int) ((float)icon_height * ((float)i->w / (float)i->h));
+ i->h = icon_height;
}
- if (i->w > 2 * bar_height)
- i->w = bar_height;
+ if (i->w > 2 * icon_height)
+ i->w = icon_height;
}
}