[wiki] [sites] Add DWM patch status2d || Clément SIPIETER

From: <git_AT_suckless.org>
Date: Wed, 17 Dec 2014 22:43:57 +0100

commit 2e1e98083a8e115a6dba752ff438f3be4b57d23f
Author: Clément SIPIETER <clement_AT_6pi.fr>
Date: Wed Dec 17 22:43:43 2014 +0100

    Add DWM patch status2d

diff --git a/dwm.suckless.org/patches/dwm-r35db6d-status2d.diff b/dwm.suckless.org/patches/dwm-r35db6d-status2d.diff
new file mode 100644
index 0000000..fde84dc
--- /dev/null
+++ b/dwm.suckless.org/patches/dwm-r35db6d-status2d.diff
_AT_@ -0,0 +1,201 @@
+diff --git a/drw.c b/drw.c
+index b130405..6dcb25d 100644
+--- a/drw.c
++++ b/drw.c
+_AT_@ -224,3 +224,34 @@ drw_cur_free(Drw *drw, Cur *cursor) {
+ XFreeCursor(drw->dpy, cursor->cursor);
+ free(cursor);
+ }
++
++void
++x_set_color(Drw *drw, Clr *color) {
++ XSetForeground(drw->dpy, drw->gc, color->rgb);
++}
++
++void
++x_drw_rect(Drw *drw, int x, int y, unsigned int w, unsigned int h) {
++ XFillRectangle(drw->dpy, drw->drawable, drw->gc, x, y, w, h);
++}
++
++void
++x_drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, const char *text) {
++ char buf[256];
++ int ty, len, olen;
++ Extnts tex;
++
++ olen = strlen(text);
++ drw_font_getexts(drw->font, text, olen, &tex);
++ ty = y + (h / 2) - (tex.h / 2) + drw->font->ascent;
++
++ len = MIN(olen, sizeof buf);
++ if(!len)
++ return;
++
++ memcpy(buf, text, len);
++ if(drw->font->set)
++ XmbDrawString(drw->dpy, drw->drawable, drw->font->set, drw->gc, x, ty, buf, len);
++ else
++ XDrawString(drw->dpy, drw->drawable, drw->gc, x, ty, buf, len);
++}
+diff --git a/drw.h b/drw.h
+index a5f34e0..e42b897 100644
+--- a/drw.h
++++ b/drw.h
+_AT_@ -38,6 +38,7 @@ typedef struct {
+ unsigned int h;
+ } Extnts;
+
++
+ /* Drawable abstraction */
+ Drw *drw_create(Display *dpy, int screen, Window win, unsigned int w, unsigned int h);
+ void drw_resize(Drw *drw, unsigned int w, unsigned int h);
+_AT_@ -67,3 +68,8 @@ void drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, const char
+
+ /* Map functions */
+ void drw_map(Drw *drw, Window win, int x, int y, unsigned int w, unsigned int h);
++
++/* X Basic call */
++void x_set_color(Drw *drw, Clr *color);
++void x_drw_rect(Drw *drw, int x, int y, unsigned int w, unsigned int h);
++void x_drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, const char *text);
+\ No newline at end of file
+diff --git a/dwm.c b/dwm.c
+index f896170..356394d 100644
+--- a/dwm.c
++++ b/dwm.c
+_AT_@ -162,6 +162,7 @@ static void detach(Client *c);
+ static void detachstack(Client *c);
+ static Monitor *dirtomon(int dir);
+ static void drawbar(Monitor *m);
++static int drawstatusbar(Monitor *m, int bh, char* text, int xx);
+ static void drawbars(void);
+ static void enternotify(XEvent *e);
+ static void expose(XEvent *e);
+_AT_@ -235,7 +236,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 */
+_AT_@ -690,6 +691,100 @@ dirtomon(int dir) {
+ return m;
+ }
+
++int
++drawstatusbar(Monitor *m, int bh, char* stext, int xx) {
++ int ret, i, w, len, x;
++ short isCode = 0;
++ Clr * color = drw->scheme->fg;
++
++ len = strlen(stext) + 1 ;
++ char *text = (char*) malloc(sizeof(char)*len);
++ char *p = text;
++ memcpy(text, stext, len);
++
++ // compute width of the status text
++ w = 0;
++ len = 0;
++ i = -1;
++ while(text[++i]) {
++ if(text[i] != '^' && !isCode) {
++ ++len;
++ } else if (text[i] == '^') {
++ isCode = !isCode;
++ if(isCode && text[++i] == 'f') {
++ w += atoi(text + ++i);
++ }
++ }
++ }
++
++ w += drw_font_getexts_width(drw->font, text, len);
++ ret = x = m->ww - w;
++ if(x < xx) {
++ ret = x = xx;
++ w = m->ww - xx;
++ }
++
++ x_set_color(drw, drw->scheme->bg);
++ x_drw_rect(drw, x, 0, w, bh);
++ x_set_color(drw, color);
++
++ // process status text
++ i = -1;
++ while(text[++i]) {
++ if(text[i] == '^' && !isCode) {
++ isCode = 1;
++
++ // draw text
++ text[i] = '
Received on Wed Dec 17 2014 - 22:43:57 CET

This archive was generated by hypermail 2.3.0 : Thu Jun 18 2015 - 17:39:52 CEST