final patches

This commit is contained in:
2023-02-24 23:36:26 +01:00
parent 7b5c3087d5
commit 0460885e55
8 changed files with 577 additions and 503 deletions

View File

@@ -1,100 +0,0 @@
diff -up b/dwm.c a/dwm.c
--- b/dwm.c 2020-07-05 16:05:02.555947738 -0300
+++ a/dwm.c 2020-07-05 16:06:19.592609932 -0300
@@ -49,7 +49,8 @@
#define CLEANMASK(mask) (mask & ~(numlockmask|LockMask) & (ShiftMask|ControlMask|Mod1Mask|Mod2Mask|Mod3Mask|Mod4Mask|Mod5Mask))
#define INTERSECT(x,y,w,h,m) (MAX(0, MIN((x)+(w),(m)->wx+(m)->ww) - MAX((x),(m)->wx)) \
* MAX(0, MIN((y)+(h),(m)->wy+(m)->wh) - MAX((y),(m)->wy)))
-#define ISVISIBLE(C) ((C->tags & C->mon->tagset[C->mon->seltags]))
+#define ISVISIBLEONTAG(C, T) ((C->tags & T))
+#define ISVISIBLE(C) ISVISIBLEONTAG(C, C->mon->tagset[C->mon->seltags])
#define LENGTH(X) (sizeof X / sizeof X[0])
#define MOUSEMASK (BUTTONMASK|PointerMotionMask)
#define WIDTH(X) ((X)->w + 2 * (X)->bw)
@@ -147,6 +148,7 @@ static int applysizehints(Client *c, int
static void arrange(Monitor *m);
static void arrangemon(Monitor *m);
static void attach(Client *c);
+static void attachBelow(Client *c);
static void attachstack(Client *c);
static void buttonpress(XEvent *e);
static void checkotherwm(void);
@@ -184,6 +186,7 @@ static void maprequest(XEvent *e);
static void monocle(Monitor *m);
static void motionnotify(XEvent *e);
static void movemouse(const Arg *arg);
+static Client *nexttagged(Client *c);
static Client *nexttiled(Client *c);
static void pop(Client *);
static void propertynotify(XEvent *e);
@@ -406,6 +409,27 @@ attach(Client *c)
c->next = c->mon->clients;
c->mon->clients = c;
}
+void
+attachBelow(Client *c)
+{
+ //If there is nothing on the monitor or the selected client is floating, attach as normal
+ if(c->mon->sel == NULL || c->mon->sel->isfloating) {
+ Client *at = nexttagged(c);
+ if(!at) {
+ attach(c);
+ return;
+ }
+ c->next = at->next;
+ at->next = c;
+ return;
+ }
+
+ //Set the new client's next property to the same as the currently selected clients next
+ c->next = c->mon->sel->next;
+ //Set the currently selected clients next property to the new client
+ c->mon->sel->next = c;
+
+}
void
attachstack(Client *c)
@@ -1063,7 +1087,7 @@ manage(Window w, XWindowAttributes *wa)
c->isfloating = c->oldstate = trans != None || c->isfixed;
if (c->isfloating)
XRaiseWindow(dpy, c->win);
- attach(c);
+ attachBelow(c);
attachstack(c);
XChangeProperty(dpy, root, netatom[NetClientList], XA_WINDOW, 32, PropModeAppend,
(unsigned char *) &(c->win), 1);
@@ -1193,6 +1217,16 @@ movemouse(const Arg *arg)
}
}
+ Client *
+nexttagged(Client *c) {
+ Client *walked = c->mon->clients;
+ for(;
+ walked && (walked->isfloating || !ISVISIBLEONTAG(walked, c->tags));
+ walked = walked->next
+ );
+ return walked;
+}
+
Client *
nexttiled(Client *c)
{
@@ -1418,7 +1452,7 @@ sendmon(Client *c, Monitor *m)
detachstack(c);
c->mon = m;
c->tags = m->tagset[m->seltags]; /* assign tags of target monitor */
- attach(c);
+ attachBelow(c);
attachstack(c);
focus(NULL);
arrange(NULL);
@@ -1901,6 +1935,7 @@ updategeom(void)
detachstack(c);
c->mon = mons;
attach(c);
+ attachBelow(c);
attachstack(c);
}
if (m == selmon)

View File

