aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFuwn <[email protected]>2024-05-23 17:47:51 -0700
committerFuwn <[email protected]>2024-05-23 17:47:51 -0700
commit8cc9c1caf4141787cb80ec45e7f5d2d4b9689785 (patch)
treedfd4a42403ac7ae6e4e6445bd010f08a487c5927
parentci(github): integration workflow (diff)
downloadseiwm-8cc9c1caf4141787cb80ec45e7f5d2d4b9689785.tar.xz
seiwm-8cc9c1caf4141787cb80ec45e7f5d2d4b9689785.zip
feat(dwm.c): add bidi patch
-rw-r--r--dwm.c24
1 files changed, 21 insertions, 3 deletions
diff --git a/dwm.c b/dwm.c
index 14eb2d3..55ee36d 100644
--- a/dwm.c
+++ b/dwm.c
@@ -21,6 +21,7 @@
* To understand everything else, start reading main().
*/
#include <errno.h>
+#include <fribidi.h>
#include <locale.h>
#include <signal.h>
#include <stdarg.h>
@@ -225,6 +226,7 @@ struct Systray {
};
/* function declarations */
+static void apply_fribidi(char *str);
static void applyrules(Client *c);
static int applysizehints(Client *c, int *x, int *y, int *w, int *h, int interact);
static void arrange(Monitor *m);
@@ -367,6 +369,7 @@ static Systray *systray = NULL;
static Client *prevzoom = NULL;
static const char broken[] = "broken";
static char stext[256];
+static char fribidi_text[256];
static char rawstext[256];
static int dwmblockssig;
pid_t dwmblockspid = 0;
@@ -483,6 +486,21 @@ comboview(const Arg *arg) {
}
void
+apply_fribidi(char *str)
+{
+ FriBidiStrIndex len = strlen(str);
+ FriBidiChar logical[256];
+ FriBidiChar visual[256];
+ FriBidiParType base = FRIBIDI_PAR_ON;
+ FriBidiCharSet charset;
+
+ charset = fribidi_parse_charset("UTF-8");
+ len = fribidi_charset_to_unicode(charset, str, len, logical);
+ fribidi_log2vis(logical, len, &base, visual, NULL, NULL, NULL);
+ fribidi_unicode_to_charset(charset, visual, len, fribidi_text);
+}
+
+void
applyrules(Client *c)
{
const char *class, *instance;
@@ -1141,12 +1159,12 @@ drawbar(Monitor *m)
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 - 2 * sp, bh, lrpad / 2 + (m->sel->icon ? m->sel->icw + ICONSPACING : 0), m->sel->name, 0);
+ apply_fribidi(m->sel->name);
if (centretitle) {
tlpad = MAX((m->ww - ((int)TEXTW(m->sel->name) - lrpad)) / 2 - x, lrpad / 2 + (m->sel->icon ? m->sel->icw + ICONSPACING : 0));
- drw_text(drw, x, 0, w - 2 * sp, bh, tlpad, m->sel->name, 0);
+ drw_text(drw, x, 0, w - 2 * sp, bh, tlpad, fribidi_text, 0);
} else {
- drw_text(drw, x, 0, w - 2 * sp, bh, lrpad / 2 + (m->sel->icon ? m->sel->icw + ICONSPACING : 0), m->sel->name, 0);
+ drw_text(drw, x, 0, w - 2 * sp, bh, lrpad / 2 + (m->sel->icon ? m->sel->icw + ICONSPACING : 0), fribidi_text, 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)