Compare commits
14 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 1bae806fe5 | |||
| 2f76a5cc49 | |||
| ab2253a0ee | |||
| c23f9dfe2e | |||
| eda3495acf | |||
| 1448916be3 | |||
| f12825443e | |||
| c750f87edd | |||
|
|
a9aa0d8ffb | ||
|
|
85fe518c1a | ||
|
|
244fa852fe | ||
|
|
7c3abae4e6 | ||
|
|
93f26863d1 | ||
|
|
74edc27caa |
20
.gitignore
vendored
Normal file
20
.gitignore
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
# Ignore dotfiles by default
|
||||
.*
|
||||
|
||||
# Ignore common (generated) file types
|
||||
*.a
|
||||
*.o
|
||||
*.d
|
||||
*.so
|
||||
*.out
|
||||
*.hex
|
||||
*.gz
|
||||
|
||||
# Ignore specific project files
|
||||
compile_commands.json
|
||||
/bin/
|
||||
/config.mk
|
||||
|
||||
# Unignore specific files.
|
||||
!.gitignore
|
||||
!.clang-format
|
||||
@@ -1,5 +1,6 @@
|
||||
MIT/X Consortium License
|
||||
|
||||
© 2010-2026 Hiltjo Posthuma <hiltjo@codemadness.org>
|
||||
© 2006-2019 Anselm R Garbe <anselm@garbe.ca>
|
||||
© 2006-2009 Jukka Salmi <jukka at salmi dot ch>
|
||||
© 2006-2007 Sander van Dijk <a dot h dot vandijk at gmail dot com>
|
||||
@@ -11,7 +12,6 @@ MIT/X Consortium License
|
||||
© 2008 Martin Hurton <martin dot hurton at gmail dot com>
|
||||
© 2008 Neale Pickett <neale dot woozle dot org>
|
||||
© 2009 Mate Nagy <mnagy at port70 dot net>
|
||||
© 2010-2016 Hiltjo Posthuma <hiltjo@codemadness.org>
|
||||
© 2010-2012 Connor Lane Smith <cls@lubutu.com>
|
||||
© 2011 Christoph Lohmann <20h@r-36.net>
|
||||
© 2015-2016 Quentin Rameau <quinq@fifth.space>
|
||||
107
Makefile
107
Makefile
@@ -1,45 +1,92 @@
|
||||
# dwm - dynamic window manager
|
||||
# See LICENSE file for copyright and license details.
|
||||
|
||||
include config.mk
|
||||
-include config.mk
|
||||
|
||||
SRC = drw.c dwm.c util.c
|
||||
OBJ = ${SRC:.c=.o}
|
||||
VERSION = 6.7
|
||||
|
||||
all: dwm
|
||||
INSTALL ?= install
|
||||
GZIP ?= gzip
|
||||
TAR ?= tar
|
||||
|
||||
.c.o:
|
||||
${CC} -c ${CFLAGS} $<
|
||||
CFLAGS := -Os $(CFLAGS) -g -std=gnu99\
|
||||
-Wall -Wextra -Wpedantic -Wno-pointer-arith
|
||||
CPPFLAGS := -DNDEBUG $(CPPFLAGS)\
|
||||
-DVERSION=\"$(VERSION)\" -D_DEFAULT_SOURCE -D_XOPEN_SOURCE=700L -DXINERAMA
|
||||
LDFLAGS := -flto $(LDFLAGS)
|
||||
LDLIBS := $(LDLIBS) -lm
|
||||
|
||||
${OBJ}: config.h config.mk
|
||||
# Use pkg-config to locate dependencies, and set the correct flags.
|
||||
ifeq (,$(shell command -v pkg-config))
|
||||
$(error Failed to locate pkg-config, please make sure it is installed or acessible through PATH.)
|
||||
else
|
||||
CPPFLAGS += $(shell pkg-config --cflags-only-I fontconfig freetype2 x11 xft xinerama)
|
||||
LDFLAGS += $(shell pkg-config --libs-only-L fontconfig freetype2 x11 xft xinerama)
|
||||
LDLIBS += $(shell pkg-config --libs-only-l fontconfig freetype2 x11 xft xinerama)
|
||||
endif
|
||||
|
||||
config.h:
|
||||
cp config.def.h $@
|
||||
SRC := $(wildcard src/*.c)
|
||||
OBJ := $(addsuffix .o,$(SRC))
|
||||
DEP := $(addsuffix .d,$(SRC))
|
||||
|
||||
dwm: ${OBJ}
|
||||
${CC} -o $@ ${OBJ} ${LDFLAGS}
|
||||
# Set Q to @ to silence commands being printed, unless --no-silent has been set
|
||||
ifeq (0, $(words $(findstring --no-silent,$(MAKEFLAGS))))
|
||||
Q=@
|
||||
endif
|
||||
|
||||
clean:
|
||||
rm -f dwm ${OBJ} dwm-${VERSION}.tar.gz
|
||||
msg = @printf '%-8s %s\n' "$(1)" "$(2)"
|
||||
|
||||
dist: clean
|
||||
mkdir -p dwm-${VERSION}
|
||||
cp -R LICENSE Makefile README config.def.h config.mk\
|
||||
dwm.1 drw.h util.h ${SRC} dwm.png transient.c dwm-${VERSION}
|
||||
tar -cf dwm-${VERSION}.tar dwm-${VERSION}
|
||||
gzip dwm-${VERSION}.tar
|
||||
rm -rf dwm-${VERSION}
|
||||
.PHONY:
|
||||
all: bin/dwm
|
||||
|
||||
install: all
|
||||
mkdir -p ${DESTDIR}${PREFIX}/bin
|
||||
cp -f dwm ${DESTDIR}${PREFIX}/bin
|
||||
chmod 755 ${DESTDIR}${PREFIX}/bin/dwm
|
||||
mkdir -p ${DESTDIR}${MANPREFIX}/man1
|
||||
sed "s/VERSION/${VERSION}/g" < dwm.1 > ${DESTDIR}${MANPREFIX}/man1/dwm.1
|
||||
chmod 644 ${DESTDIR}${MANPREFIX}/man1/dwm.1
|
||||
.PHONY:
|
||||
install: $(DESTDIR)/bin/dwm $(DESTDIR)/share/man/man1/dwm.1.gz
|
||||
$(DESTDIR)/bin/%: bin/%
|
||||
$(call msg,INSTALL,$@)
|
||||
$(Q)$(INSTALL) -D -m0755 $< $@
|
||||
|
||||
$(DESTDIR)/share/man/%: man/%
|
||||
$(call msg,INSTALL,$@)
|
||||
$(Q)$(INSTALL) -D -m0644 $< $@
|
||||
|
||||
.PHONY:
|
||||
uninstall:
|
||||
rm -f ${DESTDIR}${PREFIX}/bin/dwm\
|
||||
${DESTDIR}${MANPREFIX}/man1/dwm.1
|
||||
$(Q)$(RM) $(DESTDIR)/bin/dwm\
|
||||
$(DESTDIR)/share/man/man1/dwm.1.gz
|
||||
|
||||
.PHONY: all clean dist install uninstall
|
||||
.PHONY:
|
||||
clean:
|
||||
$(call msg,CLEAN,src/)
|
||||
$(Q)$(RM) $(OBJ)
|
||||
$(call msg,CLEAN,man/)
|
||||
$(Q)$(RM) $(MAN)
|
||||
$(call msg,CLEAN,bin/)
|
||||
$(Q)$(RM) -r bin/
|
||||
|
||||
# Links together the object files into the final binary.
|
||||
bin/dwm: $(OBJ) | bin/
|
||||
$(call msg,LD,$@)
|
||||
$(Q)$(CC) $(LDFLAGS) $(LDLIBS) -o $@ $^
|
||||
|
||||
# Compiles C sources into Object files
|
||||
%.c.o: %.c
|
||||
$(call msg,CC,$@)
|
||||
$(Q)$(CC) -c $(CPPFLAGS) $(CFLAGS) -o $@ $<
|
||||
|
||||
# Compress files requested for compression using GZIP
|
||||
%.gz: %
|
||||
$(call msg,GZIP,$@)
|
||||
$(Q)$(GZIP) -k $<
|
||||
|
||||
# Create directories
|
||||
%/:
|
||||
$(call msg-mkdir,$@)
|
||||
$(Q)mkdir $@
|
||||
|
||||
# Generate and include dependencies,
|
||||
# ignoring any errors that may occur when doing so.
|
||||
%.c.d: %.c
|
||||
$(Q)$(CC) -MM $(CPPFLAGS) -MF $@ $<
|
||||
ifeq (0, $(words $(findstring $(MAKECMDGOALS), clean)))
|
||||
-include $(DEP)
|
||||
endif
|
||||
|
||||
39
config.mk
39
config.mk
@@ -1,39 +0,0 @@
|
||||
# dwm version
|
||||
VERSION = 6.6
|
||||
|
||||
# Customize below to fit your system
|
||||
|
||||
# paths
|
||||
PREFIX = /usr/local
|
||||
MANPREFIX = ${PREFIX}/share/man
|
||||
|
||||
X11INC = /usr/X11R6/include
|
||||
X11LIB = /usr/X11R6/lib
|
||||
|
||||
# Xinerama, comment if you don't want it
|
||||
XINERAMALIBS = -lXinerama
|
||||
XINERAMAFLAGS = -DXINERAMA
|
||||
|
||||
# freetype
|
||||
FREETYPELIBS = -lfontconfig -lXft
|
||||
FREETYPEINC = /usr/include/freetype2
|
||||
# OpenBSD (uncomment)
|
||||
#FREETYPEINC = ${X11INC}/freetype2
|
||||
#MANPREFIX = ${PREFIX}/man
|
||||
|
||||
# includes and libs
|
||||
INCS = -I${X11INC} -I${FREETYPEINC}
|
||||
LIBS = -L${X11LIB} -lX11 ${XINERAMALIBS} ${FREETYPELIBS}
|
||||
|
||||
# flags
|
||||
CPPFLAGS = -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_XOPEN_SOURCE=700L -DVERSION=\"${VERSION}\" ${XINERAMAFLAGS}
|
||||
#CFLAGS = -g -std=c99 -pedantic -Wall -O0 ${INCS} ${CPPFLAGS}
|
||||
CFLAGS = -std=c99 -pedantic -Wall -Wno-deprecated-declarations -Os ${INCS} ${CPPFLAGS}
|
||||
LDFLAGS = ${LIBS}
|
||||
|
||||
# Solaris
|
||||
#CFLAGS = -fast ${INCS} -DVERSION=\"${VERSION}\"
|
||||
#LDFLAGS = ${LIBS}
|
||||
|
||||
# compiler and linker
|
||||
CC = cc
|
||||
@@ -36,6 +36,7 @@ static const float mfact = 0.55; /* factor of master area size [0.05..0.95]
|
||||
static const int nmaster = 1; /* number of clients in master area */
|
||||
static const int resizehints = 1; /* 1 means respect size hints in tiled resizals */
|
||||
static const int lockfullscreen = 1; /* 1 will force focus on the fullscreen window */
|
||||
static const int refreshrate = 120; /* refresh rate (per second) for client move/resize */
|
||||
|
||||
static const Layout layouts[] = {
|
||||
/* symbol arrange function */
|
||||
@@ -178,8 +178,7 @@ drw_clr_create(Drw *drw, Clr *dest, const char *clrname)
|
||||
die("error, cannot allocate color '%s'", clrname);
|
||||
}
|
||||
|
||||
/* Wrapper to create color schemes. The caller has to call free(3) on the
|
||||
* returned color scheme when done using it. */
|
||||
/* Create color schemes. */
|
||||
Clr *
|
||||
drw_scm_create(Drw *drw, const char *clrnames[], size_t clrcount)
|
||||
{
|
||||
@@ -187,7 +186,7 @@ drw_scm_create(Drw *drw, const char *clrnames[], size_t clrcount)
|
||||
Clr *ret;
|
||||
|
||||
/* need at least two colors for a scheme */
|
||||
if (!drw || !clrnames || clrcount < 2 || !(ret = ecalloc(clrcount, sizeof(XftColor))))
|
||||
if (!drw || !clrnames || clrcount < 2 || !(ret = ecalloc(clrcount, sizeof(Clr))))
|
||||
return NULL;
|
||||
|
||||
for (i = 0; i < clrcount; i++)
|
||||
@@ -195,6 +194,30 @@ drw_scm_create(Drw *drw, const char *clrnames[], size_t clrcount)
|
||||
return ret;
|
||||
}
|
||||
|
||||
void
|
||||
drw_clr_free(Drw *drw, Clr *c)
|
||||
{
|
||||
if (!drw || !c)
|
||||
return;
|
||||
|
||||
/* c is typedef XftColor Clr */
|
||||
XftColorFree(drw->dpy, DefaultVisual(drw->dpy, drw->screen),
|
||||
DefaultColormap(drw->dpy, drw->screen), c);
|
||||
}
|
||||
|
||||
void
|
||||
drw_scm_free(Drw *drw, Clr *scm, size_t clrcount)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
if (!drw || !scm)
|
||||
return;
|
||||
|
||||
for (i = 0; i < clrcount; i++)
|
||||
drw_clr_free(drw, &scm[i]);
|
||||
free(scm);
|
||||
}
|
||||
|
||||
void
|
||||
drw_setfontset(Drw *drw, Fnt *set)
|
||||
{
|
||||
@@ -40,7 +40,9 @@ void drw_font_getexts(Fnt *font, const char *text, unsigned int len, unsigned in
|
||||
|
||||
/* Colorscheme abstraction */
|
||||
void drw_clr_create(Drw *drw, Clr *dest, const char *clrname);
|
||||
void drw_clr_free(Drw *drw, Clr *c);
|
||||
Clr *drw_scm_create(Drw *drw, const char *clrnames[], size_t clrcount);
|
||||
void drw_scm_free(Drw *drw, Clr *scm, size_t clrcount);
|
||||
|
||||
/* Cursor abstraction */
|
||||
Cur *drw_cur_create(Drw *drw, int shape);
|
||||
@@ -486,7 +486,7 @@ cleanup(void)
|
||||
for (i = 0; i < CurLast; i++)
|
||||
drw_cur_free(drw, cursor[i]);
|
||||
for (i = 0; i < LENGTH(colors); i++)
|
||||
free(scheme[i]);
|
||||
drw_scm_free(drw, scheme[i], 3);
|
||||
free(scheme);
|
||||
XDestroyWindow(dpy, wmcheckwin);
|
||||
drw_free(drw);
|
||||
@@ -864,13 +864,14 @@ Atom
|
||||
getatomprop(Client *c, Atom prop)
|
||||
{
|
||||
int di;
|
||||
unsigned long dl;
|
||||
unsigned long nitems, dl;
|
||||
unsigned char *p = NULL;
|
||||
Atom da, atom = None;
|
||||
|
||||
if (XGetWindowProperty(dpy, c->win, prop, 0L, sizeof atom, False, XA_ATOM,
|
||||
&da, &di, &dl, &dl, &p) == Success && p) {
|
||||
atom = *(Atom *)p;
|
||||
&da, &di, &nitems, &dl, &p) == Success && p) {
|
||||
if (nitems > 0)
|
||||
atom = *(Atom *)p;
|
||||
XFree(p);
|
||||
}
|
||||
return atom;
|
||||
@@ -1171,7 +1172,7 @@ movemouse(const Arg *arg)
|
||||
handler[ev.type](&ev);
|
||||
break;
|
||||
case MotionNotify:
|
||||
if ((ev.xmotion.time - lasttime) <= (1000 / 60))
|
||||
if ((ev.xmotion.time - lasttime) <= (1000 / refreshrate))
|
||||
continue;
|
||||
lasttime = ev.xmotion.time;
|
||||
|
||||
@@ -1325,7 +1326,7 @@ resizemouse(const Arg *arg)
|
||||
handler[ev.type](&ev);
|
||||
break;
|
||||
case MotionNotify:
|
||||
if ((ev.xmotion.time - lasttime) <= (1000 / 60))
|
||||
if ((ev.xmotion.time - lasttime) <= (1000 / refreshrate))
|
||||
continue;
|
||||
lasttime = ev.xmotion.time;
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xutil.h>
|
||||
|
||||
/*
|
||||
int main(void) {
|
||||
Display *d;
|
||||
Window r, f, t = None;
|
||||
@@ -40,3 +41,4 @@ int main(void) {
|
||||
XCloseDisplay(d);
|
||||
exit(0);
|
||||
}
|
||||
*/
|
||||
Reference in New Issue
Block a user