dwm

personal fork of dwm (rnpnr branch)
git clone anongit@rnpnr.xyz:dwm.git
Log | Files | Refs | Feed | README | LICENSE

Commit: a99f6ca6d1b931baed93f7dfd2d5294def1d5929
Parent: 2c485b9db02ea8831d72e3d3eb68da092b2462e2
Author: Randy Palamar
Date:   Sun,  5 Jan 2025 07:14:27 -0700

unity build

Diffstat:
Abuild.sh | 14++++++++++++++
Mdrw.c | 13++++---------
Mdrw.h | 32++++++++++++++++----------------
Mdwm.c | 23-----------------------
Aunity.c | 62++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Dutil.c | 37-------------------------------------
Dutil.h | 9---------
7 files changed, 96 insertions(+), 94 deletions(-)

diff --git a/build.sh b/build.sh @@ -0,0 +1,14 @@ +#!/bin/sh + +version="$(git describe --dirty --always)" + +cc=${CC:-cc} + +${cc} -march=native -O3 -std=c99 -pedantic \ + -Wall -Wno-deprecated-declarations \ + -D _DEFAULT_SOURCE -D _XOPEN_SOURCE=700L \ + -D XINERAMA \ + -D VERSION=\"${version}\" \ + -I/usr/include/freetype2 \ + -lX11 -lXinerama -lfontconfig -lXft \ + unity.c -o dwm diff --git a/drw.c b/drw.c @@ -1,13 +1,4 @@ /* See LICENSE file for copyright and license details. */ -#include <ctype.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <X11/Xlib.h> -#include <X11/Xft/Xft.h> - -#include "drw.h" -#include "util.h" #define UTF_INVALID 0xFFFD @@ -196,12 +187,14 @@ drw_scm_create(Drw *drw, const char *clrnames[], size_t clrcount) return ret; } +#if 0 void drw_setfontset(Drw *drw, Fnt *set) { if (drw) drw->fonts = set; } +#endif void drw_setscheme(Drw *drw, Clr *scm) @@ -404,6 +397,7 @@ drw_fontset_getwidth(Drw *drw, const char *text) return drw_text(drw, 0, 0, 0, 0, 0, text, 0); } +#if 0 unsigned int drw_fontset_getwidth_clamp(Drw *drw, const char *text, unsigned int n) { @@ -412,6 +406,7 @@ drw_fontset_getwidth_clamp(Drw *drw, const char *text, unsigned int n) tmp = drw_text(drw, 0, 0, 0, 0, 0, text, n); return MIN(n, tmp); } +#endif void drw_font_getexts(Fnt *font, const char *text, unsigned int len, unsigned int *w, unsigned int *h) diff --git a/drw.h b/drw.h @@ -27,32 +27,32 @@ typedef struct { } Drw; /* 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); -void drw_free(Drw *drw); +static Drw *drw_create(Display *dpy, int screen, Window win, unsigned int w, unsigned int h); +static void drw_resize(Drw *drw, unsigned int w, unsigned int h); +static void drw_free(Drw *drw); /* Fnt abstraction */ -Fnt *drw_fontset_create(Drw* drw, const char *fonts[], size_t fontcount); -void drw_fontset_free(Fnt* set); -unsigned int drw_fontset_getwidth(Drw *drw, const char *text); -unsigned int drw_fontset_getwidth_clamp(Drw *drw, const char *text, unsigned int n); -void drw_font_getexts(Fnt *font, const char *text, unsigned int len, unsigned int *w, unsigned int *h); +static Fnt *drw_fontset_create(Drw* drw, const char *fonts[], size_t fontcount); +static void drw_fontset_free(Fnt* set); +static unsigned int drw_fontset_getwidth(Drw *drw, const char *text); +//static unsigned int drw_fontset_getwidth_clamp(Drw *drw, const char *text, unsigned int n); +static void drw_font_getexts(Fnt *font, const char *text, unsigned int len, unsigned int *w, unsigned int *h); /* Colorscheme abstraction */ -void drw_clr_create(Drw *drw, Clr *dest, const char *clrname); -Clr *drw_scm_create(Drw *drw, const char *clrnames[], size_t clrcount); +static void drw_clr_create(Drw *drw, Clr *dest, const char *clrname); +static Clr *drw_scm_create(Drw *drw, const char *clrnames[], size_t clrcount); /* Cursor abstraction */ -Cur *drw_cur_create(Drw *drw, int shape); -void drw_cur_free(Drw *drw, Cur *cursor); +static Cur *drw_cur_create(Drw *drw, int shape); +static void drw_cur_free(Drw *drw, Cur *cursor); /* Drawing context manipulation */ -void drw_setfontset(Drw *drw, Fnt *set); -void drw_setscheme(Drw *drw, Clr *scm); +//static void drw_setfontset(Drw *drw, Fnt *set); +static void drw_setscheme(Drw *drw, Clr *scm); /* Drawing functions */ -void drw_rect(Drw *drw, int x, int y, unsigned int w, unsigned int h, int filled, int invert); -int drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lpad, const char *text, int invert); +static void drw_rect(Drw *drw, int x, int y, unsigned int w, unsigned int h, int filled, int invert); +static int drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lpad, const char *text, int invert); /* Map functions */ void drw_map(Drw *drw, Window win, int x, int y, unsigned int w, unsigned int h); diff --git a/dwm.c b/dwm.c @@ -20,29 +20,6 @@ * * To understand everything else, start reading main(). */ -#include <errno.h> -#include <locale.h> -#include <signal.h> -#include <stdarg.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <unistd.h> -#include <sys/types.h> -#include <sys/wait.h> -#include <X11/cursorfont.h> -#include <X11/keysym.h> -#include <X11/Xatom.h> -#include <X11/Xlib.h> -#include <X11/Xproto.h> -#include <X11/Xutil.h> -#ifdef XINERAMA -#include <X11/extensions/Xinerama.h> -#endif /* XINERAMA */ -#include <X11/Xft/Xft.h> - -#include "drw.h" -#include "util.h" /* macros */ #define BUTTONMASK (ButtonPressMask|ButtonReleaseMask) diff --git a/unity.c b/unity.c @@ -0,0 +1,62 @@ +/* See LICENSE file for copyright and license details. */ +#include <ctype.h> +#include <errno.h> +#include <locale.h> +#include <signal.h> +#include <stdarg.h> +#include <stddef.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <sys/types.h> +#include <sys/wait.h> +#include <unistd.h> + +#include <X11/Xatom.h> +#include <X11/Xft/Xft.h> +#include <X11/Xlib.h> +#include <X11/Xproto.h> +#include <X11/Xutil.h> +#include <X11/cursorfont.h> +#ifdef XINERAMA +#include <X11/extensions/Xinerama.h> +#endif /* XINERAMA */ +#include <X11/keysym.h> + +#define MAX(A, B) ((A) > (B) ? (A) : (B)) +#define MIN(A, B) ((A) < (B) ? (A) : (B)) +#define BETWEEN(X, A, B) ((A) <= (X) && (X) <= (B)) +#define LENGTH(X) (sizeof (X) / sizeof (X)[0]) + +static void +die(const char *fmt, ...) +{ + va_list ap; + int saved_errno; + + saved_errno = errno; + + va_start(ap, fmt); + vfprintf(stderr, fmt, ap); + va_end(ap); + + if (fmt[0] && fmt[strlen(fmt)-1] == ':') + fprintf(stderr, " %s", strerror(saved_errno)); + fputc('\n', stderr); + + exit(1); +} + +static void * +ecalloc(size_t nmemb, size_t size) +{ + void *p; + + if (!(p = calloc(nmemb, size))) + die("calloc:"); + return p; +} + +#include "drw.h" +#include "drw.c" +#include "dwm.c" diff --git a/util.c b/util.c @@ -1,37 +0,0 @@ -/* See LICENSE file for copyright and license details. */ -#include <errno.h> -#include <stdarg.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - -#include "util.h" - -void -die(const char *fmt, ...) -{ - va_list ap; - int saved_errno; - - saved_errno = errno; - - va_start(ap, fmt); - vfprintf(stderr, fmt, ap); - va_end(ap); - - if (fmt[0] && fmt[strlen(fmt)-1] == ':') - fprintf(stderr, " %s", strerror(saved_errno)); - fputc('\n', stderr); - - exit(1); -} - -void * -ecalloc(size_t nmemb, size_t size) -{ - void *p; - - if (!(p = calloc(nmemb, size))) - die("calloc:"); - return p; -} diff --git a/util.h b/util.h @@ -1,9 +0,0 @@ -/* See LICENSE file for copyright and license details. */ - -#define MAX(A, B) ((A) > (B) ? (A) : (B)) -#define MIN(A, B) ((A) < (B) ? (A) : (B)) -#define BETWEEN(X, A, B) ((A) <= (X) && (X) <= (B)) -#define LENGTH(X) (sizeof (X) / sizeof (X)[0]) - -void die(const char *fmt, ...); -void *ecalloc(size_t nmemb, size_t size);