diff options
| -rw-r--r-- | .gitignore | 3 | ||||
| -rw-r--r-- | Makefile | 116 | ||||
| -rw-r--r-- | README.md | 48 | ||||
| -rw-r--r-- | src/config/config.mk | 40 | ||||
| -rw-r--r-- | src/core/dwm.c | 4 | ||||
| -rw-r--r-- | src/core/dwm.h | 2 | ||||
| -rw-r--r-- | src/core/globals.h | 21 | ||||
| -rw-r--r-- | src/core/types.h | 158 | ||||
| -rw-r--r-- | src/drw/drw.c | 2 | ||||
| -rw-r--r-- | src/drw/drw.h | 1 | ||||
| -rw-r--r-- | src/transient/transient.c | 90 | ||||
| -rw-r--r-- | src/ui/bar.h | 13 | ||||
| -rw-r--r-- | src/ui/input.h | 13 | ||||
| -rw-r--r-- | src/ui/systray.h | 12 | ||||
| -rw-r--r-- | src/util/util.c | 4 | ||||
| -rw-r--r-- | src/util/util.h | 4 | ||||
| -rw-r--r-- | src/wm/client.h | 26 | ||||
| -rw-r--r-- | src/wm/layout.h | 12 | ||||
| -rw-r--r-- | src/wm/monitor.h | 15 | ||||
| -rw-r--r-- | src/x11/xevents.h | 25 | ||||
| -rw-r--r-- | src/x11/xutil.h | 21 |
21 files changed, 440 insertions, 190 deletions
| @@ -4,4 +4,5 @@ | |||
| 4 | patches | 4 | patches |
| 5 | *.o | 5 | *.o |
| 6 | dwm | 6 | dwm |
| 7 | 7 | *.d | |
| 8 | .idea/ | ||
| @@ -1,46 +1,95 @@ | |||
| 1 | # dwm - dynamic window manager | 1 | # ========================= |
| 2 | # See LICENSE file for copyright and license details. | 2 | # config |
| 3 | # ========================= | ||
| 3 | 4 | ||
| 4 | include src/config/config.mk | 5 | PREFIX = /usr/local |
| 6 | MANPREFIX = ${PREFIX}/share/man | ||
| 5 | 7 | ||
| 6 | SRC = src/drw/drw.c src/core/dwm.c src/util/util.c | 8 | X11INC = /usr/X11R6/include |
| 7 | OBJ = $(SRC:.c=.o) | 9 | X11LIB = /usr/X11R6/lib |
| 8 | 10 | ||
| 9 | CFLAGS += -std=c99 -pedantic -Wall -Wno-deprecated-declarations -Os \ | 11 | FREETYPEINC = /usr/include/freetype2 |
| 10 | -I/usr/X11R6/include \ | 12 | FREETYPELIBS= -lfontconfig -lXft |
| 11 | -I/usr/include/freetype2 \ | 13 | |
| 12 | -I./src/util \ | 14 | XINERAMAFLAGS = -DXINERAMA |
| 15 | XINERAMALIBS = -lXinerama | ||
| 16 | |||
| 17 | # ========================= | ||
| 18 | # flags | ||
| 19 | # ========================= | ||
| 20 | |||
| 21 | INCS = \ | ||
| 22 | -I${X11INC} \ | ||
| 23 | -I${FREETYPEINC} \ | ||
| 24 | -I./src \ | ||
| 13 | -I./src/drw \ | 25 | -I./src/drw \ |
| 14 | -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_XOPEN_SOURCE=700L \ | 26 | -I./src/util |
| 15 | -DVERSION=\"6.4\" -DXINERAMA | 27 | |
| 28 | CPPFLAGS = \ | ||
| 29 | -D_DEFAULT_SOURCE \ | ||
| 30 | -D_BSD_SOURCE \ | ||
| 31 | -D_XOPEN_SOURCE=700L \ | ||
| 32 | -DVERSION=\"${VERSION}\" \ | ||
| 33 | ${XINERAMAFLAGS} | ||
| 34 | |||
| 35 | CFLAGS = \ | ||
| 36 | -std=c99 \ | ||
| 37 | -pedantic \ | ||
| 38 | -Wall \ | ||
| 39 | -Wno-deprecated-declarations \ | ||
| 40 | -Os \ | ||
| 41 | ${INCS} \ | ||
| 42 | ${CPPFLAGS} | ||
| 43 | |||
| 44 | LDFLAGS = \ | ||
| 45 | -L${X11LIB} \ | ||
| 46 | -lX11 \ | ||
| 47 | ${XINERAMALIBS} \ | ||
| 48 | ${FREETYPELIBS} \ | ||
| 49 | -lX11-xcb \ | ||
| 50 | -lxcb \ | ||
| 51 | -lxcb-res | ||
| 52 | |||
| 53 | CC = clang | ||
| 54 | |||
| 55 | # ========================= | ||
| 56 | # sources | ||
| 57 | # ========================= | ||
| 58 | |||
| 59 | SRC = \ | ||
| 60 | src/core/dwm.c \ | ||
| 61 | src/drw/drw.c \ | ||
| 62 | src/util/util.c | ||
| 63 | # src/core/globals.c \ | ||
| 64 | # src/x11/xevents.c \ | ||
| 65 | # src/x11/xutil.c \ | ||
| 66 | # src/wm/client.c \ | ||
| 67 | # src/wm/monitor.c \ | ||
| 68 | # src/wm/layout.c \ | ||
| 69 | # src/ui/input.c \ | ||
| 70 | # src/ui/bar.c \ | ||
| 71 | # src/ui/systray.c \ | ||
| 16 | 72 | ||
| 17 | LDFLAGS += -L/usr/X11R6/lib -lX11 -lXinerama -lfontconfig -lXft -lX11-xcb -lxcb -lxcb-res | 73 | |
| 74 | OBJ = ${SRC:.c=.o} | ||
| 75 | |||
| 76 | # ========================= | ||
| 77 | # build rules | ||
| 78 | # ========================= | ||
| 18 | 79 | ||
| 19 | all: dwm | 80 | all: dwm |
| 20 | 81 | ||
| 21 | %.o: %.c | 82 | %.o: %.c |
| 22 | ${CC} -c ${CFLAGS} -o $@ $< | 83 | ${CC} -c ${CFLAGS} -o $@ $< |
| 23 | 84 | ||
| 24 | ${OBJ}: src/config/config.h src/config/config.mk | ||
| 25 | |||
| 26 | config.h: | ||
| 27 | cp src/config/config.def.h $@ | ||
| 28 | |||
| 29 | dwm: ${OBJ} | 85 | dwm: ${OBJ} |
| 30 | ${CC} -o $@ ${OBJ} ${LDFLAGS} | 86 | ${CC} -o $@ ${OBJ} ${LDFLAGS} |
| 31 | 87 | ||
| 32 | clean: | 88 | # ========================= |
| 33 | rm -f dwm ${OBJ} dwm-${VERSION}.tar.gz | 89 | # install |
| 90 | # ========================= | ||
| 34 | 91 | ||
| 35 | dist: clean | 92 | install: dwm |
| 36 | mkdir -p dwm-${VERSION} | ||
| 37 | cp -R LICENSE Makefile README src/config/config.def.h src/config/config.mk \ | ||
| 38 | src/core/dwm.1 src/drw/drw.h src/util/util.h ${SRC} /assets/dwm.png src/transient/transient.c dwm-${VERSION} | ||
| 39 | tar -cf dwm-${VERSION}.tar dwm-${VERSION} | ||
| 40 | gzip dwm-${VERSION}.tar | ||
| 41 | rm -rf dwm-${VERSION} | ||
| 42 | |||
| 43 | install: all | ||
| 44 | mkdir -p ${DESTDIR}${PREFIX}/bin | 93 | mkdir -p ${DESTDIR}${PREFIX}/bin |
| 45 | cp -f dwm ${DESTDIR}${PREFIX}/bin | 94 | cp -f dwm ${DESTDIR}${PREFIX}/bin |
| 46 | chmod 755 ${DESTDIR}${PREFIX}/bin/dwm | 95 | chmod 755 ${DESTDIR}${PREFIX}/bin/dwm |
| @@ -50,6 +99,13 @@ install: all | |||
| 50 | 99 | ||
| 51 | uninstall: | 100 | uninstall: |
| 52 | rm -f ${DESTDIR}${PREFIX}/bin/dwm \ | 101 | rm -f ${DESTDIR}${PREFIX}/bin/dwm \ |
| 53 | ${DESTDIR}${MANPREFIX}/man1/dwm.1 | 102 | ${DESTDIR}${MANPREFIX}/man1/dwm.1 |
| 103 | |||
| 104 | # ========================= | ||
| 105 | # housekeeping | ||
| 106 | # ========================= | ||
| 107 | |||
| 108 | clean: | ||
| 109 | rm -f dwm ${OBJ} | ||
| 54 | 110 | ||
| 55 | .PHONY: all clean dist install uninstall | 111 | .PHONY: all clean install uninstall |
| @@ -1,42 +1,48 @@ | |||
| 1 | ## Installation | 1 | ## Installation |
| 2 | ------------ | ||
| 3 | Edit config.mk to match your local setup (dwm is installed into | ||
| 4 | the /usr/local namespace by default). | ||
| 5 | 2 | ||
| 6 | Afterwards enter the following command to build and install dwm (if | 3 | Hit command below in the root dir |
| 7 | necessary as root): | ||
| 8 | 4 | ||
| 9 | ```bash | 5 | ```bash |
| 10 | make clean install | 6 | make clean install |
| 11 | ``` | 7 | ``` |
| 12 | 8 | ||
| 13 | ## Running dwm | 9 | Or if you use arch-based distro and like pacman |
| 14 | Add the following line to your .xinitrc to start dwm using startx: | 10 | |
| 15 | ```bash | 11 | ```bash |
| 16 | exec dwm | 12 | makepkg -si |
| 17 | ``` | 13 | ``` |
| 18 | 14 | ||
| 19 | In order to connect dwm to a specific display, make sure that | 15 | ## Execution |
| 20 | the DISPLAY environment variable is set correctly, e.g.: | 16 | |
| 17 | Probably the best way is to use your xinitrc config file and do something like | ||
| 21 | 18 | ||
| 22 | ```bash | 19 | ```bash |
| 23 | DISPLAY=foo.bar:1 exec dwm | 20 | dbus-run-session dwm |
| 24 | ``` | 21 | ``` |
| 25 | In order to display status info in the bar, you can do something | 22 | |
| 26 | like this in your .xinitrc: | 23 | If you fancy having system stuff in your status bar you need to do something like this or use your own **better** |
| 24 | statusbar. | ||
| 27 | 25 | ||
| 28 | ```bash | 26 | ```bash |
| 29 | while xsetroot -name "`date` `uptime | sed 's/.*,//'`" | 27 | while |
| 30 | do | 28 | mem_used=$(free -h | awk '/^Mem:/ {print $3}') |
| 31 | sleep 1 | 29 | cpu_load=$(top -bn1 | grep "Cpu(s)" | awk '{print $2 + $4"%"}') |
| 32 | done & | 30 | battery_capacity=$(cat /sys/class/power_supply/BAT0/capacity) |
| 33 | exec dwm | 31 | volume_level=$(wpctl get-volume @DEFAULT_AUDIO_SINK@) |
| 32 | disk_usage=$(df -h / | awk 'NR==2 {print $3 "/" $2}') | ||
| 33 | |||
| 34 | xsetroot -name "$volume_level | Btr: $battery_capacity% | RAM: $mem_used | CPU: $cpu_load | Disk: $disk_usage | $(date '+%d.%m.%Y (%a) %T')" | ||
| 35 | do | ||
| 36 | sleep 5 | ||
| 37 | done & | ||
| 38 | |||
| 34 | ``` | 39 | ``` |
| 35 | 40 | ||
| 36 | ## Configuration | 41 | ## Configuration |
| 37 | The configuration of dwm is done by creating a custom config.h | 42 | |
| 38 | and (re)compiling the source code. | 43 | You can customize looks via `Xresources` and keybindings via `config.h`. After you're done hit `super` + `r` to restart |
| 44 | the dwm process. | ||
| 39 | 45 | ||
| 40 | ## Additional resources | 46 | ## Additional resources |
| 41 | 47 | ||
| 42 | Restart patch pulled from (gist.github.org/bpsuntrup)[bpsuntrup's gist] | 48 | Swallow, Xresources, Gaps, Systray pulled from [suckless.org](https://dwm.suckless.org/patches/) |
diff --git a/src/config/config.mk b/src/config/config.mk deleted file mode 100644 index f8dab1b..0000000 --- a/src/config/config.mk +++ /dev/null | |||
| @@ -1,40 +0,0 @@ | |||
| 1 | # dwm version | ||
| 2 | VERSION = 6.4 | ||
| 3 | |||
| 4 | # Customize below to fit your system | ||
| 5 | |||
| 6 | # paths | ||
| 7 | PREFIX = /usr/local | ||
| 8 | MANPREFIX = ${PREFIX}/share/man | ||
| 9 | |||
| 10 | X11INC = /usr/X11R6/include | ||
| 11 | X11LIB = /usr/X11R6/lib | ||
| 12 | |||
| 13 | # Xinerama, comment if you don't want it | ||
| 14 | XINERAMALIBS = -lXinerama | ||
| 15 | XINERAMAFLAGS = -DXINERAMA | ||
| 16 | |||
| 17 | # freetype | ||
| 18 | FREETYPELIBS = -lfontconfig -lXft | ||
| 19 | FREETYPEINC = /usr/include/freetype2 | ||
| 20 | # OpenBSD (uncomment) | ||
| 21 | #FREETYPEINC = ${X11INC}/freetype2 | ||
| 22 | #MANPREFIX = ${PREFIX}/man | ||
| 23 | #KVMLIB = -lkvm | ||
| 24 | |||
| 25 | # includes and libs | ||
| 26 | INCS = -I${X11INC} -I${FREETYPEINC} | ||
| 27 | LIBS = -L${X11LIB} -lX11 ${XINERAMALIBS} ${FREETYPELIBS} -lX11-xcb -lxcb -lxcb-res ${KVMLIB} | ||
| 28 | |||
| 29 | # flags | ||
| 30 | CPPFLAGS = -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_XOPEN_SOURCE=700L -DVERSION=\"${VERSION}\" ${XINERAMAFLAGS} | ||
| 31 | #CFLAGS = -g -std=c99 -pedantic -Wall -O0 ${INCS} ${CPPFLAGS} | ||
| 32 | CFLAGS = -std=c99 -pedantic -Wall -Wno-deprecated-declarations -Os ${INCS} ${CPPFLAGS} | ||
| 33 | LDFLAGS = ${LIBS} | ||
| 34 | |||
| 35 | # Solaris | ||
| 36 | #CFLAGS = -fast ${INCS} -DVERSION=\"${VERSION}\" | ||
| 37 | #LDFLAGS = ${LIBS} | ||
| 38 | |||
| 39 | # compiler and linker | ||
| 40 | CC = tcc | ||
diff --git a/src/core/dwm.c b/src/core/dwm.c index cd7fdb0..6d4cdcd 100644 --- a/src/core/dwm.c +++ b/src/core/dwm.c | |||
| @@ -851,7 +851,7 @@ Atom getatomprop(Client *c, Atom prop) | |||
| 851 | return atom; | 851 | return atom; |
| 852 | } | 852 | } |
| 853 | 853 | ||
| 854 | unsigned int getsystraywidth() | 854 | unsigned int getsystraywidth(void) |
| 855 | { | 855 | { |
| 856 | unsigned int w = 0; | 856 | unsigned int w = 0; |
| 857 | Client *i; | 857 | Client *i; |
| @@ -1970,7 +1970,7 @@ void updatebarpos(Monitor *m) | |||
| 1970 | m->by = -bh; | 1970 | m->by = -bh; |
| 1971 | } | 1971 | } |
| 1972 | 1972 | ||
| 1973 | void updateclientlist() | 1973 | void updateclientlist(void) |
| 1974 | { | 1974 | { |
| 1975 | Client *c; | 1975 | Client *c; |
| 1976 | Monitor *m; | 1976 | Monitor *m; |
diff --git a/src/core/dwm.h b/src/core/dwm.h index 273645a..d3bdf5a 100644 --- a/src/core/dwm.h +++ b/src/core/dwm.h | |||
| @@ -153,7 +153,7 @@ static void focusin(XEvent *e); | |||
| 153 | static Atom getatomprop(Client *c, Atom prop); | 153 | static Atom getatomprop(Client *c, Atom prop); |
| 154 | static int getrootptr(int *x, int *y); | 154 | static int getrootptr(int *x, int *y); |
| 155 | static long getstate(Window w); | 155 | static long getstate(Window w); |
| 156 | static unsigned int getsystraywidth(); | 156 | static unsigned int getsystraywidth(void); |
| 157 | static int gettextprop(Window w, Atom atom, char *text, unsigned int size); | 157 | static int gettextprop(Window w, Atom atom, char *text, unsigned int size); |
| 158 | static void grabbuttons(Client *c, int focused); | 158 | static void grabbuttons(Client *c, int focused); |
| 159 | static void grabkeys(void); | 159 | static void grabkeys(void); |
diff --git a/src/core/globals.h b/src/core/globals.h new file mode 100644 index 0000000..4b800fe --- /dev/null +++ b/src/core/globals.h | |||
| @@ -0,0 +1,21 @@ | |||
| 1 | |||
| 2 | #pragma once | ||
| 3 | |||
| 4 | #include "types.h" | ||
| 5 | |||
| 6 | extern Display *dpy; | ||
| 7 | extern Window root, wmcheckwin; | ||
| 8 | |||
| 9 | extern Monitor *mons, *selmon; | ||
| 10 | |||
| 11 | extern int screen; | ||
| 12 | extern int sw, sh; | ||
| 13 | extern int bh; | ||
| 14 | extern int running; | ||
| 15 | extern unsigned int numlockmask; | ||
| 16 | |||
| 17 | extern Atom wmatom[WMLast]; | ||
| 18 | extern Atom netatom[NetLast]; | ||
| 19 | extern Atom xatom[XLast]; | ||
| 20 | |||
| 21 | extern Systray *systray; | ||
diff --git a/src/core/types.h b/src/core/types.h new file mode 100644 index 0000000..dc10fc0 --- /dev/null +++ b/src/core/types.h | |||
| @@ -0,0 +1,158 @@ | |||
| 1 | |||
| 2 | #pragma once | ||
| 3 | |||
| 4 | #include <X11/Xatom.h> | ||
| 5 | #include <X11/Xlib.h> | ||
| 6 | #include <sys/types.h> | ||
| 7 | |||
| 8 | /* cursors */ | ||
| 9 | enum { CurNormal, CurResize, CurMove, CurLast }; | ||
| 10 | |||
| 11 | /* color schemes */ | ||
| 12 | enum { SchemeNorm, SchemeSel }; | ||
| 13 | |||
| 14 | /* EWMH atoms */ | ||
| 15 | enum { | ||
| 16 | NetSupported, | ||
| 17 | NetWMName, | ||
| 18 | NetWMState, | ||
| 19 | NetWMCheck, | ||
| 20 | NetSystemTray, | ||
| 21 | NetSystemTrayOP, | ||
| 22 | NetSystemTrayOrientation, | ||
| 23 | NetSystemTrayOrientationHorz, | ||
| 24 | NetWMFullscreen, | ||
| 25 | NetActiveWindow, | ||
| 26 | NetWMWindowType, | ||
| 27 | NetWMWindowTypeDialog, | ||
| 28 | NetClientList, | ||
| 29 | NetLast | ||
| 30 | }; | ||
| 31 | |||
| 32 | /* XEmbed */ | ||
| 33 | enum { Manager, Xembed, XembedInfo, XLast }; | ||
| 34 | |||
| 35 | /* ICCCM */ | ||
| 36 | enum { WMProtocols, WMDelete, WMState, WMTakeFocus, WMLast }; | ||
| 37 | |||
| 38 | /* clicks */ | ||
| 39 | enum { | ||
| 40 | ClkTagBar, | ||
| 41 | ClkLtSymbol, | ||
| 42 | ClkStatusText, | ||
| 43 | ClkWinTitle, | ||
| 44 | ClkClientWin, | ||
| 45 | ClkRootWin, | ||
| 46 | ClkLast | ||
| 47 | }; | ||
| 48 | |||
| 49 | /* generic argument */ | ||
| 50 | typedef union { | ||
| 51 | int i; | ||
| 52 | unsigned int ui; | ||
| 53 | float f; | ||
| 54 | const void *v; | ||
| 55 | } Arg; | ||
| 56 | |||
| 57 | /* input */ | ||
| 58 | typedef struct { | ||
| 59 | unsigned int click; | ||
| 60 | unsigned int mask; | ||
| 61 | unsigned int button; | ||
| 62 | void (*func)(const Arg *arg); | ||
| 63 | const Arg arg; | ||
| 64 | } Button; | ||
| 65 | |||
| 66 | typedef struct { | ||
| 67 | unsigned int mod; | ||
| 68 | KeySym keysym; | ||
| 69 | void (*func)(const Arg *); | ||
| 70 | const Arg arg; | ||
| 71 | } Key; | ||
| 72 | |||
| 73 | /* forward decls */ | ||
| 74 | typedef struct Client Client; | ||
| 75 | typedef struct Monitor Monitor; | ||
| 76 | |||
| 77 | /* layout */ | ||
| 78 | typedef struct { | ||
| 79 | const char *symbol; | ||
| 80 | void (*arrange)(Monitor *); | ||
| 81 | } Layout; | ||
| 82 | |||
| 83 | /* client */ | ||
| 84 | struct Client { | ||
| 85 | char name[256]; | ||
| 86 | |||
| 87 | float mina, maxa; | ||
| 88 | int basew, baseh, incw, inch, maxw, maxh, minw, minh; | ||
| 89 | int hintsvalid; | ||
| 90 | |||
| 91 | int x, y, w, h; | ||
| 92 | int oldx, oldy, oldw, oldh; | ||
| 93 | int bw, oldbw; | ||
| 94 | |||
| 95 | unsigned int tags; | ||
| 96 | int isfixed, isfloating, isurgent, neverfocus; | ||
| 97 | int oldstate, isfullscreen; | ||
| 98 | int isterminal, noswallow; | ||
| 99 | |||
| 100 | pid_t pid; | ||
| 101 | |||
| 102 | Client *next; | ||
| 103 | Client *snext; | ||
| 104 | Client *swallowing; | ||
| 105 | |||
| 106 | Monitor *mon; | ||
| 107 | Window win; | ||
| 108 | }; | ||
| 109 | |||
| 110 | /* monitor */ | ||
| 111 | struct Monitor { | ||
| 112 | char ltsymbol[16]; | ||
| 113 | |||
| 114 | float mfact; | ||
| 115 | int nmaster; | ||
| 116 | int num; | ||
| 117 | |||
| 118 | int mx, my, mw, mh; | ||
| 119 | int wx, wy, ww, wh; | ||
| 120 | int by; | ||
| 121 | |||
| 122 | int gappih, gappiv; | ||
| 123 | int gappoh, gappov; | ||
| 124 | |||
| 125 | unsigned int seltags; | ||
| 126 | unsigned int sellt; | ||
| 127 | unsigned int tagset[2]; | ||
| 128 | |||
| 129 | int showbar; | ||
| 130 | int topbar; | ||
| 131 | |||
| 132 | Client *clients; | ||
| 133 | Client *sel; | ||
| 134 | Client *stack; | ||
| 135 | |||
| 136 | Monitor *next; | ||
| 137 | Window barwin; | ||
| 138 | |||
| 139 | const Layout *lt[2]; | ||
| 140 | }; | ||
| 141 | |||
| 142 | /* rules */ | ||
| 143 | typedef struct { | ||
| 144 | const char *class; | ||
| 145 | const char *instance; | ||
| 146 | const char *title; | ||
| 147 | unsigned int tags; | ||
| 148 | int isfloating; | ||
| 149 | int isterminal; | ||
| 150 | int noswallow; | ||
| 151 | int monitor; | ||
| 152 | } Rule; | ||
| 153 | |||
| 154 | /* systray */ | ||
| 155 | typedef struct Systray { | ||
| 156 | Window win; | ||
| 157 | Client *icons; | ||
| 158 | } Systray; | ||
diff --git a/src/drw/drw.c b/src/drw/drw.c index 05420c0..5e90c2c 100644 --- a/src/drw/drw.c +++ b/src/drw/drw.c | |||
| @@ -111,7 +111,7 @@ static Fnt *xfont_create(Drw *drw, const char *fontname, FcPattern *fontpattern) | |||
| 111 | /* Using the pattern found at font->xfont->pattern does not | 111 | /* Using the pattern found at font->xfont->pattern does not |
| 112 | * yield the same substitution results as using the pattern | 112 | * yield the same substitution results as using the pattern |
| 113 | * returned by FcNameParse; using the latter results in the | 113 | * returned by FcNameParse; using the latter results in the |
| 114 | * desired fallback behaviour whereas the former just results in | 114 | * desired fallback behavior whereas the former just results in |
| 115 | * missing-character rectangles being drawn, at least with some | 115 | * missing-character rectangles being drawn, at least with some |
| 116 | * fonts. */ | 116 | * fonts. */ |
| 117 | if (!(xfont = | 117 | if (!(xfont = |
diff --git a/src/drw/drw.h b/src/drw/drw.h index 88308ab..e1c91ae 100644 --- a/src/drw/drw.h +++ b/src/drw/drw.h | |||
| @@ -1,5 +1,6 @@ | |||
| 1 | /* See LICENSE file for copyright and license details. */ | 1 | /* See LICENSE file for copyright and license details. */ |
| 2 | 2 | ||
| 3 | #include <X11/Xft/Xft.h> | ||
| 3 | typedef struct { | 4 | typedef struct { |
| 4 | Cursor cursor; | 5 | Cursor cursor; |
| 5 | } Cur; | 6 | } Cur; |
diff --git a/src/transient/transient.c b/src/transient/transient.c deleted file mode 100644 index fed0f77..0000000 --- a/src/transient/transient.c +++ /dev/null | |||
| @@ -1,90 +0,0 @@ | |||
| 1 | #include <X11/Xlib.h> | ||
| 2 | #include <X11/Xutil.h> | ||
| 3 | #include <stdlib.h> | ||
| 4 | #include <unistd.h> | ||
| 5 | |||
| 6 | #define FLOATING_WINDOW_WIDTH 400 | ||
| 7 | #define FLOATING_WINDOW_HEIGHT 400 | ||
| 8 | #define FLOATING_WINDOW_X_POS 100 | ||
| 9 | #define FLOATING_WINDOW_Y_POS 100 | ||
| 10 | |||
| 11 | #define TRANSIENT_WINDOW_WIDTH 100 | ||
| 12 | #define TRANSIENT_WINDOW_HEIGHT 100 | ||
| 13 | #define TRANSIENT_WINDOW_X_POS 50 | ||
| 14 | #define TRANSIENT_WINDOW_Y_POS 50 | ||
| 15 | |||
| 16 | #define SLEEP_TIME 5 | ||
| 17 | |||
| 18 | #define WINDOW_BORDER_WIDTH 0 | ||
| 19 | #define WINDOW_BORDER_COLOR 0 | ||
| 20 | #define WINDOW_BACKGROUND_COLOR 0 | ||
| 21 | |||
| 22 | /** | ||
| 23 | * @brief Function that creates and manages floating and transient window. | ||
| 24 | * | ||
| 25 | * This program opens an X display, creates a floating window with specific | ||
| 26 | * size and position, and then creates a transient (child) window after a | ||
| 27 | * specified delay. The transient window is always associated with the | ||
| 28 | * floating window, meaning it will behave as a child of the floating window. | ||
| 29 | * The program uses Xlib to interact with the X server, handle events, and | ||
| 30 | * manage window properties such as size, title, and position. | ||
| 31 | * | ||
| 32 | * The key steps are: | ||
| 33 | * 1. Create the floating window and set its size constraints. | ||
| 34 | * 2. After a delay (5 seconds), create the transient window and associate | ||
| 35 | * it with the floating window. | ||
| 36 | * 3. Display both windows on the screen. | ||
| 37 | * 4. Wait for and process X events in an infinite loop. This allows the | ||
| 38 | * windows to remain open and interact with the X server. | ||
| 39 | * | ||
| 40 | * @return int Exit status (always 0). | ||
| 41 | */ | ||
| 42 | int main(void) | ||
| 43 | { | ||
| 44 | Display *display; | ||
| 45 | Window rootWindow, floatingWindow, transientWindow = None; | ||
| 46 | XSizeHints sizeHints; | ||
| 47 | XEvent event; | ||
| 48 | |||
| 49 | display = XOpenDisplay(NULL); | ||
| 50 | if (!display) | ||
| 51 | exit(1); | ||
| 52 | |||
| 53 | rootWindow = DefaultRootWindow(display); | ||
| 54 | |||
| 55 | floatingWindow = XCreateSimpleWindow( | ||
| 56 | display, rootWindow, FLOATING_WINDOW_X_POS, FLOATING_WINDOW_Y_POS, | ||
| 57 | FLOATING_WINDOW_WIDTH, FLOATING_WINDOW_HEIGHT, WINDOW_BORDER_WIDTH, | ||
| 58 | WINDOW_BORDER_COLOR, WINDOW_BACKGROUND_COLOR); | ||
| 59 | |||
| 60 | sizeHints.min_width = sizeHints.max_width = sizeHints.min_height = | ||
| 61 | sizeHints.max_height = FLOATING_WINDOW_WIDTH; | ||
| 62 | sizeHints.flags = PMinSize | PMaxSize; | ||
| 63 | XSetWMNormalHints(display, floatingWindow, &sizeHints); | ||
| 64 | XStoreName(display, floatingWindow, "floating"); | ||
| 65 | XMapWindow(display, floatingWindow); | ||
| 66 | XSelectInput(display, floatingWindow, ExposureMask); | ||
| 67 | |||
| 68 | while (1) { | ||
| 69 | XNextEvent(display, &event); | ||
| 70 | |||
| 71 | if (transientWindow == None) { | ||
| 72 | sleep(SLEEP_TIME); | ||
| 73 | |||
| 74 | transientWindow = XCreateSimpleWindow( | ||
| 75 | display, rootWindow, TRANSIENT_WINDOW_X_POS, | ||
| 76 | TRANSIENT_WINDOW_Y_POS, TRANSIENT_WINDOW_WIDTH, | ||
| 77 | TRANSIENT_WINDOW_HEIGHT, WINDOW_BORDER_WIDTH, | ||
| 78 | WINDOW_BORDER_COLOR, WINDOW_BACKGROUND_COLOR); | ||
| 79 | |||
| 80 | XSetTransientForHint(display, transientWindow, | ||
| 81 | floatingWindow); | ||
| 82 | XStoreName(display, transientWindow, "transient"); | ||
| 83 | XMapWindow(display, transientWindow); | ||
| 84 | XSelectInput(display, transientWindow, ExposureMask); | ||
| 85 | } | ||
| 86 | } | ||
| 87 | |||
| 88 | XCloseDisplay(display); | ||
| 89 | exit(0); | ||
| 90 | } | ||
diff --git a/src/ui/bar.h b/src/ui/bar.h new file mode 100644 index 0000000..79e4912 --- /dev/null +++ b/src/ui/bar.h | |||
| @@ -0,0 +1,13 @@ | |||
| 1 | |||
| 2 | #pragma once | ||
| 3 | |||
| 4 | #include "../core/types.h" | ||
| 5 | |||
| 6 | void drawbar(Monitor *m); | ||
| 7 | void drawbars(void); | ||
| 8 | void updatebars(void); | ||
| 9 | void updatestatus(void); | ||
| 10 | unsigned int getsystraywidth(void); | ||
| 11 | |||
| 12 | extern char stext[256]; | ||
| 13 | extern int lrpad; | ||
diff --git a/src/ui/input.h b/src/ui/input.h new file mode 100644 index 0000000..54e3c58 --- /dev/null +++ b/src/ui/input.h | |||
| @@ -0,0 +1,13 @@ | |||
| 1 | |||
| 2 | #pragma once | ||
| 3 | |||
| 4 | #include "../core/types.h" | ||
| 5 | |||
| 6 | void grabkeys(void); | ||
| 7 | void grabbuttons(Client *c, int focused); | ||
| 8 | |||
| 9 | void keypress(XEvent *e); | ||
| 10 | void buttonpress(XEvent *e); | ||
| 11 | |||
| 12 | void movemouse(const Arg *arg); | ||
| 13 | void resizemouse(const Arg *arg); | ||
diff --git a/src/ui/systray.h b/src/ui/systray.h new file mode 100644 index 0000000..ad78f58 --- /dev/null +++ b/src/ui/systray.h | |||
| @@ -0,0 +1,12 @@ | |||
| 1 | |||
| 2 | #pragma once | ||
| 3 | |||
| 4 | #include "../core/types.h" | ||
| 5 | |||
| 6 | void updatesystray(void); | ||
| 7 | void removesystrayicon(Client *i); | ||
| 8 | void updatesystrayicongeom(Client *i, int w, int h); | ||
| 9 | void updatesystrayiconstate(Client *i, XPropertyEvent *ev); | ||
| 10 | |||
| 11 | Client *wintosystrayicon(Window w); | ||
| 12 | Monitor *systraytomon(Monitor *m); | ||
diff --git a/src/util/util.c b/src/util/util.c index 61c864c..7938f0f 100644 --- a/src/util/util.c +++ b/src/util/util.c | |||
| @@ -54,11 +54,11 @@ void die(const char *format_string, ...) | |||
| 54 | * int *array = ecalloc(10, sizeof(int)); // Allocate memory for an array of | 54 | * int *array = ecalloc(10, sizeof(int)); // Allocate memory for an array of |
| 55 | * 10 integers. | 55 | * 10 integers. |
| 56 | */ | 56 | */ |
| 57 | void *ecalloc(size_t num_elements, size_t element_size) | 57 | void *ecalloc(const size_t num_elements, const size_t element_size) |
| 58 | { | 58 | { |
| 59 | void *allocated_memory; | 59 | void *allocated_memory; |
| 60 | 60 | ||
| 61 | if (!(allocated_memory = calloc(num_elements, element_size))) | 61 | if (!((allocated_memory = calloc(num_elements, element_size)))) |
| 62 | die("calloc:"); | 62 | die("calloc:"); |
| 63 | 63 | ||
| 64 | return allocated_memory; | 64 | return allocated_memory; |
diff --git a/src/util/util.h b/src/util/util.h index 6ef3c86..2c2f773 100644 --- a/src/util/util.h +++ b/src/util/util.h | |||
| @@ -35,7 +35,7 @@ | |||
| 35 | * Usage: | 35 | * Usage: |
| 36 | * die("Error occurred in function %s", __func__); | 36 | * die("Error occurred in function %s", __func__); |
| 37 | */ | 37 | */ |
| 38 | void die(const char *fmt, ...); | 38 | void die(const char *format_string, ...); |
| 39 | 39 | ||
| 40 | /* | 40 | /* |
| 41 | * ecalloc() | 41 | * ecalloc() |
| @@ -56,4 +56,4 @@ void die(const char *fmt, ...); | |||
| 56 | * int *arr = ecalloc(10, sizeof(int)); // Allocate memory for an array of 10 | 56 | * int *arr = ecalloc(10, sizeof(int)); // Allocate memory for an array of 10 |
| 57 | * integers. | 57 | * integers. |
| 58 | */ | 58 | */ |
| 59 | void *ecalloc(size_t nmemb, size_t size); | 59 | void *ecalloc(size_t num_elements, size_t element_size); |
diff --git a/src/wm/client.h b/src/wm/client.h new file mode 100644 index 0000000..8a2a05e --- /dev/null +++ b/src/wm/client.h | |||
| @@ -0,0 +1,26 @@ | |||
| 1 | |||
| 2 | #pragma once | ||
| 3 | |||
| 4 | #include "../core/types.h" | ||
| 5 | |||
| 6 | void manage(Window w, XWindowAttributes *wa); | ||
| 7 | void unmanage(Client *c, int destroyed); | ||
| 8 | |||
| 9 | void attach(Client *c); | ||
| 10 | void detach(Client *c); | ||
| 11 | void attachstack(Client *c); | ||
| 12 | void detachstack(Client *c); | ||
| 13 | |||
| 14 | void focus(Client *c); | ||
| 15 | void unfocus(Client *c, int setfocus); | ||
| 16 | |||
| 17 | void resize(Client *c, int x, int y, int w, int h, int interact); | ||
| 18 | void resizeclient(Client *c, int x, int y, int w, int h); | ||
| 19 | |||
| 20 | Client *nexttiled(Client *c); | ||
| 21 | Client *wintoclient(Window w); | ||
| 22 | |||
| 23 | /* swallow (optional) */ | ||
| 24 | Client *swallowingclient(Window w); | ||
| 25 | Client *termforwin(const Client *c); | ||
| 26 | pid_t winpid(Window w); | ||
diff --git a/src/wm/layout.h b/src/wm/layout.h new file mode 100644 index 0000000..5deab64 --- /dev/null +++ b/src/wm/layout.h | |||
| @@ -0,0 +1,12 @@ | |||
| 1 | |||
| 2 | #pragma once | ||
| 3 | |||
| 4 | #include "../core/types.h" | ||
| 5 | |||
| 6 | void arrange(Monitor *m); | ||
| 7 | void arrangemon(Monitor *m); | ||
| 8 | void tile(Monitor *m); | ||
| 9 | void restack(Monitor *m); | ||
| 10 | void showhide(Client *c); | ||
| 11 | void zoom(const Arg *arg); | ||
| 12 | void setlayout(const Arg *arg); | ||
diff --git a/src/wm/monitor.h b/src/wm/monitor.h new file mode 100644 index 0000000..e09935e --- /dev/null +++ b/src/wm/monitor.h | |||
| @@ -0,0 +1,15 @@ | |||
| 1 | |||
| 2 | #pragma once | ||
| 3 | |||
| 4 | #include "../core/types.h" | ||
| 5 | |||
| 6 | Monitor *createmon(void); | ||
| 7 | void cleanupmon(Monitor *mon); | ||
| 8 | |||
| 9 | Monitor *recttomon(int x, int y, int w, int h); | ||
| 10 | Monitor *wintomon(Window w); | ||
| 11 | void sendmon(Client *c, Monitor *m); | ||
| 12 | |||
| 13 | int updategeom(void); | ||
| 14 | void updatebarpos(Monitor *m); | ||
| 15 | void resizebarwin(Monitor *m); | ||
diff --git a/src/x11/xevents.h b/src/x11/xevents.h new file mode 100644 index 0000000..98129bb --- /dev/null +++ b/src/x11/xevents.h | |||
| @@ -0,0 +1,25 @@ | |||
| 1 | |||
| 2 | #pragma once | ||
| 3 | |||
| 4 | #include <X11/Xlib.h> | ||
| 5 | |||
| 6 | void run(void); | ||
| 7 | void scan(void); | ||
| 8 | |||
| 9 | void buttonpress(XEvent *e); | ||
| 10 | void keypress(XEvent *e); | ||
| 11 | void maprequest(XEvent *e); | ||
| 12 | void configurerequest(XEvent *e); | ||
| 13 | void configurenotify(XEvent *e); | ||
| 14 | void destroynotify(XEvent *e); | ||
| 15 | void unmapnotify(XEvent *e); | ||
| 16 | void clientmessage(XEvent *e); | ||
| 17 | void propertynotify(XEvent *e); | ||
| 18 | void resizerequest(XEvent *e); | ||
| 19 | void mappingnotify(XEvent *e); | ||
| 20 | void motionnotify(XEvent *e); | ||
| 21 | void enternotify(XEvent *e); | ||
| 22 | void focusin(XEvent *e); | ||
| 23 | void expose(XEvent *e); | ||
| 24 | |||
| 25 | extern void (*handler[LASTEvent])(XEvent *); | ||
diff --git a/src/x11/xutil.h b/src/x11/xutil.h new file mode 100644 index 0000000..2e044e3 --- /dev/null +++ b/src/x11/xutil.h | |||
| @@ -0,0 +1,21 @@ | |||
| 1 | |||
| 2 | #pragma once | ||
| 3 | |||
| 4 | #include "../core/types.h" | ||
| 5 | |||
| 6 | void checkotherwm(void); | ||
| 7 | |||
| 8 | Atom getatomprop(Client *c, Atom prop); | ||
| 9 | int getrootptr(int *x, int *y); | ||
| 10 | long getstate(Window w); | ||
| 11 | int gettextprop(Window w, Atom atom, char *text, unsigned int size); | ||
| 12 | |||
| 13 | int sendevent(Window w, Atom proto, int m, long d0, long d1, long d2, long d3, | ||
| 14 | long d4); | ||
| 15 | |||
| 16 | void setfocus(Client *c); | ||
| 17 | void updatenumlockmask(void); | ||
| 18 | |||
| 19 | int xerror(Display *dpy, XErrorEvent *ee); | ||
| 20 | int xerrordummy(Display *dpy, XErrorEvent *ee); | ||
| 21 | int xerrorstart(Display *dpy, XErrorEvent *ee); | ||
