summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorbakkeby <[email protected]>2022-08-02 10:58:10 +0200
committerbakkeby <[email protected]>2022-08-02 10:58:10 +0200
commit4b20c92b4c7969472b31cf364ee081f58874f40a (patch)
tree47856d5cbaa56ac4106d16c58b61bf3be052b80f
parent2e496ed931b93c46ea89ee4f14f4c0ae2e68533f (diff)
downloaddwm-flexipatch-4b20c92b4c7969472b31cf364ee081f58874f40a.tar.gz
dwm-flexipatch-4b20c92b4c7969472b31cf364ee081f58874f40a.zip
Adding bidi patch ref. #285
-rw-r--r--README.md4
-rw-r--r--config.mk8
-rw-r--r--drw.c46
-rw-r--r--patches.def.h12
4 files changed, 62 insertions, 8 deletions
diff --git a/README.md b/README.md
index 6b9c7dc..29abf31 100644
--- a/README.md
+++ b/README.md
@@ -19,6 +19,7 @@ Browsing patches? There is a [map of patches](https://coggle.it/diagram/X9IiSSM6
### Changelog:
+2022-08-02 - Added the bidi patch
2022-07-05 - Added the tagpreview patch
@@ -287,6 +288,9 @@ Browsing patches? There is a [map of patches](https://coggle.it/diagram/X9IiSSM6
- [bartabgroups](https://dwm.suckless.org/patches/bartabgroups/)
- turns the titlebar area into a mfact-respecting tab-bar showing each client's title
+ - [bidi](https://dwm.suckless.org/patches/bidi/)
+ - adds proper support for Right-To-Left (RTL) languages (such as Farsi, Arabic or Hebrew)
+
- [center](https://dwm.suckless.org/patches/center/)
- adds an iscentered rule to automatically center clients on the current monitor
diff --git a/config.mk b/config.mk
index 8f662cd..eb1f2cf 100644
--- a/config.mk
+++ b/config.mk
@@ -51,9 +51,13 @@ FREETYPEINC = /usr/include/freetype2
# This is needed for the winicon and tagpreview patches / BAR_WINICON_PATCH / BAR_TAGPREVIEW_PATCH
#IMLIB2LIBS = -lImlib2
+# Uncomment for the bidi patch
+#BDINC = -I/usr/include/fribidi
+#BDLIBS = -lfribidi
+
# includes and libs
-INCS = -I${X11INC} -I${FREETYPEINC} ${YAJLINC} ${PANGOINC}
-LIBS = -L${X11LIB} -lX11 ${XINERAMALIBS} ${FREETYPELIBS} ${XRENDER} ${MPDCLIENT} ${XEXTLIB} ${XCBLIBS} ${KVMLIB} ${PANGOLIB} ${YAJLLIBS} ${IMLIB2LIBS}
+INCS = -I${X11INC} -I${FREETYPEINC} ${YAJLINC} ${PANGOINC} ${BDINC}
+LIBS = -L${X11LIB} -lX11 ${XINERAMALIBS} ${FREETYPELIBS} ${XRENDER} ${MPDCLIENT} ${XEXTLIB} ${XCBLIBS} ${KVMLIB} ${PANGOLIB} ${YAJLLIBS} ${IMLIB2LIBS} $(BDLIBS)
# flags
CPPFLAGS = -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_POSIX_C_SOURCE=200809L -DVERSION=\"${VERSION}\" ${XINERAMAFLAGS}
diff --git a/drw.c b/drw.c
index 1e53132..68dd015 100644
--- a/drw.c
+++ b/drw.c
@@ -9,6 +9,30 @@
#include "drw.h"
#include "util.h"
+#if BIDI_PATCH
+#include <fribidi.h>
+
+static char fribidi_text[BUFSIZ] = "";
+
+static void
+apply_fribidi(const char *str)
+{
+ FriBidiStrIndex len = strlen(str);
+ FriBidiChar logical[BUFSIZ];
+ FriBidiChar visual[BUFSIZ];
+ FriBidiParType base = FRIBIDI_PAR_ON;
+ FriBidiCharSet charset;
+
+ fribidi_text[0] = 0;
+ if (len > 0) {
+ charset = fribidi_parse_charset("UTF-8");
+ len = fribidi_charset_to_unicode(charset, str, len, logical);
+ fribidi_log2vis(logical, len, &base, visual, NULL, NULL, NULL);
+ len = fribidi_unicode_to_charset(charset, visual, len, fribidi_text);
+ }
+}
+#endif
+
#if !BAR_PANGO_PATCH
#define UTF_INVALID 0xFFFD
#define UTF_SIZ 4
@@ -394,10 +418,15 @@ drw_rect(Drw *drw, int x, int y, unsigned int w, unsigned int h, int filled, int
XDrawRectangle(drw->dpy, drw->drawable, drw->gc, x, y, w - 1, h - 1);
}
-#if BAR_PANGO_PATCH
+#if BIDI_PATCH
+int
+_drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lpad, const char *text, int invert, Bool markup)
+#else
int
drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lpad, const char *text, int invert, Bool markup)
+#endif // BIDI_PATCH
{
+#if BAR_PANGO_PATCH
char buf[1024];
int ty;
unsigned int ew;
@@ -458,11 +487,7 @@ drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lp
XftDrawDestroy(d);
return x + (render ? w : 0);
-}
#else
-int
-drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lpad, const char *text, int invert, Bool ignored)
-{
char buf[1024];
int ty;
unsigned int ew;
@@ -593,8 +618,17 @@ drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lp
XftDrawDestroy(d);
return x + (render ? w : 0);
-}
#endif // BAR_PANGO_PATCH
+}
+
+#if BIDI_PATCH
+int
+drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lpad, const char *text, int invert, Bool markup)
+{
+ apply_fribidi(text);
+ return _drw_text(drw, x, y, w, h, lpad, fribidi_text, invert, markup);
+}
+#endif // BIDI_PATCH
#if BAR_POWERLINE_TAGS_PATCH || BAR_POWERLINE_STATUS_PATCH
void
diff --git a/patches.def.h b/patches.def.h
index eec95f9..2338139 100644
--- a/patches.def.h
+++ b/patches.def.h
@@ -490,6 +490,18 @@
*/
#define AUTORESIZE_PATCH 0
+/* This patch adds proper support for Right-To-Left languages. (such as Farsi, Arabic or Hebrew).
+ *
+ * You need to uncomment the corresponding lines in config.mk to use the -lfribidi library
+ * when including this patch.
+ *
+ * This patch depends on the following additional library:
+ * - fribidi
+ *
+ * https://dwm.suckless.org/patches/bidi/
+ */
+#define BIDI_PATCH 0
+
/* This patch adds an iscentered rule to automatically center clients on the current monitor.
* This patch takes precedence over centeredwindowname, alwayscenter and fancybar patches.
* https://dwm.suckless.org/patches/center/