diff --git a/config.def.h b/config.def.h index af32234..201c1fb 100644 --- a/config.def.h +++ b/config.def.h @@ -549,13 +549,13 @@ static const BarRule barrules[] = { { -1, 0, BAR_ALIGN_LEFT, width_stbutton, draw_stbutton, click_stbutton, NULL, "statusbutton" }, #endif // BAR_STATUSBUTTON_PATCH #if BAR_POWERLINE_TAGS_PATCH - { 0, 0, BAR_ALIGN_LEFT, width_pwrl_tags, draw_pwrl_tags, click_pwrl_tags, NULL, "powerline_tags" }, + { 0, 0, BAR_ALIGN_LEFT, width_pwrl_tags, draw_pwrl_tags, click_pwrl_tags, hover_pwrl_tags, "powerline_tags" }, #endif // BAR_POWERLINE_TAGS_PATCH #if BAR_TAGS_PATCH { -1, 0, BAR_ALIGN_LEFT, width_tags, draw_tags, click_tags, hover_tags, "tags" }, #endif // BAR_TAGS_PATCH #if BAR_TAGLABELS_PATCH - { -1, 0, BAR_ALIGN_LEFT, width_taglabels, draw_taglabels, click_taglabels, NULL, "taglabels" }, + { -1, 0, BAR_ALIGN_LEFT, width_taglabels, draw_taglabels, click_taglabels, hover_taglabels, "taglabels" }, #endif // BAR_TAGLABELS_PATCH #if BAR_TAGGRID_PATCH { -1, 0, BAR_ALIGN_LEFT, width_taggrid, draw_taggrid, click_taggrid, NULL, "taggrid" }, diff --git a/patch/bar_powerline_tags.c b/patch/bar_powerline_tags.c index d5ad787..0987c9b 100644 --- a/patch/bar_powerline_tags.c +++ b/patch/bar_powerline_tags.c @@ -105,3 +105,57 @@ click_pwrl_tags(Bar *bar, Arg *arg, BarArg *a) return ClkTagBar; } +int +hover_pwrl_tags(Bar *bar, BarArg *a, XMotionEvent *ev) +{ + #if BAR_TAGPREVIEW_PATCH + int i = 0, x = lrpad / 2; + int px, py; + int plw = drw->fonts->h / 2 + 1; + Monitor *m = bar->mon; + #if VANITYGAPS_PATCH + int ov = gappov; + int oh = gappoh; + #else + int ov = 0; + int oh = 0; + #endif // VANITYGAPS_PATCH + + #if BAR_HIDEVACANTTAGS_PATCH + Client *c; + unsigned int occ = 0; + for (c = bar->mon->clients; c; c = c->next) + occ |= c->tags == 255 ? 0 : c->tags; + #endif // BAR_HIDEVACANTTAGS_PATCH + + do { + #if BAR_HIDEVACANTTAGS_PATCH + if (!(occ & 1 << i || bar->mon->tagset[bar->mon->seltags] & 1 << i)) + continue; + #endif // BAR_HIDEVACANTTAGS_PATCH + x += TEXTW(tagicon(bar->mon, i)) + plw; + } while (a->x >= x && ++i < NUMTAGS); + + if (i < NUMTAGS) { + if ((i + 1) != selmon->previewshow && !(selmon->tagset[selmon->seltags] & 1 << i)) { + if (bar->by > m->my + m->mh / 2) // bottom bar + py = bar->by - m->mh / scalepreview - oh; + else // top bar + py = bar->by + bar->bh + oh; + px = bar->bx + ev->x - m->mw / scalepreview / 2; + if (px + m->mw / scalepreview > m->mx + m->mw) + px = m->wx + m->ww - m->mw / scalepreview - ov; + else if (px < bar->bx) + px = m->wx + ov; + selmon->previewshow = i + 1; + showtagpreview(i, px, py); + } else if (selmon->tagset[selmon->seltags] & 1 << i) { + hidetagpreview(selmon); + } + } else if (selmon->previewshow != 0) { + hidetagpreview(selmon); + } + #endif // BAR_TAGPREVIEW_PATCH + + return 1; +} diff --git a/patch/bar_powerline_tags.h b/patch/bar_powerline_tags.h index a51dcc7..b0838a6 100644 --- a/patch/bar_powerline_tags.h +++ b/patch/bar_powerline_tags.h @@ -1,4 +1,4 @@ static int width_pwrl_tags(Bar *bar, BarArg *a); static int draw_pwrl_tags(Bar *bar, BarArg *a); static int click_pwrl_tags(Bar *bar, Arg *arg, BarArg *a); - +static int hover_pwrl_tags(Bar *bar, BarArg *a, XMotionEvent *ev); diff --git a/patch/bar_taglabels.c b/patch/bar_taglabels.c index 9e6d441..cf1b762 100644 --- a/patch/bar_taglabels.c +++ b/patch/bar_taglabels.c @@ -89,3 +89,48 @@ click_taglabels(Bar *bar, Arg *arg, BarArg *a) } return ClkTagBar; } + +int +hover_taglabels(Bar *bar, BarArg *a, XMotionEvent *ev) +{ + #if BAR_TAGPREVIEW_PATCH + int i = 0, x = lrpad / 2; + int px, py; + Monitor *m = bar->mon; + #if VANITYGAPS_PATCH + int ov = gappov; + int oh = gappoh; + #else + int ov = 0; + int oh = 0; + #endif // VANITYGAPS_PATCH + + do { + if (!m->taglabel[i][0]) + continue; + x += TEXTW(m->taglabel[i]); + } while (a->x >= x && ++i < NUMTAGS); + + if (i < NUMTAGS) { + if ((i + 1) != selmon->previewshow && !(selmon->tagset[selmon->seltags] & 1 << i)) { + if (bar->by > m->my + m->mh / 2) // bottom bar + py = bar->by - m->mh / scalepreview - oh; + else // top bar + py = bar->by + bar->bh + oh; + px = bar->bx + ev->x - m->mw / scalepreview / 2; + if (px + m->mw / scalepreview > m->mx + m->mw) + px = m->wx + m->ww - m->mw / scalepreview - ov; + else if (px < bar->bx) + px = m->wx + ov; + selmon->previewshow = i + 1; + showtagpreview(i, px, py); + } else if (selmon->tagset[selmon->seltags] & 1 << i) { + hidetagpreview(selmon); + } + } else if (selmon->previewshow != 0) { + hidetagpreview(selmon); + } + #endif // BAR_TAGPREVIEW_PATCH + + return 1; +} diff --git a/patch/bar_taglabels.h b/patch/bar_taglabels.h index 57250f9..61b5aa0 100644 --- a/patch/bar_taglabels.h +++ b/patch/bar_taglabels.h @@ -2,4 +2,5 @@ static int width_taglabels(Bar *bar, BarArg *a); static int draw_taglabels(Bar *bar, BarArg *a); -static int click_taglabels(Bar *bar, Arg *arg, BarArg *a); \ No newline at end of file +static int click_taglabels(Bar *bar, Arg *arg, BarArg *a); +static int hover_taglabels(Bar *bar, BarArg *a, XMotionEvent *ev);