Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use Xcursor theme from .Xresources #4

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
use nix nix/shell.nix --pure
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ st
config.h
tags
.nvimlog

.direnv/
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ options:
@echo "LDFLAGS = $(STLDFLAGS)"
@echo "CC = $(CC)"

config.h:
cp config.def.h config.h
config.h: config.def.h
cp $< $@

.c.o:
$(CC) $(STCFLAGS) -c $<
Expand All @@ -29,7 +29,7 @@ boxdraw.o: config.h st.h boxdraw_data.h
$(OBJ): config.h config.mk

st: $(OBJ)
$(CC) -o $@ $(OBJ) $(STLDFLAGS)
$(CC) -o $@ $^ $(STLDFLAGS)

clean:
rm -f st $(OBJ) st-$(VERSION).tar.gz
Expand Down
6 changes: 2 additions & 4 deletions config.def.h
Original file line number Diff line number Diff line change
Expand Up @@ -177,11 +177,9 @@ static unsigned int cols = 80;
static unsigned int rows = 24;

/*
* Default colour and shape of the mouse cursor
* Default shape of the mouse cursor
*/
static unsigned int mouseshape = XC_xterm;
static unsigned int mousefg = 7;
static unsigned int mousebg = 0;
static char* mouseshape = "xterm";

/*
* Color used to display font attributes when fontconfig selected a font which
Expand Down
2 changes: 1 addition & 1 deletion config.mk
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ INCS = -I$(X11INC) \
`$(PKG_CONFIG) --cflags fontconfig` \
`$(PKG_CONFIG) --cflags freetype2` \
`$(PKG_CONFIG) --cflags harfbuzz`
LIBS = -L$(X11LIB) -lm -lrt -lX11 -lutil -lXft -lXrender\
LIBS = -L$(X11LIB) -lm -lrt -lX11 -lutil -lXft -lXrender -lXcursor \
`$(PKG_CONFIG) --libs fontconfig` \
`$(PKG_CONFIG) --libs freetype2` \
`$(PKG_CONFIG) --libs harfbuzz`
Expand Down
21 changes: 21 additions & 0 deletions nix/shell.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#! /usr/bin/env nix-shell
#! nix-shell --pure shell.nix

{ pkgs ? import <nixpkgs> {} }:

pkgs.mkShell {
buildInputs = with pkgs; [
gnumake pkg-config
xorg.libX11.dev
xorg.libXft
xorg.libXinerama
xorg.libXcursor
freetype
harfbuzz ];

shellHook = ''
export SSH_AUTH_SOCK=/run/user/$UID/keyring/ssh
export GIT_SSL_CAINFO=/etc/ssl/certs/ca-certificates.crt
export SSL_CERT_FILE=/etc/ssl/certs/ca-certificates.crt
'';
}
44 changes: 14 additions & 30 deletions x.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include <X11/Xft/Xft.h>
#include <X11/XKBlib.h>
#include <X11/Xresource.h>
#include <X11/Xcursor/Xcursor.h>

char *argv0;
#include "arg.h"
Expand Down Expand Up @@ -1105,7 +1106,7 @@ xloadsparefont(FcPattern *pattern, int flags)
{
FcPattern *match;
FcResult result;

match = FcFontMatch(NULL, pattern, &result);
if (!match) {
return 1;
Expand Down Expand Up @@ -1147,50 +1148,50 @@ xloadsparefonts(void)
}

for (fp = font2; fp - font2 < fc; ++fp) {

if (**fp == '-')
pattern = XftXlfdParse(*fp, False, False);
else
pattern = FcNameParse((FcChar8 *)*fp);

if (!pattern)
die("can't open spare font %s\n", *fp);

if (defaultfontsize > 0) {
sizeshift = usedfontsize - defaultfontsize;
if (sizeshift != 0 &&
FcPatternGetDouble(pattern, FC_PIXEL_SIZE, 0, &fontval) ==
FcResultMatch) {
FcResultMatch) {
fontval += sizeshift;
FcPatternDel(pattern, FC_PIXEL_SIZE);
FcPatternDel(pattern, FC_SIZE);
FcPatternAddDouble(pattern, FC_PIXEL_SIZE, fontval);
}
}

FcPatternAddBool(pattern, FC_SCALABLE, 1);

FcConfigSubstitute(NULL, pattern, FcMatchPattern);
XftDefaultSubstitute(xw.dpy, xw.scr, pattern);

if (xloadsparefont(pattern, FRC_NORMAL))
die("can't open spare font %s\n", *fp);

FcPatternDel(pattern, FC_SLANT);
FcPatternAddInteger(pattern, FC_SLANT, FC_SLANT_ITALIC);
if (xloadsparefont(pattern, FRC_ITALIC))
die("can't open spare font %s\n", *fp);

FcPatternDel(pattern, FC_WEIGHT);
FcPatternAddInteger(pattern, FC_WEIGHT, FC_WEIGHT_BOLD);
if (xloadsparefont(pattern, FRC_ITALICBOLD))
die("can't open spare font %s\n", *fp);

FcPatternDel(pattern, FC_SLANT);
FcPatternAddInteger(pattern, FC_SLANT, FC_SLANT_ROMAN);
if (xloadsparefont(pattern, FRC_BOLD))
die("can't open spare font %s\n", *fp);

FcPatternDestroy(pattern);
}
}
Expand Down Expand Up @@ -1358,26 +1359,9 @@ xinit(int cols, int rows)

/* white cursor, black outline */
xw.pointerisvisible = 1;
xw.vpointer = XCreateFontCursor(xw.dpy, mouseshape);
xw.vpointer = XcursorLibraryLoadCursor(xw.dpy, mouseshape);
XDefineCursor(xw.dpy, xw.win, xw.vpointer);

if (XParseColor(xw.dpy, xw.cmap, colorname[mousefg], &xmousefg) == 0) {
xmousefg.red = 0xffff;
xmousefg.green = 0xffff;
xmousefg.blue = 0xffff;
}

if (XParseColor(xw.dpy, xw.cmap, colorname[mousebg], &xmousebg) == 0) {
xmousebg.red = 0x0000;
xmousebg.green = 0x0000;
xmousebg.blue = 0x0000;
}

XRecolorCursor(xw.dpy, xw.vpointer, &xmousefg, &xmousebg);
blankpm = XCreateBitmapFromData(xw.dpy, xw.win, &(char){0}, 1, 1);
xw.bpointer = XCreatePixmapCursor(xw.dpy, blankpm, blankpm,
&xmousefg, &xmousebg, 0, 0);

xw.xembed = XInternAtom(xw.dpy, "_XEMBED", False);
xw.wmdeletewin = XInternAtom(xw.dpy, "WM_DELETE_WINDOW", False);
xw.netwmname = XInternAtom(xw.dpy, "_NET_WM_NAME", False);
Expand Down