Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

awesomebar, alpha, systray, winicon #2

Closed
kaykay38 opened this issue Oct 20, 2021 · 3 comments
Closed

awesomebar, alpha, systray, winicon #2

kaykay38 opened this issue Oct 20, 2021 · 3 comments

Comments

@kaykay38
Copy link

kaykay38 commented Oct 20, 2021

Hi Adam,

I am trying to figure out how to patch winicon with awesomebar, alpha, and systray. Here is my code for drawbar which is where the main conflict is.

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

	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]);
		sw = TEXTW(stext) - lrpad + 2; /* 2px right padding */
		drw_text(drw, m->ww - sw - stw, 0, sw, bh, 0, stext, 0);
	}

	for (c = m->clients; c; c = c->next) {
		if (ISVISIBLE(c))
			n++;
		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 = blw = 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 - sw - stw - x) > bh) {
		if (n > 0) {
			int remainder = w % n;
			int tabw = (1.0 / (double)n) * w + 1;
			for (c = m->clients; c; c = c->next) {
				if (!ISVISIBLE(c))
					continue;
				if (m->sel == c)
					scm = SchemeSel;
				else if (HIDDEN(c))
					scm = SchemeHid;
				else
					scm = SchemeNorm;
				drw_setscheme(drw, scheme[scm]);

				if (remainder >= 0) {
					if (remainder == 0) {
						tabw--;
					}
					remainder--;
				}
				drw_text(drw, x, 0, tabw, bh, lrpad / 2, c->name, 0);
				x += tabw;
			}
		} else {
			drw_setscheme(drw, scheme[SchemeNorm]);
			drw_rect(drw, x, 0, w, bh, 1, 1);
		}
	}

	m->bt = n;
	m->btw = w;
	drw_map(drw, m->barwin, 0, 0, m->ww - stw, bh);
}

Here is the diff dwm.c.rej

 	if ((w = m->ww - sw - 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);
+			drw_text(drw, x, 0, w, bh, lrpad / 2 + (m->sel->icon ? m->sel->icw + ICONSPACING : 0), m->sel->name, 0);
+			if (m->sel->icon) drw_pic(drw, x + lrpad / 2, (bh - m->sel->ich) / 2, m->sel->icw, m->sel->ich, m->sel->icon);
 			if (m->sel->isfloating)
 				drw_rect(drw, x + boxs, boxs, boxw, boxw, m->sel->isfixed, 0);
 		} else {
@kaykay38 kaykay38 changed the title awesomebar, alpha, winicon awesomebar, alpha, systray, winicon Oct 20, 2021
@AdamYuan
Copy link
Owner

change line 62 in your drawbar function :

				drw_text(drw, x, 0, tabw, bh, lrpad / 2, c->name, 0);

to

				drw_text(drw, x, 0, tabw, bh, lrpad / 2 + (c->icon ? c->icw + ICONSPACING : 0), c->name, 0);
				if (c->icon) drw_pic(drw, x + lrpad / 2, (bh - c->ich) / 2, c->icw, c->ich, c->icon);

should work

@AdamYuan
Copy link
Owner

AdamYuan commented Oct 21, 2021

As for alpha patch, just apply the modifications in README, or crashes will occur.

@AdamYuan AdamYuan pinned this issue Oct 21, 2021
@AdamYuan AdamYuan unpinned this issue Oct 21, 2021
@kaykay38
Copy link
Author

@AdamYuan Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants