summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--config.h8
-rw-r--r--drw.c110
-rw-r--r--drw.h15
3 files changed, 5 insertions, 128 deletions
diff --git a/config.h b/config.h
index 3802796..a23d624 100644
--- a/config.h
+++ b/config.h
@@ -3,6 +3,7 @@
/* Constants */
#define TERMINAL "st"
#define BROWSER "glide"
+#define WALLPAPER "/usr/share/wallpapers/windows7.jpg"
/* appearance */
static const unsigned int borderpx = 2; /* border pixel of windows */
@@ -24,7 +25,7 @@ static const char *colors[][5] = {
static const char *const autostart[] = {
/* program arguments options null terminator */
"xhidecursor", "", "", NULL,
- "hsetroot", "-fill", "/usr/share/wallpapers/windows7.jpg", NULL,
+ "hsetroot", "-fill", WALLPAPER, NULL,
NULL
};
@@ -109,8 +110,8 @@ static const Key keys[] = {
TAGKEYS( XK_2, 1)
TAGKEYS( XK_3, 2)
- { MODKEY|ShiftMask|ControlMask, XK_BackSpace, quit, {0} },
- { MODKEY|ShiftMask, XK_r, quit, {1} },
+ { MODKEY|ShiftMask|ControlMask, XK_BackSpace, quit, {0} },
+ { MODKEY|ShiftMask, XK_BackSpace, quit, {1} },
{ MODKEY, XK_n, spawn, SHCMD(TERMINAL" -e newsboat") },
{ MODKEY, XK_Escape, spawn, SHCMD(TERMINAL" -e htop") },
@@ -120,6 +121,7 @@ static const Key keys[] = {
{ MODKEY|ShiftMask, XK_w, spawn, SHCMD("icecat") },
{ MODKEY, XK_a, swapfocus, {0} },
{ MODKEY|ShiftMask, XK_a, spawn, SHCMD("scrcpy") },
+ { MODKEY, XK_BackSpace, swapfocus, {0} },
#ifdef __linux__
{ MODKEY, XK_g, spawn, SHCMD(TERMINAL" -c stfloat -e watch -c -n 2 genlop -c") },
diff --git a/drw.c b/drw.c
index 58a2760..45ca7b4 100644
--- a/drw.c
+++ b/drw.c
@@ -28,108 +28,13 @@ drw_create(Display *dpy, int screen, Window root, unsigned int w, unsigned int h
}
void
-drw_resize(Drw *drw, unsigned int w, unsigned int h)
-{
- if (!drw)
- return;
-
- drw->w = w;
- drw->h = h;
- if (drw->drawable)
- XFreePixmap(drw->dpy, drw->drawable);
- drw->drawable = XCreatePixmap(drw->dpy, drw->root, w, h, DefaultDepth(drw->dpy, drw->screen));
-}
-
-void
drw_free(Drw *drw)
{
XFreePixmap(drw->dpy, drw->drawable);
XFreeGC(drw->dpy, drw->gc);
- drw_fontset_free(drw->fonts);
free(drw);
}
-/* This function is an implementation detail. Library users should use
- * drw_fontset_create instead.
- */
-static Fnt *
-xfont_create(Drw *drw, const char *fontname, FcPattern *fontpattern)
-{
- Fnt *font;
- XftFont *xfont = NULL;
- FcPattern *pattern = NULL;
-
- if (fontname) {
- /* Using the pattern found at font->xfont->pattern does not yield the
- * same substitution results as using the pattern returned by
- * FcNameParse; using the latter results in the desired fallback
- * behaviour whereas the former just results in missing-character
- * rectangles being drawn, at least with some fonts. */
- if (!(xfont = XftFontOpenName(drw->dpy, drw->screen, fontname))) {
- fprintf(stderr, "error, cannot load font from name: '%s'\n", fontname);
- return NULL;
- }
- if (!(pattern = FcNameParse((FcChar8 *) fontname))) {
- fprintf(stderr, "error, cannot parse font name to pattern: '%s'\n", fontname);
- XftFontClose(drw->dpy, xfont);
- return NULL;
- }
- } else if (fontpattern) {
- if (!(xfont = XftFontOpenPattern(drw->dpy, fontpattern))) {
- fprintf(stderr, "error, cannot load font from pattern.\n");
- return NULL;
- }
- } else {
- die("no font specified.");
- }
-
- font = ecalloc(1, sizeof(Fnt));
- font->xfont = xfont;
- font->pattern = pattern;
- font->h = xfont->ascent + xfont->descent;
- font->dpy = drw->dpy;
-
- return font;
-}
-
-static void
-xfont_free(Fnt *font)
-{
- if (!font)
- return;
- if (font->pattern)
- FcPatternDestroy(font->pattern);
- XftFontClose(font->dpy, font->xfont);
- free(font);
-}
-
-Fnt*
-drw_fontset_create(Drw* drw, const char *fonts[], size_t fontcount)
-{
- Fnt *cur, *ret = NULL;
- size_t i;
-
- if (!drw || !fonts)
- return NULL;
-
- for (i = 1; i <= fontcount; i++) {
- if ((cur = xfont_create(drw, fonts[fontcount - i], NULL))) {
- cur->next = ret;
- ret = cur;
- }
- }
- return (drw->fonts = ret);
-}
-
-void
-drw_fontset_free(Fnt *font)
-{
- if (font) {
- drw_fontset_free(font->next);
- xfont_free(font);
- }
-}
-
void
drw_clr_create(Drw *drw, Clr *dest, const char *clrname)
{
@@ -161,21 +66,6 @@ drw_scm_create(Drw *drw, const char *clrnames[], size_t clrcount)
return ret;
}
-void
-drw_font_getexts(Fnt *font, const char *text, unsigned int len, unsigned int *w, unsigned int *h)
-{
- XGlyphInfo ext;
-
- if (!font || !text)
- return;
-
- XftTextExtentsUtf8(font->dpy, font->xfont, (XftChar8 *)text, len, &ext);
- if (w)
- *w = ext.xOff;
- if (h)
- *h = font->h;
-}
-
Cur *
drw_cur_create(Drw *drw, int shape)
{
diff --git a/drw.h b/drw.h
index 5a54185..7d8a605 100644
--- a/drw.h
+++ b/drw.h
@@ -4,14 +4,6 @@ typedef struct {
Cursor cursor;
} Cur;
-typedef struct Fnt {
- Display *dpy;
- unsigned int h;
- XftFont *xfont;
- FcPattern *pattern;
- struct Fnt *next;
-} Fnt;
-
enum { ColFg, ColBg, ColBorder, ColFloat, ColMaster }; /* Clr scheme index */
typedef XftColor Clr;
@@ -23,19 +15,12 @@ typedef struct {
Drawable drawable;
GC gc;
Clr *scheme;
- Fnt *fonts;
} 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);
-/* Fnt abstraction */
-Fnt *drw_fontset_create(Drw* drw, const char *fonts[], size_t fontcount);
-void drw_fontset_free(Fnt* set);
-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);