bakkeby / patches

Collection of patches for dwm, st and dmenu
285 stars 30 forks source link

picom + systray patch #59

Open devourers opened 1 year ago

devourers commented 1 year ago

systray 6.3 on dwm, other patches should not interfere. I have a following issue -- whenever system tray initializes it is completely black on one monitor and transparent on another. However, tray is working -- if I click on the black square with app icon -- menu pops up and its working. If kill picom -- tray appears, new icons appear, it is operational. And even if I restart picom it still works. So my issue is that on systray init picom somehow hides it -- is there a workaround?

bakkeby commented 1 year ago

Given that you are raising this under the patches repository I am assuming that you are maintaining your own build of dwm.

and transparent on another

Reading between the lines do you perhaps have the statusallmons patch? The systray is a window and X does not support drawing the same window in two places, so if you have it set to be included on every monitor then space will be reserved for the systray, but it can only exist in one place hence it would appear transparent on another as it is simply not there.

system tray initializes it is completely black on one monitor

I think that would likely be due to this known issue: https://github.com/bakkeby/dwm-flexipatch/discussions/136

devourers commented 1 year ago

No, I don't have statusallmons, and the workaround is simply to restart picom once tray is initialized, yeah. I was wondering if there is some permanent fix may be, but oh well. Thanks anyway!

bakkeby commented 1 year ago

There is a workaround for the black icon issue.

Can you show what your drawbar function looks like?

devourers commented 1 year ago

Here

void
drawbar(Monitor *m)
{
    int x, w, tw = 0, stw = 0;
    int boxs = drw->fonts->h / 9;
    int boxw = drw->fonts->h / 6 + 2;
    unsigned int i, occ = 0, urg = 0;
    Client *c;

    if (!m->showbar)
        return;

    if(showsystray && m == systraytomon(m) && !systrayonleft)
        stw = getsystraywidth();

    /* draw status first so it can be overdrawn by tags later */
    if (m == selmon) { /* status is only drawn on selected monitor */
        drw_setscheme(drw, scheme[SchemeNorm]);
        tw = TEXTW(stext) - lrpad / 2 + 2; /* 2px extra right padding */
        drw_text(drw, m->ww - tw - stw, 0, tw, bh, lrpad / 2 - 2, stext, 0);
    }

    resizebarwin(m);
    for (c = m->clients; c; c = c->next) {
        occ |= c->tags;
        if (c->isurgent)
            urg |= c->tags;
    }
    x = 0;
    for (i = 0; i < LENGTH(tags); i++) {
        w = TEXTW(tags[i]);
        drw_setscheme(drw, scheme[m->tagset[m->seltags] & 1 << i ? SchemeSel : SchemeNorm]);
        drw_text(drw, x, 0, w, bh, lrpad / 2, tags[i], urg & 1 << i);
        if (occ & 1 << i)
            drw_rect(drw, x + boxs, boxs, boxw, boxw,
                m == selmon && selmon->sel && selmon->sel->tags & 1 << i,
                urg & 1 << i);
        x += w;
    }
    w = TEXTW(m->ltsymbol);
    drw_setscheme(drw, scheme[SchemeNorm]);
    x = drw_text(drw, x, 0, w, bh, lrpad / 2, m->ltsymbol, 0);

    if ((w = m->ww - tw - stw - x) > bh) {
        if (m->sel) {
            drw_setscheme(drw, scheme[m == selmon ? SchemeSel : SchemeNorm]);
            drw_text(drw, x, 0, w, bh, lrpad / 2, m->sel->name, 0);
            if (m->sel->isfloating)
                drw_rect(drw, x + boxs, boxs, boxw, boxw, m->sel->isfixed, 0);
        } else {
            drw_setscheme(drw, scheme[SchemeNorm]);
            drw_rect(drw, x, 0, w, bh, 1, 1);
        }
    }
    drw_map(drw, m->barwin, 0, 0, m->ww - stw, bh);
}
bakkeby commented 1 year ago

That looks fine to me. I'd recommend trying the workaround of using a different font size or use other mechanisms for changing the initial size of systray icons.

N-R-K commented 1 year ago

Can you show how you are starting dwm?

For example, you are using xinitrc like the following:

cmd0 &
cmd1 &

exec dwm

Then there's no guarantee that cmd{0,1} will complete before dwm launches (it probably wouldn't). If you add a line with the command wait right before the exec dwm line, and it fixes the issue, then we've found the cause.