about summary refs log tree commit diff
path: root/nixpkgs/pkgs/applications/window-managers/tabbed
diff options
context:
space:
mode:
authorAlyssa Ross <hi@alyssa.is>2019-01-07 02:18:36 +0000
committerAlyssa Ross <hi@alyssa.is>2019-01-07 02:18:47 +0000
commit36f56d99fa0a0765c9f1de4a5f17a9b05830c3f2 (patch)
treeb3faaf573407b32aa645237a4d16b82778a39a92 /nixpkgs/pkgs/applications/window-managers/tabbed
parent4e31070265257dc67d120c27e0f75c2344fdfa9a (diff)
parentabf060725d7614bd3b9f96764262dfbc2f9c2199 (diff)
downloadnixlib-36f56d99fa0a0765c9f1de4a5f17a9b05830c3f2.tar
nixlib-36f56d99fa0a0765c9f1de4a5f17a9b05830c3f2.tar.gz
nixlib-36f56d99fa0a0765c9f1de4a5f17a9b05830c3f2.tar.bz2
nixlib-36f56d99fa0a0765c9f1de4a5f17a9b05830c3f2.tar.lz
nixlib-36f56d99fa0a0765c9f1de4a5f17a9b05830c3f2.tar.xz
nixlib-36f56d99fa0a0765c9f1de4a5f17a9b05830c3f2.tar.zst
nixlib-36f56d99fa0a0765c9f1de4a5f17a9b05830c3f2.zip
Add 'nixpkgs/' from commit 'abf060725d7614bd3b9f96764262dfbc2f9c2199'
git-subtree-dir: nixpkgs
git-subtree-mainline: 4e31070265257dc67d120c27e0f75c2344fdfa9a
git-subtree-split: abf060725d7614bd3b9f96764262dfbc2f9c2199
Diffstat (limited to 'nixpkgs/pkgs/applications/window-managers/tabbed')
-rw-r--r--nixpkgs/pkgs/applications/window-managers/tabbed/default.nix33
-rw-r--r--nixpkgs/pkgs/applications/window-managers/tabbed/xft.patch234
2 files changed, 267 insertions, 0 deletions
diff --git a/nixpkgs/pkgs/applications/window-managers/tabbed/default.nix b/nixpkgs/pkgs/applications/window-managers/tabbed/default.nix
new file mode 100644
index 000000000000..a9c0f993d775
--- /dev/null
+++ b/nixpkgs/pkgs/applications/window-managers/tabbed/default.nix
@@ -0,0 +1,33 @@
+{stdenv, fetchgit, xproto, libX11, libXft, customConfig ? null, patches ? [] }:
+
+with stdenv.lib;
+
+stdenv.mkDerivation rec {
+  name = "tabbed-20180310";
+
+  src = fetchgit {
+    url = https://git.suckless.org/tabbed;
+    rev = "b5f9ec647aae2d9a1d3bd586eb7523a4e0a329a3";
+    sha256 = "0frj2yjaf0mfjwgyfappksfir52mx2xxd3cdg5533m5d88vbmxss";
+  };
+
+  inherit patches;
+
+  postPatch = stdenv.lib.optionalString (customConfig != null) ''
+    cp ${builtins.toFile "config.h" customConfig} ./config.h
+  '';
+
+  buildInputs = [ xproto libX11 libXft ];
+
+  makeFlags = [
+    "PREFIX=$(out)"
+  ];
+
+  meta = {
+    homepage = https://tools.suckless.org/tabbed;
+    description = "Simple generic tabbed fronted to xembed aware applications";
+    license = licenses.mit;
+    maintainers = with maintainers; [ vrthra ];
+    platforms = platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/window-managers/tabbed/xft.patch b/nixpkgs/pkgs/applications/window-managers/tabbed/xft.patch
new file mode 100644
index 000000000000..f4f1e82e7052
--- /dev/null
+++ b/nixpkgs/pkgs/applications/window-managers/tabbed/xft.patch
@@ -0,0 +1,234 @@
+diff --git a/config.def.h b/config.def.h
+index b3da7f0..ce43686 100644
+--- a/config.def.h
++++ b/config.def.h
+@@ -1,7 +1,7 @@
+ /* See LICENSE file for copyright and license details. */
+ 
+ /* appearance */
+-static const char font[]        = "-*-*-medium-*-*-*-14-*-*-*-*-*-*-*";
++static const char font[]        = "monospace-9";
+ static const char* normbgcolor  = "#222222";
+ static const char* normfgcolor  = "#cccccc";
+ static const char* selbgcolor   = "#555555";
+diff --git a/config.mk b/config.mk
+index dd741e4..ed3a2e9 100644
+--- a/config.mk
++++ b/config.mk
+@@ -9,7 +9,7 @@ MANPREFIX = ${PREFIX}/share/man
+ 
+ # includes and libs
+ INCS = -I. -I/usr/include
+-LIBS = -L/usr/lib -lc -lX11
++LIBS = -L/usr/lib -lc -lXft -lX11
+ 
+ # flags
+ CPPFLAGS = -DVERSION=\"${VERSION}\" -D_DEFAULT_SOURCE
+diff --git a/tabbed.c b/tabbed.c
+index b15f9cb..6e50c41 100644
+--- a/tabbed.c
++++ b/tabbed.c
+@@ -15,6 +15,7 @@
+ #include <X11/Xproto.h>
+ #include <X11/Xutil.h>
+ #include <X11/XKBlib.h>
++#include <X11/Xft/Xft.h>
+ 
+ #include "arg.h"
+ 
+@@ -64,17 +65,16 @@ typedef struct {
+ 
+ typedef struct {
+ 	int x, y, w, h;
+-	unsigned long norm[ColLast];
+-	unsigned long sel[ColLast];
+-	unsigned long urg[ColLast];
++	XftColor norm[ColLast];
++	XftColor sel[ColLast];
++	XftColor urg[ColLast];
+ 	Drawable drawable;
+ 	GC gc;
+ 	struct {
+ 		int ascent;
+ 		int descent;
+ 		int height;
+-		XFontSet set;
+-		XFontStruct *xfont;
++		XftFont *xfont;
+ 	} font;
+ } DC; /* draw context */
+ 
+@@ -97,7 +97,7 @@ static void unmapnotify(const XEvent *e);
+ static void destroynotify(const XEvent *e);
+ static void die(const char *errstr, ...);
+ static void drawbar(void);
+-static void drawtext(const char *text, unsigned long col[ColLast]);
++static void drawtext(const char *text, XftColor col[ColLast]);
+ static void *ecalloc(size_t n, size_t size);
+ static void *erealloc(void *o, size_t size);
+ static void expose(const XEvent *e);
+@@ -107,7 +107,7 @@ static void focusonce(const Arg *arg);
+ static void fullscreen(const Arg *arg);
+ static char* getatom(int a);
+ static int getclient(Window w);
+-static unsigned long getcolor(const char *colstr);
++static XftColor getcolor(const char *colstr);
+ static int getfirsttab(void);
+ static Bool gettextprop(Window w, Atom atom, char *text, unsigned int size);
+ static void initfont(const char *fontstr);
+@@ -220,12 +220,6 @@ cleanup(void) {
+ 	free(clients);
+ 	clients = NULL;
+ 
+-	if(dc.font.set) {
+-		XFreeFontSet(dpy, dc.font.set);
+-	} else {
+-		XFreeFont(dpy, dc.font.xfont);
+-	}
+-
+ 	XFreePixmap(dpy, dc.drawable);
+ 	XFreeGC(dpy, dc.gc);
+ 	XDestroyWindow(dpy, win);
+@@ -315,7 +309,7 @@ die(const char *errstr, ...) {
+ 
+ void
+ drawbar(void) {
+-	unsigned long *col;
++	XftColor *col;
+ 	int c, cc, fc, width;
+ 	char *name = NULL;
+ 
+@@ -368,12 +362,13 @@ drawbar(void) {
+ }
+ 
+ void
+-drawtext(const char *text, unsigned long col[ColLast]) {
++drawtext(const char *text, XftColor col[ColLast]) {
+ 	int i, x, y, h, len, olen;
+ 	char buf[256];
++	XftDraw *d;
+ 	XRectangle r = { dc.x, dc.y, dc.w, dc.h };
+ 
+-	XSetForeground(dpy, dc.gc, col[ColBG]);
++	XSetForeground(dpy, dc.gc, col[ColBG].pixel);
+ 	XFillRectangles(dpy, dc.drawable, dc.gc, &r, 1);
+ 	if(!text)
+ 		return;
+@@ -394,13 +389,12 @@ drawtext(const char *text, unsigned long col[ColLast]) {
+ 		for(i = len; i && i > len - 3; buf[--i] = '.');
+ 	}
+ 
+-	XSetForeground(dpy, dc.gc, col[ColFG]);
+-	if(dc.font.set) {
+-		XmbDrawString(dpy, dc.drawable, dc.font.set,
+-				dc.gc, x, y, buf, len);
+-	} else {
+-		XDrawString(dpy, dc.drawable, dc.gc, x, y, buf, len);
+-	}
++	XSetForeground(dpy, dc.gc, col[ColFG].pixel);
++
++	d = XftDrawCreate(dpy, dc.drawable, DefaultVisual(dpy, screen), DefaultColormap(dpy,screen));
++
++	XftDrawStringUtf8(d, &col[ColFG], dc.font.xfont, x, y, (XftChar8 *) buf, len);
++	XftDrawDestroy(d);
+ }
+ 
+ void *
+@@ -537,15 +531,14 @@ getclient(Window w) {
+ 	return -1;
+ }
+ 
+-unsigned long
++XftColor
+ getcolor(const char *colstr) {
+-	Colormap cmap = DefaultColormap(dpy, screen);
+-	XColor color;
++	XftColor color;
+ 
+-	if(!XAllocNamedColor(dpy, cmap, colstr, &color, &color))
++	if(!XftColorAllocName(dpy, DefaultVisual(dpy, screen), DefaultColormap(dpy, screen), colstr, &color))
+ 		die("tabbed: cannot allocate color '%s'\n", colstr);
+ 
+-	return color.pixel;
++	return color;
+ }
+ 
+ int
+@@ -594,41 +587,11 @@ gettextprop(Window w, Atom atom, char *text, unsigned int size) {
+ 
+ void
+ initfont(const char *fontstr) {
+-	char *def, **missing, **font_names;
+-	int i, n;
+-	XFontStruct **xfonts;
+-
+-	missing = NULL;
+-	if(dc.font.set)
+-		XFreeFontSet(dpy, dc.font.set);
+-
+-	dc.font.set = XCreateFontSet(dpy, fontstr, &missing, &n, &def);
+-	if(missing) {
+-		while(n--)
+-			fprintf(stderr, "tabbed: missing fontset: %s\n", missing[n]);
+-		XFreeStringList(missing);
+-	}
+-
+-	if(dc.font.set) {
+-		dc.font.ascent = dc.font.descent = 0;
+-		n = XFontsOfFontSet(dc.font.set, &xfonts, &font_names);
+-		for(i = 0, dc.font.ascent = 0, dc.font.descent = 0; i < n; i++) {
+-			dc.font.ascent = MAX(dc.font.ascent, (*xfonts)->ascent);
+-			dc.font.descent = MAX(dc.font.descent,(*xfonts)->descent);
+-			xfonts++;
+-		}
+-	} else {
+-		if(dc.font.xfont)
+-			XFreeFont(dpy, dc.font.xfont);
+-		dc.font.xfont = NULL;
+-		if(!(dc.font.xfont = XLoadQueryFont(dpy, fontstr))
+-				&& !(dc.font.xfont = XLoadQueryFont(dpy, "fixed"))) {
+-			die("tabbed: cannot load font: '%s'\n", fontstr);
+-		}
++	if(!(dc.font.xfont = XftFontOpenName(dpy,screen,fontstr)) && !(dc.font.xfont = XftFontOpenName(dpy,screen,"fixed")))
++		die("error, cannot load font: '%s'\n", fontstr);
+ 
+-		dc.font.ascent = dc.font.xfont->ascent;
+-		dc.font.descent = dc.font.xfont->descent;
+-	}
++	dc.font.ascent = dc.font.xfont->ascent;
++	dc.font.descent = dc.font.xfont->descent;
+ 	dc.font.height = dc.font.ascent + dc.font.descent;
+ }
+ 
+@@ -1000,11 +963,9 @@ setup(void) {
+ 	dc.drawable = XCreatePixmap(dpy, root, ww, wh,
+ 			DefaultDepth(dpy, screen));
+ 	dc.gc = XCreateGC(dpy, root, 0, 0);
+-	if(!dc.font.set)
+-		XSetFont(dpy, dc.gc, dc.font.xfont->fid);
+ 
+ 	win = XCreateSimpleWindow(dpy, root, wx, wy, ww, wh, 0,
+-			dc.norm[ColFG], dc.norm[ColBG]);
++			dc.norm[ColFG].pixel, dc.norm[ColBG].pixel);
+ 	XMapRaised(dpy, win);
+ 	XSelectInput(dpy, win, SubstructureNotifyMask|FocusChangeMask|
+ 			ButtonPressMask|ExposureMask|KeyPressMask|PropertyChangeMask|
+@@ -1070,15 +1031,9 @@ spawn(const Arg *arg) {
+ 
+ int
+ textnw(const char *text, unsigned int len) {
+-	XRectangle r;
+-
+-	if(dc.font.set) {
+-		XmbTextExtents(dc.font.set, text, len, NULL, &r);
+-
+-		return r.width;
+-	}
+-
+-	return XTextWidth(dc.font.xfont, text, len);
++	XGlyphInfo ext;
++	XftTextExtentsUtf8(dpy, dc.font.xfont, (XftChar8 *) text, len, &ext);
++	return ext.xOff;
+ }
+ 
+ void