@@ -1,166 +0,0 @@
diff --git a/dwm.c b/dwm.c
index a96f33c..24b1eeb 100644
--- a/dwm.c
+++ b/dwm.c
@@ -163,6 +163,7 @@ static void detachstack(Client *c);
static Monitor *dirtomon(int dir);
static void drawbar(Monitor *m);
static void drawbars(void);
+static int drawstatusbar(Monitor *m, int bh, char* text);
static void enternotify(XEvent *e);
static void expose(XEvent *e);
static void focus(Client *c);
@@ -237,7 +238,7 @@ static void zoom(const Arg *arg);
/* variables */
static const char broken[] = "broken";
-static char stext[256];
+static char stext[1024];
static int screen;
static int sw, sh; /* X display screen geometry width, height */
static int bh, blw = 0; /* bar geometry */
@@ -485,7 +486,7 @@ cleanup(void)
cleanupmon(mons);
for (i = 0; i < CurLast; i++)
drw_cur_free(drw, cursor[i]);
- for (i = 0; i < LENGTH(colors); i++)
+ for (i = 0; i < LENGTH(colors) + 1; i++)
free(scheme[i]);
XDestroyWindow(dpy, wmcheckwin);
drw_free(drw);
@@ -693,6 +694,114 @@ dirtomon(int dir)
return m;
}
+int
+drawstatusbar(Monitor *m, int bh, char* stext) {
+ int ret, i, w, x, len;
+ short isCode = 0;
+ char *text;
+ char *p;
+
+ len = strlen(stext) + 1 ;
+ if (!(text = (char*) malloc(sizeof(char)*len)))
+ die("malloc");
+ p = text;
+ memcpy(text, stext, len);
+
+ /* compute width of the status text */
+ w = 0;
+ i = -1;
+ while (text[++i]) {
+ if (text[i] == '^') {
+ if (!isCode) {
+ isCode = 1;
+ text[i] = '\0';
+ w += TEXTW(text) - lrpad;
+ text[i] = '^';
+ if (text[++i] == 'f')
+ w += atoi(text + ++i);
+ } else {
+ isCode = 0;
+ text = text + i + 1;
+ i = -1;
+ }
+ }
+ }
+ if (!isCode)
+ w += TEXTW(text) - lrpad;
+ else
+ isCode = 0;
+ text = p;
+
+ w += 2; /* 1px padding on both sides */
+ ret = x = m->ww - w;
+
+ drw_setscheme(drw, scheme[LENGTH(colors)]);
+ drw->scheme[ColFg] = scheme[SchemeNorm][ColFg];
+ drw->scheme[ColBg] = scheme[SchemeNorm][ColBg];
+ drw_rect(drw, x, 0, w, bh, 1, 1);
+ x++;
+
+ /* process status text */
+ i = -1;
+ while (text[++i]) {
+ if (text[i] == '^' && !isCode) {
+ isCode = 1;
+
+ text[i] = '\0';
+ w = TEXTW(text) - lrpad;
+ drw_text(drw, x, 0, w, bh, 0, text, 0);
+
+ x += w;
+
+ /* process code */
+ while (text[++i] != '^') {
+ if (text[i] == 'c') {
+ char buf[8];
+ memcpy(buf, (char*)text+i+1, 7);
+ buf[7] = '\0';
+ drw_clr_create(drw, &drw->scheme[ColFg], buf);
+ i += 7;
+ } else if (text[i] == 'b') {
+ char buf[8];
+ memcpy(buf, (char*)text+i+1, 7);
+ buf[7] = '\0';
+ drw_clr_create(drw, &drw->scheme[ColBg], buf);
+ i += 7;
+ } else if (text[i] == 'd') {
+ drw->scheme[ColFg] = scheme[SchemeNorm][ColFg];
+ drw->scheme[ColBg] = scheme[SchemeNorm][ColBg];
+ } else if (text[i] == 'r') {
+ int rx = atoi(text + ++i);
+ while (text[++i] != ',');
+ int ry = atoi(text + ++i);
+ while (text[++i] != ',');
+ int rw = atoi(text + ++i);
+ while (text[++i] != ',');
+ int rh = atoi(text + ++i);
+
+ drw_rect(drw, rx + x, ry, rw, rh, 1, 0);
+ } else if (text[i] == 'f') {
+ x += atoi(text + ++i);
+ }
+ }
+
+ text = text + i + 1;
+ i=-1;
+ isCode = 0;
+ }
+ }
+
+ if (!isCode) {
+ w = TEXTW(text) - lrpad;
+ drw_text(drw, x, 0, w, bh, 0, text, 0);
+ }
+
+ drw_setscheme(drw, scheme[SchemeNorm]);
+ free(p);
+
+ return ret;
+}
+
void
drawbar(Monitor *m)
{
@@ -707,9 +816,7 @@ 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);
+ tw = m->ww - drawstatusbar(m, bh, stext);
}
for (c = m->clients; c; c = c->next) {
@@ -1571,7 +1678,8 @@ setup(void)
cursor[CurResize] = drw_cur_create(drw, XC_sizing);
cursor[CurMove] = drw_cur_create(drw, XC_fleur);
/* init appearance */
- scheme = ecalloc(LENGTH(colors), sizeof(Clr *));
+ scheme = ecalloc(LENGTH(colors) + 1, sizeof(Clr *));
+ scheme[LENGTH(colors)] = drw_scm_create(drw, colors[0], 3);
for (i = 0; i < LENGTH(colors); i++)
scheme[i] = drw_scm_create(drw, colors[i], 3);
/* init bars */

View File

@@ -1,100 +0,0 @@
From bd7dd6d06e8b8c9dd6b595b2ce5f6e88b9565311 Mon Sep 17 00:00:00 2001
From: tdu <tdukv@protonmail.com>
Date: Wed, 26 Aug 2020 21:26:21 +0300
Subject: [PATCH] Use the 16 terminal colors from xrdb for status2d.
^C<num>^ - fg.
^B<num>^ - bg.
---
config.def.h | 34 ++++++++++++++++++++++++++++++++++
dwm.c | 22 ++++++++++++++++++++++
2 files changed, 56 insertions(+)
diff --git a/config.def.h b/config.def.h
index 5db7d05..46bc6fe 100644
--- a/config.def.h
+++ b/config.def.h
@@ -13,6 +13,40 @@ static char normfgcolor[] = "#bbbbbb";
static char selfgcolor[] = "#eeeeee";
static char selbordercolor[] = "#005577";
static char selbgcolor[] = "#005577";
+static char termcol0[] = "#000000"; /* black */
+static char termcol1[] = "#ff0000"; /* red */
+static char termcol2[] = "#33ff00"; /* green */
+static char termcol3[] = "#ff0099"; /* yellow */
+static char termcol4[] = "#0066ff"; /* blue */
+static char termcol5[] = "#cc00ff"; /* magenta */
+static char termcol6[] = "#00ffff"; /* cyan */
+static char termcol7[] = "#d0d0d0"; /* white */
+static char termcol8[] = "#808080"; /* black */
+static char termcol9[] = "#ff0000"; /* red */
+static char termcol10[] = "#33ff00"; /* green */
+static char termcol11[] = "#ff0099"; /* yellow */
+static char termcol12[] = "#0066ff"; /* blue */
+static char termcol13[] = "#cc00ff"; /* magenta */
+static char termcol14[] = "#00ffff"; /* cyan */
+static char termcol15[] = "#ffffff"; /* white */
+static char *termcolor[] = {
+ termcol0,
+ termcol1,
+ termcol2,
+ termcol3,
+ termcol4,
+ termcol5,
+ termcol6,
+ termcol7,
+ termcol8,
+ termcol9,
+ termcol10,
+ termcol11,
+ termcol12,
+ termcol13,
+ termcol14,
+ termcol15,
+};
static char *colors[][3] = {
/* fg bg border */
[SchemeNorm] = { normfgcolor, normbgcolor, normbordercolor },
diff --git a/dwm.c b/dwm.c
index 87547f0..601dc1d 100644
--- a/dwm.c
+++ b/dwm.c
@@ -784,6 +784,12 @@ drawstatusbar(Monitor *m, int bh, char* stext) {
buf[7] = '\0';
drw_clr_create(drw, &drw->scheme[ColBg], buf);
i += 7;
+ } else if (text[i] == 'C') {
+ int c = atoi(text + ++i);
+ drw_clr_create(drw, &drw->scheme[ColFg], termcolor[c]);
+ } else if (text[i] == 'B') {
+ int c = atoi(text + ++i);
+ drw_clr_create(drw, &drw->scheme[ColBg], termcolor[c]);
} else if (text[i] == 'd') {
drw->scheme[ColFg] = scheme[SchemeNorm][ColFg];
drw->scheme[ColBg] = scheme[SchemeNorm][ColBg];
@@ -1163,6 +1169,22 @@ loadxrdb()
XRDB_LOAD_COLOR("dwm.selbordercolor", selbordercolor);
XRDB_LOAD_COLOR("dwm.selbgcolor", selbgcolor);
XRDB_LOAD_COLOR("dwm.selfgcolor", selfgcolor);
+ XRDB_LOAD_COLOR("color0", termcol0);
+ XRDB_LOAD_COLOR("color1", termcol1);
+ XRDB_LOAD_COLOR("color2", termcol2);
+ XRDB_LOAD_COLOR("color3", termcol3);
+ XRDB_LOAD_COLOR("color4", termcol4);
+ XRDB_LOAD_COLOR("color5", termcol5);
+ XRDB_LOAD_COLOR("color6", termcol6);
+ XRDB_LOAD_COLOR("color7", termcol7);
+ XRDB_LOAD_COLOR("color8", termcol8);
+ XRDB_LOAD_COLOR("color9", termcol9);
+ XRDB_LOAD_COLOR("color10", termcol10);
+ XRDB_LOAD_COLOR("color11", termcol11);
+ XRDB_LOAD_COLOR("color12", termcol12);
+ XRDB_LOAD_COLOR("color13", termcol13);
+ XRDB_LOAD_COLOR("color14", termcol14);
+ XRDB_LOAD_COLOR("color15", termcol15);
}
}
}
--
2.28.0