summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormoadAlami <moadalami40@gmail.com>2023-09-12 20:50:04 +0100
committermoadAlami <moadalami40@gmail.com>2023-09-12 20:50:04 +0100
commit252437668f46adf3e85fa0549ff679439e298c8f (patch)
treef8904acbe6bbc0b2a3aa389496d77f55d4f58234
parent6d95ff6f6cc7cc88df1dceb10e831a1b2f9a17ef (diff)
parent5793570a1979aaa2a4bba587277e89f47f13a534 (diff)
Merge branch 'patching' of github.com:moadAlami/dwm into patching
-rw-r--r--README2
-rw-r--r--config.h3
-rw-r--r--config.mk8
-rw-r--r--dwm.c56
4 files changed, 63 insertions, 6 deletions
diff --git a/README b/README
index eca7244..1f8294f 100644
--- a/README
+++ b/README
@@ -49,4 +49,4 @@ and (re)compiling the source code.
Patches applied
---------------
-zoomswap - scratchpad - sticky - statuscmd - pertag - noborder - movestack - hide vacant tags - actualfullscreen - bar height - alpha monocle layout
+zoomswap - scratchpad - sticky - statuscmd - pertag - noborder - movestack - hide vacant tags - actualfullscreen - bar height - alpha monocle layout - alternativetags - bidi
diff --git a/config.h b/config.h
index 976eb16..a42c67d 100644
--- a/config.h
+++ b/config.h
@@ -40,6 +40,8 @@ static const char *dec_bright[] = {
/* tagging */
static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" };
+static const char *tagsalt[] = { "", "", "", "", "", "", "", "", "" };
+static const int momentaryalttags = 1; /* 1 means alttags will show only when key is held down*/
static const Rule rules[] = {
/* xprop(1):
@@ -111,6 +113,7 @@ static const Key keys[] = {
{ MODKEY|ShiftMask, XK_0, tag, {.ui = ~0 } },
{ MODKEY, XK_comma, focusmon, {.i = -1 } },
{ MODKEY, XK_period, focusmon, {.i = +1 } },
+ { MODKEY, XK_n, togglealttag, {0} },
{ MODKEY|ShiftMask, XK_comma, tagmon, {.i = -1 } },
{ MODKEY|ShiftMask, XK_period, tagmon, {.i = +1 } },
{MODKEY, XK_s, togglesticky, {0}},
diff --git a/config.mk b/config.mk
index ba64d3d..64a4fdb 100644
--- a/config.mk
+++ b/config.mk
@@ -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
@@ -21,9 +23,11 @@ FREETYPEINC = /usr/include/freetype2
#FREETYPEINC = ${X11INC}/freetype2
#MANPREFIX = ${PREFIX}/man
+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_XOPEN_SOURCE=700L -DVERSION=\"${VERSION}\" ${XINERAMAFLAGS}
diff --git a/dwm.c b/dwm.c
index c10f57b..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>
@@ -132,6 +133,7 @@ struct Monitor {
Window barwin;
const Layout *lt[2];
Pertag *pertag;
+ unsigned int alttag;
};
typedef struct {
@@ -144,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);
@@ -181,6 +184,7 @@ static void grabbuttons(Client *c, int focused);
static void grabkeys(void);
static void incnmaster(const Arg *arg);
static void keypress(XEvent *e);
+static void keyrelease(XEvent *e);
static void killclient(const Arg *arg);
static void manage(Window w, XWindowAttributes *wa);
static void mappingnotify(XEvent *e);
@@ -215,6 +219,7 @@ static void spawn(const Arg *arg);
static void tag(const Arg *arg);
static void tagmon(const Arg *arg);
static void tile(Monitor *m);
+static void togglealttag(const Arg *arg);
static void togglebar(const Arg *arg);
static void togglefloating(const Arg *arg);
static void togglesticky(const Arg *arg);
@@ -247,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;
@@ -266,6 +272,7 @@ static void (*handler[LASTEvent]) (XEvent *) = {
[Expose] = expose,
[FocusIn] = focusin,
[KeyPress] = keypress,
+ [KeyRelease] = keyrelease,
[MappingNotify] = mappingnotify,
[MapRequest] = maprequest,
[MotionNotify] = motionnotify,
@@ -300,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;
@@ -762,7 +784,7 @@ dirtomon(int dir)
void
drawbar(Monitor *m)
{
- int x, w, tw = 0;
+ int x, w, wdelta, tw = 0;
int boxs = drw->fonts->h / 9;
int boxw = drw->fonts->h / 6 + 2;
unsigned int i, occ = 0, urg = 0;
@@ -804,8 +826,9 @@ drawbar(Monitor *m)
if(!(occ & 1 << i || m->tagset[m->seltags] & 1 << i))
continue;
w = TEXTW(tags[i]);
+ wdelta = selmon->alttag ? abs(TEXTW(tags[i]) - TEXTW(tagsalt[i])) / 2 : 0;
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, wdelta + lrpad / 2, (selmon->alttag ? tagsalt[i] : tags[i]), urg & 1 << i);
x += w;
}
w = TEXTW(m->ltsymbol);
@@ -815,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 {
@@ -1129,6 +1153,25 @@ keypress(XEvent *e)
}
void
+keyrelease(XEvent *e)
+{
+ unsigned int i;
+ KeySym keysym;
+ XKeyEvent *ev;
+
+ ev = &e->xkey;
+ keysym = XKeycodeToKeysym(dpy, (KeyCode)ev->keycode, 0);
+
+ for (i = 0; i < LENGTH(keys); i++)
+ if (momentaryalttags
+ && keys[i].func && keys[i].func == togglealttag
+ && selmon->alttag
+ && (keysym == keys[i].keysym
+ || CLEANMASK(keys[i].mod) == CLEANMASK(ev->state)))
+ keys[i].func(&(keys[i].arg));
+}
+
+void
killclient(const Arg *arg)
{
if (!selmon->sel)
@@ -1884,6 +1927,13 @@ tile(Monitor *m)
}
void
+togglealttag(const Arg *arg)
+{
+ selmon->alttag = !selmon->alttag;
+ drawbar(selmon);
+}
+
+void
togglebar(const Arg *arg)
{
selmon->showbar = selmon->pertag->showbars[selmon->pertag->curtag] = !selmon->showbar;