mirror of
https://github.com/eRgo35/dots.git
synced 2025-12-16 15:36:11 +01:00
final patches
This commit is contained in:
183
dwm/.dwm/dwm.c
183
dwm/.dwm/dwm.c
@@ -52,7 +52,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 HIDDEN(C) ((getstate(C->win) == IconicState))
|
||||
#define LENGTH(X) (sizeof X / sizeof X[0])
|
||||
#define MOUSEMASK (BUTTONMASK|PointerMotionMask)
|
||||
@@ -178,6 +179,7 @@ static int applysizehints(Client *c, int *x, int *y, int *w, int *h, int interac
|
||||
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 compileregexes(void);
|
||||
@@ -197,6 +199,7 @@ static void drawbar(Monitor *m);
|
||||
static void drawbars(void);
|
||||
static void drawtab(Monitor *m);
|
||||
static void drawtabs(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);
|
||||
@@ -224,6 +227,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 *c);
|
||||
static void propertynotify(XEvent *e);
|
||||
@@ -293,7 +297,7 @@ static const char autostartsh[] = "autostart.sh";
|
||||
static const char broken[] = "broken";
|
||||
static const char dwmdir[] = "dwm";
|
||||
static const char localshare[] = ".local/share";
|
||||
static char stext[256];
|
||||
static char stext[1024];
|
||||
static int screen;
|
||||
static int sw, sh; /* X display screen geometry width, height */
|
||||
static int bh; /* bar height */
|
||||
@@ -474,6 +478,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)
|
||||
@@ -587,7 +612,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]);
|
||||
free(scheme);
|
||||
XDestroyWindow(dpy, wmcheckwin);
|
||||
@@ -833,6 +858,120 @@ 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] == '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];
|
||||
} 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)
|
||||
{
|
||||
@@ -847,9 +986,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) {
|
||||
@@ -1389,6 +1526,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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1450,7 +1603,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);
|
||||
@@ -1580,6 +1733,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)
|
||||
{
|
||||
@@ -1920,7 +2083,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);
|
||||
@@ -2094,7 +2257,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 */
|
||||
@@ -2543,6 +2707,7 @@ updategeom(void)
|
||||
detachstack(c);
|
||||
c->mon = mons;
|
||||
attach(c);
|
||||
attachBelow(c);
|
||||
attachstack(c);
|
||||
}
|
||||
if (m == selmon)
|
||||
|
||||
Reference in New Issue
Block a user