[wiki] [sites] [PATCH][dwm] Update dwm-bidi patch (statusbar fix) || MahdiMirzade

From: <git_AT_suckless.org>
Date: Wed, 09 Mar 2022 15:25:03 +0100

commit 5f811a8c21d7d0d7b5c9e6a2220f31ae4e0fb68e
Author: MahdiMirzade <me_AT_mahdym.ir>
Date: Wed Mar 9 17:53:42 2022 +0330

    [PATCH][dwm] Update dwm-bidi patch (statusbar fix)

diff --git a/dwm.suckless.org/patches/bidi/dwm-bidi-20220309-0386419.diff b/dwm.suckless.org/patches/bidi/dwm-bidi-20220309-0386419.diff
new file mode 100644
index 00000000..1d9be028
--- /dev/null
+++ b/dwm.suckless.org/patches/bidi/dwm-bidi-20220309-0386419.diff
_AT_@ -0,0 +1,132 @@
+From 0386419cfb5311d4a7516ece8f3f8fe923c43098 Mon Sep 17 00:00:00 2001
+From: MahdiMirzade <me_AT_mahdym.ir>
+Date: Wed, 9 Mar 2022 17:44:42 +0330
+Subject: [PATCH] [PATCH] Added support for RTL languages (Farsi, Arabic and
+ Hebrew using the FriBiDi library) - 9th Mar 2022 Fix
+
+---
+ config.mk | 8 ++++++--
+ dwm.c | 40 +++++++++++++++++++++++++++++++++-------
+ 2 files changed, 39 insertions(+), 9 deletions(-)
+
+diff --git a/config.mk b/config.mk
+index b6eb7e0..5b60a24 100644
+--- a/config.mk
++++ b/config.mk
+_AT_@ -10,6 +10,8 @@ MANPREFIX = ${PREFIX}/share/man
+ X11INC = /usr/X11R6/include
+ X11LIB = /usr/X11R6/lib
+
++BDINC = /usr/include/fribidi
++
+ # Xinerama, comment if you don't want it
+ XINERAMALIBS = -lXinerama
+ XINERAMAFLAGS = -DXINERAMA
+_AT_@ -20,9 +22,11 @@ FREETYPEINC = /usr/include/freetype2
+ # OpenBSD (uncomment)
+ #FREETYPEINC = ${X11INC}/freetype2
+
++BDLIBS = -lfribidi
++
+ # includes and libs
+-INCS = -I${X11INC} -I${FREETYPEINC}
+-LIBS = -L${X11LIB} -lX11 ${XINERAMALIBS} ${FREETYPELIBS}
++INCS = -I${X11INC} -I${FREETYPEINC} -I$(BDINC)
++LIBS = -L${X11LIB} -lX11 ${XINERAMALIBS} ${FREETYPELIBS} $(BDLIBS)
+
+ # flags
+ CPPFLAGS = -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_POSIX_C_SOURCE=200809L -DVERSION=\"${VERSION}\" ${XINERAMAFLAGS}
+diff --git a/dwm.c b/dwm.c
+index a96f33c..4f11fa0 100644
+--- a/dwm.c
++++ b/dwm.c
+_AT_@ -40,6 +40,7 @@
+ #include <X11/extensions/Xinerama.h>
+ #endif /* XINERAMA */
+ #include <X11/Xft/Xft.h>
++#include <fribidi.h>
+
+ #include "drw.h"
+ #include "util.h"
+_AT_@ -238,6 +239,7 @@ static void zoom(const Arg *arg);
+ /* variables */
+ static const char broken[] = "broken";
+ static char stext[256];
++static char fribidi_text[BUFSIZ] = "";
+ static int screen;
+ static int sw, sh; /* X display screen geometry width, height */
+ static int bh, blw = 0; /* bar geometry */
+_AT_@ -276,6 +278,26 @@ static Window root, wmcheckwin;
+ struct NumTags { char limitexceeded[LENGTH(tags) > 31 ? -1 : 1]; };
+
+ /* function implementations */
++static void
++apply_fribidi(char *str)
++{
++ FriBidiStrIndex len = strlen(str);
++ FriBidiChar logical[BUFSIZ];
++ FriBidiChar visual[BUFSIZ];
++ FriBidiParType base = FRIBIDI_PAR_ON;
++ FriBidiCharSet charset;
++ fribidi_boolean result;
++
++ fribidi_text[0] = 0;
++ if (len>0)
++ {
++ charset = fribidi_parse_charset("UTF-8");
++ len = fribidi_charset_to_unicode(charset, str, len, logical);
++ result = fribidi_log2vis(logical, len, &base, visual, NULL, NULL, NULL);
++ len = fribidi_unicode_to_charset(charset, visual, len, fribidi_text);
++ }
++}
++
+ void
+ applyrules(Client *c)
+ {
+_AT_@ -708,8 +730,9 @@ drawbar(Monitor *m)
+ /* 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; /* 2px right padding */
+- drw_text(drw, m->ww - tw, 0, tw, bh, 0, stext, 0);
++ apply_fribidi(stext);
++ tw = TEXTW(fribidi_text) - lrpad + 2; /* 2px right padding */
++ drw_text(drw, m->ww - tw, 0, tw, bh, 0, fribidi_text, 0);
+ }
+
+ for (c = m->clients; c; c = c->next) {
+_AT_@ -719,23 +742,26 @@ drawbar(Monitor *m)
+ }
+ x = 0;
+ for (i = 0; i < LENGTH(tags); i++) {
+- w = TEXTW(tags[i]);
++ apply_fribidi(tags[i]);
++ w = TEXTW(fribidi_text);
+ 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);
++ drw_text(drw, x, 0, w, bh, lrpad / 2, fribidi_text, 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);
++ apply_fribidi(m->ltsymbol);
++ w = blw = TEXTW(fribidi_text);
+ drw_setscheme(drw, scheme[SchemeNorm]);
+- x = drw_text(drw, x, 0, w, bh, lrpad / 2, m->ltsymbol, 0);
++ x = drw_text(drw, x, 0, w, bh, lrpad / 2, fribidi_text, 0);
+
+ if ((w = m->ww - tw - 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);
++ apply_fribidi(m->sel->name);
++ drw_text(drw, x, 0, w, bh, lrpad / 2, fribidi_text, 0);
+ if (m->sel->isfloating)
+ drw_rect(drw, x + boxs, boxs, boxw, boxw, m->sel->isfixed, 0);
+ } else {
+--
+2.35.1
+
diff --git a/dwm.suckless.org/patches/bidi/index.md b/dwm.suckless.org/patches/bidi/index.md
index e77d450e..0b32b843 100644
--- a/dwm.suckless.org/patches/bidi/index.md
+++ b/dwm.suckless.org/patches/bidi/index.md
_AT_@ -17,7 +17,8 @@ with dwm-bidi:
 
 Download
 --------
-* [dwm-bidi-20220219-302953a.diff](dwm-bidi-20220219-302953a.diff)
+* [dwm-bidi-20220309-0386419.diff](dwm-bidi-20220309-0386419.diff)
+* [dwm-bidi-20220219-302953a.diff](dwm-bidi-20220219-302953a.diff) (old)
 
 Authors
 -------
Received on Wed Mar 09 2022 - 15:25:03 CET

This archive was generated by hypermail 2.3.0 : Wed Mar 09 2022 - 15:36:50 CET