From 07109bb861018f4de7785c082262c1e0ff3fede0 Mon Sep 17 00:00:00 2001 From: Sam Chudnick Date: Thu, 16 Feb 2023 20:53:20 -0500 Subject: initial commit --- patches/alpha.diff | 122 ++++++++++++++++ patches/tabbed-autohide-0.6.diff | 50 +++++++ patches/tabbed-bar-height-0.6.diff | 24 ++++ patches/tabbed-clientnumber-0.6.diff | 23 +++ patches/tabbed-xresources-20210317-dabf6a2.diff | 178 ++++++++++++++++++++++++ 5 files changed, 397 insertions(+) create mode 100644 patches/alpha.diff create mode 100644 patches/tabbed-autohide-0.6.diff create mode 100644 patches/tabbed-bar-height-0.6.diff create mode 100644 patches/tabbed-clientnumber-0.6.diff create mode 100644 patches/tabbed-xresources-20210317-dabf6a2.diff (limited to 'patches') diff --git a/patches/alpha.diff b/patches/alpha.diff new file mode 100644 index 0000000..3ce77a7 --- /dev/null +++ b/patches/alpha.diff @@ -0,0 +1,122 @@ +diff --git a/config.mk b/config.mk +index 3a71529..095cead 100644 +--- a/config.mk ++++ b/config.mk +@@ -9,7 +9,7 @@ MANPREFIX = ${PREFIX}/share/man + + # includes and libs + INCS = -I. -I/usr/include -I/usr/include/freetype2 +-LIBS = -L/usr/lib -lc -lX11 -lfontconfig -lXft ++LIBS = -L/usr/lib -lc -lX11 -lfontconfig -lXft -lXrender + + # flags + CPPFLAGS = -DVERSION=\"${VERSION}\" -D_DEFAULT_SOURCE +diff --git a/tabbed.c b/tabbed.c +index 9a44795..b4d47d1 100644 +--- a/tabbed.c ++++ b/tabbed.c +@@ -170,6 +170,9 @@ static char **cmd; + static char *wmname = "tabbed"; + static const char *geometry; + ++static Colormap cmap; ++static Visual *visual = NULL; ++ + char *argv0; + + /* configuration, allows nested code to access above variables */ +@@ -255,8 +258,8 @@ configurenotify(const XEvent *e) + ww = ev->width; + wh = ev->height; + XFreePixmap(dpy, dc.drawable); +- dc.drawable = XCreatePixmap(dpy, root, ww, wh, +- DefaultDepth(dpy, screen)); ++ dc.drawable = XCreatePixmap(dpy, win, ww, wh, ++ 32); + if (sel > -1) + resize(sel, ww, wh - bh); + XSync(dpy, False); +@@ -399,7 +402,7 @@ drawtext(const char *text, XftColor col[ColLast]) + ; + } + +- d = XftDrawCreate(dpy, dc.drawable, DefaultVisual(dpy, screen), DefaultColormap(dpy, screen)); ++ d = XftDrawCreate(dpy, dc.drawable, visual, cmap); + XftDrawStringUtf8(d, &col[ColFG], dc.font.xfont, x, y, (XftChar8 *) buf, len); + XftDrawDestroy(d); + } +@@ -564,7 +567,7 @@ getcolor(const char *colstr) + { + XftColor color; + +- if (!XftColorAllocName(dpy, DefaultVisual(dpy, screen), DefaultColormap(dpy, screen), colstr, &color)) ++ if (!XftColorAllocName(dpy, visual, cmap, colstr, &color)) + die("%s: cannot allocate color '%s'\n", argv0, colstr); + + return color; +@@ -1016,18 +1019,60 @@ setup(void) + wy = dh + wy - wh - 1; + } + ++ XVisualInfo *vis; ++ XRenderPictFormat *fmt; ++ int nvi; ++ int i; ++ ++ XVisualInfo tpl = { ++ .screen = screen, ++ .depth = 32, ++ .class = TrueColor ++ }; ++ ++ vis = XGetVisualInfo(dpy, VisualScreenMask | VisualDepthMask | VisualClassMask, &tpl, &nvi); ++ for(i = 0; i < nvi; i ++) { ++ fmt = XRenderFindVisualFormat(dpy, vis[i].visual); ++ if (fmt->type == PictTypeDirect && fmt->direct.alphaMask) { ++ visual = vis[i].visual; ++ break; ++ } ++ } ++ ++ XFree(vis); ++ ++ if (! visual) { ++ fprintf(stderr, "Couldn't find ARGB visual.\n"); ++ exit(1); ++ } ++ ++ cmap = XCreateColormap( dpy, root, visual, None); + dc.norm[ColBG] = getcolor(normbgcolor); + dc.norm[ColFG] = getcolor(normfgcolor); + dc.sel[ColBG] = getcolor(selbgcolor); + dc.sel[ColFG] = getcolor(selfgcolor); + dc.urg[ColBG] = getcolor(urgbgcolor); + dc.urg[ColFG] = getcolor(urgfgcolor); +- dc.drawable = XCreatePixmap(dpy, root, ww, wh, +- DefaultDepth(dpy, screen)); +- dc.gc = XCreateGC(dpy, root, 0, 0); + +- win = XCreateSimpleWindow(dpy, root, wx, wy, ww, wh, 0, +- dc.norm[ColFG].pixel, dc.norm[ColBG].pixel); ++ XSetWindowAttributes attrs; ++ attrs.background_pixel = dc.norm[ColBG].pixel; ++ attrs.border_pixel = dc.norm[ColFG].pixel; ++ attrs.bit_gravity = NorthWestGravity; ++ attrs.event_mask = FocusChangeMask | KeyPressMask ++ | ExposureMask | VisibilityChangeMask | StructureNotifyMask ++ | ButtonMotionMask | ButtonPressMask | ButtonReleaseMask; ++ attrs.background_pixmap = None ; ++ attrs.colormap = cmap; ++ ++ win = XCreateWindow(dpy, root, wx, wy, ++ ww, wh, 0, 32, InputOutput, ++ visual, CWBackPixmap | CWBorderPixel | CWBitGravity ++ | CWEventMask | CWColormap, &attrs); ++ ++ dc.drawable = XCreatePixmap(dpy, win, ww, wh, ++ 32); ++ dc.gc = XCreateGC(dpy, dc.drawable, 0, 0); ++ + XMapRaised(dpy, win); + XSelectInput(dpy, win, SubstructureNotifyMask | FocusChangeMask | + ButtonPressMask | ExposureMask | KeyPressMask | diff --git a/patches/tabbed-autohide-0.6.diff b/patches/tabbed-autohide-0.6.diff new file mode 100644 index 0000000..fd641b4 --- /dev/null +++ b/patches/tabbed-autohide-0.6.diff @@ -0,0 +1,50 @@ +diff --git a/tabbed.c b/tabbed.c +index ff3ada0..c41db0c 100644 +--- a/tabbed.c ++++ b/tabbed.c +@@ -152,7 +152,7 @@ static void (*handler[LASTEvent]) (const XEvent *) = { + [MapRequest] = maprequest, + [PropertyNotify] = propertynotify, + }; +-static int bh, wx, wy, ww, wh; ++static int bh, wx, wy, ww, wh, vbh; + static unsigned int numlockmask = 0; + static Bool running = True, nextfocus, doinitspawn = True, + fillagain = False, closelastclient = False; +@@ -307,6 +307,6 @@ void + drawbar(void) { + unsigned long *col; +- int c, fc, width, n = 0; ++ int c, fc, width, n = 0, nbh, i; + char *name = NULL; + + if (nclients == 0) { +@@ -314,10 +314,19 @@ drawbar(void) + dc.w = ww; + XFetchName(dpy, win, &name); + drawtext(name ? name : "", dc.norm); +- XCopyArea(dpy, dc.drawable, win, dc.gc, 0, 0, ww, bh, 0, 0); ++ XCopyArea(dpy, dc.drawable, win, dc.gc, 0, 0, ww, vbh, 0, 0); + XSync(dpy, False); + + return; + } + ++ nbh = nclients > 1 ? vbh : 0; ++ if (bh != nbh) { ++ bh = nbh; ++ for (i = 0; i < nclients; i++) ++ XMoveResizeWindow(dpy, clients[i]->win, 0, bh, ww, wh - bh); ++ } ++ if (bh == 0) ++ return; ++ + width = ww; +@@ -920,6 +929,6 @@ setup(void) + screen = DefaultScreen(dpy); + root = RootWindow(dpy, screen); + initfont(font); +- bh = dc.h = dc.font.height + 2; ++ vbh = dc.h = dc.font.height + 2; + + /* init atoms */ diff --git a/patches/tabbed-bar-height-0.6.diff b/patches/tabbed-bar-height-0.6.diff new file mode 100644 index 0000000..fddcb28 --- /dev/null +++ b/patches/tabbed-bar-height-0.6.diff @@ -0,0 +1,24 @@ +diff --color -up tabbed-0.6-clean/config.def.h tabbed-0.6-modified/config.def.h +--- tabbed-0.6-clean/config.def.h 2014-01-21 10:22:03.000000000 -0800 ++++ tabbed-0.6-modified/config.def.h 2021-03-30 20:23:45.752478278 -0700 +@@ -10,7 +10,7 @@ static const char before[] = "<"; + static const char after[] = ">"; + static const int tabwidth = 200; + static const Bool foreground = True; +- ++static const int barHeight = 24; + /* + * Where to place a new tab when it is opened. When npisrelative is True, + * then the current position is changed + newposition. If npisrelative +diff --color -up tabbed-0.6-clean/tabbed.c tabbed-0.6-modified/tabbed.c +--- tabbed-0.6-clean/tabbed.c 2014-01-21 10:22:03.000000000 -0800 ++++ tabbed-0.6-modified/tabbed.c 2021-03-30 20:24:23.712477426 -0700 +@@ -920,7 +920,7 @@ setup(void) { + screen = DefaultScreen(dpy); + root = RootWindow(dpy, screen); + initfont(font); +- bh = dc.h = dc.font.height + 2; ++ bh = dc.h = barHeight; + + /* init atoms */ + wmatom[WMProtocols] = XInternAtom(dpy, "WM_PROTOCOLS", False); diff --git a/patches/tabbed-clientnumber-0.6.diff b/patches/tabbed-clientnumber-0.6.diff new file mode 100644 index 0000000..430245c --- /dev/null +++ b/patches/tabbed-clientnumber-0.6.diff @@ -0,0 +1,23 @@ +diff --git a/tabbed.c b/tabbed.c +index d30206b..70642cb 100644 +--- a/tabbed.c ++++ b/tabbed.c +@@ -308,6 +308,7 @@ drawbar(void) { + unsigned long *col; + int c, fc, width, n = 0; + char *name = NULL; ++ char tabtitle[256]; + + if(nclients == 0) { + dc.x = 0; +@@ -353,7 +354,9 @@ drawbar(void) { + } else { + col = dc.norm; + } +- drawtext(clients[c]->name, col); ++ snprintf(tabtitle, sizeof(tabtitle), "%d: %s", ++ c + 1, clients[c]->name); ++ drawtext(tabtitle, col); + dc.x += dc.w; + clients[c]->tabx = dc.x; + } diff --git a/patches/tabbed-xresources-20210317-dabf6a2.diff b/patches/tabbed-xresources-20210317-dabf6a2.diff new file mode 100644 index 0000000..15610a7 --- /dev/null +++ b/patches/tabbed-xresources-20210317-dabf6a2.diff @@ -0,0 +1,178 @@ +From 8c48f1564c555bbd21758a3a70a9984e61c34a35 Mon Sep 17 00:00:00 2001 +From: 6d6f7274686f6e <4648531+6d6f7274686f6e@users.noreply.github.com> +Date: Wed, 17 Mar 2021 10:59:18 +0100 +Subject: [PATCH] xresources support + +--- + config.def.h | 27 ++++++++++++++------ + tabbed.c | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++++ + 2 files changed, 89 insertions(+), 7 deletions(-) + +diff --git a/config.def.h b/config.def.h +index defa426..244e288 100644 +--- a/config.def.h ++++ b/config.def.h +@@ -1,13 +1,13 @@ + /* See LICENSE file for copyright and license details. */ + + /* appearance */ +-static const char font[] = "monospace:size=9"; +-static const char* normbgcolor = "#222222"; +-static const char* normfgcolor = "#cccccc"; +-static const char* selbgcolor = "#555555"; +-static const char* selfgcolor = "#ffffff"; +-static const char* urgbgcolor = "#111111"; +-static const char* urgfgcolor = "#cc0000"; ++static char font[] = "monospace:size=9"; ++static char* normbgcolor = "#222222"; ++static char* normfgcolor = "#cccccc"; ++static char* selbgcolor = "#555555"; ++static char* selfgcolor = "#ffffff"; ++static char* urgbgcolor = "#111111"; ++static char* urgfgcolor = "#cc0000"; + static const char before[] = "<"; + static const char after[] = ">"; + static const char titletrim[] = "..."; +@@ -33,6 +33,19 @@ static Bool npisrelative = False; + } \ + } + ++/* ++ * Xresources preferences to load at startup ++ */ ++ResourcePref resources[] = { ++ { "font", STRING, &font }, ++ { "color0", STRING, &normbgcolor }, ++ { "color4", STRING, &normfgcolor }, ++ { "color4", STRING, &selbgcolor }, ++ { "color7", STRING, &selfgcolor }, ++ { "color2", STRING, &urgbgcolor }, ++ { "color3", STRING, &urgfgcolor }, ++}; ++ + #define MODKEY ControlMask + static Key keys[] = { + /* modifier key function argument */ +diff --git a/tabbed.c b/tabbed.c +index eafe28a..c5bffc7 100644 +--- a/tabbed.c ++++ b/tabbed.c +@@ -13,6 +13,7 @@ + #include + #include + #include ++#include + #include + #include + #include +@@ -85,11 +86,26 @@ typedef struct { + Bool urgent; + Bool closed; + } Client; ++ ++/* Xresources preferences */ ++enum resource_type { ++ STRING = 0, ++ INTEGER = 1, ++ FLOAT = 2 ++}; ++ ++typedef struct { ++ char *name; ++ enum resource_type type; ++ void *dst; ++} ResourcePref; ++ + + /* function declarations */ + static void buttonpress(const XEvent *e); + static void cleanup(void); + static void clientmessage(const XEvent *e); ++static void config_init(void); + static void configurenotify(const XEvent *e); + static void configurerequest(const XEvent *e); + static void createnotify(const XEvent *e); +@@ -120,6 +136,7 @@ static void move(const Arg *arg); + static void movetab(const Arg *arg); + static void propertynotify(const XEvent *e); + static void resize(int c, int w, int h); ++static int resource_load(XrmDatabase db, char *name, enum resource_type rtype, void *dst); + static void rotate(const Arg *arg); + static void run(void); + static void sendxembed(int c, long msg, long detail, long d1, long d2); +@@ -245,6 +262,23 @@ clientmessage(const XEvent *e) + } + } + ++void ++config_init(void) ++{ ++ char *resm; ++ XrmDatabase db; ++ ResourcePref *p; ++ ++ XrmInitialize(); ++ resm = XResourceManagerString(dpy); ++ if (!resm) ++ return; ++ ++ db = XrmGetStringDatabase(resm); ++ for (p = resources; p < resources + LENGTH(resources); p++) ++ resource_load(db, p->name, p->type, p->dst); ++} ++ + void + configurenotify(const XEvent *e) + { +@@ -897,6 +931,40 @@ resize(int c, int w, int h) + (XEvent *)&ce); + } + ++int ++resource_load(XrmDatabase db, char *name, enum resource_type rtype, void *dst) ++{ ++ char **sdst = dst; ++ int *idst = dst; ++ float *fdst = dst; ++ ++ char fullname[256]; ++ char fullclass[256]; ++ char *type; ++ XrmValue ret; ++ ++ snprintf(fullname, sizeof(fullname), "%s.%s", "tabbed", name); ++ snprintf(fullclass, sizeof(fullclass), "%s.%s", "tabbed", name); ++ fullname[sizeof(fullname) - 1] = fullclass[sizeof(fullclass) - 1] = '\0'; ++ ++ XrmGetResource(db, fullname, fullclass, &type, &ret); ++ if (ret.addr == NULL || strncmp("String", type, 64)) ++ return 1; ++ ++ switch (rtype) { ++ case STRING: ++ *sdst = ret.addr; ++ break; ++ case INTEGER: ++ *idst = strtoul(ret.addr, NULL, 10); ++ break; ++ case FLOAT: ++ *fdst = strtof(ret.addr, NULL); ++ break; ++ } ++ return 0; ++} ++ + void + rotate(const Arg *arg) + { +@@ -1354,6 +1422,7 @@ main(int argc, char *argv[]) + if (!(dpy = XOpenDisplay(NULL))) + die("%s: cannot open display\n", argv0); + ++ config_init(); + setup(); + printf("0x%lx\n", win); + fflush(NULL); +-- +2.30.2 + -- cgit v1.2.3