summaryrefslogtreecommitdiff
path: root/dwm.c
diff options
context:
space:
mode:
authorMouad Alami <moadalami40@gmail.com>2023-09-12 15:42:32 +0100
committerMouad Alami <moadalami40@gmail.com>2023-09-12 15:42:32 +0100
commitac937caaec7921ff526b32594942ba16bf26159f (patch)
tree0064518c8a4b057649dba4708894c46f6cce42e9 /dwm.c
parentb0c17bbe25e022e3de907c7361e9d9883cd78ffd (diff)
added bidirectional patch
Diffstat (limited to 'dwm.c')
-rw-r--r--dwm.c21
1 files changed, 20 insertions, 1 deletions
diff --git a/dwm.c b/dwm.c
index 8ab1c33..9ff14bd 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>
@@ -145,6 +146,7 @@ typedef struct {
} Rule;
/* 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);
@@ -250,6 +252,7 @@ static void zoom(const Arg *arg);
static Client *prevzoom = NULL;
static const char broken[] = "broken";
static char stext[256];
+static char fribidi_text[256];
static int statusw;
static int statussig;
static pid_t statuspid = -1;
@@ -304,6 +307,21 @@ struct NumTags { char limitexceeded[LENGTH(tags) > 31 ? -1 : 1]; };
/* function implementations */
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;
@@ -820,7 +838,8 @@ drawbar(Monitor *m)
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 {