mirror of
https://git.sr.ht/~coasteen/dotfiles
synced 2026-03-26 09:18:35 +01:00
update
This commit is contained in:
parent
bf190cca21
commit
faab48346d
340 changed files with 24771 additions and 968 deletions
18
.Xresources
18
.Xresources
|
|
@ -1,2 +1,20 @@
|
|||
Xcursor.theme: Adwaita
|
||||
Xcursor.size: 24
|
||||
|
||||
!xterm
|
||||
XTerm*termName: xterm-256color
|
||||
XTerm*loginShell: true
|
||||
XTerm*scrollBar: false
|
||||
!xtermFont
|
||||
xterm*font: *-fixed-*-*-*-18-*
|
||||
!xtermCursor
|
||||
XTerm*cursorColor: white
|
||||
XTerm*cursorBlink: false
|
||||
!xtermSCrollback
|
||||
XTerm*saveLines: 5000
|
||||
!clipboard
|
||||
XTerm*selectToClipboard: true
|
||||
XTerm*rightScrollBar: false
|
||||
|
||||
!colors for xterm
|
||||
XTerm*background: #ffffff
|
||||
|
|
|
|||
20
.mpdconf
Normal file
20
.mpdconf
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
bind_to_address "/home/coast/.mpd/socket"
|
||||
bind_to_address "127.0.0.1"
|
||||
music_directory "/home/coast/Music"
|
||||
playlist_directory "/home/coast/.mpd/playlists"
|
||||
db_file "~/.mpd/database"
|
||||
log_file "~/.mpd/log"
|
||||
|
||||
audio_output {
|
||||
type "oss"
|
||||
name "OSS Output"
|
||||
mixer_type "software"
|
||||
}
|
||||
|
||||
audio_output {
|
||||
type "fifo"
|
||||
name "myfifo"
|
||||
path "/tmp/mpd.fifo"
|
||||
format "44100:16:2"
|
||||
}
|
||||
|
||||
49
.ssh/config
Normal file
49
.ssh/config
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
Host srv
|
||||
HostName seqyusphere.eu
|
||||
User coast
|
||||
DynamicForward 65000
|
||||
ExitOnForwardFailure yes
|
||||
ServerAliveInterval 60
|
||||
ServerAliveCountMax 3
|
||||
ControlMaster auto
|
||||
ControlPath ~/.ssh/control-%r@%h:%p-srv1
|
||||
ControlPersist 10m
|
||||
Host srv2
|
||||
HostName sx7n8.tech
|
||||
User coast
|
||||
DynamicForward 65000
|
||||
ExitOnForwardFailure yes
|
||||
ServerAliveInterval 60
|
||||
ServerAliveCountMax 3
|
||||
ControlMaster auto
|
||||
ControlPath ~/.ssh/control-%r@%h:%p-srv2
|
||||
ControlPersist 10m
|
||||
Host srv3
|
||||
HostName 75.127.15.21
|
||||
User root
|
||||
DynamicForward 65000
|
||||
ExitOnForwardFailure yes
|
||||
ServerAliveInterval 60
|
||||
ServerAliveCountMax 3
|
||||
ControlMaster auto
|
||||
ControlPath ~/.ssh/control-%r@%h:%p-srv3
|
||||
ControlPersist 10m
|
||||
Host srv4
|
||||
HostName aegea.satanistdates.com
|
||||
User coast
|
||||
DynamicForward 65000
|
||||
ExitOnForwardFailure yes
|
||||
ServerAliveInterval 60
|
||||
ServerAliveCountMax 3
|
||||
ControlMaster auto
|
||||
ControlPath ~/.ssh/control-%r@%h:%p-srv4
|
||||
ControlPersist 10m
|
||||
Host laptop
|
||||
HostName 192.168.1.157
|
||||
User coast
|
||||
ForwardX11Trusted yes
|
||||
ServerAliveInterval 60
|
||||
ServerAliveCountMax 3
|
||||
ControlMaster auto
|
||||
ControlPath ~/.ssh/control-%r@%h:%p-laptop
|
||||
ControlPersist 10m
|
||||
1
.ssh/id_ed25519.pub
Normal file
1
.ssh/id_ed25519.pub
Normal file
|
|
@ -0,0 +1 @@
|
|||
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAID+3SBxM4mng0JZcDBGkWGQ0ce4Lfar77XmkVWdIxAo/ coast@unix
|
||||
14
.ssh/known_hosts
Normal file
14
.ssh/known_hosts
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
seqyusphere.eu ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIIsCqg+vMQqjaxmaJBDN7PF1TCtI6QrhKdqRqPu3EI4f
|
||||
seqyusphere.eu ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCZWiFZnmrYgNfcgtArMDo8syugQjLaiakSE721sgHX0l2FaxkARUoUNzn+IBnBlyTxlu99rNCgoXyBHRaej9BAhzX/h0/kztehUSbIx+vIsUIVSWS4puBWPCIQUBiTqhFarVXqXZQxWMcuIWgezK801OcIHKM0FYly9nGPQPn9T18qO7JHe2ZSL7vC9tSpoW7BjejQiMAoSXx2lMCx8ad5gJyVy1owPQic4wZARQrTy7N3j/0XZw9x5eT/HsEz5077E0cMPhffCoxR+Y96Lpvay3624scPrFcLeBg95hNSDlZ4g3CATVvzD9L50DVTdg5bTXLAFscevVIcWa7ilqfcp1DNG0yIqLgnbxXKczDUUvN8/lyzd7bIU0yJv6tF/sB8DbcO1Y4IsrEZmc+zKFuMRD0BUvflKGDuXkaa/bA7qxibXRJ/rDiZs/w+AiWM8HEGbeArV5Rnge6PwPKbqLkBGK2YH8BqKXhjS/GsHWH9q/ZhxffOYVWse+0s74pOpk8=
|
||||
seqyusphere.eu ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBCWGPP8kdABlhCODrFCrS1+ffkpe8AZUtaAVH26zDNxIcRVGgrxyZUayIUNy9ngOvVI1+qd69iznkXV1QSZmlnk=
|
||||
89.168.25.90 ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAID6xG3mCulhO5TOz3LQdS3rzYaj8FfjKMPpONSsVLKlD
|
||||
sx7n8.tech ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAID6xG3mCulhO5TOz3LQdS3rzYaj8FfjKMPpONSsVLKlD
|
||||
75.127.15.21 ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIIefA/3degJWW2tFWq1Iof1Z5DF3b917A0r5X4B7ysP3
|
||||
75.127.15.21 ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDaobKfUfRtv1QPmhdoXNDftEW19N+LdVtQIS0nFgZoGubhcL2WtKX6ixVjt/Q6rJs3erpHrsChhHzrahBoNGSwrDhYMI3SLWYjOjXKynhe/XHq8HxS5Zh9iEiJDM8ttsd64q+T9I1w9ymKhV5HvTGataFqaZy5LdDeNvKBfDGeHm+Q6QxejzzwE34fe8Toc6O6ogDsqfEEj8gLpXAfyG2Esoum1sKQOflWEqFAkuRzmTQfR8TFgfUfL5YXMd5iARRK/Toca5Ggy9sQJ3FkZzrUNg6G2Lj4RjJWILHVw4d9JTgWdwBJYHEeYyIX+UGaGMsgI6YfFNxAfmmZwYRWHhQtAOAbp9MhZCRi8fZuYm1fYUpHqIrFFiPNaxUpDGbrrntt6nIASLyrZxDVj6zj0y0QmcMjSJfXR9xQ/K3YfHQ8RYllU2yK5j8IAQ47aiCBYJrvUvYaguHuXwVlMvO9grg5AcWGcCF/iHeWodRoi5IeGvd57QBv9Q17NW7GoGDBM90=
|
||||
75.127.15.21 ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBKeO8duThCyh54eF7oIVfjXXAIcWnqMMWcdz3UBw92KNBXZf4OZjtp1bLh3VRl5WR1tLYh7e0XboJ5/6VXBA/wo=
|
||||
192.168.1.156 ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIP4IYj2E9ff8nX3L13J5hb/bNiBpN9/SY++6HUtFdKf3
|
||||
192.168.1.156 ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCl6GNo41Yf1gbMLsBCyO5BctVV3A9BFQZa4Y5weQE4cNNg07GdFrkf/1P1jgTqYzbjsb7hu8zJYm8hL4U04q38n1jQ6REJv4WlC+FHQ6YKNnaRJw0TY+1GsfGiHUKVt8sLP59KLmP0Sx5f2qlb0CicEX0ONOYJymCQY5BtWvGdDl0KMkdSV186FiPtat8gyP7Jt2yXtyjcIt+Ht0tW9QzKHIclrsFHRNiOA0vOcAp94a7OFt6eA+T7f7+e120o1jX/VoW0IXgSHBmiebdh6iIlzS2FU90np2Sd7o4FZRPN3+qgdMBy0fdCZOJSf8mLjsj1EITrdRUaByhvm7qPfP7DKvMu0iVY+nNH4l1Ym2gCg/VdV+SYTiRriOhzzbjP3SdQVaZ9Zz8klrK2V9OCh0X2A7MEiMFp604c99snvYkRYl0J24dgbTpT9LWXgbmFJUu807doQhPXoi4ClM3LtoigK1MJOs8C2x2r8EIDqAeNB+7CFgDatKljGfGm2E2SIAk=
|
||||
192.168.1.156 ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBOkM7hEoN2R1p8TAVAXw5/vfi1Gsz8B635EmnLW2Ld2IvPRzhNsChZk5rVbAt+x5AxtPCPxriKgU42GJzXH89kM=
|
||||
192.168.1.157 ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIP4IYj2E9ff8nX3L13J5hb/bNiBpN9/SY++6HUtFdKf3
|
||||
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIPJaO4rT28fkZj95NO9TZft5aATyV0aBlyZKaRIPtltl coast@unix
|
||||
aegea.satanistdates.com ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIGPilf7LPN5ezz8tgVM/aGFrdWmm8T6HzZ+GXxKcMUmY
|
||||
52
.zprofile
52
.zprofile
|
|
@ -8,10 +8,22 @@ export XDG_DATA_DIRS="/var/lib/flatpak/exports/share:$HOME/.local/share/flatpak/
|
|||
export EIX_LIMIT=0
|
||||
|
||||
#aliasrc
|
||||
alias frgj="ssh -L 3000:localhost:3000 ubuntu@89.168.25.90 -i .ssh/vpssun"
|
||||
alias nf="neofetch"
|
||||
|
||||
#OS-based aliases
|
||||
[ "$(uname -s)" = "FreeBSD" ] && alias make=gmake
|
||||
|
||||
alias \
|
||||
sysrc="doas sysrc"\
|
||||
service="doas service"\
|
||||
sysctl="doas sysctl"\
|
||||
px="proxychains -q"\
|
||||
pkg="doas proxychains -q pkg"
|
||||
|
||||
alias s=ssh\ laptop
|
||||
alias s1="ssh coast@seqyusphere.eu"
|
||||
alias s2="ssh coast@sx7n8.tech"
|
||||
alias nrs="doas nixos-rebuild switch --flake /etc/nixos#core"
|
||||
alias neofetch="neofetch"
|
||||
alias nf="clear && fastfetch"
|
||||
alias mutt="neomutt"
|
||||
alias mt="neomutt"
|
||||
alias emoji="cat ~/.local/src/local/share/emoji | grep"
|
||||
|
|
@ -39,12 +51,10 @@ alias hotp="htop"
|
|||
alias copykey='cat ~/.local/share/vault1.key | xclip -sel clipboard'
|
||||
alias mic="micro"
|
||||
alias nx="nsxiv"
|
||||
alias stx="startx"
|
||||
alias e="doas emerge --ask --verbose"
|
||||
alias es="eix"
|
||||
alias fe="flatpak search"
|
||||
alias fei="flatpak install"
|
||||
alias startx="startw"
|
||||
alias ac="doas emerge -ac"
|
||||
alias ls="ls --color=auto"
|
||||
alias alsamixer="alsamixer -c 0"
|
||||
|
|
@ -75,3 +85,35 @@ noipv6(){
|
|||
doas sysctl -w net.ipv6.conf.default.disable_ipv6=1
|
||||
doas sysctl -w net.ipv6.conf.lo.disable_ipv6=1
|
||||
}
|
||||
|
||||
#PROXYCHAINS_IGNORE=(
|
||||
# cd exit clear fg bg jobs history
|
||||
# ssh scp sftp
|
||||
# proxychains
|
||||
#)
|
||||
#
|
||||
#autoload -U add-zsh-hook
|
||||
#
|
||||
#_proxychains_auto() {
|
||||
# local cmd="$BUFFER"
|
||||
# [[ -z "$cmd" ]] && return
|
||||
#
|
||||
# # get first word of command
|
||||
# local first=${cmd%% *}
|
||||
#
|
||||
# # ignore listed commands
|
||||
# for ignore in "${PROXYCHAINS_IGNORE[@]}"; do
|
||||
# [[ "$first" == "$ignore" ]] && return
|
||||
# done
|
||||
#
|
||||
# # sudo/doas handling
|
||||
# if [[ "$cmd" == sudo\ * ]]; then
|
||||
# BUFFER="sudo proxychains ${cmd#sudo }"
|
||||
# elif [[ "$cmd" == doas\ * ]]; then
|
||||
# BUFFER="doas proxychains ${cmd#doas }"
|
||||
# else
|
||||
# BUFFER="proxychains $cmd"
|
||||
# fi
|
||||
#}
|
||||
#
|
||||
#add-zsh-hook preexec _proxychains_auto
|
||||
|
|
|
|||
|
|
@ -5,8 +5,8 @@ VERSION = 5.3
|
|||
PREFIX = /usr/local
|
||||
MANPREFIX = $(PREFIX)/share/man
|
||||
|
||||
X11INC = /usr/X11R6/include
|
||||
X11LIB = /usr/X11R6/lib
|
||||
X11INC = /usr/local/include
|
||||
X11LIB = /usr/local/lib
|
||||
|
||||
# Xinerama, comment if you don't want it
|
||||
XINERAMALIBS = -lXinerama
|
||||
|
|
@ -14,7 +14,7 @@ XINERAMAFLAGS = -DXINERAMA
|
|||
|
||||
# freetype
|
||||
FREETYPELIBS = -lfontconfig -lXft
|
||||
FREETYPEINC = /usr/include/freetype2
|
||||
FREETYPEINC = /usr/local/include/freetype2
|
||||
# OpenBSD (uncomment)
|
||||
#FREETYPEINC = $(X11INC)/freetype2
|
||||
#MANPREFIX = ${PREFIX}/man
|
||||
|
|
@ -29,4 +29,4 @@ CFLAGS = -std=c99 -pedantic -Wall -Os $(INCS) $(CPPFLAGS)
|
|||
LDFLAGS = $(LIBS)
|
||||
|
||||
# compiler and linker
|
||||
CC = cc
|
||||
CC = clang
|
||||
|
|
|
|||
BIN
dmenu/dmenu
BIN
dmenu/dmenu
Binary file not shown.
BIN
dmenu/dmenu.o
BIN
dmenu/dmenu.o
Binary file not shown.
BIN
dmenu/drw.o
BIN
dmenu/drw.o
Binary file not shown.
BIN
dmenu/stest
BIN
dmenu/stest
Binary file not shown.
BIN
dmenu/stest.o
BIN
dmenu/stest.o
Binary file not shown.
BIN
dmenu/util.o
BIN
dmenu/util.o
Binary file not shown.
3
dwm/.github/FUNDING.yml
vendored
Normal file
3
dwm/.github/FUNDING.yml
vendored
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
# These are supported funding model platforms
|
||||
|
||||
custom: ["https://suckless.org/donations/", "https://paypal.me/dwmflexipatch"]
|
||||
5
dwm/.gitignore
vendored
Normal file
5
dwm/.gitignore
vendored
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
*.o
|
||||
dwm
|
||||
dwm-msg
|
||||
config.h
|
||||
patches.h
|
||||
28
dwm/Makefile
28
dwm/Makefile
|
|
@ -9,21 +9,21 @@ OBJ = ${SRC:.c=.o}
|
|||
# FreeBSD users, prefix all ifdef, else and endif statements with a . for this to work (e.g. .ifdef)
|
||||
|
||||
ifdef YAJLLIBS
|
||||
all: options dwm dwm-msg
|
||||
all: dwm dwm-msg
|
||||
else
|
||||
all: options dwm
|
||||
all: dwm
|
||||
endif
|
||||
|
||||
options:
|
||||
@echo dwm build options:
|
||||
@echo "CFLAGS = ${CFLAGS}"
|
||||
@echo "LDFLAGS = ${LDFLAGS}"
|
||||
@echo "CC = ${CC}"
|
||||
|
||||
.c.o:
|
||||
${CC} -c ${CFLAGS} $<
|
||||
|
||||
${OBJ}: config.h config.mk
|
||||
${OBJ}: config.h config.mk patches.h
|
||||
|
||||
config.h:
|
||||
cp config.def.h $@
|
||||
|
||||
patches.h:
|
||||
cp patches.def.h $@
|
||||
|
||||
dwm: ${OBJ}
|
||||
${CC} -o $@ ${OBJ} ${LDFLAGS}
|
||||
|
|
@ -51,7 +51,7 @@ install: all
|
|||
ifdef YAJLLIBS
|
||||
cp -f dwm-msg ${DESTDIR}${PREFIX}/bin
|
||||
endif
|
||||
cp -f patch/dwmc ${DESTDIR}${PREFIX}/bin
|
||||
#cp -f patch/dwmc ${DESTDIR}${PREFIX}/bin
|
||||
chmod 755 ${DESTDIR}${PREFIX}/bin/dwm
|
||||
ifdef YAJLLIBS
|
||||
chmod 755 ${DESTDIR}${PREFIX}/bin/dwm-msg
|
||||
|
|
@ -59,9 +59,13 @@ endif
|
|||
mkdir -p ${DESTDIR}${MANPREFIX}/man1
|
||||
sed "s/VERSION/${VERSION}/g" < dwm.1 > ${DESTDIR}${MANPREFIX}/man1/dwm.1
|
||||
chmod 644 ${DESTDIR}${MANPREFIX}/man1/dwm.1
|
||||
mkdir -p ${DESTDIR}${PREFIX}/share/xsessions
|
||||
test -f ${DESTDIR}${PREFIX}/share/xsessions/dwm.desktop || cp -n dwm.desktop ${DESTDIR}${PREFIX}/share/xsessions
|
||||
chmod 644 ${DESTDIR}${PREFIX}/share/xsessions/dwm.desktop
|
||||
|
||||
uninstall:
|
||||
rm -f ${DESTDIR}${PREFIX}/bin/dwm\
|
||||
${DESTDIR}${MANPREFIX}/man1/dwm.1
|
||||
${DESTDIR}${MANPREFIX}/man1/dwm.1\
|
||||
${DESTDIR}${PREFIX}/share/xsessions/dwm.desktop
|
||||
|
||||
.PHONY: all options clean dist install uninstall
|
||||
.PHONY: all clean dist install uninstall
|
||||
|
|
|
|||
1022
dwm/README.md
1022
dwm/README.md
File diff suppressed because it is too large
Load diff
2257
dwm/config.def.h
Normal file
2257
dwm/config.def.h
Normal file
File diff suppressed because it is too large
Load diff
2466
dwm/config.h
2466
dwm/config.h
File diff suppressed because it is too large
Load diff
|
|
@ -1,5 +1,5 @@
|
|||
# dwm version
|
||||
VERSION = 6.3
|
||||
VERSION = 6.8
|
||||
|
||||
# Customize below to fit your system
|
||||
|
||||
|
|
@ -7,8 +7,12 @@ VERSION = 6.3
|
|||
PREFIX = /usr/local
|
||||
MANPREFIX = ${PREFIX}/share/man
|
||||
|
||||
X11INC = /usr/X11R6/include
|
||||
X11LIB = /usr/X11R6/lib
|
||||
X11INC = /usr/local/include
|
||||
X11LIB = /usr/local/lib
|
||||
|
||||
# FreeBSD (uncomment)
|
||||
#X11INC = /usr/local/include
|
||||
#X11LIB = /usr/local/lib
|
||||
|
||||
# Xinerama, comment if you don't want it
|
||||
XINERAMALIBS = -lXinerama
|
||||
|
|
@ -16,7 +20,13 @@ XINERAMAFLAGS = -DXINERAMA
|
|||
|
||||
# freetype
|
||||
FREETYPELIBS = -lfontconfig -lXft
|
||||
FREETYPEINC = /usr/include/freetype2
|
||||
FREETYPEINC = /usr/local/include/freetype2
|
||||
# FreeBSD (uncomment)
|
||||
#FREETYPEINC = /usr/local/include/freetype2
|
||||
# OpenBSD (uncomment)
|
||||
#FREETYPEINC = ${X11INC}/freetype2
|
||||
# OpenBSD - Uncomment this for the swallow patch / SWALLOW_PATCH
|
||||
#KVMLIB = -lkvm
|
||||
|
||||
# Uncomment this for the alpha patch and the winicon patch (BAR_ALPHA_PATCH, BAR_WINICON_PATCH)
|
||||
XRENDER = -lXrender
|
||||
|
|
@ -36,20 +46,31 @@ XRENDER = -lXrender
|
|||
#XEXTLIB = -lXext
|
||||
|
||||
# Uncomment this for the swallow patch / SWALLOW_PATCH
|
||||
XCBLIBS = -lX11-xcb -lxcb -lxcb-res
|
||||
#XCBLIBS = -lX11-xcb -lxcb -lxcb-res
|
||||
|
||||
# This is needed for the winicon and tagpreview patches / BAR_WINICON_PATCH / BAR_TAGPREVIEW_PATCH
|
||||
#IMLIB2LIBS = -lImlib2
|
||||
|
||||
# Uncomment for the banish patch / BANISH_PATCH (for mouse related features)
|
||||
#XILIB = `pkg-config --libs xi xfixes`
|
||||
|
||||
# Uncomment for the bidi patch
|
||||
#BDINC = `pkg-config --cflags fribidi`
|
||||
#BDLIBS = `pkg-config --libs fribidi`
|
||||
|
||||
# includes and libs
|
||||
INCS = -I${X11INC} -I${FREETYPEINC} ${YAJLINC} ${PANGOINC}
|
||||
LIBS = -L${X11LIB} -lX11 ${XINERAMALIBS} ${FREETYPELIBS} ${XRENDER} ${MPDCLIENT} ${XEXTLIB} ${XCBLIBS} ${KVMLIB} ${PANGOLIB} ${YAJLLIBS} ${IMLIB2LIBS}
|
||||
INCS = -I${X11INC} -I${FREETYPEINC} ${YAJLINC} ${PANGOINC} ${BDINC}
|
||||
LIBS = -L${X11LIB} -lX11 ${XINERAMALIBS} ${FREETYPELIBS} ${XRENDER} ${MPDCLIENT} ${XEXTLIB} ${XCBLIBS} ${KVMLIB} ${PANGOLIB} ${YAJLLIBS} ${IMLIB2LIBS} $(BDLIBS) $(XILIB)
|
||||
|
||||
# flags
|
||||
CPPFLAGS = -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_POSIX_C_SOURCE=200809L -DVERSION=\"${VERSION}\" ${XINERAMAFLAGS}
|
||||
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-unused-function -Wno-deprecated-declarations -Os ${INCS} ${CPPFLAGS}
|
||||
LDFLAGS = ${LIBS}
|
||||
|
||||
# Solaris
|
||||
#CFLAGS = -fast ${INCS} -DVERSION=\"${VERSION}\"
|
||||
#LDFLAGS = ${LIBS}
|
||||
|
||||
# compiler and linker
|
||||
CC = cc
|
||||
|
|
|
|||
40
dwm/configure
vendored
40
dwm/configure
vendored
|
|
@ -1,40 +0,0 @@
|
|||
#!/bin/sh
|
||||
|
||||
#OS=$(printf 'Linux\nOpenBSD\nFreeBSD\nSolaris' | fzf --layout=reverse --height 40%)
|
||||
OS=$(uname)
|
||||
|
||||
case $OS in
|
||||
Linux) cp -f mkconfig/config.mk.linux config.mk ;;
|
||||
OpenBSD) cp -f mkconfig/config.mk.openbsd config.mk ;;
|
||||
FreeBSD) cp -f mkconfig/config.mk.freebsd config.mk ;;
|
||||
Solaris) cp -f mkconfig/config.mk.solaris config.mk ;;
|
||||
esac
|
||||
|
||||
#sed -i 's/##/#/g' config.mk
|
||||
#sed -i '14 s/^/#/' config.mk
|
||||
#sed -i '15 s/^/#/' config.mk
|
||||
#sed -i '25 s/^/#/' config.mk
|
||||
#sed -i '27 s/^/#/' config.mk
|
||||
#sed -i '29 s/^/#/' config.mk
|
||||
#sed -i '65 s/^/#/' config.mk
|
||||
#sed -i '66 s/^/#/' config.mk
|
||||
#sed -i 's/##/#/g' config.mk
|
||||
#
|
||||
#if [ "$OS" = "Linux" ]; then
|
||||
# true
|
||||
#else if [ "$OS" = "OpenBSD" ]; then
|
||||
# sed -i '27 s/.//' config.mk
|
||||
# sed -i '29 s/.//' config.mk
|
||||
#else if [ "$OS" = "FreeBSD" ]; then
|
||||
# sed -i '14 s/.//' config.mk
|
||||
# sed -i '15 s/.//' config.mk
|
||||
# sed -i '25 s/.//' config.mk
|
||||
#else if [ "$OS" = "Solaris" ]; then
|
||||
# sed -i '65 s/.//' config.mk
|
||||
# sed -i '66 s/.//' config.mk
|
||||
#fi
|
||||
#fi
|
||||
#fi
|
||||
#fi
|
||||
#
|
||||
#sed -i 's/##/#/g' config.mk
|
||||
490
dwm/drw.c
490
dwm/drw.c
|
|
@ -5,64 +5,86 @@
|
|||
#include <X11/Xlib.h>
|
||||
#include <X11/Xft/Xft.h>
|
||||
|
||||
#include "patches.h"
|
||||
#include "drw.h"
|
||||
#include "util.h"
|
||||
|
||||
#define UTF_INVALID 0xFFFD
|
||||
#define UTF_SIZ 4
|
||||
#if BIDI_PATCH
|
||||
#include <fribidi.h>
|
||||
|
||||
static const unsigned char utfbyte[UTF_SIZ + 1] = {0x80, 0, 0xC0, 0xE0, 0xF0};
|
||||
static const unsigned char utfmask[UTF_SIZ + 1] = {0xC0, 0x80, 0xE0, 0xF0, 0xF8};
|
||||
static const long utfmin[UTF_SIZ + 1] = { 0, 0, 0x80, 0x800, 0x10000};
|
||||
static const long utfmax[UTF_SIZ + 1] = {0x10FFFF, 0x7F, 0x7FF, 0xFFFF, 0x10FFFF};
|
||||
static char fribidi_text[BUFSIZ] = "";
|
||||
|
||||
|
||||
static long
|
||||
utf8decodebyte(const char c, size_t *i)
|
||||
static void
|
||||
apply_fribidi(const char *str)
|
||||
{
|
||||
for (*i = 0; *i < (UTF_SIZ + 1); ++(*i))
|
||||
if (((unsigned char)c & utfmask[*i]) == utfbyte[*i])
|
||||
return (unsigned char)c & ~utfmask[*i];
|
||||
return 0;
|
||||
}
|
||||
FriBidiStrIndex len = strlen(str);
|
||||
FriBidiChar logical[BUFSIZ];
|
||||
FriBidiChar visual[BUFSIZ];
|
||||
FriBidiParType base = FRIBIDI_PAR_ON;
|
||||
FriBidiCharSet charset;
|
||||
|
||||
static size_t
|
||||
utf8validate(long *u, size_t i)
|
||||
{
|
||||
if (!BETWEEN(*u, utfmin[i], utfmax[i]) || BETWEEN(*u, 0xD800, 0xDFFF))
|
||||
*u = UTF_INVALID;
|
||||
for (i = 1; *u > utfmax[i]; ++i)
|
||||
;
|
||||
return i;
|
||||
}
|
||||
|
||||
static size_t
|
||||
utf8decode(const char *c, long *u, size_t clen)
|
||||
{
|
||||
size_t i, j, len, type;
|
||||
long udecoded;
|
||||
|
||||
*u = UTF_INVALID;
|
||||
if (!clen)
|
||||
return 0;
|
||||
udecoded = utf8decodebyte(c[0], &len);
|
||||
if (!BETWEEN(len, 1, UTF_SIZ))
|
||||
return 1;
|
||||
for (i = 1, j = 1; i < clen && j < len; ++i, ++j) {
|
||||
udecoded = (udecoded << 6) | utf8decodebyte(c[i], &type);
|
||||
if (type)
|
||||
return j;
|
||||
fribidi_text[0] = 0;
|
||||
if (len > 0) {
|
||||
charset = fribidi_parse_charset("UTF-8");
|
||||
len = fribidi_charset_to_unicode(charset, str, len, logical);
|
||||
fribidi_log2vis(logical, len, &base, visual, NULL, NULL, NULL);
|
||||
len = fribidi_unicode_to_charset(charset, visual, len, fribidi_text);
|
||||
}
|
||||
if (j < len)
|
||||
return 0;
|
||||
*u = udecoded;
|
||||
utf8validate(u, len);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !BAR_PANGO_PATCH
|
||||
#define UTF_INVALID 0xFFFD
|
||||
#endif // BAR_PANGO_PATCH
|
||||
|
||||
#if BAR_POWERLINE_TAGS_PATCH || BAR_POWERLINE_STATUS_PATCH
|
||||
Clr transcheme[3];
|
||||
#endif // BAR_POWERLINE_TAGS_PATCH | BAR_POWERLINE_STATUS_PATCH
|
||||
|
||||
#if !BAR_PANGO_PATCH
|
||||
static int
|
||||
utf8decode(const char *s_in, long *u, int *err)
|
||||
{
|
||||
static const unsigned char lens[] = {
|
||||
/* 0XXXX */ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
/* 10XXX */ 0, 0, 0, 0, 0, 0, 0, 0, /* invalid */
|
||||
/* 110XX */ 2, 2, 2, 2,
|
||||
/* 1110X */ 3, 3,
|
||||
/* 11110 */ 4,
|
||||
/* 11111 */ 0, /* invalid */
|
||||
};
|
||||
static const unsigned char leading_mask[] = { 0x7F, 0x1F, 0x0F, 0x07 };
|
||||
static const unsigned int overlong[] = { 0x0, 0x80, 0x0800, 0x10000 };
|
||||
|
||||
const unsigned char *s = (const unsigned char *)s_in;
|
||||
int len = lens[*s >> 3];
|
||||
*u = UTF_INVALID;
|
||||
*err = 1;
|
||||
if (len == 0)
|
||||
return 1;
|
||||
|
||||
long cp = s[0] & leading_mask[len - 1];
|
||||
for (int i = 1; i < len; ++i) {
|
||||
if (s[i] == '\0' || (s[i] & 0xC0) != 0x80)
|
||||
return i;
|
||||
cp = (cp << 6) | (s[i] & 0x3F);
|
||||
}
|
||||
/* out of range, surrogate, overlong encoding */
|
||||
if (cp > 0x10FFFF || (cp >> 11) == 0x1B || cp < overlong[len - 1])
|
||||
return len;
|
||||
|
||||
*err = 0;
|
||||
*u = cp;
|
||||
return len;
|
||||
}
|
||||
#endif // BAR_PANGO_PATCH
|
||||
|
||||
Drw *
|
||||
#if BAR_ALPHA_PATCH
|
||||
drw_create(Display *dpy, int screen, Window root, unsigned int w, unsigned int h, Visual *visual, unsigned int depth, Colormap cmap)
|
||||
#else
|
||||
drw_create(Display *dpy, int screen, Window root, unsigned int w, unsigned int h)
|
||||
#endif // BAR_ALPHA_PATCH
|
||||
{
|
||||
Drw *drw = ecalloc(1, sizeof(Drw));
|
||||
|
||||
|
|
@ -72,11 +94,22 @@ drw_create(Display *dpy, int screen, Window root, unsigned int w, unsigned int h
|
|||
drw->w = w;
|
||||
drw->h = h;
|
||||
|
||||
#if BAR_ALPHA_PATCH
|
||||
drw->visual = visual;
|
||||
drw->depth = depth;
|
||||
drw->cmap = cmap;
|
||||
drw->drawable = XCreatePixmap(dpy, root, w, h, depth);
|
||||
#if BAR_WINICON_PATCH
|
||||
drw->picture = XRenderCreatePicture(dpy, drw->drawable, XRenderFindVisualFormat(dpy, visual), 0, NULL);
|
||||
#endif // BAR_WINICON_PATCH
|
||||
drw->gc = XCreateGC(dpy, drw->drawable, 0, NULL);
|
||||
#else
|
||||
drw->drawable = XCreatePixmap(dpy, root, w, h, DefaultDepth(dpy, screen));
|
||||
#if BAR_WINICON_PATCH
|
||||
drw->picture = XRenderCreatePicture(dpy, drw->drawable, XRenderFindVisualFormat(dpy, DefaultVisual(dpy, screen)), 0, NULL);
|
||||
#endif // BAR_WINICON_PATCH
|
||||
drw->gc = XCreateGC(dpy, root, 0, NULL);
|
||||
#endif // BAR_ALPHA_PATCH
|
||||
XSetLineAttributes(dpy, drw->gc, 1, LineSolid, CapButt, JoinMiter);
|
||||
|
||||
return drw;
|
||||
|
|
@ -90,20 +123,72 @@ drw_resize(Drw *drw, unsigned int w, unsigned int h)
|
|||
|
||||
drw->w = w;
|
||||
drw->h = h;
|
||||
#if BAR_WINICON_PATCH
|
||||
if (drw->picture)
|
||||
XRenderFreePicture(drw->dpy, drw->picture);
|
||||
#endif // BAR_WINICON_PATCH
|
||||
if (drw->drawable)
|
||||
XFreePixmap(drw->dpy, drw->drawable);
|
||||
#if BAR_ALPHA_PATCH
|
||||
drw->drawable = XCreatePixmap(drw->dpy, drw->root, w, h, drw->depth);
|
||||
#if BAR_WINICON_PATCH
|
||||
drw->picture = XRenderCreatePicture(drw->dpy, drw->drawable, XRenderFindVisualFormat(drw->dpy, drw->visual), 0, NULL);
|
||||
#endif // BAR_WINICON_PATCH
|
||||
#else // !BAR_ALPHA_PATCH
|
||||
drw->drawable = XCreatePixmap(drw->dpy, drw->root, w, h, DefaultDepth(drw->dpy, drw->screen));
|
||||
#if BAR_WINICON_PATCH
|
||||
drw->picture = XRenderCreatePicture(drw->dpy, drw->drawable, XRenderFindVisualFormat(drw->dpy, DefaultVisual(drw->dpy, drw->screen)), 0, NULL);
|
||||
#endif // BAR_WINICON_PATCH
|
||||
#endif // BAR_ALPHA_PATCH
|
||||
}
|
||||
|
||||
void
|
||||
drw_free(Drw *drw)
|
||||
{
|
||||
#if BAR_WINICON_PATCH
|
||||
XRenderFreePicture(drw->dpy, drw->picture);
|
||||
#endif // BAR_WINICON_PATCH
|
||||
XFreePixmap(drw->dpy, drw->drawable);
|
||||
XFreeGC(drw->dpy, drw->gc);
|
||||
drw_fontset_free(drw->fonts);
|
||||
free(drw);
|
||||
}
|
||||
|
||||
#if BAR_PANGO_PATCH
|
||||
/* This function is an implementation detail. Library users should use
|
||||
* drw_font_create instead.
|
||||
*/
|
||||
static Fnt *
|
||||
xfont_create(Drw *drw, const char *fontname)
|
||||
{
|
||||
Fnt *font;
|
||||
PangoFontMap *fontmap;
|
||||
PangoContext *context;
|
||||
PangoFontDescription *desc;
|
||||
PangoFontMetrics *metrics;
|
||||
|
||||
if (!fontname) {
|
||||
die("no font specified.");
|
||||
}
|
||||
|
||||
font = ecalloc(1, sizeof(Fnt));
|
||||
font->dpy = drw->dpy;
|
||||
|
||||
fontmap = pango_xft_get_font_map(drw->dpy, drw->screen);
|
||||
context = pango_font_map_create_context(fontmap);
|
||||
desc = pango_font_description_from_string(fontname);
|
||||
font->layout = pango_layout_new(context);
|
||||
pango_layout_set_font_description(font->layout, desc);
|
||||
|
||||
metrics = pango_context_get_metrics(context, desc, pango_language_from_string ("en-us"));
|
||||
font->h = pango_font_metrics_get_height(metrics) / PANGO_SCALE;
|
||||
|
||||
pango_font_metrics_unref(metrics);
|
||||
g_object_unref(context);
|
||||
|
||||
return font;
|
||||
}
|
||||
#else
|
||||
/* This function is an implementation detail. Library users should use
|
||||
* drw_fontset_create instead.
|
||||
*/
|
||||
|
|
@ -138,6 +223,7 @@ xfont_create(Drw *drw, const char *fontname, FcPattern *fontpattern)
|
|||
die("no font specified.");
|
||||
}
|
||||
|
||||
#if BAR_NO_COLOR_EMOJI_PATCH
|
||||
/* Do not allow using color fonts. This is a workaround for a BadLength
|
||||
* error from Xft with color glyphs. Modelled on the Xterm workaround. See
|
||||
* https://bugzilla.redhat.com/show_bug.cgi?id=1498269
|
||||
|
|
@ -150,6 +236,7 @@ xfont_create(Drw *drw, const char *fontname, FcPattern *fontpattern)
|
|||
XftFontClose(drw->dpy, xfont);
|
||||
return NULL;
|
||||
}
|
||||
#endif // BAR_NO_COLOR_EMOJI_PATCH
|
||||
|
||||
font = ecalloc(1, sizeof(Fnt));
|
||||
font->xfont = xfont;
|
||||
|
|
@ -159,18 +246,38 @@ xfont_create(Drw *drw, const char *fontname, FcPattern *fontpattern)
|
|||
|
||||
return font;
|
||||
}
|
||||
#endif // BAR_PANGO_PATCH
|
||||
|
||||
static void
|
||||
xfont_free(Fnt *font)
|
||||
{
|
||||
if (!font)
|
||||
return;
|
||||
#if BAR_PANGO_PATCH
|
||||
if (font->layout)
|
||||
g_object_unref(font->layout);
|
||||
#else
|
||||
if (font->pattern)
|
||||
FcPatternDestroy(font->pattern);
|
||||
XftFontClose(font->dpy, font->xfont);
|
||||
#endif // BAR_PANGO_PATCH
|
||||
free(font);
|
||||
}
|
||||
|
||||
#if BAR_PANGO_PATCH
|
||||
Fnt*
|
||||
drw_font_create(Drw* drw, const char font[])
|
||||
{
|
||||
Fnt *fnt = NULL;
|
||||
|
||||
if (!drw || !font)
|
||||
return NULL;
|
||||
|
||||
fnt = xfont_create(drw, font);
|
||||
|
||||
return (drw->fonts = fnt);
|
||||
}
|
||||
#else
|
||||
Fnt*
|
||||
drw_fontset_create(Drw* drw, const char *fonts[], size_t fontcount)
|
||||
{
|
||||
|
|
@ -188,12 +295,15 @@ drw_fontset_create(Drw* drw, const char *fonts[], size_t fontcount)
|
|||
}
|
||||
return (drw->fonts = ret);
|
||||
}
|
||||
#endif // BAR_PANGO_PATCH
|
||||
|
||||
void
|
||||
drw_fontset_free(Fnt *font)
|
||||
{
|
||||
if (font) {
|
||||
#if !BAR_PANGO_PATCH
|
||||
drw_fontset_free(font->next);
|
||||
#endif // BAR_PANGO_PATCH
|
||||
xfont_free(font);
|
||||
}
|
||||
}
|
||||
|
|
@ -203,16 +313,37 @@ drw_clr_create(
|
|||
Drw *drw,
|
||||
Clr *dest,
|
||||
const char *clrname
|
||||
#if BAR_ALPHA_PATCH
|
||||
, unsigned int alpha
|
||||
#endif // BAR_ALPHA_PATCH
|
||||
) {
|
||||
if (!drw || !dest || !clrname)
|
||||
return;
|
||||
|
||||
#if BAR_ALPHA_PATCH
|
||||
if (!XftColorAllocName(drw->dpy, drw->visual, drw->cmap,
|
||||
clrname, dest))
|
||||
#if DO_NOT_DIE_ON_COLOR_ALLOCATION_FAILURE_PATCH
|
||||
fprintf(stderr, "warning, cannot allocate color '%s'", clrname);
|
||||
#else
|
||||
die("error, cannot allocate color '%s'", clrname);
|
||||
#endif // DO_NOT_DIE_ON_COLOR_ALLOCATION_FAILURE_PATCH
|
||||
|
||||
dest->pixel = (dest->pixel & 0x00ffffffU) | (alpha << 24);
|
||||
#else
|
||||
if (!XftColorAllocName(drw->dpy, DefaultVisual(drw->dpy, drw->screen),
|
||||
DefaultColormap(drw->dpy, drw->screen),
|
||||
clrname, dest))
|
||||
#if DO_NOT_DIE_ON_COLOR_ALLOCATION_FAILURE_PATCH
|
||||
fprintf(stderr, "warning, cannot allocate color '%s'", clrname);
|
||||
#else
|
||||
die("error, cannot allocate color '%s'", clrname);
|
||||
#endif // DO_NOT_DIE_ON_COLOR_ALLOCATION_FAILURE_PATCH
|
||||
|
||||
#if NO_TRANSPARENT_BORDERS_PATCH
|
||||
dest->pixel |= 0xff << 24;
|
||||
#endif // NO_TRANSPARENT_BORDERS_PATCH
|
||||
#endif // BAR_ALPHA_PATCH
|
||||
}
|
||||
|
||||
/* Wrapper to create color schemes. The caller has to call free(3) on the
|
||||
|
|
@ -221,7 +352,9 @@ Clr *
|
|||
drw_scm_create(
|
||||
Drw *drw,
|
||||
char *clrnames[],
|
||||
#if BAR_ALPHA_PATCH
|
||||
const unsigned int alphas[],
|
||||
#endif // BAR_ALPHA_PATCH
|
||||
size_t clrcount
|
||||
) {
|
||||
size_t i;
|
||||
|
|
@ -232,16 +365,22 @@ drw_scm_create(
|
|||
return NULL;
|
||||
|
||||
for (i = 0; i < clrcount; i++)
|
||||
#if BAR_ALPHA_PATCH
|
||||
drw_clr_create(drw, &ret[i], clrnames[i], alphas[i]);
|
||||
#else
|
||||
drw_clr_create(drw, &ret[i], clrnames[i]);
|
||||
#endif // BAR_ALPHA_PATCH
|
||||
return ret;
|
||||
}
|
||||
|
||||
#if !BAR_PANGO_PATCH
|
||||
void
|
||||
drw_setfontset(Drw *drw, Fnt *set)
|
||||
{
|
||||
if (drw)
|
||||
drw->fonts = set;
|
||||
}
|
||||
#endif // BAR_PANGO_PATCH
|
||||
|
||||
void
|
||||
drw_setscheme(Drw *drw, Clr *scm)
|
||||
|
|
@ -250,6 +389,16 @@ drw_setscheme(Drw *drw, Clr *scm)
|
|||
drw->scheme = scm;
|
||||
}
|
||||
|
||||
#if BAR_POWERLINE_TAGS_PATCH || BAR_POWERLINE_STATUS_PATCH
|
||||
void
|
||||
drw_settrans(Drw *drw, Clr *psc, Clr *nsc)
|
||||
{
|
||||
if (drw) {
|
||||
transcheme[0] = psc[ColBg]; transcheme[1] = nsc[ColBg]; transcheme[2] = psc[ColBorder];
|
||||
drw->scheme = transcheme;
|
||||
}
|
||||
}
|
||||
#endif // BAR_POWERLINE_TAGS_PATCH | BAR_POWERLINE_STATUS_PATCH
|
||||
|
||||
void
|
||||
drw_rect(Drw *drw, int x, int y, unsigned int w, unsigned int h, int filled, int invert)
|
||||
|
|
@ -263,23 +412,21 @@ drw_rect(Drw *drw, int x, int y, unsigned int w, unsigned int h, int filled, int
|
|||
XDrawRectangle(drw->dpy, drw->drawable, drw->gc, x, y, w - 1, h - 1);
|
||||
}
|
||||
|
||||
#if BIDI_PATCH
|
||||
int
|
||||
drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lpad, const char *text, int invert, Bool ignored)
|
||||
_drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lpad, const char *text, int invert, Bool markup)
|
||||
#else
|
||||
int
|
||||
drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lpad, const char *text, int invert, Bool markup)
|
||||
#endif // BIDI_PATCH
|
||||
{
|
||||
#if BAR_PANGO_PATCH
|
||||
char buf[1024];
|
||||
int ty;
|
||||
unsigned int ew;
|
||||
int i, ty, th;
|
||||
unsigned int ew, eh;
|
||||
XftDraw *d = NULL;
|
||||
Fnt *usedfont, *curfont, *nextfont;
|
||||
size_t i, len;
|
||||
int utf8strlen, utf8charlen, render = x || y || w || h;
|
||||
long utf8codepoint = 0;
|
||||
const char *utf8str;
|
||||
FcCharSet *fccharset;
|
||||
FcPattern *fcpattern;
|
||||
FcPattern *match;
|
||||
XftResult result;
|
||||
int charexists = 0;
|
||||
size_t len;
|
||||
int render = x || y || w || h;
|
||||
|
||||
if (!drw || (render && !drw->scheme) || !text || !drw->fonts)
|
||||
return 0;
|
||||
|
|
@ -289,24 +436,130 @@ drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lp
|
|||
} else {
|
||||
XSetForeground(drw->dpy, drw->gc, drw->scheme[invert ? ColFg : ColBg].pixel);
|
||||
XFillRectangle(drw->dpy, drw->drawable, drw->gc, x, y, w, h);
|
||||
if (w < lpad)
|
||||
return x + w;
|
||||
#if BAR_ALPHA_PATCH
|
||||
d = XftDrawCreate(drw->dpy, drw->drawable, drw->visual, drw->cmap);
|
||||
#else
|
||||
d = XftDrawCreate(drw->dpy, drw->drawable,
|
||||
DefaultVisual(drw->dpy, drw->screen),
|
||||
DefaultColormap(drw->dpy, drw->screen));
|
||||
#endif // BAR_ALPHA_PATCH
|
||||
x += lpad;
|
||||
w -= lpad;
|
||||
}
|
||||
|
||||
len = strlen(text);
|
||||
|
||||
if (len) {
|
||||
drw_font_getexts(drw->fonts, text, len, &ew, &eh, markup);
|
||||
th = eh;
|
||||
/* shorten text if necessary */
|
||||
for (len = MIN(len, sizeof(buf) - 1); len && ew > w; len--) {
|
||||
drw_font_getexts(drw->fonts, text, len, &ew, &eh, markup);
|
||||
if (eh > th)
|
||||
th = eh;
|
||||
}
|
||||
|
||||
if (len) {
|
||||
memcpy(buf, text, len);
|
||||
buf[len] = '\0';
|
||||
if (len < strlen(text))
|
||||
for (i = len; i && i > len - 3; buf[--i] = '.')
|
||||
; /* NOP */
|
||||
|
||||
if (render) {
|
||||
ty = y + (h - th) / 2;
|
||||
if (markup)
|
||||
pango_layout_set_markup(drw->fonts->layout, buf, len);
|
||||
else
|
||||
pango_layout_set_text(drw->fonts->layout, buf, len);
|
||||
pango_xft_render_layout(d, &drw->scheme[invert ? ColBg : ColFg],
|
||||
drw->fonts->layout, x * PANGO_SCALE, ty * PANGO_SCALE);
|
||||
if (markup) /* clear markup attributes */
|
||||
pango_layout_set_attributes(drw->fonts->layout, NULL);
|
||||
}
|
||||
x += ew;
|
||||
w -= ew;
|
||||
}
|
||||
}
|
||||
if (d)
|
||||
XftDrawDestroy(d);
|
||||
|
||||
return x + (render ? w : 0);
|
||||
#else
|
||||
int ty, ellipsis_x = 0;
|
||||
unsigned int tmpw, ew, ellipsis_w = 0, ellipsis_len, hash, h0, h1;
|
||||
XftDraw *d = NULL;
|
||||
Fnt *usedfont, *curfont, *nextfont;
|
||||
int utf8strlen, utf8charlen, utf8err, render = x || y || w || h;
|
||||
long utf8codepoint = 0;
|
||||
const char *utf8str;
|
||||
FcCharSet *fccharset;
|
||||
FcPattern *fcpattern;
|
||||
FcPattern *match;
|
||||
XftResult result;
|
||||
int charexists = 0, overflow = 0;
|
||||
/* keep track of a couple codepoints for which we have no match. */
|
||||
static unsigned int nomatches[128], ellipsis_width, invalid_width;
|
||||
static const char invalid[] = "<EFBFBD>";
|
||||
|
||||
if (!drw || (render && (!drw->scheme || !w)) || !text || !drw->fonts)
|
||||
return 0;
|
||||
|
||||
if (!render) {
|
||||
w = invert ? invert : ~invert;
|
||||
} else {
|
||||
XSetForeground(drw->dpy, drw->gc, drw->scheme[invert ? ColFg : ColBg].pixel);
|
||||
XFillRectangle(drw->dpy, drw->drawable, drw->gc, x, y, w, h);
|
||||
if (w < lpad)
|
||||
return x + w;
|
||||
#if BAR_ALPHA_PATCH
|
||||
d = XftDrawCreate(drw->dpy, drw->drawable, drw->visual, drw->cmap);
|
||||
#else
|
||||
d = XftDrawCreate(drw->dpy, drw->drawable,
|
||||
DefaultVisual(drw->dpy, drw->screen),
|
||||
DefaultColormap(drw->dpy, drw->screen));
|
||||
#endif // BAR_ALPHA_PATCH
|
||||
x += lpad;
|
||||
w -= lpad;
|
||||
}
|
||||
|
||||
usedfont = drw->fonts;
|
||||
if (!ellipsis_width && render)
|
||||
ellipsis_width = drw_fontset_getwidth(drw, "...", markup);
|
||||
if (!invalid_width && render)
|
||||
invalid_width = drw_fontset_getwidth(drw, invalid, markup);
|
||||
while (1) {
|
||||
utf8strlen = 0;
|
||||
ew = ellipsis_len = utf8err = utf8charlen = utf8strlen = 0;
|
||||
utf8str = text;
|
||||
nextfont = NULL;
|
||||
while (*text) {
|
||||
utf8charlen = utf8decode(text, &utf8codepoint, UTF_SIZ);
|
||||
utf8charlen = utf8decode(text, &utf8codepoint, &utf8err);
|
||||
for (curfont = drw->fonts; curfont; curfont = curfont->next) {
|
||||
charexists = charexists || XftCharExists(drw->dpy, curfont->xfont, utf8codepoint);
|
||||
if (charexists) {
|
||||
if (curfont == usedfont) {
|
||||
utf8strlen += utf8charlen;
|
||||
drw_font_getexts(curfont, text, utf8charlen, &tmpw, NULL);
|
||||
if (ew + ellipsis_width <= w) {
|
||||
/* keep track where the ellipsis still fits */
|
||||
ellipsis_x = x + ew;
|
||||
ellipsis_w = w - ew;
|
||||
ellipsis_len = utf8strlen;
|
||||
}
|
||||
|
||||
if (ew + tmpw > w) {
|
||||
overflow = 1;
|
||||
/* called from drw_fontset_getwidth_clamp():
|
||||
* it wants the width AFTER the overflow
|
||||
*/
|
||||
if (!render)
|
||||
x += tmpw;
|
||||
else
|
||||
utf8strlen = ellipsis_len;
|
||||
} else if (curfont == usedfont) {
|
||||
text += utf8charlen;
|
||||
utf8strlen += utf8err ? 0 : utf8charlen;
|
||||
ew += utf8err ? 0 : tmpw;
|
||||
} else {
|
||||
nextfont = curfont;
|
||||
}
|
||||
|
|
@ -314,36 +567,31 @@ drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lp
|
|||
}
|
||||
}
|
||||
|
||||
if (!charexists || nextfont)
|
||||
if (overflow || !charexists || nextfont || utf8err)
|
||||
break;
|
||||
else
|
||||
charexists = 0;
|
||||
}
|
||||
|
||||
if (utf8strlen) {
|
||||
drw_font_getexts(usedfont, utf8str, utf8strlen, &ew, NULL);
|
||||
/* shorten text if necessary */
|
||||
for (len = MIN(utf8strlen, sizeof(buf) - 1); len && ew > w; drw_font_getexts(usedfont, utf8str, len, &ew, NULL))
|
||||
len--;
|
||||
|
||||
if (len) {
|
||||
memcpy(buf, utf8str, len);
|
||||
buf[len] = '\0';
|
||||
if (len < utf8strlen)
|
||||
for (i = len; i && i > len - 3; buf[--i] = '.')
|
||||
; /* NOP */
|
||||
|
||||
if (render) {
|
||||
ty = y + (h - usedfont->h) / 2 + usedfont->xfont->ascent;
|
||||
XftDrawStringUtf8(d, &drw->scheme[invert ? ColBg : ColFg],
|
||||
usedfont->xfont, x, ty, (XftChar8 *)buf, len);
|
||||
}
|
||||
x += ew;
|
||||
w -= ew;
|
||||
if (render) {
|
||||
ty = y + (h - usedfont->h) / 2 + usedfont->xfont->ascent;
|
||||
XftDrawStringUtf8(d, &drw->scheme[invert ? ColBg : ColFg],
|
||||
usedfont->xfont, x, ty, (XftChar8 *)utf8str, utf8strlen);
|
||||
}
|
||||
x += ew;
|
||||
w -= ew;
|
||||
}
|
||||
if (utf8err && (!render || invalid_width < w)) {
|
||||
if (render)
|
||||
drw_text(drw, x, y, w, h, 0, invalid, invert, markup);
|
||||
x += invalid_width;
|
||||
w -= invalid_width;
|
||||
}
|
||||
if (render && overflow)
|
||||
drw_text(drw, ellipsis_x, y, ellipsis_w, h, 0, "...", invert, markup);
|
||||
|
||||
if (!*text) {
|
||||
if (!*text || overflow) {
|
||||
break;
|
||||
} else if (nextfont) {
|
||||
charexists = 0;
|
||||
|
|
@ -353,6 +601,15 @@ drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lp
|
|||
* character must be drawn. */
|
||||
charexists = 1;
|
||||
|
||||
hash = (unsigned int)utf8codepoint;
|
||||
hash = ((hash >> 16) ^ hash) * 0x21F0AAAD;
|
||||
hash = ((hash >> 15) ^ hash) * 0xD35A2D97;
|
||||
h0 = ((hash >> 15) ^ hash) % LENGTH(nomatches);
|
||||
h1 = (hash >> 17) % LENGTH(nomatches);
|
||||
/* avoid expensive XftFontMatch call when we know we won't find a match */
|
||||
if (nomatches[h0] == utf8codepoint || nomatches[h1] == utf8codepoint)
|
||||
goto no_match;
|
||||
|
||||
fccharset = FcCharSetCreate();
|
||||
FcCharSetAddChar(fccharset, utf8codepoint);
|
||||
|
||||
|
|
@ -364,7 +621,9 @@ drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lp
|
|||
fcpattern = FcPatternDuplicate(drw->fonts->pattern);
|
||||
FcPatternAddCharSet(fcpattern, FC_CHARSET, fccharset);
|
||||
FcPatternAddBool(fcpattern, FC_SCALABLE, FcTrue);
|
||||
#if BAR_NO_COLOR_EMOJI_PATCH
|
||||
FcPatternAddBool(fcpattern, FC_COLOR, FcFalse);
|
||||
#endif // BAR_NO_COLOR_EMOJI_PATCH
|
||||
|
||||
FcConfigSubstitute(NULL, fcpattern, FcMatchPattern);
|
||||
FcDefaultSubstitute(fcpattern);
|
||||
|
|
@ -381,6 +640,8 @@ drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lp
|
|||
curfont->next = usedfont;
|
||||
} else {
|
||||
xfont_free(usedfont);
|
||||
nomatches[nomatches[h0] ? h1 : h0] = utf8codepoint;
|
||||
no_match:
|
||||
usedfont = drw->fonts;
|
||||
}
|
||||
}
|
||||
|
|
@ -390,8 +651,50 @@ drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lp
|
|||
XftDrawDestroy(d);
|
||||
|
||||
return x + (render ? w : 0);
|
||||
#endif // BAR_PANGO_PATCH
|
||||
}
|
||||
|
||||
#if BIDI_PATCH
|
||||
int
|
||||
drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lpad, const char *text, int invert, Bool markup)
|
||||
{
|
||||
apply_fribidi(text);
|
||||
return _drw_text(drw, x, y, w, h, lpad, fribidi_text, invert, markup);
|
||||
}
|
||||
#endif // BIDI_PATCH
|
||||
|
||||
#if BAR_POWERLINE_TAGS_PATCH || BAR_POWERLINE_STATUS_PATCH
|
||||
void
|
||||
drw_arrow(Drw *drw, int x, int y, unsigned int w, unsigned int h, int direction, int slash)
|
||||
{
|
||||
if (!drw || !drw->scheme)
|
||||
return;
|
||||
|
||||
/* direction=1 draws right arrow */
|
||||
x = direction ? x : x + w;
|
||||
w = direction ? w : -w;
|
||||
/* slash=1 draws slash instead of arrow */
|
||||
unsigned int hh = slash ? (direction ? 0 : h) : h/2;
|
||||
|
||||
XPoint points[] = {
|
||||
{x , y },
|
||||
{x + w, y + hh },
|
||||
{x , y + h },
|
||||
};
|
||||
|
||||
XPoint bg[] = {
|
||||
{x , y },
|
||||
{x + w, y },
|
||||
{x + w, y + h},
|
||||
{x , y + h},
|
||||
};
|
||||
|
||||
XSetForeground(drw->dpy, drw->gc, drw->scheme[ColBg].pixel);
|
||||
XFillPolygon(drw->dpy, drw->drawable, drw->gc, bg, 4, Convex, CoordModeOrigin);
|
||||
XSetForeground(drw->dpy, drw->gc, drw->scheme[ColFg].pixel);
|
||||
XFillPolygon(drw->dpy, drw->drawable, drw->gc, points, 3, Nonconvex, CoordModeOrigin);
|
||||
}
|
||||
#endif // BAR_POWERLINE_TAGS_PATCH | BAR_POWERLINE_STATUS_PATCH
|
||||
|
||||
void
|
||||
drw_map(Drw *drw, Window win, int x, int y, unsigned int w, unsigned int h)
|
||||
|
|
@ -411,6 +714,27 @@ drw_fontset_getwidth(Drw *drw, const char *text, Bool markup)
|
|||
return drw_text(drw, 0, 0, 0, 0, 0, text, 0, markup);
|
||||
}
|
||||
|
||||
#if BAR_PANGO_PATCH
|
||||
void
|
||||
drw_font_getexts(Fnt *font, const char *text, unsigned int len, unsigned int *w, unsigned int *h, Bool markup)
|
||||
{
|
||||
if (!font || !text)
|
||||
return;
|
||||
|
||||
PangoRectangle r;
|
||||
if (markup)
|
||||
pango_layout_set_markup(font->layout, text, len);
|
||||
else
|
||||
pango_layout_set_text(font->layout, text, len);
|
||||
pango_layout_get_extents(font->layout, 0, &r);
|
||||
if (markup) /* clear markup attributes */
|
||||
pango_layout_set_attributes(font->layout, NULL);
|
||||
if (w)
|
||||
*w = r.width / PANGO_SCALE;
|
||||
if (h)
|
||||
*h = r.height / PANGO_SCALE;
|
||||
}
|
||||
#else
|
||||
void
|
||||
drw_font_getexts(Fnt *font, const char *text, unsigned int len, unsigned int *w, unsigned int *h)
|
||||
{
|
||||
|
|
@ -425,6 +749,7 @@ drw_font_getexts(Fnt *font, const char *text, unsigned int len, unsigned int *w,
|
|||
if (h)
|
||||
*h = font->h;
|
||||
}
|
||||
#endif // BAR_PANGO_PATCH
|
||||
|
||||
Cur *
|
||||
drw_cur_create(Drw *drw, int shape)
|
||||
|
|
@ -448,4 +773,3 @@ drw_cur_free(Drw *drw, Cur *cursor)
|
|||
XFreeCursor(drw->dpy, cursor->cursor);
|
||||
free(cursor);
|
||||
}
|
||||
|
||||
|
|
|
|||
34
dwm/drw.h
34
dwm/drw.h
|
|
@ -1,5 +1,9 @@
|
|||
/* See LICENSE file for copyright and license details. */
|
||||
|
||||
#if BAR_PANGO_PATCH
|
||||
#include <pango/pango.h>
|
||||
#include <pango/pangoxft.h>
|
||||
#endif // BAR_PANGO_PATCH
|
||||
|
||||
typedef struct {
|
||||
Cursor cursor;
|
||||
|
|
@ -8,9 +12,13 @@ typedef struct {
|
|||
typedef struct Fnt {
|
||||
Display *dpy;
|
||||
unsigned int h;
|
||||
#if BAR_PANGO_PATCH
|
||||
PangoLayout *layout;
|
||||
#else
|
||||
XftFont *xfont;
|
||||
FcPattern *pattern;
|
||||
struct Fnt *next;
|
||||
#endif // BAR_PANGO_PATCH
|
||||
} Fnt;
|
||||
|
||||
enum { ColFg, ColBg, ColBorder, ColFloat, ColCount }; /* Clr scheme index */
|
||||
|
|
@ -21,23 +29,37 @@ typedef struct {
|
|||
Display *dpy;
|
||||
int screen;
|
||||
Window root;
|
||||
#if BAR_ALPHA_PATCH
|
||||
Visual *visual;
|
||||
unsigned int depth;
|
||||
Colormap cmap;
|
||||
#endif // BAR_ALPHA_PATCH
|
||||
Drawable drawable;
|
||||
#if BAR_WINICON_PATCH
|
||||
Picture picture;
|
||||
#endif // BAR_WINICON_PATCH
|
||||
GC gc;
|
||||
Clr *scheme;
|
||||
Fnt *fonts;
|
||||
} Drw;
|
||||
|
||||
/* Drawable abstraction */
|
||||
#if BAR_ALPHA_PATCH
|
||||
Drw *drw_create(Display *dpy, int screen, Window win, unsigned int w, unsigned int h, Visual *visual, unsigned int depth, Colormap cmap);
|
||||
#else
|
||||
Drw *drw_create(Display *dpy, int screen, Window win, unsigned int w, unsigned int h);
|
||||
#endif // BAR_ALPHA_PATCH
|
||||
void drw_resize(Drw *drw, unsigned int w, unsigned int h);
|
||||
void drw_free(Drw *drw);
|
||||
|
||||
/* Fnt abstraction */
|
||||
#if BAR_PANGO_PATCH
|
||||
Fnt *drw_font_create(Drw* drw, const char font[]);
|
||||
void drw_font_getexts(Fnt *font, const char *text, unsigned int len, unsigned int *w, unsigned int *h, Bool markup);
|
||||
#else
|
||||
Fnt *drw_fontset_create(Drw* drw, const char *fonts[], size_t fontcount);
|
||||
void drw_font_getexts(Fnt *font, const char *text, unsigned int len, unsigned int *w, unsigned int *h);
|
||||
#endif // BAR_PANGO_PATCH
|
||||
void drw_fontset_free(Fnt* set);
|
||||
unsigned int drw_fontset_getwidth(Drw *drw, const char *text, Bool markup);
|
||||
|
||||
|
|
@ -46,12 +68,16 @@ void drw_clr_create(
|
|||
Drw *drw,
|
||||
Clr *dest,
|
||||
const char *clrname
|
||||
#if BAR_ALPHA_PATCH
|
||||
, unsigned int alpha
|
||||
#endif // BAR_ALPHA_PATCH
|
||||
);
|
||||
Clr *drw_scm_create(
|
||||
Drw *drw,
|
||||
char *clrnames[],
|
||||
#if BAR_ALPHA_PATCH
|
||||
const unsigned int alphas[],
|
||||
#endif // BAR_ALPHA_PATCH
|
||||
size_t clrcount
|
||||
);
|
||||
|
||||
|
|
@ -60,12 +86,20 @@ Cur *drw_cur_create(Drw *drw, int shape);
|
|||
void drw_cur_free(Drw *drw, Cur *cursor);
|
||||
|
||||
/* Drawing context manipulation */
|
||||
#if !BAR_PANGO_PATCH
|
||||
void drw_setfontset(Drw *drw, Fnt *set);
|
||||
#endif // BAR_PANGO_PATCH
|
||||
void drw_setscheme(Drw *drw, Clr *scm);
|
||||
#if BAR_POWERLINE_TAGS_PATCH || BAR_POWERLINE_STATUS_PATCH
|
||||
void drw_settrans(Drw *drw, Clr *psc, Clr *nsc);
|
||||
#endif // BAR_POWERLINE_TAGS_PATCH | BAR_POWERLINE_STATUS_PATCH
|
||||
|
||||
/* 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, Bool markup);
|
||||
#if BAR_POWERLINE_TAGS_PATCH || BAR_POWERLINE_STATUS_PATCH
|
||||
void drw_arrow(Drw *drw, int x, int y, unsigned int w, unsigned int h, int direction, int slash);
|
||||
#endif // BAR_POWERLINE_TAGS_PATCH | BAR_POWERLINE_STATUS_PATCH
|
||||
|
||||
/* Map functions */
|
||||
void drw_map(Drw *drw, Window win, int x, int y, unsigned int w, unsigned int h);
|
||||
|
|
|
|||
85
dwm/dwm.1
85
dwm/dwm.1
|
|
@ -49,119 +49,108 @@ label toggles between tiled and floating layout.
|
|||
.B Button3
|
||||
click on a tag label adds/removes all windows with that tag to/from the view.
|
||||
.TP
|
||||
.B Super\-Button1
|
||||
.B Mod1\-Button1
|
||||
click on a tag label applies that tag to the focused window.
|
||||
.TP
|
||||
.B Super\-Button3
|
||||
.B Mod1\-Button3
|
||||
click on a tag label adds/removes that tag to/from the focused window.
|
||||
.SS Keyboard commands
|
||||
.TP
|
||||
.B Super\-Return
|
||||
.B Mod1\-Shift\-Return
|
||||
Start
|
||||
.BR st(1).
|
||||
.TP
|
||||
.B Super\-Shift\-Return
|
||||
Start or toggle
|
||||
.BR st(1)
|
||||
as a floating (scratchpad) terminal.
|
||||
.TP
|
||||
.B Super\-d
|
||||
.B Mod1\-p
|
||||
Spawn
|
||||
.BR dmenu(1)
|
||||
for launching other programs.
|
||||
.TP
|
||||
.B Super\-f
|
||||
Toggles fullscreen state of focused window.
|
||||
.TP
|
||||
.B Super\-,
|
||||
.B Mod1\-,
|
||||
Focus previous screen, if any.
|
||||
.TP
|
||||
.B Super\-.
|
||||
.B Mod1\-.
|
||||
Focus next screen, if any.
|
||||
.TP
|
||||
.B Super\-Shift\-,
|
||||
.B Mod1\-Shift\-,
|
||||
Send focused window to previous screen, if any.
|
||||
.TP
|
||||
.B Super\-Shift\-.
|
||||
.B Mod1\-Shift\-.
|
||||
Send focused window to next screen, if any.
|
||||
.TP
|
||||
.B Super\-b
|
||||
.B Mod1\-b
|
||||
Toggles bar on and off.
|
||||
.TP
|
||||
.B Super\-t
|
||||
.B Mod1\-t
|
||||
Sets tiled layout.
|
||||
.TP
|
||||
.B Super\-m
|
||||
Zooms/cycles focused window to/from master area (tiled layouts only).
|
||||
.B Mod1\-f
|
||||
Sets floating layout.
|
||||
.TP
|
||||
.B Super\-space
|
||||
Toggles between floating and tiled layout.
|
||||
.B Mod1\-m
|
||||
Sets monocle layout.
|
||||
.TP
|
||||
.B Super\-j
|
||||
.B Mod1\-space
|
||||
Toggles between current and previous layout.
|
||||
.TP
|
||||
.B Mod1\-j
|
||||
Focus next window.
|
||||
.TP
|
||||
.B Super\-k
|
||||
.B Mod1\-k
|
||||
Focus previous window.
|
||||
.TP
|
||||
.B Super\-Shift\-j
|
||||
Move focused stack window downward.
|
||||
.TP
|
||||
.B Super\-Shift\-k
|
||||
Move focused stack window upward.
|
||||
.TP
|
||||
.B Super\-o
|
||||
.B Mod1\-i
|
||||
Increase number of windows in master area.
|
||||
.TP
|
||||
.B Super\-Shift\-o
|
||||
.B Mod1\-d
|
||||
Decrease number of windows in master area.
|
||||
.TP
|
||||
.B Super\-l
|
||||
.B Mod1\-l
|
||||
Increase master area size.
|
||||
.TP
|
||||
.B Super\-h
|
||||
.B Mod1\-h
|
||||
Decrease master area size.
|
||||
.TP
|
||||
.B Super\-m
|
||||
.B Mod1\-Return
|
||||
Zooms/cycles focused window to/from master area (tiled layouts only).
|
||||
.TP
|
||||
.B Super\-q
|
||||
.B Mod1\-Shift\-c
|
||||
Close focused window.
|
||||
.TP
|
||||
.B Super\-Shift\-space
|
||||
.B Mod1\-Shift\-space
|
||||
Toggle focused window between tiled and floating state.
|
||||
.TP
|
||||
.B Super\-Tab
|
||||
.B Mod1\-Tab
|
||||
Toggles to the previously selected tags.
|
||||
.TP
|
||||
.B Super\-Shift\-[1..n]
|
||||
.B Mod1\-Shift\-[1..n]
|
||||
Apply nth tag to focused window.
|
||||
.TP
|
||||
.B Super\-Shift\-0
|
||||
.B Mod1\-Shift\-0
|
||||
Apply all tags to focused window.
|
||||
.TP
|
||||
.B Super\-Control\-Shift\-[1..n]
|
||||
.B Mod1\-Control\-Shift\-[1..n]
|
||||
Add/remove nth tag to/from focused window.
|
||||
.TP
|
||||
.B Super\-[1..n]
|
||||
.B Mod1\-[1..n]
|
||||
View all windows with nth tag.
|
||||
.TP
|
||||
.B Super\-0
|
||||
.B Mod1\-0
|
||||
View all windows with any tag.
|
||||
.TP
|
||||
.B Super\-Control\-[1..n]
|
||||
.B Mod1\-Control\-[1..n]
|
||||
Add/remove all windows with nth tag to/from the view.
|
||||
.TP
|
||||
.B Super\-Shift\-q, Super\-Shift\-e
|
||||
.B Mod1\-Shift\-q
|
||||
Quit dwm.
|
||||
.SS Mouse commands
|
||||
.TP
|
||||
.B Super\-Button1
|
||||
.B Mod1\-Button1
|
||||
Move focused window while dragging. Tiled windows will be toggled to the floating state.
|
||||
.TP
|
||||
.B Super\-Button2
|
||||
.B Mod1\-Button2
|
||||
Toggles focused window between floating and tiled state.
|
||||
.TP
|
||||
.B Super\-Button3
|
||||
.B Mod1\-Button3
|
||||
Resize focused window while dragging. Tiled windows will be toggled to the floating state.
|
||||
.SH CUSTOMIZATION
|
||||
dwm is customized by creating a custom config.h and (re)compiling the source
|
||||
|
|
|
|||
7
dwm/dwm.desktop
Normal file
7
dwm/dwm.desktop
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
[Desktop Entry]
|
||||
Encoding=UTF-8
|
||||
Name=Dwm
|
||||
Comment=Dynamic window manager
|
||||
Exec=dwm
|
||||
Icon=dwm
|
||||
Type=XSession
|
||||
|
|
@ -1,59 +0,0 @@
|
|||
# dwm version
|
||||
VERSION = 6.3
|
||||
|
||||
# Customize below to fit your system
|
||||
|
||||
# paths
|
||||
PREFIX = /usr/local
|
||||
MANPREFIX = ${PREFIX}/share/man
|
||||
|
||||
X11INC = /usr/X11R6/include
|
||||
X11LIB = /usr/X11R6/lib
|
||||
|
||||
X11INC = /usr/local/include
|
||||
X11LIB = /usr/local/lib
|
||||
|
||||
# Xinerama, comment if you don't want it
|
||||
XINERAMALIBS = -lXinerama
|
||||
XINERAMAFLAGS = -DXINERAMA
|
||||
|
||||
# freetype
|
||||
FREETYPELIBS = -lfontconfig -lXft
|
||||
FREETYPEINC = /usr/include/freetype2
|
||||
FREETYPEINC = /usr/local/include/freetype2
|
||||
|
||||
# Uncomment this for the alpha patch and the winicon patch (BAR_ALPHA_PATCH, BAR_WINICON_PATCH)
|
||||
XRENDER = -lXrender
|
||||
|
||||
# Uncomment this for the mdpcontrol patch / MDPCONTROL_PATCH
|
||||
#MPDCLIENT = -lmpdclient
|
||||
|
||||
# Uncomment for the pango patch / BAR_PANGO_PATCH
|
||||
#PANGOINC = `pkg-config --cflags xft pango pangoxft`
|
||||
#PANGOLIB = `pkg-config --libs xft pango pangoxft`
|
||||
|
||||
# Uncomment for the ipc patch / IPC_PATCH
|
||||
#YAJLLIBS = -lyajl
|
||||
#YAJLINC = -I/usr/include/yajl
|
||||
|
||||
# Uncomment this for the rounded corners patch / ROUNDED_CORNERS_PATCH
|
||||
#XEXTLIB = -lXext
|
||||
|
||||
# Uncomment this for the swallow patch / SWALLOW_PATCH
|
||||
XCBLIBS = -lX11-xcb -lxcb -lxcb-res
|
||||
|
||||
# This is needed for the winicon and tagpreview patches / BAR_WINICON_PATCH / BAR_TAGPREVIEW_PATCH
|
||||
#IMLIB2LIBS = -lImlib2
|
||||
|
||||
# includes and libs
|
||||
INCS = -I${X11INC} -I${FREETYPEINC} ${YAJLINC} ${PANGOINC}
|
||||
LIBS = -L${X11LIB} -lX11 ${XINERAMALIBS} ${FREETYPELIBS} ${XRENDER} ${MPDCLIENT} ${XEXTLIB} ${XCBLIBS} ${KVMLIB} ${PANGOLIB} ${YAJLLIBS} ${IMLIB2LIBS}
|
||||
|
||||
# flags
|
||||
CPPFLAGS = -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_POSIX_C_SOURCE=200809L -DVERSION=\"${VERSION}\" ${XINERAMAFLAGS}
|
||||
#CFLAGS = -g -std=c99 -pedantic -Wall -O0 ${INCS} ${CPPFLAGS}
|
||||
CFLAGS = -std=c99 -pedantic -Wall -Wno-unused-function -Wno-deprecated-declarations -Os ${INCS} ${CPPFLAGS}
|
||||
LDFLAGS = ${LIBS}
|
||||
|
||||
# compiler and linker
|
||||
CC = cc
|
||||
|
|
@ -1,55 +0,0 @@
|
|||
# dwm version
|
||||
VERSION = 6.3
|
||||
|
||||
# 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
|
||||
|
||||
# Uncomment this for the alpha patch and the winicon patch (BAR_ALPHA_PATCH, BAR_WINICON_PATCH)
|
||||
XRENDER = -lXrender
|
||||
|
||||
# Uncomment this for the mdpcontrol patch / MDPCONTROL_PATCH
|
||||
#MPDCLIENT = -lmpdclient
|
||||
|
||||
# Uncomment for the pango patch / BAR_PANGO_PATCH
|
||||
#PANGOINC = `pkg-config --cflags xft pango pangoxft`
|
||||
#PANGOLIB = `pkg-config --libs xft pango pangoxft`
|
||||
|
||||
# Uncomment for the ipc patch / IPC_PATCH
|
||||
#YAJLLIBS = -lyajl
|
||||
#YAJLINC = -I/usr/include/yajl
|
||||
|
||||
# Uncomment this for the rounded corners patch / ROUNDED_CORNERS_PATCH
|
||||
#XEXTLIB = -lXext
|
||||
|
||||
# Uncomment this for the swallow patch / SWALLOW_PATCH
|
||||
XCBLIBS = -lX11-xcb -lxcb -lxcb-res
|
||||
|
||||
# This is needed for the winicon and tagpreview patches / BAR_WINICON_PATCH / BAR_TAGPREVIEW_PATCH
|
||||
#IMLIB2LIBS = -lImlib2
|
||||
|
||||
# includes and libs
|
||||
INCS = -I${X11INC} -I${FREETYPEINC} ${YAJLINC} ${PANGOINC}
|
||||
LIBS = -L${X11LIB} -lX11 ${XINERAMALIBS} ${FREETYPELIBS} ${XRENDER} ${MPDCLIENT} ${XEXTLIB} ${XCBLIBS} ${KVMLIB} ${PANGOLIB} ${YAJLLIBS} ${IMLIB2LIBS}
|
||||
|
||||
# flags
|
||||
CPPFLAGS = -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_POSIX_C_SOURCE=200809L -DVERSION=\"${VERSION}\" ${XINERAMAFLAGS}
|
||||
#CFLAGS = -g -std=c99 -pedantic -Wall -O0 ${INCS} ${CPPFLAGS}
|
||||
CFLAGS = -std=c99 -pedantic -Wall -Wno-unused-function -Wno-deprecated-declarations -Os ${INCS} ${CPPFLAGS}
|
||||
LDFLAGS = ${LIBS}
|
||||
|
||||
# compiler and linker
|
||||
CC = cc
|
||||
|
|
@ -1,57 +0,0 @@
|
|||
# dwm version
|
||||
VERSION = 6.3
|
||||
|
||||
# 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
|
||||
FREETYPEINC = ${X11INC}/freetype2
|
||||
KVMLIB = -lkvm
|
||||
|
||||
# Uncomment this for the alpha patch and the winicon patch (BAR_ALPHA_PATCH, BAR_WINICON_PATCH)
|
||||
XRENDER = -lXrender
|
||||
|
||||
# Uncomment this for the mdpcontrol patch / MDPCONTROL_PATCH
|
||||
#MPDCLIENT = -lmpdclient
|
||||
|
||||
# Uncomment for the pango patch / BAR_PANGO_PATCH
|
||||
#PANGOINC = `pkg-config --cflags xft pango pangoxft`
|
||||
#PANGOLIB = `pkg-config --libs xft pango pangoxft`
|
||||
|
||||
# Uncomment for the ipc patch / IPC_PATCH
|
||||
#YAJLLIBS = -lyajl
|
||||
#YAJLINC = -I/usr/include/yajl
|
||||
|
||||
# Uncomment this for the rounded corners patch / ROUNDED_CORNERS_PATCH
|
||||
#XEXTLIB = -lXext
|
||||
|
||||
# Uncomment this for the swallow patch / SWALLOW_PATCH
|
||||
XCBLIBS = -lX11-xcb -lxcb -lxcb-res
|
||||
|
||||
# This is needed for the winicon and tagpreview patches / BAR_WINICON_PATCH / BAR_TAGPREVIEW_PATCH
|
||||
#IMLIB2LIBS = -lImlib2
|
||||
|
||||
# includes and libs
|
||||
INCS = -I${X11INC} -I${FREETYPEINC} ${YAJLINC} ${PANGOINC}
|
||||
LIBS = -L${X11LIB} -lX11 ${XINERAMALIBS} ${FREETYPELIBS} ${XRENDER} ${MPDCLIENT} ${XEXTLIB} ${XCBLIBS} ${KVMLIB} ${PANGOLIB} ${YAJLLIBS} ${IMLIB2LIBS}
|
||||
|
||||
# flags
|
||||
CPPFLAGS = -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_POSIX_C_SOURCE=200809L -DVERSION=\"${VERSION}\" ${XINERAMAFLAGS}
|
||||
#CFLAGS = -g -std=c99 -pedantic -Wall -O0 ${INCS} ${CPPFLAGS}
|
||||
CFLAGS = -std=c99 -pedantic -Wall -Wno-unused-function -Wno-deprecated-declarations -Os ${INCS} ${CPPFLAGS}
|
||||
LDFLAGS = ${LIBS}
|
||||
|
||||
# compiler and linker
|
||||
CC = cc
|
||||
|
|
@ -1,58 +0,0 @@
|
|||
# dwm version
|
||||
VERSION = 6.3
|
||||
|
||||
# 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
|
||||
|
||||
# Uncomment this for the alpha patch and the winicon patch (BAR_ALPHA_PATCH, BAR_WINICON_PATCH)
|
||||
XRENDER = -lXrender
|
||||
|
||||
# Uncomment this for the mdpcontrol patch / MDPCONTROL_PATCH
|
||||
#MPDCLIENT = -lmpdclient
|
||||
|
||||
# Uncomment for the pango patch / BAR_PANGO_PATCH
|
||||
#PANGOINC = `pkg-config --cflags xft pango pangoxft`
|
||||
#PANGOLIB = `pkg-config --libs xft pango pangoxft`
|
||||
|
||||
# Uncomment for the ipc patch / IPC_PATCH
|
||||
#YAJLLIBS = -lyajl
|
||||
#YAJLINC = -I/usr/include/yajl
|
||||
|
||||
# Uncomment this for the rounded corners patch / ROUNDED_CORNERS_PATCH
|
||||
#XEXTLIB = -lXext
|
||||
|
||||
# Uncomment this for the swallow patch / SWALLOW_PATCH
|
||||
XCBLIBS = -lX11-xcb -lxcb -lxcb-res
|
||||
|
||||
# This is needed for the winicon and tagpreview patches / BAR_WINICON_PATCH / BAR_TAGPREVIEW_PATCH
|
||||
#IMLIB2LIBS = -lImlib2
|
||||
|
||||
# includes and libs
|
||||
INCS = -I${X11INC} -I${FREETYPEINC} ${YAJLINC} ${PANGOINC}
|
||||
LIBS = -L${X11LIB} -lX11 ${XINERAMALIBS} ${FREETYPELIBS} ${XRENDER} ${MPDCLIENT} ${XEXTLIB} ${XCBLIBS} ${KVMLIB} ${PANGOLIB} ${YAJLLIBS} ${IMLIB2LIBS}
|
||||
|
||||
# flags
|
||||
CPPFLAGS = -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_POSIX_C_SOURCE=200809L -DVERSION=\"${VERSION}\" ${XINERAMAFLAGS}
|
||||
#CFLAGS = -g -std=c99 -pedantic -Wall -O0 ${INCS} ${CPPFLAGS}
|
||||
CFLAGS = -std=c99 -pedantic -Wall -Wno-unused-function -Wno-deprecated-declarations -Os ${INCS} ${CPPFLAGS}
|
||||
LDFLAGS = ${LIBS}
|
||||
|
||||
CFLAGS = -fast ${INCS} -DVERSION=\"${VERSION}\"
|
||||
LDFLAGS = ${LIBS}
|
||||
|
||||
# compiler and linker
|
||||
CC = cc
|
||||
223
dwm/patch/alttab.c
Normal file
223
dwm/patch/alttab.c
Normal file
|
|
@ -0,0 +1,223 @@
|
|||
int alttabn; /* move that many clients forward */
|
||||
int ntabs; /* number of active clients in tag */
|
||||
int isalt;
|
||||
Client **altsnext; /* array of all clients in the tag */
|
||||
Window alttabwin;
|
||||
|
||||
void
|
||||
alttab()
|
||||
{
|
||||
Monitor *m = selmon;
|
||||
|
||||
/* move to next window */
|
||||
if (m->sel && m->sel->snext) {
|
||||
alttabn++;
|
||||
if (alttabn >= ntabs)
|
||||
alttabn = 0; /* reset alttabn */
|
||||
|
||||
focus(altsnext[alttabn]);
|
||||
restack(m);
|
||||
}
|
||||
|
||||
/* redraw tab */
|
||||
XRaiseWindow(dpy, alttabwin);
|
||||
drawalttab(ntabs, 0, m);
|
||||
}
|
||||
|
||||
void
|
||||
alttabend()
|
||||
{
|
||||
Monitor *m = selmon;
|
||||
Client *buff;
|
||||
int i;
|
||||
|
||||
if (!isalt)
|
||||
return;
|
||||
|
||||
/* Move all clients between first and choosen position,
|
||||
* one down in stack and put choosen client to the first position
|
||||
* so they remain in right order for the next time that alt-tab is used
|
||||
*/
|
||||
if (ntabs > 1) {
|
||||
if (alttabn != 0) { /* if user picked original client do nothing */
|
||||
buff = altsnext[alttabn];
|
||||
if (alttabn > 1)
|
||||
for (i = alttabn; i > 0; i--)
|
||||
altsnext[i] = altsnext[i - 1];
|
||||
else /* swap them if there are just 2 clients */
|
||||
altsnext[alttabn] = altsnext[0];
|
||||
altsnext[0] = buff;
|
||||
}
|
||||
|
||||
/* restack clients */
|
||||
for (i = ntabs - 1; i >= 0; i--) {
|
||||
focus(altsnext[i]);
|
||||
restack(m);
|
||||
}
|
||||
|
||||
free(altsnext); /* free list of clients */
|
||||
}
|
||||
|
||||
/* destroy the window */
|
||||
isalt = 0;
|
||||
ntabs = 0;
|
||||
XUnmapWindow(dpy, alttabwin);
|
||||
XDestroyWindow(dpy, alttabwin);
|
||||
}
|
||||
|
||||
void
|
||||
drawalttab(int nwins, int first, Monitor *m)
|
||||
{
|
||||
Client *c;
|
||||
int i, h;
|
||||
int y = 0;
|
||||
int px = m->mx;
|
||||
int py = m->my;
|
||||
|
||||
if (first) {
|
||||
XSetWindowAttributes wa = {
|
||||
.override_redirect = True,
|
||||
#if BAR_ALPHA_PATCH
|
||||
.background_pixel = 0,
|
||||
.border_pixel = 0,
|
||||
.colormap = cmap,
|
||||
#else
|
||||
.background_pixmap = ParentRelative,
|
||||
#endif // BAR_ALPHA_PATCH
|
||||
.event_mask = ButtonPressMask|ExposureMask
|
||||
};
|
||||
|
||||
/* decide position of tabwin */
|
||||
if (tabposx == 1)
|
||||
px = m->mx + (m->mw / 2) - (maxwtab / 2);
|
||||
else if (tabposx == 2)
|
||||
px = m->mx + m->mw - maxwtab;
|
||||
|
||||
if (tabposy == 1)
|
||||
py = m->my + (m->mh / 2) - (maxhtab / 2);
|
||||
else if (tabposy == 2)
|
||||
py = m->my + m->mh - maxhtab;
|
||||
|
||||
h = maxhtab;
|
||||
|
||||
#if BAR_ALPHA_PATCH
|
||||
alttabwin = XCreateWindow(dpy, root, px, py, maxwtab, maxhtab, 2, depth,
|
||||
InputOutput, visual,
|
||||
CWOverrideRedirect|CWBackPixel|CWBorderPixel|CWColormap|CWEventMask, &wa);
|
||||
#else
|
||||
alttabwin = XCreateWindow(dpy, root, px, py, maxwtab, maxhtab, 2, DefaultDepth(dpy, screen),
|
||||
CopyFromParent, DefaultVisual(dpy, screen),
|
||||
CWOverrideRedirect|CWBackPixmap|CWEventMask, &wa);
|
||||
#endif // BAR_ALPHA_PATCH
|
||||
|
||||
XDefineCursor(dpy, alttabwin, cursor[CurNormal]->cursor);
|
||||
XMapRaised(dpy, alttabwin);
|
||||
}
|
||||
|
||||
h = maxhtab / ntabs;
|
||||
for (i = 0; i < ntabs; i++) { /* draw all clients into tabwin */
|
||||
c = altsnext[i];
|
||||
if (!ISVISIBLE(c))
|
||||
continue;
|
||||
if (HIDDEN(c))
|
||||
continue;
|
||||
|
||||
drw_setscheme(drw, scheme[c == m->sel ? SchemeSel : SchemeNorm]);
|
||||
drw_text(drw, 0, y, maxwtab, h, 0, c->name, 0, 0);
|
||||
y += h;
|
||||
}
|
||||
|
||||
drw_setscheme(drw, scheme[SchemeNorm]);
|
||||
drw_map(drw, alttabwin, 0, 0, maxwtab, maxhtab);
|
||||
}
|
||||
|
||||
void
|
||||
alttabstart(const Arg *arg)
|
||||
{
|
||||
Client *c;
|
||||
Monitor *m = selmon;
|
||||
int grabbed;
|
||||
int i;
|
||||
|
||||
altsnext = NULL;
|
||||
if (alttabwin)
|
||||
alttabend();
|
||||
|
||||
if (isalt == 1) {
|
||||
alttabend();
|
||||
return;
|
||||
}
|
||||
|
||||
isalt = 1;
|
||||
alttabn = 0;
|
||||
ntabs = 0;
|
||||
|
||||
for (c = m->clients; c; c = c->next) {
|
||||
if (!ISVISIBLE(c))
|
||||
continue;
|
||||
if (HIDDEN(c))
|
||||
continue;
|
||||
|
||||
++ntabs;
|
||||
}
|
||||
|
||||
if (!ntabs) {
|
||||
alttabend();
|
||||
return;
|
||||
}
|
||||
|
||||
altsnext = (Client **) malloc(ntabs * sizeof(Client *));
|
||||
|
||||
for (i = 0, c = m->stack; c; c = c->snext) {
|
||||
if (!ISVISIBLE(c))
|
||||
continue;
|
||||
if (HIDDEN(c))
|
||||
continue;
|
||||
|
||||
altsnext[i] = c;
|
||||
i++;
|
||||
}
|
||||
|
||||
drawalttab(ntabs, 1, m);
|
||||
|
||||
struct timespec ts = { .tv_sec = 0, .tv_nsec = 1000000 };
|
||||
|
||||
/* grab keyboard (take all input from keyboard) */
|
||||
grabbed = 1;
|
||||
for (i = 0; i < 1000; i++) {
|
||||
if (XGrabKeyboard(dpy, root, True, GrabModeAsync, GrabModeAsync, CurrentTime) == GrabSuccess)
|
||||
break;
|
||||
nanosleep(&ts, NULL);
|
||||
if (i == 1000 - 1)
|
||||
grabbed = 0;
|
||||
}
|
||||
|
||||
XEvent event;
|
||||
alttab();
|
||||
|
||||
if (grabbed == 0) {
|
||||
alttabend();
|
||||
return;
|
||||
}
|
||||
|
||||
while (grabbed) {
|
||||
XNextEvent(dpy, &event);
|
||||
if (event.type == KeyPress || event.type == KeyRelease) {
|
||||
if (event.type == KeyRelease && event.xkey.keycode == tabmodkey) /* if mod key is released break cycle */
|
||||
break;
|
||||
|
||||
if (event.type == KeyPress) {
|
||||
if (event.xkey.keycode == tabcyclekey) { /* if tab is pressed move to the next window */
|
||||
alttab();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
c = m->sel;
|
||||
alttabend();
|
||||
|
||||
XUngrabKeyboard(dpy, CurrentTime);
|
||||
focus(c);
|
||||
restack(m);
|
||||
}
|
||||
5
dwm/patch/alttab.h
Normal file
5
dwm/patch/alttab.h
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
#include <time.h>
|
||||
|
||||
static void drawalttab(int nwins, int first, Monitor *m);
|
||||
static void alttabstart(const Arg *arg);
|
||||
static void alttabend();
|
||||
20
dwm/patch/alwaysontop.c
Normal file
20
dwm/patch/alwaysontop.c
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
void
|
||||
togglealwaysontop(const Arg *arg)
|
||||
{
|
||||
Client *c = selmon->sel;
|
||||
|
||||
if (!c)
|
||||
return;
|
||||
#if !FAKEFULLSCREEN_PATCH
|
||||
#if FAKEFULLSCREEN_CLIENT_PATCH
|
||||
if (c->isfullscreen && !c->fakefullscreen)
|
||||
return;
|
||||
#else
|
||||
if (c->isfullscreen)
|
||||
return;
|
||||
#endif // FAKEFULLSCREEN_CLIENT_PATCH
|
||||
#endif // FAKEFULLSCREEN_PATCH
|
||||
|
||||
c->alwaysontop = !c->alwaysontop;
|
||||
restack(selmon);
|
||||
}
|
||||
1
dwm/patch/alwaysontop.h
Normal file
1
dwm/patch/alwaysontop.h
Normal file
|
|
@ -0,0 +1 @@
|
|||
static void togglealwaysontop(const Arg *arg);
|
||||
25
dwm/patch/aspectresize.c
Normal file
25
dwm/patch/aspectresize.c
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
void
|
||||
aspectresize(const Arg *arg)
|
||||
{
|
||||
/* only floating windows can be moved */
|
||||
Client *c;
|
||||
c = selmon->sel;
|
||||
float ratio;
|
||||
int w, h,nw, nh;
|
||||
|
||||
if (!c || !arg)
|
||||
return;
|
||||
if (selmon->lt[selmon->sellt]->arrange && !c->isfloating)
|
||||
return;
|
||||
|
||||
ratio = (float)c->w / (float)c->h;
|
||||
h = arg->i;
|
||||
w = (int)(ratio * h);
|
||||
|
||||
nw = c->w + w;
|
||||
nh = c->h + h;
|
||||
|
||||
XRaiseWindow(dpy, c->win);
|
||||
resize(c, c->x, c->y, nw, nh, True);
|
||||
}
|
||||
|
||||
2
dwm/patch/aspectresize.h
Normal file
2
dwm/patch/aspectresize.h
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
static void aspectresize(const Arg *arg);
|
||||
|
||||
|
|
@ -1,9 +1,34 @@
|
|||
void
|
||||
attachx(Client *c)
|
||||
{
|
||||
#if ATTACHABOVE_PATCH || ATTACHASIDE_PATCH || ATTACHBOTTOM_PATCH || SEAMLESS_RESTART_PATCH
|
||||
Client *at;
|
||||
#endif // ATTACHABOVE_PATCH | ATTACHASIDE_PATCH | ATTACHBOTTOM_PATCH | SEAMLESS_RESTART_PATCH
|
||||
|
||||
#if SEAMLESS_RESTART_PATCH
|
||||
if (c->idx > 0) { /* then the client has a designated position in the client list */
|
||||
for (at = c->mon->clients; at; at = at->next) {
|
||||
if (c->idx < at->idx) {
|
||||
c->next = at;
|
||||
c->mon->clients = c;
|
||||
return;
|
||||
} else if (at->idx <= c->idx && (!at->next || c->idx <= at->next->idx)) {
|
||||
c->next = at->next;
|
||||
at->next = c;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif // SEAMLESS_RESTART_PATCH
|
||||
|
||||
#if ATTACHABOVE_PATCH
|
||||
if (!(c->mon->sel == NULL || c->mon->sel == c->mon->clients || c->mon->sel->isfloating)) {
|
||||
for (at = c->mon->clients; at->next != c->mon->sel; at = at->next);
|
||||
c->next = at->next;
|
||||
at->next = c;
|
||||
return;
|
||||
}
|
||||
#elif ATTACHASIDE_PATCH
|
||||
unsigned int n;
|
||||
for (at = c->mon->clients, n = 0; at; at = at->next)
|
||||
if (!at->isfloating && ISVISIBLEONTAG(at, c->tags))
|
||||
|
|
@ -15,6 +40,20 @@ attachx(Client *c)
|
|||
at->next = c;
|
||||
return;
|
||||
}
|
||||
#elif ATTACHBELOW_PATCH
|
||||
if (!(c->mon->sel == NULL || c->mon->sel == c || c->mon->sel->isfloating)) {
|
||||
c->next = c->mon->sel->next;
|
||||
c->mon->sel->next = c;
|
||||
return;
|
||||
}
|
||||
#elif ATTACHBOTTOM_PATCH
|
||||
for (at = c->mon->clients; at && at->next; at = at->next);
|
||||
if (at) {
|
||||
at->next = c;
|
||||
c->next = NULL;
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
attach(c); // master (default)
|
||||
}
|
||||
|
||||
|
|
|
|||
76
dwm/patch/autostart.c
Normal file
76
dwm/patch/autostart.c
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
void
|
||||
runautostart(void)
|
||||
{
|
||||
char *pathpfx;
|
||||
char *path;
|
||||
char *xdgdatahome;
|
||||
char *home;
|
||||
struct stat sb;
|
||||
|
||||
if ((home = getenv("HOME")) == NULL)
|
||||
/* this is almost impossible */
|
||||
return;
|
||||
|
||||
/* if $XDG_DATA_HOME is set and not empty, use $XDG_DATA_HOME/dwm,
|
||||
* otherwise use ~/.local/share/dwm as autostart script directory
|
||||
*/
|
||||
xdgdatahome = getenv("XDG_DATA_HOME");
|
||||
if (xdgdatahome != NULL && *xdgdatahome != '\0') {
|
||||
/* space for path segments, separators and nul */
|
||||
pathpfx = ecalloc(1, strlen(xdgdatahome) + strlen(dwmdir) + 2);
|
||||
|
||||
if (sprintf(pathpfx, "%s/%s", xdgdatahome, dwmdir) <= 0) {
|
||||
free(pathpfx);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
/* space for path segments, separators and nul */
|
||||
pathpfx = ecalloc(1, strlen(home) + strlen(localshare)
|
||||
+ strlen(dwmdir) + 3);
|
||||
|
||||
if (sprintf(pathpfx, "%s/%s/%s", home, localshare, dwmdir) < 0) {
|
||||
free(pathpfx);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/* check if the autostart script directory exists */
|
||||
if (! (stat(pathpfx, &sb) == 0 && S_ISDIR(sb.st_mode))) {
|
||||
/* the XDG conformant path does not exist or is no directory
|
||||
* so we try ~/.dwm instead
|
||||
*/
|
||||
char *pathpfx_new = realloc(pathpfx, strlen(home) + strlen(dwmdir) + 3);
|
||||
if(pathpfx_new == NULL) {
|
||||
free(pathpfx);
|
||||
return;
|
||||
}
|
||||
pathpfx = pathpfx_new;
|
||||
|
||||
if (sprintf(pathpfx, "%s/.%s", home, dwmdir) <= 0) {
|
||||
free(pathpfx);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/* try the blocking script first */
|
||||
path = ecalloc(1, strlen(pathpfx) + strlen(autostartblocksh) + 2);
|
||||
if (sprintf(path, "%s/%s", pathpfx, autostartblocksh) <= 0) {
|
||||
free(path);
|
||||
free(pathpfx);
|
||||
}
|
||||
|
||||
if (access(path, X_OK) == 0)
|
||||
system(path);
|
||||
|
||||
/* now the non-blocking script */
|
||||
if (sprintf(path, "%s/%s", pathpfx, autostartsh) <= 0) {
|
||||
free(path);
|
||||
free(pathpfx);
|
||||
}
|
||||
|
||||
if (access(path, X_OK) == 0)
|
||||
system(strcat(path, " &"));
|
||||
|
||||
free(pathpfx);
|
||||
free(path);
|
||||
}
|
||||
2
dwm/patch/autostart.h
Normal file
2
dwm/patch/autostart.h
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
static void runautostart(void);
|
||||
|
||||
71
dwm/patch/banish.c
Normal file
71
dwm/patch/banish.c
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
static int cursor_hidden = 0;
|
||||
/* mouse_x and mouse_y are used to store the actual co-ordinates of the mouse cursor when
|
||||
* hidden. These can be manipulated freely, e.g. when using the warp patch, to set a new
|
||||
* cursor position for when the cursor is to be revealed again. */
|
||||
static int mouse_x = 0;
|
||||
static int mouse_y = 0;
|
||||
static int xi_opcode;
|
||||
static unsigned long long last_button_press = 0;
|
||||
|
||||
void
|
||||
genericevent(XEvent *e)
|
||||
{
|
||||
if (e->xcookie.extension != xi_opcode)
|
||||
return;
|
||||
|
||||
if (!XGetEventData(dpy, &e->xcookie))
|
||||
return;
|
||||
|
||||
switch (e->xcookie.evtype) {
|
||||
case XI_RawMotion:
|
||||
if (cursor_hidden)
|
||||
showcursor(NULL);
|
||||
break;
|
||||
case XI_RawTouchBegin:
|
||||
case XI_RawTouchEnd:
|
||||
case XI_RawTouchUpdate:
|
||||
if (!cursor_hidden)
|
||||
hidecursor(NULL);
|
||||
break;
|
||||
case XI_RawKeyRelease:
|
||||
if (now() - last_button_press > 2000 && !cursor_hidden) {
|
||||
hidecursor(NULL);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
XFreeEventData(dpy, &e->xcookie);
|
||||
}
|
||||
|
||||
void
|
||||
hidecursor(const Arg *arg)
|
||||
{
|
||||
if (cursor_hidden)
|
||||
return;
|
||||
|
||||
XFixesHideCursor(dpy, root);
|
||||
if (getrootptr(&mouse_x, &mouse_y)) {
|
||||
XWarpPointer(dpy, None, root, 0, 0, 0, 0, selmon->mx + selmon->mw, selmon->my);
|
||||
}
|
||||
|
||||
cursor_hidden = 1;
|
||||
}
|
||||
|
||||
unsigned long long
|
||||
now(void) {
|
||||
struct timespec currentTime;
|
||||
clock_gettime(CLOCK_REALTIME, ¤tTime);
|
||||
return currentTime.tv_sec * 1000LL + currentTime.tv_nsec / 1000000LL;
|
||||
}
|
||||
|
||||
void
|
||||
showcursor(const Arg *arg)
|
||||
{
|
||||
if (!cursor_hidden)
|
||||
return;
|
||||
|
||||
XWarpPointer(dpy, None, root, 0, 0, 0, 0, mouse_x, mouse_y);
|
||||
XFixesShowCursor(dpy, root);
|
||||
|
||||
cursor_hidden = 0;
|
||||
}
|
||||
8
dwm/patch/banish.h
Normal file
8
dwm/patch/banish.h
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
#include <time.h>
|
||||
#include <X11/extensions/Xfixes.h>
|
||||
#include <X11/extensions/XInput2.h>
|
||||
|
||||
static void genericevent(XEvent *e);
|
||||
static void hidecursor(const Arg *arg);
|
||||
static unsigned long long now(void);
|
||||
static void showcursor(const Arg *arg);
|
||||
7
dwm/patch/bar_alternativetags.c
Normal file
7
dwm/patch/bar_alternativetags.c
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
void
|
||||
togglealttag()
|
||||
{
|
||||
selmon->alttag = !selmon->alttag;
|
||||
drawbar(selmon);
|
||||
}
|
||||
|
||||
2
dwm/patch/bar_alternativetags.h
Normal file
2
dwm/patch/bar_alternativetags.h
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
static void togglealttag();
|
||||
|
||||
94
dwm/patch/bar_anybar.c
Normal file
94
dwm/patch/bar_anybar.c
Normal file
|
|
@ -0,0 +1,94 @@
|
|||
void
|
||||
managealtbar(Window win, XWindowAttributes *wa)
|
||||
{
|
||||
Monitor *m;
|
||||
Bar *bar;
|
||||
int i = 0;
|
||||
if (!(m = recttomon(wa->x, wa->y, wa->width, wa->height)))
|
||||
return;
|
||||
for (bar = m->bar; bar && bar->win && bar->next; bar = bar->next); // find last bar
|
||||
if (!bar) {
|
||||
bar = m->bar = ecalloc(1, sizeof(Bar));
|
||||
bar->topbar = topbar;
|
||||
} else if (bar && bar->win) {
|
||||
i = bar->idx + 1;
|
||||
bar->next = ecalloc(1, sizeof(Bar));
|
||||
#if BAR_ANYBAR_TOP_AND_BOTTOM_BARS_PATCH
|
||||
bar->next->topbar = !bar->topbar;
|
||||
#else
|
||||
bar->next->topbar = topbar;
|
||||
#endif // BAR_ANYBAR_TOP_AND_BOTTOM_BARS_PATCH
|
||||
bar = bar->next;
|
||||
}
|
||||
bar->external = 1;
|
||||
bar->showbar = 1;
|
||||
bar->mon = m;
|
||||
bar->idx = i;
|
||||
bar->borderpx = 0;
|
||||
bar->win = win;
|
||||
bar->bw = wa->width;
|
||||
bar->bh = wa->height;
|
||||
updatebarpos(m);
|
||||
arrange(m);
|
||||
XSelectInput(dpy, win, EnterWindowMask|FocusChangeMask|PropertyChangeMask|StructureNotifyMask);
|
||||
XMapWindow(dpy, win);
|
||||
XMoveResizeWindow(dpy, bar->win, bar->bx, bar->by, bar->bw, bar->bh);
|
||||
arrange(selmon);
|
||||
XChangeProperty(dpy, root, netatom[NetClientList], XA_WINDOW, 32, PropModeAppend,
|
||||
(unsigned char *) &win, 1);
|
||||
}
|
||||
|
||||
void
|
||||
spawnbar()
|
||||
{
|
||||
if (*altbarcmd)
|
||||
system(altbarcmd);
|
||||
}
|
||||
|
||||
void
|
||||
unmanagealtbar(Window w)
|
||||
{
|
||||
Monitor *m = wintomon(w);
|
||||
Bar *bar, *next, *prev = NULL;
|
||||
|
||||
if (!m)
|
||||
return;
|
||||
|
||||
for (bar = m->bar; bar && bar->win; bar = next) {
|
||||
next = bar->next;
|
||||
if (bar->win == w) {
|
||||
if (prev)
|
||||
prev->next = next;
|
||||
else
|
||||
m->bar = next;
|
||||
free(bar);
|
||||
break;
|
||||
}
|
||||
prev = bar;
|
||||
}
|
||||
updatebarpos(m);
|
||||
arrange(m);
|
||||
}
|
||||
|
||||
int
|
||||
wmclasscontains(Window win, const char *class, const char *name)
|
||||
{
|
||||
XClassHint ch = { NULL, NULL };
|
||||
int res = 1;
|
||||
|
||||
if (XGetClassHint(dpy, win, &ch)) {
|
||||
if (ch.res_name && strstr(ch.res_name, name) == NULL)
|
||||
res = 0;
|
||||
if (ch.res_class && strstr(ch.res_class, class) == NULL)
|
||||
res = 0;
|
||||
} else
|
||||
res = 0;
|
||||
|
||||
if (ch.res_class)
|
||||
XFree(ch.res_class);
|
||||
if (ch.res_name)
|
||||
XFree(ch.res_name);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
5
dwm/patch/bar_anybar.h
Normal file
5
dwm/patch/bar_anybar.h
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
static void managealtbar(Window win, XWindowAttributes *wa);
|
||||
static void spawnbar();
|
||||
static void unmanagealtbar(Window w);
|
||||
static int wmclasscontains(Window win, const char *class, const char *name);
|
||||
|
||||
123
dwm/patch/bar_awesomebar.c
Normal file
123
dwm/patch/bar_awesomebar.c
Normal file
|
|
@ -0,0 +1,123 @@
|
|||
int
|
||||
width_awesomebar(Bar *bar, BarArg *a)
|
||||
{
|
||||
return a->w;
|
||||
}
|
||||
|
||||
int
|
||||
draw_awesomebar(Bar *bar, BarArg *a)
|
||||
{
|
||||
int n = 0, scm, remainder = 0, tabw, tpad, tx, tw;
|
||||
unsigned int i;
|
||||
#if BAR_CENTEREDWINDOWNAME_PATCH
|
||||
int cpad;
|
||||
#endif // BAR_CENTEREDWINDOWNAME_PATCH
|
||||
#if BAR_WINICON_PATCH
|
||||
int ipad;
|
||||
#endif // BAR_WINICON_PATCH
|
||||
#if BAR_TITLE_LEFT_PAD_PATCH && BAR_TITLE_RIGHT_PAD_PATCH
|
||||
int x = a->x + lrpad / 2, w = a->w - lrpad;
|
||||
#elif BAR_TITLE_LEFT_PAD_PATCH
|
||||
int x = a->x + lrpad / 2, w = a->w - lrpad / 2;
|
||||
#elif BAR_TITLE_RIGHT_PAD_PATCH
|
||||
int x = a->x, w = a->w - lrpad / 2;
|
||||
#else
|
||||
int x = a->x, w = a->w;
|
||||
#endif // BAR_TITLE_LEFT_PAD_PATCH | BAR_TITLE_RIGHT_PAD_PATCH
|
||||
|
||||
Client *c;
|
||||
for (c = bar->mon->clients; c; c = c->next)
|
||||
if (ISVISIBLE(c))
|
||||
n++;
|
||||
|
||||
if (n > 0) {
|
||||
remainder = w % n;
|
||||
tabw = w / n;
|
||||
for (i = 0, c = bar->mon->clients; c; c = c->next, i++) {
|
||||
if (!ISVISIBLE(c))
|
||||
continue;
|
||||
if (bar->mon->sel == c && HIDDEN(c))
|
||||
scm = SchemeHidSel;
|
||||
else if (HIDDEN(c))
|
||||
scm = SchemeHidNorm;
|
||||
else if (bar->mon->sel == c)
|
||||
scm = SchemeTitleSel;
|
||||
else
|
||||
scm = SchemeTitleNorm;
|
||||
|
||||
tpad = lrpad / 2;
|
||||
#if BAR_CENTEREDWINDOWNAME_PATCH
|
||||
cpad = 0;
|
||||
#endif // BAR_CENTEREDWINDOWNAME_PATCH
|
||||
#if BAR_WINICON_PATCH
|
||||
ipad = c->icon ? c->icw + ICONSPACING : 0;
|
||||
#endif // BAR_WINICON_PATCH
|
||||
|
||||
tx = x;
|
||||
tw = tabw;
|
||||
|
||||
#if BAR_WINICON_PATCH && BAR_CENTEREDWINDOWNAME_PATCH
|
||||
if (TEXTW(c->name) + ipad < tabw)
|
||||
cpad = (tabw - TEXTW(c->name) - ipad) / 2;
|
||||
#elif BAR_CENTEREDWINDOWNAME_PATCH
|
||||
if (TEXTW(c->name) < tabw)
|
||||
cpad = (tabw - TEXTW(c->name)) / 2;
|
||||
#endif // BAR_CENTEREDWINDOWNAME_PATCH
|
||||
|
||||
drw_setscheme(drw, scheme[scm]);
|
||||
|
||||
XSetForeground(drw->dpy, drw->gc, drw->scheme[ColBg].pixel);
|
||||
XFillRectangle(drw->dpy, drw->drawable, drw->gc, tx, a->y, tw, a->h);
|
||||
|
||||
#if BAR_CENTEREDWINDOWNAME_PATCH
|
||||
/* Apply center padding, if any */
|
||||
tx += cpad;
|
||||
tw -= cpad;
|
||||
#endif // BAR_CENTEREDWINDOWNAME_PATCH
|
||||
|
||||
tx += tpad;
|
||||
tw -= lrpad;
|
||||
|
||||
#if BAR_WINICON_PATCH
|
||||
if (ipad) {
|
||||
drw_pic(drw, tx, a->y + (a->h - c->ich) / 2, c->icw, c->ich, c->icon);
|
||||
tx += ipad;
|
||||
tw -= ipad;
|
||||
}
|
||||
#endif // BAR_WINICON_PATCH
|
||||
|
||||
drw_text(drw, tx, a->y, tw, a->h, 0, c->name, 0, False);
|
||||
|
||||
drawstateindicator(c->mon, c, 1, x, a->y, tabw + (i < remainder ? 1 : 0), a->h, 0, 0, c->isfixed);
|
||||
x += tabw + (i < remainder ? 1 : 0);
|
||||
}
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
int
|
||||
click_awesomebar(Bar *bar, Arg *arg, BarArg *a)
|
||||
{
|
||||
int x = 0, n = 0;
|
||||
Client *c;
|
||||
|
||||
for (c = bar->mon->clients; c; c = c->next)
|
||||
if (ISVISIBLE(c))
|
||||
n++;
|
||||
|
||||
c = bar->mon->clients;
|
||||
|
||||
do {
|
||||
if (!c || !ISVISIBLE(c))
|
||||
continue;
|
||||
else
|
||||
x += (1.0 / (double)n) * a->w;
|
||||
} while (c && a->x > x && (c = c->next));
|
||||
|
||||
if (c) {
|
||||
arg->v = c;
|
||||
return ClkWinTitle;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
4
dwm/patch/bar_awesomebar.h
Normal file
4
dwm/patch/bar_awesomebar.h
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
static int width_awesomebar(Bar *bar, BarArg *a);
|
||||
static int draw_awesomebar(Bar *bar, BarArg *a);
|
||||
static int click_awesomebar(Bar *bar, Arg *arg, BarArg *a);
|
||||
|
||||
51
dwm/patch/bar_dwmblocks.c
Normal file
51
dwm/patch/bar_dwmblocks.c
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
static int statussig;
|
||||
pid_t statuspid = -1;
|
||||
|
||||
pid_t
|
||||
getstatusbarpid()
|
||||
{
|
||||
char buf[32], *str = buf, *c;
|
||||
FILE *fp;
|
||||
|
||||
if (statuspid > 0) {
|
||||
snprintf(buf, sizeof(buf), "/proc/%u/cmdline", statuspid);
|
||||
if ((fp = fopen(buf, "r"))) {
|
||||
fgets(buf, sizeof(buf), fp);
|
||||
while ((c = strchr(str, '/')))
|
||||
str = c + 1;
|
||||
fclose(fp);
|
||||
if (!strcmp(str, STATUSBAR))
|
||||
return statuspid;
|
||||
}
|
||||
}
|
||||
if (!(fp = popen("pgrep -o "STATUSBAR, "r")))
|
||||
return -1;
|
||||
fgets(buf, sizeof(buf), fp);
|
||||
pclose(fp);
|
||||
return strtol(buf, NULL, 10);
|
||||
}
|
||||
|
||||
void
|
||||
sigstatusbar(const Arg *arg)
|
||||
{
|
||||
union sigval sv;
|
||||
|
||||
if (!statussig)
|
||||
return;
|
||||
if ((statuspid = getstatusbarpid()) <= 0)
|
||||
return;
|
||||
|
||||
#if BAR_DWMBLOCKS_SIGUSR1_PATCH
|
||||
sv.sival_int = (statussig << 8) | arg->i;
|
||||
if (sigqueue(statuspid, SIGUSR1, sv) == -1) {
|
||||
if (errno == ESRCH) {
|
||||
if (!getstatusbarpid())
|
||||
sigqueue(statuspid, SIGUSR1, sv);
|
||||
}
|
||||
}
|
||||
#else
|
||||
sv.sival_int = arg->i;
|
||||
sigqueue(statuspid, SIGRTMIN+statussig, sv);
|
||||
#endif // BAR_DWMBLOCKS_SIGUSR1_PATCH
|
||||
}
|
||||
|
||||
3
dwm/patch/bar_dwmblocks.h
Normal file
3
dwm/patch/bar_dwmblocks.h
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
static int getstatusbarpid();
|
||||
static void sigstatusbar(const Arg *arg);
|
||||
|
||||
52
dwm/patch/bar_ewmhtags.c
Normal file
52
dwm/patch/bar_ewmhtags.c
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
void
|
||||
setcurrentdesktop(void)
|
||||
{
|
||||
long data[] = { 0 };
|
||||
XChangeProperty(dpy, root, netatom[NetCurrentDesktop], XA_CARDINAL, 32, PropModeReplace, (unsigned char *)data, 1);
|
||||
}
|
||||
|
||||
void
|
||||
setdesktopnames(void)
|
||||
{
|
||||
int i;
|
||||
XTextProperty text;
|
||||
char *tags[NUMTAGS];
|
||||
for (i = 0; i < NUMTAGS; i++)
|
||||
tags[i] = tagicon(selmon, i);
|
||||
Xutf8TextListToTextProperty(dpy, tags, NUMTAGS, XUTF8StringStyle, &text);
|
||||
XSetTextProperty(dpy, root, &text, netatom[NetDesktopNames]);
|
||||
}
|
||||
|
||||
void
|
||||
setfloatinghint(Client *c)
|
||||
{
|
||||
Atom target = XInternAtom(dpy, "_IS_FLOATING", 0);
|
||||
unsigned int floating[1] = {c->isfloating};
|
||||
XChangeProperty(dpy, c->win, target, XA_CARDINAL, 32, PropModeReplace, (unsigned char *)floating, 1);
|
||||
}
|
||||
|
||||
void
|
||||
setnumdesktops(void)
|
||||
{
|
||||
long data[] = { NUMTAGS };
|
||||
XChangeProperty(dpy, root, netatom[NetNumberOfDesktops], XA_CARDINAL, 32, PropModeReplace, (unsigned char *)data, 1);
|
||||
}
|
||||
|
||||
void
|
||||
setviewport(void)
|
||||
{
|
||||
long data[] = { 0, 0 };
|
||||
XChangeProperty(dpy, root, netatom[NetDesktopViewport], XA_CARDINAL, 32, PropModeReplace, (unsigned char *)data, 2);
|
||||
}
|
||||
|
||||
void
|
||||
updatecurrentdesktop(void)
|
||||
{
|
||||
long rawdata[] = { selmon->tagset[selmon->seltags] };
|
||||
int i = 0;
|
||||
while (*rawdata >> (i + 1)) {
|
||||
i++;
|
||||
}
|
||||
long data[] = { i };
|
||||
XChangeProperty(dpy, root, netatom[NetCurrentDesktop], XA_CARDINAL, 32, PropModeReplace, (unsigned char *)data, 1);
|
||||
}
|
||||
7
dwm/patch/bar_ewmhtags.h
Normal file
7
dwm/patch/bar_ewmhtags.h
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
static void setcurrentdesktop(void);
|
||||
static void setdesktopnames(void);
|
||||
static void setfloatinghint(Client *c);
|
||||
static void setnumdesktops(void);
|
||||
static void setviewport(void);
|
||||
static void updatecurrentdesktop(void);
|
||||
|
||||
103
dwm/patch/bar_fancybar.c
Normal file
103
dwm/patch/bar_fancybar.c
Normal file
|
|
@ -0,0 +1,103 @@
|
|||
int
|
||||
width_fancybar(Bar *bar, BarArg *a)
|
||||
{
|
||||
return a->w;
|
||||
}
|
||||
|
||||
int
|
||||
draw_fancybar(Bar *bar, BarArg *a)
|
||||
{
|
||||
int tabw, mw, ew = 0, n = 0, tx, tw;
|
||||
#if BAR_WINICON_PATCH
|
||||
int ipad;
|
||||
#endif // BAR_WINICON_PATCH
|
||||
unsigned int i;
|
||||
Client *c;
|
||||
Monitor *m = bar->mon;
|
||||
|
||||
#if BAR_TITLE_LEFT_PAD_PATCH && BAR_TITLE_RIGHT_PAD_PATCH
|
||||
int x = a->x + lrpad / 2, w = a->w - lrpad;
|
||||
#elif BAR_TITLE_LEFT_PAD_PATCH
|
||||
int x = a->x + lrpad / 2, w = a->w - lrpad / 2;
|
||||
#elif BAR_TITLE_RIGHT_PAD_PATCH
|
||||
int x = a->x, w = a->w - lrpad / 2;
|
||||
#else
|
||||
int x = a->x, w = a->w;
|
||||
#endif // BAR_TITLE_LEFT_PAD_PATCH | BAR_TITLE_RIGHT_PAD_PATCH
|
||||
|
||||
for (c = m->clients; c; c = c->next) {
|
||||
if (ISVISIBLE(c))
|
||||
n++;
|
||||
}
|
||||
|
||||
if (n > 0) {
|
||||
tabw = TEXTW(m->sel->name);
|
||||
#if BAR_WINICON_PATCH
|
||||
if (m->sel->icon)
|
||||
tabw += m->sel->icw + ICONSPACING;
|
||||
#endif // BAR_WINICON_PATCH
|
||||
mw = (tabw >= w || n == 1) ? 0 : (w - tabw) / (n - 1);
|
||||
|
||||
i = 0;
|
||||
|
||||
for (c = m->clients; c; c = c->next) {
|
||||
if (!ISVISIBLE(c) || c == m->sel)
|
||||
continue;
|
||||
tabw = TEXTW(c->name);
|
||||
#if BAR_WINICON_PATCH
|
||||
if (c->icon)
|
||||
tabw += c->icw + ICONSPACING;
|
||||
#endif // BAR_WINICON_PATCH
|
||||
if (tabw < mw)
|
||||
ew += (mw - tabw);
|
||||
else
|
||||
i++;
|
||||
}
|
||||
|
||||
if (i > 0)
|
||||
mw += ew / i;
|
||||
|
||||
for (c = m->clients; c; c = c->next) {
|
||||
if (!ISVISIBLE(c))
|
||||
continue;
|
||||
tabw = MIN(m->sel == c ? w : mw, TEXTW(c->name));
|
||||
#if BAR_WINICON_PATCH
|
||||
ipad = c->icon ? c->icw + ICONSPACING : 0;
|
||||
tabw += ipad;
|
||||
#endif // BAR_WINICON_PATCH
|
||||
tx = x;
|
||||
tw = tabw;
|
||||
drw_setscheme(drw, scheme[m->sel == c ? SchemeTitleSel : SchemeTitleNorm]);
|
||||
|
||||
XSetForeground(drw->dpy, drw->gc, drw->scheme[ColBg].pixel);
|
||||
XFillRectangle(drw->dpy, drw->drawable, drw->gc, tx, a->y, tw, a->h);
|
||||
|
||||
if (tabw <= 0) /* trap special handling of 0 in drw_text */
|
||||
continue;
|
||||
|
||||
tx += lrpad / 2;
|
||||
tw -= lrpad;
|
||||
|
||||
#if BAR_WINICON_PATCH
|
||||
if (ipad) {
|
||||
drw_pic(drw, tx, a->y + (a->h - c->ich) / 2, c->icw, c->ich, c->icon);
|
||||
tx += ipad;
|
||||
tw -= ipad;
|
||||
}
|
||||
#endif // BAR_WINICON_PATCH
|
||||
|
||||
drw_text(drw, tx, a->y, tw, a->h, 0, c->name, 0, False);
|
||||
drawstateindicator(c->mon, c, 1, x, a->y, tabw, a->h, 0, 0, c->isfixed);
|
||||
x += tabw;
|
||||
w -= tabw;
|
||||
}
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
int
|
||||
click_fancybar(Bar *bar, Arg *arg, BarArg *a)
|
||||
{
|
||||
return ClkWinTitle;
|
||||
}
|
||||
|
||||
4
dwm/patch/bar_fancybar.h
Normal file
4
dwm/patch/bar_fancybar.h
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
static int width_fancybar(Bar *bar, BarArg *a);
|
||||
static int draw_fancybar(Bar *bar, BarArg *a);
|
||||
static int click_fancybar(Bar *bar, Arg *arg, BarArg *a);
|
||||
|
||||
482
dwm/patch/bar_flexwintitle.c
Normal file
482
dwm/patch/bar_flexwintitle.c
Normal file
|
|
@ -0,0 +1,482 @@
|
|||
/* Flexwintitle properties, you can override these in your config.h if you want. */
|
||||
#ifndef FLEXWINTITLE_BORDERS
|
||||
#define FLEXWINTITLE_BORDERS 1 // 0 = off, 1 = on
|
||||
#endif
|
||||
#ifndef FLEXWINTITLE_SHOWFLOATING
|
||||
#define FLEXWINTITLE_SHOWFLOATING 0 // whether to show titles for floating windows, hidden clients are always shown
|
||||
#endif
|
||||
#ifndef FLEXWINTITLE_MASTERWEIGHT
|
||||
#define FLEXWINTITLE_MASTERWEIGHT 9 // master weight compared to stack, hidden and floating window titles
|
||||
#endif
|
||||
#ifndef FLEXWINTITLE_STACKWEIGHT
|
||||
#define FLEXWINTITLE_STACKWEIGHT 3 // stack weight compared to master, hidden and floating window titles
|
||||
#endif
|
||||
#ifndef FLEXWINTITLE_HIDDENWEIGHT
|
||||
#define FLEXWINTITLE_HIDDENWEIGHT 1 // hidden window title weight
|
||||
#endif
|
||||
#ifndef FLEXWINTITLE_FLOATWEIGHT
|
||||
#define FLEXWINTITLE_FLOATWEIGHT 1 // floating window title weight, set to 0 to not show floating windows
|
||||
#endif
|
||||
|
||||
#define SCHEMEFOR(c) getschemefor(m, c, groupactive == c)
|
||||
|
||||
enum { GRP_NOSELECTION, GRP_MASTER, GRP_STACK1, GRP_STACK2, GRP_FLOAT, GRP_HIDDEN };
|
||||
|
||||
int
|
||||
width_flexwintitle(Bar *bar, BarArg *a)
|
||||
{
|
||||
return a->w;
|
||||
}
|
||||
|
||||
int
|
||||
draw_flexwintitle(Bar *bar, BarArg *a)
|
||||
{
|
||||
drw_rect(drw, a->x, a->y, a->w, a->h, 1, 1);
|
||||
return flextitlecalculate(bar->mon, a->x, a->w, -1, flextitledraw, NULL, a);
|
||||
}
|
||||
|
||||
int
|
||||
click_flexwintitle(Bar *bar, Arg *arg, BarArg *a)
|
||||
{
|
||||
flextitlecalculate(bar->mon, 0, a->w, a->x, flextitleclick, arg, a);
|
||||
return ClkWinTitle;
|
||||
}
|
||||
|
||||
Client *
|
||||
flextitledrawarea(Monitor *m, Client *c, int x, int r, int w, int max_clients, int scheme, int draw_tiled, int draw_hidden, int draw_floating,
|
||||
int passx, void(*tabfn)(Monitor *, Client *, int, int, int, int, Arg *arg, BarArg *barg), Arg *arg, BarArg *barg)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; c && i < max_clients; c = c->next) {
|
||||
if (
|
||||
ISVISIBLE(c) &&
|
||||
(
|
||||
(draw_tiled && !c->isfloating && !HIDDEN(c)) ||
|
||||
(draw_floating && c->isfloating && !HIDDEN(c)) ||
|
||||
(draw_hidden && HIDDEN(c))
|
||||
)
|
||||
) {
|
||||
tabfn(m, c, passx, x, w + (i < r ? 1 : 0), scheme, arg, barg);
|
||||
x += w + (i < r ? 1 : 0);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
||||
int
|
||||
getschemefor(Monitor *m, int group, int activegroup)
|
||||
{
|
||||
switch (group) {
|
||||
case GRP_NOSELECTION:
|
||||
case GRP_MASTER:
|
||||
case GRP_STACK1:
|
||||
case GRP_STACK2:
|
||||
#if BSTACK_LAYOUT
|
||||
if (m->lt[m->sellt]->arrange == &bstack)
|
||||
return (activegroup ? SchemeFlexActLTR : SchemeFlexInaLTR);
|
||||
#endif // BSTACK_LAYOUT
|
||||
#if BSTACKHORIZ_LAYOUT
|
||||
if (m->lt[m->sellt]->arrange == &bstackhoriz) {
|
||||
if (group == GRP_MASTER)
|
||||
return (activegroup ? SchemeFlexActLTR : SchemeFlexInaLTR);
|
||||
else
|
||||
return (activegroup ? SchemeFlexActTTB : SchemeFlexInaTTB);
|
||||
}
|
||||
#endif // BSTACKHORIZ_LAYOUT
|
||||
#if CENTEREDMASTER_LAYOUT
|
||||
if (m->lt[m->sellt]->arrange == ¢eredmaster)
|
||||
return (activegroup ? SchemeFlexActTTB : SchemeFlexInaTTB);
|
||||
#endif // CENTEREDMASTER_LAYOUT
|
||||
#if CENTEREDFLOATINGMASTER_LAYOUT
|
||||
if (m->lt[m->sellt]->arrange == ¢eredfloatingmaster)
|
||||
return (activegroup ? SchemeFlexActLTR : SchemeFlexInaLTR);
|
||||
#endif // CENTEREDFLOATINGMASTER_LAYOUT
|
||||
#if COLUMNS_LAYOUT
|
||||
if (m->lt[m->sellt]->arrange == &col) {
|
||||
if (group == GRP_MASTER)
|
||||
return (activegroup ? SchemeFlexActLTR : SchemeFlexInaLTR);
|
||||
else
|
||||
return (activegroup ? SchemeFlexActTTB : SchemeFlexInaTTB);
|
||||
}
|
||||
#endif // COLUMNS_LAYOUT
|
||||
#if DECK_LAYOUT
|
||||
if (m->lt[m->sellt]->arrange == &deck) {
|
||||
if (group == GRP_MASTER)
|
||||
return (activegroup ? SchemeFlexActTTB : SchemeFlexInaTTB);
|
||||
else
|
||||
return (activegroup ? SchemeFlexActMONO : SchemeFlexInaMONO);
|
||||
}
|
||||
#endif // DECK_LAYOUT
|
||||
#if FIBONACCI_DWINDLE_LAYOUT
|
||||
if (m->lt[m->sellt]->arrange == &dwindle)
|
||||
return (activegroup ? SchemeFlexActDWDL : SchemeFlexInaDWDL);
|
||||
#endif // FIBONACCI_DWINDLE_LAYOUT
|
||||
#if FIBONACCI_SPIRAL_LAYOUT
|
||||
if (m->lt[m->sellt]->arrange == &spiral)
|
||||
return (activegroup ? SchemeFlexActSPRL : SchemeFlexInaSPRL);
|
||||
#endif // FIBONACCI_SPIRAL_LAYOUT
|
||||
#if FLEXTILE_DELUXE_LAYOUT
|
||||
if (m->lt[m->sellt]->arrange == &flextile)
|
||||
return (activegroup ? SchemeFlexActTTB + m->ltaxis[group] : SchemeFlexInaTTB + m->ltaxis[group]);
|
||||
#endif // FLEXTILE_DELUXE_LAYOUT
|
||||
#if GAPPLESSGRID_LAYOUT
|
||||
if (m->lt[m->sellt]->arrange == &gaplessgrid)
|
||||
return (activegroup ? SchemeFlexActGRID : SchemeFlexInaGRID);
|
||||
#endif // GAPPLESSGRID_LAYOUT
|
||||
#if GRIDMODE_LAYOUT
|
||||
if (m->lt[m->sellt]->arrange == &grid)
|
||||
return (activegroup ? SchemeFlexActGRDM : SchemeFlexInaGRDM);
|
||||
#endif // GRIDMODE_LAYOUT
|
||||
#if HORIZGRID_LAYOUT
|
||||
if (m->lt[m->sellt]->arrange == &horizgrid)
|
||||
return (activegroup ? SchemeFlexActHGRD : SchemeFlexInaHGRD);
|
||||
#endif // HORIZGRID_LAYOUT
|
||||
#if NROWGRID_LAYOUT
|
||||
if (m->lt[m->sellt]->arrange == &nrowgrid)
|
||||
return (activegroup ? SchemeFlexActGRD1 : SchemeFlexInaGRD1);
|
||||
#endif // NROWGRID_LAYOUT
|
||||
#if TILE_LAYOUT
|
||||
if (m->lt[m->sellt]->arrange == &tile)
|
||||
return (activegroup ? SchemeFlexActTTB : SchemeFlexInaTTB);
|
||||
#endif // TILE_LAYOUT
|
||||
#if MONOCLE_LAYOUT
|
||||
if (m->lt[m->sellt]->arrange == &monocle)
|
||||
return (activegroup ? SchemeFlexActMONO : SchemeFlexInaMONO);
|
||||
#endif // MONOCLE_LAYOUT
|
||||
return SchemeTitleNorm;
|
||||
case GRP_HIDDEN:
|
||||
return SchemeHidNorm;
|
||||
case GRP_FLOAT:
|
||||
return (activegroup ? SchemeFlexActFloat : SchemeFlexInaFloat);
|
||||
}
|
||||
return SchemeTitleNorm;
|
||||
}
|
||||
|
||||
int
|
||||
getselschemefor(int scheme)
|
||||
{
|
||||
if (scheme == SchemeFlexActFloat || scheme == SchemeFlexInaFloat)
|
||||
return SchemeFlexSelFloat;
|
||||
if (scheme >= SchemeFlexInaTTB)
|
||||
return scheme + SchemeFlexInaTTB - SchemeFlexActTTB;
|
||||
if (scheme >= SchemeFlexActTTB)
|
||||
return scheme + SchemeFlexSelTTB - SchemeFlexActTTB;
|
||||
return SchemeTitleSel;
|
||||
}
|
||||
|
||||
void
|
||||
flextitledraw(Monitor *m, Client *c, int unused, int x, int w, int tabscheme, Arg *arg, BarArg *a)
|
||||
{
|
||||
if (!c)
|
||||
return;
|
||||
int i, nclienttags = 0, nviewtags = 0;
|
||||
int tpad = lrpad / 2;
|
||||
#if BAR_WINICON_PATCH
|
||||
int ipad = c->icon ? c->icw + ICONSPACING : 0;
|
||||
#endif // BAR_WINICON_PATCH
|
||||
#if BAR_CENTEREDWINDOWNAME_PATCH
|
||||
int cpad = 0;
|
||||
#endif // BAR_CENTEREDWINDOWNAME_PATCH
|
||||
int tx = x;
|
||||
int tw = w;
|
||||
|
||||
int clientscheme = (
|
||||
#if RENAMED_SCRATCHPADS_PATCH
|
||||
c->scratchkey != 0 && c == selmon->sel
|
||||
? SchemeScratchSel
|
||||
: c->scratchkey != 0
|
||||
? SchemeScratchNorm
|
||||
:
|
||||
#endif // RENAMED_SCRATCHPADS_PATCH
|
||||
c == selmon->sel && HIDDEN(c)
|
||||
? SchemeHidSel
|
||||
: HIDDEN(c)
|
||||
? SchemeHidNorm
|
||||
: c == selmon->sel
|
||||
? getselschemefor(tabscheme)
|
||||
: c->isurgent
|
||||
? SchemeUrg
|
||||
: tabscheme
|
||||
);
|
||||
|
||||
drw_setscheme(drw, scheme[clientscheme]);
|
||||
XSetWindowBorder(dpy, c->win, scheme[clientscheme][ColBorder].pixel);
|
||||
|
||||
if (w <= TEXTW("A") - lrpad + tpad) // reduce text padding if wintitle is too small
|
||||
tpad = (w - TEXTW("A") + lrpad < 0 ? 0 : (w - TEXTW("A") + lrpad) / 2);
|
||||
#if BAR_WINICON_PATCH && BAR_CENTEREDWINDOWNAME_PATCH
|
||||
else if (TEXTW(c->name) + ipad < w)
|
||||
cpad = (w - TEXTW(c->name) - ipad) / 2;
|
||||
#elif BAR_CENTEREDWINDOWNAME_PATCH
|
||||
else if (TEXTW(c->name) < w)
|
||||
cpad = (w - TEXTW(c->name)) / 2;
|
||||
#endif // BAR_CENTEREDWINDOWNAME_PATCH
|
||||
|
||||
XSetForeground(drw->dpy, drw->gc, drw->scheme[ColBg].pixel);
|
||||
XFillRectangle(drw->dpy, drw->drawable, drw->gc, x, a->y, w, a->h);
|
||||
|
||||
#if BAR_CENTEREDWINDOWNAME_PATCH
|
||||
/* Apply center padding, if any */
|
||||
tx += cpad;
|
||||
tw -= cpad;
|
||||
#endif // BAR_CENTEREDWINDOWNAME_PATCH
|
||||
|
||||
tx += tpad;
|
||||
tw -= lrpad;
|
||||
|
||||
#if BAR_WINICON_PATCH
|
||||
if (ipad) {
|
||||
drw_pic(drw, tx, a->y + (a->h - c->ich) / 2, c->icw, c->ich, c->icon);
|
||||
tx += ipad;
|
||||
tw -= ipad;
|
||||
}
|
||||
#endif // BAR_WINICON_PATCH
|
||||
|
||||
drw_text(drw, tx, a->y, tw, a->h, 0, c->name, 0, False);
|
||||
drawstateindicator(m, c, 1, x + 2, a->y, w, a->h, 0, 0, 0);
|
||||
|
||||
if (FLEXWINTITLE_BORDERS) {
|
||||
XSetForeground(drw->dpy, drw->gc, scheme[SchemeSel][ColBorder].pixel);
|
||||
XFillRectangle(drw->dpy, drw->drawable, drw->gc, x, a->y, 1, a->h);
|
||||
XFillRectangle(drw->dpy, drw->drawable, drw->gc, x + w - (x + w >= a->w ? 1 : 0), a->y, 1, a->h);
|
||||
}
|
||||
|
||||
/* Optional tags icons */
|
||||
for (i = 0; i < NUMTAGS; i++) {
|
||||
if ((m->tagset[m->seltags] >> i) & 1)
|
||||
nviewtags++;
|
||||
if ((c->tags >> i) & 1)
|
||||
nclienttags++;
|
||||
}
|
||||
|
||||
if (TAGSINDICATOR == 2 || nclienttags > 1 || nviewtags > 1)
|
||||
drawindicator(m, c, 1, x, a->y, w, a->h, 0, 0, 0, INDICATOR_RIGHT_TAGS);
|
||||
}
|
||||
|
||||
#ifndef HIDDEN
|
||||
#define HIDDEN(C) 0
|
||||
#endif
|
||||
|
||||
void
|
||||
flextitleclick(Monitor *m, Client *c, int passx, int x, int w, int unused, Arg *arg, BarArg *barg)
|
||||
{
|
||||
if (passx >= x && passx <= x + w)
|
||||
arg->v = c;
|
||||
}
|
||||
|
||||
int
|
||||
flextitlecalculate(
|
||||
Monitor *m, int offx, int tabw, int passx,
|
||||
void(*tabfn)(Monitor *, Client *, int, int, int, int, Arg *arg, BarArg *barg),
|
||||
Arg *arg, BarArg *barg
|
||||
) {
|
||||
Client *c;
|
||||
int n, center = 0, mirror = 0, fixed = 0; // layout configuration
|
||||
int clientsnmaster = 0, clientsnstack = 0, clientsnfloating = 0, clientsnhidden = 0;
|
||||
int i, w, r, num = 0, den, fulllayout = 0;
|
||||
int clientsnstack2 = 0;
|
||||
int groupactive = 0;
|
||||
int selidx = 0;
|
||||
int dualstack = 0;
|
||||
int rw, rr;
|
||||
|
||||
int mas_x = offx, st1_x = offx, st2_x = offx, hid_x = offx, flt_x = offx;
|
||||
int mas_w, st1_w, st2_w, hid_w;
|
||||
|
||||
for (i = 0, c = m->clients; c; c = c->next) {
|
||||
if (!ISVISIBLE(c))
|
||||
continue;
|
||||
if (HIDDEN(c)) {
|
||||
if (FLEXWINTITLE_HIDDENWEIGHT)
|
||||
clientsnhidden++;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (c->isfloating) {
|
||||
if (FLEXWINTITLE_FLOATWEIGHT)
|
||||
clientsnfloating++;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (m->sel == c)
|
||||
selidx = i;
|
||||
|
||||
if (i < m->nmaster)
|
||||
clientsnmaster++;
|
||||
#if FLEXTILE_DELUXE_LAYOUT
|
||||
else if (m->nstack) {
|
||||
if (clientsnstack < m->nstack)
|
||||
clientsnstack++;
|
||||
else
|
||||
clientsnstack2++;
|
||||
}
|
||||
#endif // FLEXTILE_DELUXE_LAYOUT
|
||||
else if ((i - m->nmaster) % 2)
|
||||
clientsnstack2++;
|
||||
else
|
||||
clientsnstack++;
|
||||
i++;
|
||||
}
|
||||
|
||||
if (!m->sel)
|
||||
groupactive = GRP_NOSELECTION;
|
||||
else if (HIDDEN(m->sel))
|
||||
groupactive = GRP_HIDDEN;
|
||||
else if (m->sel->isfloating)
|
||||
groupactive = GRP_FLOAT;
|
||||
else if (selidx < clientsnmaster)
|
||||
groupactive = GRP_MASTER;
|
||||
else if (selidx < clientsnmaster + clientsnstack)
|
||||
groupactive = GRP_STACK1;
|
||||
else if (selidx < clientsnmaster + clientsnstack + clientsnstack2)
|
||||
groupactive = GRP_STACK2;
|
||||
|
||||
n = clientsnmaster + clientsnstack + clientsnstack2 + clientsnfloating + clientsnhidden;
|
||||
if (n == 0)
|
||||
return 0;
|
||||
#if FLEXTILE_DELUXE_LAYOUT
|
||||
else if (m->lt[m->sellt]->arrange == &flextile) {
|
||||
int layout = m->ltaxis[LAYOUT];
|
||||
if (layout < 0) {
|
||||
mirror = 1;
|
||||
layout *= -1;
|
||||
}
|
||||
if (layout > FLOATING_MASTER) {
|
||||
layout -= FLOATING_MASTER;
|
||||
fixed = 1;
|
||||
}
|
||||
|
||||
if (layout == SPLIT_HORIZONTAL_DUAL_STACK || layout == SPLIT_HORIZONTAL_DUAL_STACK_FIXED)
|
||||
dualstack = 1;
|
||||
else if (layout == SPLIT_CENTERED_VERTICAL && (fixed || n - m->nmaster > 1))
|
||||
center = 1;
|
||||
else if (layout == FLOATING_MASTER)
|
||||
center = 1;
|
||||
else if (layout == SPLIT_CENTERED_HORIZONTAL) {
|
||||
if (fixed || n - m->nmaster > 1)
|
||||
center = 1;
|
||||
}
|
||||
}
|
||||
#endif // FLEXTILE_DELUXE_LAYOUT
|
||||
#if CENTEREDMASTER_LAYOUT
|
||||
else if (m->lt[m->sellt]->arrange == ¢eredmaster && (fixed || n - m->nmaster > 1))
|
||||
center = 1;
|
||||
#endif // CENTEREDMASTER_LAYOUT
|
||||
#if CENTEREDFLOATINGMASTER_LAYOUT
|
||||
else if (m->lt[m->sellt]->arrange == ¢eredfloatingmaster)
|
||||
center = 1;
|
||||
#endif // CENTEREDFLOATINGMASTER_LAYOUT
|
||||
|
||||
/* Certain layouts have no master / stack areas */
|
||||
if (!m->lt[m->sellt]->arrange // floating layout
|
||||
|| (!n || (!fixed && m->nmaster && n <= m->nmaster)) // no master
|
||||
#if MONOCLE_LAYOUT
|
||||
|| m->lt[m->sellt]->arrange == &monocle
|
||||
#endif // MONOCLE_LAYOUT
|
||||
#if GRIDMODE_LAYOUT
|
||||
|| m->lt[m->sellt]->arrange == &grid
|
||||
#endif // GRIDMODE_LAYOUT
|
||||
#if HORIZGRID_LAYOUT
|
||||
|| m->lt[m->sellt]->arrange == &horizgrid
|
||||
#endif // HORIZGRID_LAYOUT
|
||||
#if GAPPLESSGRID_LAYOUT
|
||||
|| m->lt[m->sellt]->arrange == &gaplessgrid
|
||||
#endif // GAPPLESSGRID_LAYOUT
|
||||
#if NROWGRID_LAYOUT
|
||||
|| m->lt[m->sellt]->arrange == &nrowgrid
|
||||
#endif // NROWGRID_LAYOUT
|
||||
#if FLEXTILE_DELUXE_LAYOUT
|
||||
|| (m->lt[m->sellt]->arrange == &flextile && m->ltaxis[LAYOUT] == NO_SPLIT)
|
||||
#endif // FLEXTILE_DELUXE_LAYOUT
|
||||
)
|
||||
fulllayout = 1;
|
||||
|
||||
num = tabw;
|
||||
c = m->clients;
|
||||
|
||||
/* floating mode */
|
||||
if ((fulllayout && FLEXWINTITLE_FLOATWEIGHT > 0) || clientsnmaster + clientsnstack == 0 || !m->lt[m->sellt]->arrange) {
|
||||
den = clientsnmaster + clientsnstack + clientsnstack2 + clientsnfloating + clientsnhidden;
|
||||
w = num / den;
|
||||
r = num % den; // rest
|
||||
c = flextitledrawarea(m, c, mas_x, r, w, den, !m->lt[m->sellt]->arrange ? SchemeFlexActFloat : SCHEMEFOR(GRP_MASTER), 1, FLEXWINTITLE_HIDDENWEIGHT, FLEXWINTITLE_FLOATWEIGHT, passx, tabfn, arg, barg); // floating
|
||||
/* no master and stack mode, e.g. monocole, grid layouts, fibonacci */
|
||||
} else if (fulllayout) {
|
||||
den = clientsnmaster + clientsnstack + clientsnstack2 + clientsnhidden;
|
||||
w = num / den;
|
||||
r = num % den; // rest
|
||||
c = flextitledrawarea(m, c, mas_x, r, w, den, SCHEMEFOR(GRP_MASTER), 1, FLEXWINTITLE_HIDDENWEIGHT, 0, passx, tabfn, arg, barg); // full
|
||||
/* tiled mode */
|
||||
} else {
|
||||
den = clientsnmaster * FLEXWINTITLE_MASTERWEIGHT + (clientsnstack + clientsnstack2) * FLEXWINTITLE_STACKWEIGHT + clientsnfloating * FLEXWINTITLE_FLOATWEIGHT + clientsnhidden * FLEXWINTITLE_HIDDENWEIGHT;
|
||||
w = num / den; // weight width per client
|
||||
r = num % den; // weight rest width
|
||||
rw = r / n; // rest incr per client
|
||||
rr = r % n; // rest rest
|
||||
#if FLEXTILE_DELUXE_LAYOUT
|
||||
if ((!center && !dualstack) || (center && n <= m->nmaster + (m->nstack ? m->nstack : 1)))
|
||||
#else
|
||||
if ((!center && !dualstack) || (center && n <= m->nmaster + 1))
|
||||
#endif // FLEXTILE_DELUXE_LAYOUT
|
||||
{
|
||||
clientsnstack += clientsnstack2;
|
||||
clientsnstack2 = 0;
|
||||
if (groupactive == GRP_STACK2)
|
||||
groupactive = GRP_STACK1;
|
||||
}
|
||||
|
||||
mas_w = clientsnmaster * rw + w * clientsnmaster * FLEXWINTITLE_MASTERWEIGHT + (rr > 0 ? MIN(rr, clientsnmaster) : 0);
|
||||
rr -= clientsnmaster;
|
||||
st1_w = clientsnstack * (rw + w * FLEXWINTITLE_STACKWEIGHT) + (rr > 0 ? MIN(rr, clientsnstack) : 0);
|
||||
rr -= clientsnstack;
|
||||
st2_w = clientsnstack2 * (rw + w * FLEXWINTITLE_STACKWEIGHT) + (rr > 0 ? MIN(rr, clientsnstack2) : 0);
|
||||
rr -= clientsnstack2;
|
||||
hid_w = clientsnhidden * (rw + w * FLEXWINTITLE_HIDDENWEIGHT) + (rr > 0 ? MIN(rr, clientsnhidden) : 0);
|
||||
rr -= clientsnhidden;
|
||||
rr = r % n;
|
||||
|
||||
if (mirror) {
|
||||
if (center && clientsnstack2) {
|
||||
mas_x = st1_x + st1_w;
|
||||
st2_x = mas_x + mas_w;
|
||||
hid_x = st2_x + st2_w;
|
||||
} else {
|
||||
if (clientsnstack2) {
|
||||
st2_x = st1_x + st1_w;
|
||||
mas_x = st2_x + st2_w;
|
||||
} else
|
||||
mas_x = st1_x + st1_w;
|
||||
hid_x = mas_x + mas_w;
|
||||
}
|
||||
} else {
|
||||
if (center && clientsnstack2) {
|
||||
mas_x = st2_x + st2_w;
|
||||
st1_x = mas_x + mas_w;
|
||||
hid_x = st1_x + st1_w;
|
||||
} else {
|
||||
st1_x = mas_x + mas_w;
|
||||
if (clientsnstack2) {
|
||||
st2_x = st1_x + st1_w;
|
||||
hid_x = st2_x + st2_w;
|
||||
} else
|
||||
hid_x = st1_x + st1_w;
|
||||
}
|
||||
}
|
||||
|
||||
flt_x = hid_x + hid_w;
|
||||
c = flextitledrawarea(m, c, mas_x, rr, w * FLEXWINTITLE_MASTERWEIGHT + rw, clientsnmaster, SCHEMEFOR(GRP_MASTER), 1, 0, 0, passx, tabfn, arg, barg); // master
|
||||
rr -= clientsnmaster;
|
||||
c = flextitledrawarea(m, c, st1_x, rr, w * FLEXWINTITLE_STACKWEIGHT + rw, clientsnstack, SCHEMEFOR(GRP_STACK1), 1, 0, 0, passx, tabfn, arg, barg); // stack1
|
||||
rr -= clientsnstack;
|
||||
if (clientsnstack2) {
|
||||
c = flextitledrawarea(m, c, st2_x, rr, w * FLEXWINTITLE_STACKWEIGHT + rw, clientsnstack2, SCHEMEFOR(GRP_STACK2), 1, 0, 0, passx, tabfn, arg, barg); // stack2
|
||||
rr -= clientsnstack2;
|
||||
}
|
||||
c = flextitledrawarea(m, m->clients, hid_x, rr, w * FLEXWINTITLE_HIDDENWEIGHT + rw, clientsnhidden, SCHEMEFOR(GRP_HIDDEN), 0, 1, 0, passx, tabfn, arg, barg); // hidden
|
||||
rr -= clientsnhidden;
|
||||
c = flextitledrawarea(m, m->clients, flt_x, rr, w * FLEXWINTITLE_FLOATWEIGHT + rw, clientsnfloating, SCHEMEFOR(GRP_FLOAT), 0, 0, 1, passx, tabfn, arg, barg); // floating
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
11
dwm/patch/bar_flexwintitle.h
Normal file
11
dwm/patch/bar_flexwintitle.h
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
static int width_flexwintitle(Bar *bar, BarArg *a);
|
||||
static int draw_flexwintitle(Bar *bar, BarArg *a);
|
||||
static int click_flexwintitle(Bar *bar, Arg *arg, BarArg *a);
|
||||
|
||||
static void flextitledraw(Monitor *m, Client *c, int unused, int x, int w, int groupactive, Arg *arg, BarArg *barg);
|
||||
static void flextitleclick(Monitor *m, Client *c, int passx, int x, int w, int unused, Arg *arg, BarArg *barg);
|
||||
static int flextitlecalculate(Monitor *m, int offx, int w, int passx, void(*tabfn)(Monitor *, Client *, int, int, int, int, Arg *arg, BarArg *barg), Arg *arg, BarArg *barg);
|
||||
static int getschemefor(Monitor *m, int group, int activegroup);
|
||||
static int getselschemefor(int scheme);
|
||||
static Client *flextitledrawarea(Monitor *m, Client *c, int x, int r, int w, int max_clients, int tabscheme, int draw_tiled, int draw_hidden, int draw_floating, int passx, void(*tabfn)(Monitor *, Client *, int, int, int, int, Arg *arg, BarArg *barg), Arg *arg, BarArg *barg);
|
||||
|
||||
43
dwm/patch/bar_holdbar.c
Normal file
43
dwm/patch/bar_holdbar.c
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
void
|
||||
holdbar(const Arg *arg)
|
||||
{
|
||||
if (selmon->showbar)
|
||||
return;
|
||||
Bar *bar;
|
||||
selmon->showbar = 2;
|
||||
updatebarpos(selmon);
|
||||
for (bar = selmon->bar; bar; bar = bar->next)
|
||||
XMoveResizeWindow(dpy, bar->win, bar->bx, bar->by, bar->bw, bar->bh);
|
||||
drawbar(selmon);
|
||||
}
|
||||
|
||||
void
|
||||
keyrelease(XEvent *e)
|
||||
{
|
||||
Bar *bar;
|
||||
if (XEventsQueued(dpy, QueuedAfterReading)) {
|
||||
XEvent ne;
|
||||
XPeekEvent(dpy, &ne);
|
||||
|
||||
if (ne.type == KeyPress && ne.xkey.time == e->xkey.time &&
|
||||
ne.xkey.keycode == e->xkey.keycode) {
|
||||
XNextEvent(dpy, &ne);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (e->xkey.keycode == XKeysymToKeycode(dpy, HOLDKEY) && selmon->showbar == 2) {
|
||||
selmon->showbar = 0;
|
||||
updatebarpos(selmon);
|
||||
for (bar = selmon->bar; bar; bar = bar->next)
|
||||
XMoveResizeWindow(dpy, bar->win, bar->bx, bar->by, bar->bw, bar->bh);
|
||||
#if BAR_SYSTRAY_PATCH
|
||||
if (!selmon->showbar && systray)
|
||||
XMoveWindow(dpy, systray->win, -32000, -32000);
|
||||
#endif // BAR_SYSTRAY_PATCH
|
||||
arrange(selmon);
|
||||
}
|
||||
#if COMBO_PATCH
|
||||
combo = 0;
|
||||
#endif // COMBO_PATCH
|
||||
}
|
||||
|
||||
3
dwm/patch/bar_holdbar.h
Normal file
3
dwm/patch/bar_holdbar.h
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
static void keyrelease(XEvent *e);
|
||||
static void holdbar(const Arg *arg);
|
||||
|
||||
|
|
@ -96,9 +96,20 @@ drawindicator(Monitor *m, Client *c, unsigned int occ, int x, int y, int w, int
|
|||
void
|
||||
drawstateindicator(Monitor *m, Client *c, unsigned int occ, int x, int y, int w, int h, unsigned int tag, int filled, int invert)
|
||||
{
|
||||
#if FAKEFULLSCREEN_CLIENT_PATCH && !FAKEFULLSCREEN_PATCH
|
||||
if (c->fakefullscreen && c->isfloating)
|
||||
drawindicator(m, c, occ, x, y, w, h, tag, filled, invert, floatfakefsindicatortype);
|
||||
else if (c->fakefullscreen)
|
||||
drawindicator(m, c, occ, x, y, w, h, tag, filled, invert, fakefsindicatortype);
|
||||
else
|
||||
#endif // FAKEFULLSCREEN_CLIENT_PATCH
|
||||
if (c->isfloating)
|
||||
drawindicator(m, c, occ, x, y, w, h, tag, filled, invert, floatindicatortype);
|
||||
else
|
||||
drawindicator(m, c, occ, x, y, w, h, tag, filled, invert, tiledindicatortype);
|
||||
#if ALWAYSONTOP_PATCH
|
||||
if (c->isfloating && c->alwaysontop)
|
||||
drawindicator(m, c, occ, x, y, w, h, tag, filled, invert, aotindicatortype);
|
||||
#endif // ALWAYSONTOP_PATCH
|
||||
}
|
||||
|
||||
|
|
|
|||
81
dwm/patch/bar_launcher.c
Normal file
81
dwm/patch/bar_launcher.c
Normal file
|
|
@ -0,0 +1,81 @@
|
|||
#if BAR_STATUS2D_PATCH
|
||||
int
|
||||
width_launcher(Bar *bar, BarArg *a)
|
||||
{
|
||||
int i, x = 0;
|
||||
|
||||
for (i = 0; i < LENGTH(launchers); i++) {
|
||||
x += status2dtextlength(launchers[i].name) + lrpad;
|
||||
}
|
||||
return x;
|
||||
}
|
||||
|
||||
int
|
||||
draw_launcher(Bar *bar, BarArg *a)
|
||||
{
|
||||
int i, w = 0;;
|
||||
|
||||
for (i = 0; i < LENGTH(launchers); i++) {
|
||||
w = status2dtextlength(launchers[i].name);
|
||||
drawstatusbar(a, launchers[i].name);
|
||||
a->x += w + lrpad;
|
||||
}
|
||||
|
||||
return a->x ;
|
||||
}
|
||||
|
||||
int
|
||||
click_launcher(Bar *bar, Arg *arg, BarArg *a)
|
||||
{
|
||||
int i, x = 0;
|
||||
|
||||
for (i = 0; i < LENGTH(launchers); i++) {
|
||||
x += status2dtextlength(launchers[i].name) + lrpad;
|
||||
if (a->x < x) {
|
||||
spawn(&launchers[i].command);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
#else
|
||||
int
|
||||
width_launcher(Bar *bar, BarArg *a)
|
||||
{
|
||||
int i, x = 0;
|
||||
|
||||
for (i = 0; i < LENGTH(launchers); i++) {
|
||||
x += TEXTW(launchers[i].name);
|
||||
}
|
||||
return x;
|
||||
}
|
||||
|
||||
int
|
||||
draw_launcher(Bar *bar, BarArg *a)
|
||||
{
|
||||
int i, x = 0, w = 0;;
|
||||
|
||||
for (i = 0; i < LENGTH(launchers); i++) {
|
||||
w = TEXTW(launchers[i].name);
|
||||
drw_text(drw, x, 0, w, bh, lrpad / 2, launchers[i].name, 0, True);
|
||||
x += w;
|
||||
}
|
||||
|
||||
return x;
|
||||
}
|
||||
|
||||
int
|
||||
click_launcher(Bar *bar, Arg *arg, BarArg *a)
|
||||
{
|
||||
int i, x = 0;
|
||||
|
||||
for (i = 0; i < LENGTH(launchers); i++) {
|
||||
x += TEXTW(launchers[i].name);
|
||||
if (a->x < x) {
|
||||
spawn(&launchers[i].command);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
#endif // BAR_STATUS2D_PATCH
|
||||
8
dwm/patch/bar_launcher.h
Normal file
8
dwm/patch/bar_launcher.h
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
typedef struct {
|
||||
char* name;
|
||||
const Arg command;
|
||||
} Launcher;
|
||||
|
||||
static int width_launcher(Bar *bar, BarArg *a);
|
||||
static int draw_launcher(Bar *bar, BarArg *a);
|
||||
static int click_launcher(Bar *bar, Arg *arg, BarArg *a);
|
||||
18
dwm/patch/bar_layoutmenu.c
Normal file
18
dwm/patch/bar_layoutmenu.c
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
void
|
||||
layoutmenu(const Arg *arg) {
|
||||
FILE *p;
|
||||
char c[3], *s;
|
||||
int i;
|
||||
|
||||
if (!(p = popen(layoutmenu_cmd, "r")))
|
||||
return;
|
||||
s = fgets(c, sizeof(c), p);
|
||||
pclose(p);
|
||||
|
||||
if (!s || *s == '\0' || c[0] == '\0')
|
||||
return;
|
||||
|
||||
i = atoi(c);
|
||||
setlayout(&((Arg) { .v = &layouts[i] }));
|
||||
}
|
||||
|
||||
2
dwm/patch/bar_layoutmenu.h
Normal file
2
dwm/patch/bar_layoutmenu.h
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
static void layoutmenu(const Arg *arg);
|
||||
|
||||
|
|
@ -7,6 +7,9 @@ width_ltsymbol(Bar *bar, BarArg *a)
|
|||
int
|
||||
draw_ltsymbol(Bar *bar, BarArg *a)
|
||||
{
|
||||
#if BAR_LTSYMBOL_SCHEME_PATCH
|
||||
drw_setscheme(drw, scheme[SchemeLtSymbol]);
|
||||
#endif // BAR_LTSYMBOL_SCHEME_PATCH
|
||||
return drw_text(drw, a->x, a->y, a->w, a->h, lrpad / 2, bar->mon->ltsymbol, 0, False);
|
||||
}
|
||||
|
||||
|
|
@ -15,4 +18,3 @@ click_ltsymbol(Bar *bar, Arg *arg, BarArg *a)
|
|||
{
|
||||
return ClkLtSymbol;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
static int width_ltsymbol(Bar *bar, BarArg *a);
|
||||
static int draw_ltsymbol(Bar *bar, BarArg *a);
|
||||
static int click_ltsymbol(Bar *bar, Arg *arg, BarArg *a);
|
||||
|
||||
|
|
|
|||
122
dwm/patch/bar_powerline_status.c
Normal file
122
dwm/patch/bar_powerline_status.c
Normal file
|
|
@ -0,0 +1,122 @@
|
|||
static Clr **statusscheme;
|
||||
|
||||
int
|
||||
width_pwrl_status(Bar *bar, BarArg *a)
|
||||
{
|
||||
#if BAR_STATUSCMD_PATCH
|
||||
return widthpowerlinestatus(rawstext);
|
||||
#else
|
||||
return widthpowerlinestatus(stext);
|
||||
#endif // BAR_STATUSCMD_PATCH
|
||||
}
|
||||
|
||||
#if BAR_EXTRASTATUS_PATCH
|
||||
int
|
||||
width_pwrl_status_es(Bar *bar, BarArg *a)
|
||||
{
|
||||
#if BAR_STATUSCMD_PATCH
|
||||
return widthpowerlinestatus(rawestext);
|
||||
#else
|
||||
return widthpowerlinestatus(estext);
|
||||
#endif // BAR_STATUSCMD_PATCH
|
||||
}
|
||||
#endif // BAR_EXTRASTATUS_PATCH
|
||||
|
||||
int
|
||||
draw_pwrl_status(Bar *bar, BarArg *a)
|
||||
{
|
||||
#if BAR_STATUSCMD_PATCH
|
||||
return drawpowerlinestatus(a->x + a->w, rawstext, a);
|
||||
#else
|
||||
return drawpowerlinestatus(a->x + a->w, stext, a);
|
||||
#endif // BAR_STATUSCMD_PATCH
|
||||
}
|
||||
|
||||
#if BAR_EXTRASTATUS_PATCH
|
||||
int
|
||||
draw_pwrl_status_es(Bar *bar, BarArg *a)
|
||||
{
|
||||
#if BAR_STATUSCMD_PATCH
|
||||
return drawpowerlinestatus(a->x + a->w, rawestext, a);
|
||||
#else
|
||||
return drawpowerlinestatus(a->x + a->w, estext, a);
|
||||
#endif // BAR_STATUSCMD_PATCH
|
||||
}
|
||||
#endif // BAR_EXTRASTATUS_PATCH
|
||||
|
||||
int
|
||||
click_pwrl_status(Bar *bar, Arg *arg, BarArg *a)
|
||||
{
|
||||
return ClkStatusText;
|
||||
}
|
||||
|
||||
int
|
||||
widthpowerlinestatus(char *stext)
|
||||
{
|
||||
char status[512];
|
||||
int w = 0, i, n = strlen(stext);
|
||||
int plw = drw->fonts->h / 2 + 1;
|
||||
char *bs, bp = '|';
|
||||
strcpy(status, stext);
|
||||
|
||||
for (i = n, bs = &status[n-1]; i >= 0; i--, bs--) {
|
||||
if (*bs == '<' || *bs == '/' || *bs == '\\' || *bs == '>' || *bs == '|') { /* block start */
|
||||
if (bp != '|')
|
||||
w += plw;
|
||||
w += TEXTW(bs+2);
|
||||
bp = *bs;
|
||||
*bs = 0;
|
||||
}
|
||||
}
|
||||
if (bp != '|')
|
||||
w += plw * 2;
|
||||
|
||||
return w;
|
||||
}
|
||||
|
||||
int
|
||||
drawpowerlinestatus(int xpos, char *stext, BarArg *barg)
|
||||
{
|
||||
char status[512];
|
||||
int i, n = strlen(stext), cn = 0;
|
||||
int x = xpos, w = 0;
|
||||
int plw = drw->fonts->h / 2 + 1;
|
||||
char *bs, bp = '|';
|
||||
Clr *prevscheme = statusscheme[0], *nxtscheme;
|
||||
strcpy(status, stext);
|
||||
|
||||
for (i = n, bs = &status[n-1]; i >= 0; i--, bs--) {
|
||||
if (*bs == '<' || *bs == '/' || *bs == '\\' || *bs == '>' || *bs == '|') { /* block start */
|
||||
cn = ((int) *(bs+1)) - 1;
|
||||
|
||||
if (cn < LENGTH(statuscolors)) {
|
||||
drw_settrans(drw, prevscheme, (nxtscheme = statusscheme[cn]));
|
||||
} else {
|
||||
drw_settrans(drw, prevscheme, (nxtscheme = statusscheme[0]));
|
||||
}
|
||||
|
||||
if (bp != '|') {
|
||||
drw_arrow(drw, x - plw, barg->y, plw, barg->h, bp == '\\' || bp == '>' ? 1 : 0, bp == '<' ? 0 : 1);
|
||||
x -= plw;
|
||||
}
|
||||
|
||||
drw_setscheme(drw, nxtscheme);
|
||||
w = TEXTW(bs+2);
|
||||
drw_text(drw, x - w, barg->y, w, barg->h, lrpad / 2, bs+2, 0, False);
|
||||
x -= w;
|
||||
|
||||
bp = *bs;
|
||||
*bs = 0;
|
||||
prevscheme = nxtscheme;
|
||||
}
|
||||
}
|
||||
if (bp != '|') {
|
||||
drw_settrans(drw, prevscheme, scheme[SchemeNorm]);
|
||||
drw_arrow(drw, x - plw, barg->y, plw, barg->h, bp == '\\' || bp == '>' ? 1 : 0, bp == '<' ? 0 : 1);
|
||||
drw_rect(drw, x - 2 * plw, barg->y, plw, barg->h, 1, 1);
|
||||
x -= plw * 2;
|
||||
}
|
||||
|
||||
return xpos - x;
|
||||
}
|
||||
|
||||
12
dwm/patch/bar_powerline_status.h
Normal file
12
dwm/patch/bar_powerline_status.h
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
static int width_pwrl_status(Bar *bar, BarArg *a);
|
||||
#if BAR_EXTRASTATUS_PATCH
|
||||
static int width_pwrl_status_es(Bar *bar, BarArg *a);
|
||||
#endif // BAR_EXTRASTATUS_PATCH
|
||||
static int draw_pwrl_status(Bar *bar, BarArg *a);
|
||||
#if BAR_EXTRASTATUS_PATCH
|
||||
static int draw_pwrl_status_es(Bar *bar, BarArg *a);
|
||||
#endif // BAR_EXTRASTATUS_PATCH
|
||||
static int click_pwrl_status(Bar *bar, Arg *arg, BarArg *a);
|
||||
static int drawpowerlinestatus(int x, char *stext, BarArg *a);
|
||||
static int widthpowerlinestatus(char *stext);
|
||||
|
||||
166
dwm/patch/bar_powerline_tags.c
Normal file
166
dwm/patch/bar_powerline_tags.c
Normal file
|
|
@ -0,0 +1,166 @@
|
|||
int
|
||||
width_pwrl_tags(Bar *bar, BarArg *a)
|
||||
{
|
||||
int w, i;
|
||||
int plw = drw->fonts->h / 2 + 1;
|
||||
#if BAR_HIDEVACANTTAGS_PATCH
|
||||
Client *c;
|
||||
unsigned int occ = 0;
|
||||
for (c = bar->mon->clients; c; c = c->next)
|
||||
occ |= c->tags == 255 ? 0 : c->tags;
|
||||
#endif // BAR_HIDEVACANTTAGS_PATCH
|
||||
|
||||
for (w = 0, i = 0; i < NUMTAGS; i++) {
|
||||
#if BAR_HIDEVACANTTAGS_PATCH
|
||||
if (!(occ & 1 << i || bar->mon->tagset[bar->mon->seltags] & 1 << i))
|
||||
continue;
|
||||
#endif // BAR_HIDEVACANTTAGS_PATCH
|
||||
w += TEXTW(tagicon(bar->mon, i)) + plw;
|
||||
}
|
||||
return w + lrpad;
|
||||
}
|
||||
|
||||
int
|
||||
draw_pwrl_tags(Bar *bar, BarArg *a)
|
||||
{
|
||||
int x, w;
|
||||
int invert;
|
||||
int plw = drw->fonts->h / 2 + 1;
|
||||
unsigned int i, occ = 0, urg = 0;
|
||||
char *icon;
|
||||
Client *c;
|
||||
Clr *prevscheme, *nxtscheme;
|
||||
|
||||
for (c = bar->mon->clients; c; c = c->next) {
|
||||
#if BAR_HIDEVACANTTAGS_PATCH
|
||||
occ |= c->tags == 255 ? 0 : c->tags;
|
||||
#else
|
||||
occ |= c->tags;
|
||||
#endif // BAR_HIDEVACANTTAGS_PATCH
|
||||
if (c->isurgent)
|
||||
urg |= c->tags;
|
||||
}
|
||||
x = a->x;
|
||||
prevscheme = scheme[SchemeNorm];
|
||||
for (i = 0; i < NUMTAGS; i++) {
|
||||
#if BAR_HIDEVACANTTAGS_PATCH
|
||||
/* do not draw vacant tags */
|
||||
if (!(occ & 1 << i || bar->mon->tagset[bar->mon->seltags] & 1 << i))
|
||||
continue;
|
||||
#endif // BAR_HIDEVACANTTAGS_PATCH
|
||||
|
||||
icon = tagicon(bar->mon, i);
|
||||
invert = 0;
|
||||
w = TEXTW(icon);
|
||||
if (urg & 1 << i) {
|
||||
drw_settrans(drw, prevscheme, (nxtscheme = scheme[bar->mon->tagset[bar->mon->seltags] & 1 << i ? SchemeSel : SchemeUrg]));
|
||||
} else {
|
||||
drw_settrans(drw, prevscheme, (nxtscheme = scheme[bar->mon->tagset[bar->mon->seltags] & 1 << i ? SchemeSel : SchemeNorm]));
|
||||
}
|
||||
#if BAR_POWERLINE_TAGS_SLASH_PATCH
|
||||
drw_arrow(drw, x, a->y, plw, a->h, 1, 1);
|
||||
#else
|
||||
drw_arrow(drw, x, a->y, plw, a->h, 1, 0);
|
||||
#endif // BAR_POWERLINE_TAGS_SLASH_PATCH
|
||||
x += plw;
|
||||
drw_setscheme(drw, nxtscheme);
|
||||
drw_text(drw, x, a->y, w, a->h, lrpad / 2, icon, invert, False);
|
||||
drawindicator(bar->mon, NULL, occ, x, a->y, w, a->h, i, -1, invert, tagindicatortype);
|
||||
x += w;
|
||||
prevscheme = nxtscheme;
|
||||
}
|
||||
nxtscheme = scheme[SchemeNorm];
|
||||
|
||||
drw_settrans(drw, prevscheme, nxtscheme);
|
||||
#if BAR_POWERLINE_TAGS_SLASH_PATCH
|
||||
drw_arrow(drw, x, a->y, plw, a->h, 1, 1);
|
||||
#else
|
||||
drw_arrow(drw, x, a->y, plw, a->h, 1, 0);
|
||||
#endif // BAR_POWERLINE_TAGS_SLASH_PATCH
|
||||
return 1;
|
||||
}
|
||||
|
||||
int
|
||||
click_pwrl_tags(Bar *bar, Arg *arg, BarArg *a)
|
||||
{
|
||||
int i = 0, x = lrpad / 2;
|
||||
int plw = drw->fonts->h / 2 + 1;
|
||||
#if BAR_HIDEVACANTTAGS_PATCH
|
||||
Client *c;
|
||||
unsigned int occ = 0;
|
||||
for (c = bar->mon->clients; c; c = c->next)
|
||||
occ |= c->tags == 255 ? 0 : c->tags;
|
||||
#endif // BAR_HIDEVACANTTAGS_PATCH
|
||||
|
||||
do {
|
||||
#if BAR_HIDEVACANTTAGS_PATCH
|
||||
if (!(occ & 1 << i || bar->mon->tagset[bar->mon->seltags] & 1 << i))
|
||||
continue;
|
||||
#endif // BAR_HIDEVACANTTAGS_PATCH
|
||||
x += TEXTW(tagicon(bar->mon, i)) + plw;
|
||||
} while (a->x >= x && ++i < NUMTAGS);
|
||||
if (i < NUMTAGS) {
|
||||
arg->ui = 1 << i;
|
||||
}
|
||||
#if BAR_TAGPREVIEW_PATCH
|
||||
if (selmon->previewshow != 0) {
|
||||
hidetagpreview(selmon);
|
||||
}
|
||||
#endif // BAR_TAGPREVIEW_PATCH
|
||||
return ClkTagBar;
|
||||
}
|
||||
|
||||
int
|
||||
hover_pwrl_tags(Bar *bar, BarArg *a, XMotionEvent *ev)
|
||||
{
|
||||
#if BAR_TAGPREVIEW_PATCH
|
||||
int i = 0, x = lrpad / 2;
|
||||
int px, py;
|
||||
int plw = drw->fonts->h / 2 + 1;
|
||||
Monitor *m = bar->mon;
|
||||
#if VANITYGAPS_PATCH
|
||||
int ov = gappov;
|
||||
int oh = gappoh;
|
||||
#else
|
||||
int ov = 0;
|
||||
int oh = 0;
|
||||
#endif // VANITYGAPS_PATCH
|
||||
|
||||
#if BAR_HIDEVACANTTAGS_PATCH
|
||||
Client *c;
|
||||
unsigned int occ = 0;
|
||||
for (c = bar->mon->clients; c; c = c->next)
|
||||
occ |= c->tags == 255 ? 0 : c->tags;
|
||||
#endif // BAR_HIDEVACANTTAGS_PATCH
|
||||
|
||||
do {
|
||||
#if BAR_HIDEVACANTTAGS_PATCH
|
||||
if (!(occ & 1 << i || bar->mon->tagset[bar->mon->seltags] & 1 << i))
|
||||
continue;
|
||||
#endif // BAR_HIDEVACANTTAGS_PATCH
|
||||
x += TEXTW(tagicon(bar->mon, i)) + plw;
|
||||
} while (a->x >= x && ++i < NUMTAGS);
|
||||
|
||||
if (i < NUMTAGS) {
|
||||
if ((i + 1) != selmon->previewshow && !(selmon->tagset[selmon->seltags] & 1 << i)) {
|
||||
if (bar->by > m->my + m->mh / 2) // bottom bar
|
||||
py = bar->by - m->mh / scalepreview - oh;
|
||||
else // top bar
|
||||
py = bar->by + bar->bh + oh;
|
||||
px = bar->bx + ev->x - m->mw / scalepreview / 2;
|
||||
if (px + m->mw / scalepreview > m->mx + m->mw)
|
||||
px = m->wx + m->ww - m->mw / scalepreview - ov;
|
||||
else if (px < bar->bx)
|
||||
px = m->wx + ov;
|
||||
selmon->previewshow = i + 1;
|
||||
showtagpreview(i, px, py);
|
||||
} else if (selmon->tagset[selmon->seltags] & 1 << i) {
|
||||
hidetagpreview(selmon);
|
||||
}
|
||||
} else if (selmon->previewshow != 0) {
|
||||
hidetagpreview(selmon);
|
||||
}
|
||||
#endif // BAR_TAGPREVIEW_PATCH
|
||||
|
||||
return 1;
|
||||
}
|
||||
4
dwm/patch/bar_powerline_tags.h
Normal file
4
dwm/patch/bar_powerline_tags.h
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
static int width_pwrl_tags(Bar *bar, BarArg *a);
|
||||
static int draw_pwrl_tags(Bar *bar, BarArg *a);
|
||||
static int click_pwrl_tags(Bar *bar, Arg *arg, BarArg *a);
|
||||
static int hover_pwrl_tags(Bar *bar, BarArg *a, XMotionEvent *ev);
|
||||
|
|
@ -4,6 +4,13 @@ width_status(Bar *bar, BarArg *a)
|
|||
return TEXTWM(stext);
|
||||
}
|
||||
|
||||
#if BAR_EXTRASTATUS_PATCH
|
||||
int
|
||||
width_status_es(Bar *bar, BarArg *a)
|
||||
{
|
||||
return TEXTWM(estext) - lrpad;
|
||||
}
|
||||
#endif // BAR_EXTRASTATUS_PATCH
|
||||
|
||||
int
|
||||
draw_status(Bar *bar, BarArg *a)
|
||||
|
|
@ -11,6 +18,13 @@ draw_status(Bar *bar, BarArg *a)
|
|||
return drw_text(drw, a->x, a->y, a->w, a->h, lrpad / 2, stext, 0, True);
|
||||
}
|
||||
|
||||
#if BAR_EXTRASTATUS_PATCH
|
||||
int
|
||||
draw_status_es(Bar *bar, BarArg *a)
|
||||
{
|
||||
return drw_text(drw, a->x, a->y, a->w, a->h, 0, estext, 0, True);
|
||||
}
|
||||
#endif // BAR_EXTRASTATUS_PATCH
|
||||
|
||||
int
|
||||
click_status(Bar *bar, Arg *arg, BarArg *a)
|
||||
|
|
|
|||
|
|
@ -1,4 +1,10 @@
|
|||
static int width_status(Bar *bar, BarArg *a);
|
||||
#if BAR_EXTRASTATUS_PATCH
|
||||
static int width_status_es(Bar *bar, BarArg *a);
|
||||
#endif // BAR_EXTRASTATUS_PATCH
|
||||
static int draw_status(Bar *bar, BarArg *a);
|
||||
#if BAR_EXTRASTATUS_PATCH
|
||||
static int draw_status_es(Bar *bar, BarArg *a);
|
||||
#endif // BAR_EXTRASTATUS_PATCH
|
||||
static int click_status(Bar *bar, Arg *arg, BarArg *a);
|
||||
|
||||
|
|
|
|||
263
dwm/patch/bar_status2d.c
Normal file
263
dwm/patch/bar_status2d.c
Normal file
|
|
@ -0,0 +1,263 @@
|
|||
#if BAR_STATUS2D_XRDB_TERMCOLORS_PATCH
|
||||
static char termcol0[] = "#000000"; /* black */
|
||||
static char termcol1[] = "#ff0000"; /* red */
|
||||
static char termcol2[] = "#33ff00"; /* green */
|
||||
static char termcol3[] = "#ff0099"; /* yellow */
|
||||
static char termcol4[] = "#0066ff"; /* blue */
|
||||
static char termcol5[] = "#cc00ff"; /* magenta */
|
||||
static char termcol6[] = "#00ffff"; /* cyan */
|
||||
static char termcol7[] = "#d0d0d0"; /* white */
|
||||
static char termcol8[] = "#808080"; /* black */
|
||||
static char termcol9[] = "#ff0000"; /* red */
|
||||
static char termcol10[] = "#33ff00"; /* green */
|
||||
static char termcol11[] = "#ff0099"; /* yellow */
|
||||
static char termcol12[] = "#0066ff"; /* blue */
|
||||
static char termcol13[] = "#cc00ff"; /* magenta */
|
||||
static char termcol14[] = "#00ffff"; /* cyan */
|
||||
static char termcol15[] = "#ffffff"; /* white */
|
||||
static char *termcolor[] = {
|
||||
termcol0, termcol1, termcol2, termcol3, termcol4, termcol5, termcol6, termcol7,
|
||||
termcol8, termcol9, termcol10, termcol11, termcol12, termcol13, termcol14, termcol15,
|
||||
};
|
||||
#endif // BAR_STATUS2D_XRDB_TERMCOLORS_PATCH
|
||||
|
||||
int
|
||||
width_status2d(Bar *bar, BarArg *a)
|
||||
{
|
||||
#if BAR_EXTRASTATUS_PATCH || BAR_STATUSCMD_PATCH
|
||||
return status2dtextlength(rawstext);
|
||||
#else
|
||||
return status2dtextlength(stext);
|
||||
#endif // #if BAR_EXTRASTATUS_PATCH | BAR_STATUSCMD_PATCH
|
||||
}
|
||||
|
||||
#if BAR_EXTRASTATUS_PATCH
|
||||
int
|
||||
width_status2d_es(Bar *bar, BarArg *a)
|
||||
{
|
||||
#if BAR_STATUSCMD_PATCH
|
||||
return status2dtextlength(rawestext);
|
||||
#else
|
||||
return status2dtextlength(estext);
|
||||
#endif // BAR_STATUSCMD_PATCH
|
||||
}
|
||||
#endif // BAR_EXTRASTATUS_PATCH
|
||||
|
||||
int
|
||||
draw_status2d(Bar *bar, BarArg *a)
|
||||
{
|
||||
#if BAR_EXTRASTATUS_PATCH || BAR_STATUSCMD_PATCH
|
||||
return drawstatusbar(a, rawstext);
|
||||
#else
|
||||
return drawstatusbar(a, stext);
|
||||
#endif // #if BAR_EXTRASTATUS_PATCH | BAR_STATUSCMD_PATCH
|
||||
}
|
||||
|
||||
#if BAR_EXTRASTATUS_PATCH
|
||||
int
|
||||
draw_status2d_es(Bar *bar, BarArg *a)
|
||||
{
|
||||
#if BAR_STATUSCMD_PATCH
|
||||
return drawstatusbar(a, rawestext);
|
||||
#else
|
||||
return drawstatusbar(a, estext);
|
||||
#endif // BAR_STATUSCMD_PATCH
|
||||
}
|
||||
#endif // BAR_EXTRASTATUS_PATCH
|
||||
|
||||
#if !BAR_STATUSCMD_PATCH
|
||||
int
|
||||
click_status2d(Bar *bar, Arg *arg, BarArg *a)
|
||||
{
|
||||
return ClkStatusText;
|
||||
}
|
||||
#endif // BAR_STATUSCMD_PATCH
|
||||
|
||||
int
|
||||
drawstatusbar(BarArg *a, char* stext)
|
||||
{
|
||||
int i, w, len;
|
||||
int x = a->x;
|
||||
int y = a->y;
|
||||
short isCode = 0;
|
||||
char *text;
|
||||
char *p;
|
||||
Clr oldbg, oldfg;
|
||||
len = strlen(stext);
|
||||
if (!(text = (char*) malloc(sizeof(char)*(len + 1))))
|
||||
die("malloc");
|
||||
p = text;
|
||||
#if BAR_STATUSCMD_PATCH
|
||||
copyvalidchars(text, stext);
|
||||
#else
|
||||
memcpy(text, stext, len);
|
||||
#endif // BAR_STATUSCMD_PATCH
|
||||
text[len] = '\0';
|
||||
|
||||
drw_setscheme(drw, scheme[LENGTH(colors)]);
|
||||
drw->scheme[ColFg] = scheme[SchemeNorm][ColFg];
|
||||
drw->scheme[ColBg] = scheme[SchemeNorm][ColBg];
|
||||
|
||||
/* process status text */
|
||||
i = -1;
|
||||
while (text[++i]) {
|
||||
if (text[i] == '^' && !isCode) {
|
||||
isCode = 1;
|
||||
|
||||
text[i] = '\0';
|
||||
w = TEXTWM(text) - lrpad;
|
||||
drw_text(drw, x, y, w, bh, 0, text, 0, True);
|
||||
|
||||
x += w;
|
||||
|
||||
/* process code */
|
||||
while (text[++i] != '^') {
|
||||
if (text[i] == 'c') {
|
||||
char buf[8];
|
||||
if (i + 7 >= len) {
|
||||
i += 7;
|
||||
len = 0;
|
||||
break;
|
||||
}
|
||||
memcpy(buf, (char*)text+i+1, 7);
|
||||
buf[7] = '\0';
|
||||
#if BAR_ALPHA_PATCH && BAR_STATUS2D_NO_ALPHA_PATCH
|
||||
drw_clr_create(drw, &drw->scheme[ColFg], buf, 0xff);
|
||||
#elif BAR_ALPHA_PATCH
|
||||
drw_clr_create(drw, &drw->scheme[ColFg], buf, alphas[SchemeNorm][ColFg]);
|
||||
#else
|
||||
drw_clr_create(drw, &drw->scheme[ColFg], buf);
|
||||
#endif // BAR_ALPHA_PATCH
|
||||
i += 7;
|
||||
} else if (text[i] == 'b') {
|
||||
char buf[8];
|
||||
if (i + 7 >= len) {
|
||||
i += 7;
|
||||
len = 0;
|
||||
break;
|
||||
}
|
||||
memcpy(buf, (char*)text+i+1, 7);
|
||||
buf[7] = '\0';
|
||||
#if BAR_ALPHA_PATCH && BAR_STATUS2D_NO_ALPHA_PATCH
|
||||
drw_clr_create(drw, &drw->scheme[ColBg], buf, 0xff);
|
||||
#elif BAR_ALPHA_PATCH
|
||||
drw_clr_create(drw, &drw->scheme[ColBg], buf, alphas[SchemeNorm][ColBg]);
|
||||
#else
|
||||
drw_clr_create(drw, &drw->scheme[ColBg], buf);
|
||||
#endif // BAR_ALPHA_PATCH
|
||||
i += 7;
|
||||
#if BAR_STATUS2D_XRDB_TERMCOLORS_PATCH
|
||||
} else if (text[i] == 'C') {
|
||||
int c = atoi(text + ++i) % 16;
|
||||
#if BAR_ALPHA_PATCH && BAR_STATUS2D_NO_ALPHA_PATCH
|
||||
drw_clr_create(drw, &drw->scheme[ColFg], termcolor[c], 0xff);
|
||||
#elif BAR_ALPHA_PATCH
|
||||
drw_clr_create(drw, &drw->scheme[ColFg], termcolor[c], alphas[SchemeNorm][ColBg]);
|
||||
#else
|
||||
drw_clr_create(drw, &drw->scheme[ColFg], termcolor[c]);
|
||||
#endif // BAR_ALPHA_PATCH
|
||||
} else if (text[i] == 'B') {
|
||||
int c = atoi(text + ++i) % 16;
|
||||
#if BAR_ALPHA_PATCH && BAR_STATUS2D_NO_ALPHA_PATCH
|
||||
drw_clr_create(drw, &drw->scheme[ColBg], termcolor[c], 0xff);
|
||||
#elif BAR_ALPHA_PATCH
|
||||
drw_clr_create(drw, &drw->scheme[ColBg], termcolor[c], alphas[SchemeNorm][ColBg]);
|
||||
#else
|
||||
drw_clr_create(drw, &drw->scheme[ColBg], termcolor[c]);
|
||||
#endif // BAR_ALPHA_PATCH
|
||||
#endif // BAR_STATUS2D_XRDB_TERMCOLORS_PATCH
|
||||
} else if (text[i] == 'd') {
|
||||
drw->scheme[ColFg] = scheme[SchemeNorm][ColFg];
|
||||
drw->scheme[ColBg] = scheme[SchemeNorm][ColBg];
|
||||
} else if (text[i] == 'w') {
|
||||
Clr swp;
|
||||
swp = drw->scheme[ColFg];
|
||||
drw->scheme[ColFg] = drw->scheme[ColBg];
|
||||
drw->scheme[ColBg] = swp;
|
||||
} else if (text[i] == 'v') {
|
||||
oldfg = drw->scheme[ColFg];
|
||||
oldbg = drw->scheme[ColBg];
|
||||
} else if (text[i] == 't') {
|
||||
drw->scheme[ColFg] = oldfg;
|
||||
drw->scheme[ColBg] = oldbg;
|
||||
} else if (text[i] == 'r') {
|
||||
int rx = atoi(text + ++i);
|
||||
while (text[++i] != ',');
|
||||
int ry = atoi(text + ++i);
|
||||
while (text[++i] != ',');
|
||||
int rw = atoi(text + ++i);
|
||||
while (text[++i] != ',');
|
||||
int rh = atoi(text + ++i);
|
||||
|
||||
if (ry < 0)
|
||||
ry = 0;
|
||||
if (rx < 0)
|
||||
rx = 0;
|
||||
|
||||
drw_rect(drw, rx + x, y + ry, rw, rh, 1, 0);
|
||||
} else if (text[i] == 'f') {
|
||||
x += atoi(text + ++i);
|
||||
}
|
||||
}
|
||||
|
||||
text = text + i + 1;
|
||||
len -= i + 1;
|
||||
i = -1;
|
||||
isCode = 0;
|
||||
if (len <= 0)
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!isCode && len > 0) {
|
||||
w = TEXTWM(text) - lrpad;
|
||||
drw_text(drw, x, y, w, bh, 0, text, 0, True);
|
||||
x += w;
|
||||
}
|
||||
free(p);
|
||||
|
||||
drw_setscheme(drw, scheme[SchemeNorm]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int
|
||||
status2dtextlength(char* stext)
|
||||
{
|
||||
int i, w, len;
|
||||
short isCode = 0;
|
||||
char *text;
|
||||
char *p;
|
||||
|
||||
len = strlen(stext) + 1;
|
||||
if (!(text = (char*) malloc(sizeof(char)*len)))
|
||||
die("malloc");
|
||||
p = text;
|
||||
#if BAR_STATUSCMD_PATCH
|
||||
copyvalidchars(text, stext);
|
||||
#else
|
||||
memcpy(text, stext, len);
|
||||
#endif // BAR_STATUSCMD_PATCH
|
||||
|
||||
/* compute width of the status text */
|
||||
w = 0;
|
||||
i = -1;
|
||||
while (text[++i]) {
|
||||
if (text[i] == '^') {
|
||||
if (!isCode) {
|
||||
isCode = 1;
|
||||
text[i] = '\0';
|
||||
w += TEXTWM(text) - lrpad;
|
||||
text[i] = '^';
|
||||
if (text[++i] == 'f')
|
||||
w += atoi(text + ++i);
|
||||
} else {
|
||||
isCode = 0;
|
||||
text = text + i + 1;
|
||||
i = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!isCode)
|
||||
w += TEXTWM(text) - lrpad;
|
||||
free(p);
|
||||
return w;
|
||||
}
|
||||
14
dwm/patch/bar_status2d.h
Normal file
14
dwm/patch/bar_status2d.h
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
static int width_status2d(Bar *bar, BarArg *a);
|
||||
#if BAR_EXTRASTATUS_PATCH
|
||||
static int width_status2d_es(Bar *bar, BarArg *a);
|
||||
#endif // BAR_EXTRASTATUS_PATCH
|
||||
static int draw_status2d(Bar *bar, BarArg *a);
|
||||
#if BAR_EXTRASTATUS_PATCH
|
||||
static int draw_status2d_es(Bar *bar, BarArg *a);
|
||||
#endif // BAR_EXTRASTATUS_PATCH
|
||||
#if !BAR_STATUSCMD_PATCH
|
||||
static int click_status2d(Bar *bar, Arg *arg, BarArg *a);
|
||||
#endif // BAR_STATUSCMD_PATCH
|
||||
static int drawstatusbar(BarArg *a, char *text);
|
||||
static int status2dtextlength(char *stext);
|
||||
|
||||
18
dwm/patch/bar_statusbutton.c
Normal file
18
dwm/patch/bar_statusbutton.c
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
int
|
||||
width_stbutton(Bar *bar, BarArg *a)
|
||||
{
|
||||
return TEXTW(buttonbar);
|
||||
}
|
||||
|
||||
int
|
||||
draw_stbutton(Bar *bar, BarArg *a)
|
||||
{
|
||||
return drw_text(drw, a->x, a->y, a->w, a->h, lrpad / 2, buttonbar, 0, False);
|
||||
}
|
||||
|
||||
int
|
||||
click_stbutton(Bar *bar, Arg *arg, BarArg *a)
|
||||
{
|
||||
return ClkButton;
|
||||
}
|
||||
|
||||
4
dwm/patch/bar_statusbutton.h
Normal file
4
dwm/patch/bar_statusbutton.h
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
static int width_stbutton(Bar *bar, BarArg *a);
|
||||
static int draw_stbutton(Bar *bar, BarArg *a);
|
||||
static int click_stbutton(Bar *bar, Arg *arg, BarArg *a);
|
||||
|
||||
79
dwm/patch/bar_statuscmd.c
Normal file
79
dwm/patch/bar_statuscmd.c
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
#if !BAR_DWMBLOCKS_PATCH
|
||||
static const char statusexport[] = "export BUTTON=-;";
|
||||
static int statuscmdn;
|
||||
static char lastbutton[] = "-";
|
||||
#endif // BAR_DWMBLOCKS_PATCH
|
||||
|
||||
int
|
||||
click_statuscmd(Bar *bar, Arg *arg, BarArg *a)
|
||||
{
|
||||
return click_statuscmd_text(arg, a->x, rawstext);
|
||||
}
|
||||
|
||||
#if BAR_EXTRASTATUS_PATCH
|
||||
int
|
||||
click_statuscmd_es(Bar *bar, Arg *arg, BarArg *a)
|
||||
{
|
||||
return click_statuscmd_text(arg, a->x, rawestext);
|
||||
}
|
||||
#endif // BAR_EXTRASTATUS_PATCH
|
||||
|
||||
int
|
||||
click_statuscmd_text(Arg *arg, int rel_x, char *text)
|
||||
{
|
||||
int i = -1;
|
||||
int x = 0;
|
||||
char ch;
|
||||
#if BAR_DWMBLOCKS_PATCH
|
||||
statussig = -1;
|
||||
#else
|
||||
statuscmdn = 0;
|
||||
#endif // BAR_DWMBLOCKS_PATCH
|
||||
while (text[++i]) {
|
||||
if ((unsigned char)text[i] < ' ') {
|
||||
#if BAR_STATUSCOLORS_PATCH
|
||||
if (text[i] < 17)
|
||||
continue;
|
||||
#endif // BAR_STATUSCOLORS_PATCH
|
||||
ch = text[i];
|
||||
text[i] = '\0';
|
||||
#if BAR_STATUS2D_PATCH && !BAR_STATUSCOLORS_PATCH
|
||||
x += status2dtextlength(text);
|
||||
#else
|
||||
x += TEXTWM(text) - lrpad;
|
||||
#endif // BAR_STATUS2D_PATCH
|
||||
text[i] = ch;
|
||||
text += i+1;
|
||||
i = -1;
|
||||
#if BAR_DWMBLOCKS_PATCH
|
||||
if (x >= rel_x && statussig != -1)
|
||||
break;
|
||||
statussig = ch;
|
||||
#else
|
||||
if (x >= rel_x)
|
||||
break;
|
||||
if (ch <= LENGTH(statuscmds))
|
||||
statuscmdn = ch;
|
||||
#endif // BAR_DWMBLOCKS_PATCH
|
||||
}
|
||||
}
|
||||
#if BAR_DWMBLOCKS_PATCH
|
||||
if (statussig == -1)
|
||||
statussig = 0;
|
||||
#endif // BAR_DWMBLOCKS_PATCH
|
||||
return ClkStatusText;
|
||||
}
|
||||
|
||||
void
|
||||
copyvalidchars(char *text, char *rawtext)
|
||||
{
|
||||
int i = -1, j = 0;
|
||||
|
||||
while (rawtext[++i]) {
|
||||
if ((unsigned char)rawtext[i] >= ' ') {
|
||||
text[j++] = rawtext[i];
|
||||
}
|
||||
}
|
||||
text[j] = '\0';
|
||||
}
|
||||
|
||||
12
dwm/patch/bar_statuscmd.h
Normal file
12
dwm/patch/bar_statuscmd.h
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
static int click_statuscmd(Bar *bar, Arg *arg, BarArg *a);
|
||||
#if BAR_EXTRASTATUS_PATCH
|
||||
static int click_statuscmd_es(Bar *bar, Arg *arg, BarArg *a);
|
||||
#endif // BAR_EXTRASTATUS_PATCH
|
||||
static int click_statuscmd_text(Arg *arg, int rel_x, char *text);
|
||||
static void copyvalidchars(char *text, char *rawtext);
|
||||
|
||||
typedef struct {
|
||||
const char *cmd;
|
||||
int id;
|
||||
} StatusCmd;
|
||||
|
||||
102
dwm/patch/bar_statuscolors.c
Normal file
102
dwm/patch/bar_statuscolors.c
Normal file
|
|
@ -0,0 +1,102 @@
|
|||
int
|
||||
width_statuscolors(Bar *bar, BarArg *a)
|
||||
{
|
||||
#if BAR_STATUSCMD_PATCH
|
||||
return textw_wosc(rawstext);
|
||||
#else
|
||||
return textw_wosc(stext);
|
||||
#endif // BAR_STATUSCMD_PATCH
|
||||
}
|
||||
|
||||
#if BAR_EXTRASTATUS_PATCH
|
||||
int
|
||||
width_statuscolors_es(Bar *bar, BarArg *a)
|
||||
{
|
||||
#if BAR_STATUSCMD_PATCH
|
||||
return textw_wosc(rawestext);
|
||||
#else
|
||||
return textw_wosc(estext);
|
||||
#endif // BAR_STATUSCMD_PATCH
|
||||
}
|
||||
#endif // BAR_EXTRASTATUS_PATCH
|
||||
|
||||
int
|
||||
draw_statuscolors(Bar *bar, BarArg *a)
|
||||
{
|
||||
#if BAR_STATUSCMD_PATCH
|
||||
return draw_wosc(bar, a, rawstext);
|
||||
#else
|
||||
return draw_wosc(bar, a, stext);
|
||||
#endif // BAR_STATUSCMD_PATCH
|
||||
}
|
||||
|
||||
#if BAR_EXTRASTATUS_PATCH
|
||||
int
|
||||
draw_statuscolors_es(Bar *bar, BarArg *a)
|
||||
{
|
||||
#if BAR_STATUSCMD_PATCH
|
||||
return draw_wosc(bar, a, rawestext);
|
||||
#else
|
||||
return draw_wosc(bar, a, estext);
|
||||
#endif // BAR_STATUSCMD_PATCH
|
||||
}
|
||||
#endif // BAR_EXTRASTATUS_PATCH
|
||||
|
||||
#if !BAR_STATUSCMD_PATCH
|
||||
int
|
||||
click_statuscolors(Bar *bar, Arg *arg, BarArg *a)
|
||||
{
|
||||
return ClkStatusText;
|
||||
}
|
||||
#endif // BAR_STATUSCMD_PATCH
|
||||
|
||||
int
|
||||
textw_wosc(char *s)
|
||||
{
|
||||
char *ts = s;
|
||||
char *tp = s;
|
||||
int sw = 0;
|
||||
char ctmp;
|
||||
while (1) {
|
||||
if ((unsigned int)*ts > LENGTH(colors)) {
|
||||
ts++;
|
||||
continue;
|
||||
}
|
||||
ctmp = *ts;
|
||||
*ts = '\0';
|
||||
sw += drw_fontset_getwidth(drw, tp, True);
|
||||
*ts = ctmp;
|
||||
if (ctmp == '\0')
|
||||
break;
|
||||
tp = ++ts;
|
||||
}
|
||||
|
||||
return sw;
|
||||
}
|
||||
|
||||
int
|
||||
draw_wosc(Bar *bar, BarArg *a, char *s)
|
||||
{
|
||||
char *ts = s;
|
||||
char *tp = s;
|
||||
int tx = 0;
|
||||
char ctmp;
|
||||
|
||||
while (1) {
|
||||
if ((unsigned int)*ts > LENGTH(colors)) {
|
||||
ts++;
|
||||
continue;
|
||||
}
|
||||
ctmp = *ts;
|
||||
*ts = '\0';
|
||||
drw_text(drw, a->x + tx, a->y, a->w - tx, a->h, 0, tp, 0, True);
|
||||
tx += TEXTW(tp) - lrpad;
|
||||
if (ctmp == '\0')
|
||||
break;
|
||||
drw_setscheme(drw, scheme[(unsigned int)(ctmp-1)]);
|
||||
*ts = ctmp;
|
||||
tp = ++ts;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
13
dwm/patch/bar_statuscolors.h
Normal file
13
dwm/patch/bar_statuscolors.h
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
static int width_statuscolors(Bar *bar, BarArg *a);
|
||||
#if BAR_EXTRASTATUS_PATCH
|
||||
static int width_statuscolors_es(Bar *bar, BarArg *a);
|
||||
#endif // BAR_EXTRASTATUS_PATCH
|
||||
static int draw_statuscolors(Bar *bar, BarArg *a);
|
||||
#if BAR_EXTRASTATUS_PATCH
|
||||
static int draw_statuscolors_es(Bar *bar, BarArg *a);
|
||||
#endif // BAR_EXTRASTATUS_PATCH
|
||||
#if !BAR_STATUSCMD_PATCH
|
||||
static int click_statuscolors(Bar *bar, Arg *arg, BarArg *a);
|
||||
#endif // BAR_STATUSCMD_PATCH
|
||||
static int textw_wosc(char *s);
|
||||
static int draw_wosc(Bar *bar, BarArg *a, char *s);
|
||||
208
dwm/patch/bar_systray.c
Normal file
208
dwm/patch/bar_systray.c
Normal file
|
|
@ -0,0 +1,208 @@
|
|||
static Systray *systray = NULL;
|
||||
static unsigned long systrayorientation = _NET_SYSTEM_TRAY_ORIENTATION_HORZ;
|
||||
|
||||
int
|
||||
width_systray(Bar *bar, BarArg *a)
|
||||
{
|
||||
unsigned int w = 0;
|
||||
Client *i;
|
||||
if (!systray)
|
||||
return 1;
|
||||
if (showsystray) {
|
||||
for (i = systray->icons; i; w += i->w + systrayspacing, i = i->next);
|
||||
if (!w)
|
||||
XMoveWindow(dpy, systray->win, -systray->h, bar->by);
|
||||
}
|
||||
return w ? w + lrpad - systrayspacing : 0;
|
||||
}
|
||||
|
||||
int
|
||||
draw_systray(Bar *bar, BarArg *a)
|
||||
{
|
||||
if (!showsystray)
|
||||
return 0;
|
||||
|
||||
XSetWindowAttributes wa;
|
||||
XWindowChanges wc;
|
||||
Client *i;
|
||||
unsigned int w;
|
||||
|
||||
if (!systray) {
|
||||
/* init systray */
|
||||
if (!(systray = (Systray *)calloc(1, sizeof(Systray))))
|
||||
die("fatal: could not malloc() %u bytes\n", sizeof(Systray));
|
||||
|
||||
wa.override_redirect = True;
|
||||
wa.event_mask = ButtonPressMask|ExposureMask;
|
||||
wa.border_pixel = 0;
|
||||
systray->h = MIN(a->h, drw->fonts->h);
|
||||
#if BAR_ALPHA_PATCH
|
||||
wa.background_pixel = 0;
|
||||
wa.colormap = cmap;
|
||||
systray->win = XCreateWindow(dpy, root, bar->bx + a->x + lrpad / 2, -systray->h, MAX(a->w + 40, 1), systray->h, 0, depth,
|
||||
InputOutput, visual,
|
||||
CWOverrideRedirect|CWBorderPixel|CWBackPixel|CWColormap|CWEventMask, &wa); // CWBackPixmap
|
||||
#else
|
||||
wa.background_pixel = scheme[SchemeNorm][ColBg].pixel;
|
||||
systray->win = XCreateSimpleWindow(dpy, root, bar->bx + a->x + lrpad / 2, -systray->h, MIN(a->w, 1), systray->h, 0, 0, scheme[SchemeNorm][ColBg].pixel);
|
||||
XChangeWindowAttributes(dpy, systray->win, CWOverrideRedirect|CWBackPixel|CWBorderPixel|CWEventMask, &wa);
|
||||
#endif // BAR_ALPHA_PATCH
|
||||
|
||||
XSelectInput(dpy, systray->win, SubstructureNotifyMask);
|
||||
XChangeProperty(dpy, systray->win, netatom[NetSystemTrayOrientation], XA_CARDINAL, 32,
|
||||
PropModeReplace, (unsigned char *)&systrayorientation, 1);
|
||||
#if BAR_ALPHA_PATCH
|
||||
XChangeProperty(dpy, systray->win, netatom[NetSystemTrayVisual], XA_VISUALID, 32,
|
||||
PropModeReplace, (unsigned char *)&visual->visualid, 1);
|
||||
#endif // BAR_ALPHA_PATCH
|
||||
XChangeProperty(dpy, systray->win, netatom[NetWMWindowType], XA_ATOM, 32,
|
||||
PropModeReplace, (unsigned char *)&netatom[NetWMWindowTypeDock], 1);
|
||||
XMapRaised(dpy, systray->win);
|
||||
XSetSelectionOwner(dpy, netatom[NetSystemTray], systray->win, CurrentTime);
|
||||
if (XGetSelectionOwner(dpy, netatom[NetSystemTray]) == systray->win) {
|
||||
sendevent(root, xatom[Manager], StructureNotifyMask, CurrentTime, netatom[NetSystemTray], systray->win, 0, 0);
|
||||
XSync(dpy, False);
|
||||
} else {
|
||||
fprintf(stderr, "dwm: unable to obtain system tray.\n");
|
||||
free(systray);
|
||||
systray = NULL;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
systray->bar = bar;
|
||||
|
||||
wc.stack_mode = Above;
|
||||
wc.sibling = bar->win;
|
||||
XConfigureWindow(dpy, systray->win, CWSibling|CWStackMode, &wc);
|
||||
|
||||
drw_setscheme(drw, scheme[SchemeNorm]);
|
||||
for (w = 0, i = systray->icons; i; i = i->next) {
|
||||
#if BAR_ALPHA_PATCH
|
||||
wa.background_pixel = 0;
|
||||
#else
|
||||
wa.background_pixel = scheme[SchemeNorm][ColBg].pixel;
|
||||
#endif // BAR_ALPHA_PATCH
|
||||
XChangeWindowAttributes(dpy, i->win, CWBackPixel, &wa);
|
||||
XMapRaised(dpy, i->win);
|
||||
i->x = w;
|
||||
XMoveResizeWindow(dpy, i->win, i->x, 0, i->w, i->h);
|
||||
w += i->w;
|
||||
if (i->next)
|
||||
w += systrayspacing;
|
||||
if (i->mon != bar->mon)
|
||||
i->mon = bar->mon;
|
||||
}
|
||||
|
||||
#if !BAR_ALPHA_PATCH
|
||||
wa.background_pixel = scheme[SchemeNorm][ColBg].pixel;
|
||||
XChangeWindowAttributes(dpy, systray->win, CWBackPixel, &wa);
|
||||
XClearWindow(dpy, systray->win);
|
||||
#endif // BAR_ALPHA_PATCH
|
||||
|
||||
XMoveResizeWindow(dpy, systray->win, bar->bx + a->x + lrpad / 2, (w ? bar->by + a->y + (a->h - systray->h) / 2: -systray->h), MAX(w, 1), systray->h);
|
||||
return w;
|
||||
}
|
||||
|
||||
int
|
||||
click_systray(Bar *bar, Arg *arg, BarArg *a)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
void
|
||||
removesystrayicon(Client *i)
|
||||
{
|
||||
Client **ii;
|
||||
|
||||
if (!showsystray || !i)
|
||||
return;
|
||||
for (ii = &systray->icons; *ii && *ii != i; ii = &(*ii)->next);
|
||||
if (ii)
|
||||
*ii = i->next;
|
||||
XReparentWindow(dpy, i->win, root, 0, 0);
|
||||
free(i);
|
||||
drawbarwin(systray->bar);
|
||||
}
|
||||
|
||||
void
|
||||
resizerequest(XEvent *e)
|
||||
{
|
||||
XResizeRequestEvent *ev = &e->xresizerequest;
|
||||
Client *i;
|
||||
|
||||
if ((i = wintosystrayicon(ev->window))) {
|
||||
updatesystrayicongeom(i, ev->width, ev->height);
|
||||
drawbarwin(systray->bar);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
updatesystrayicongeom(Client *i, int w, int h)
|
||||
{
|
||||
if (!systray)
|
||||
return;
|
||||
|
||||
int icon_height = systray->h;
|
||||
if (i) {
|
||||
i->h = icon_height;
|
||||
if (w == h)
|
||||
i->w = icon_height;
|
||||
else if (h == icon_height)
|
||||
i->w = w;
|
||||
else
|
||||
i->w = (int) ((float)icon_height * ((float)w / (float)h));
|
||||
applysizehints(i, &(i->x), &(i->y), &(i->w), &(i->h), False);
|
||||
/* force icons into the systray dimensions if they don't want to */
|
||||
if (i->h > icon_height) {
|
||||
if (i->w == i->h)
|
||||
i->w = icon_height;
|
||||
else
|
||||
i->w = (int) ((float)icon_height * ((float)i->w / (float)i->h));
|
||||
i->h = icon_height;
|
||||
}
|
||||
if (i->w > 2 * icon_height)
|
||||
i->w = icon_height;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
updatesystrayiconstate(Client *i, XPropertyEvent *ev)
|
||||
{
|
||||
long flags;
|
||||
int code = 0;
|
||||
|
||||
if (!showsystray || !systray || !i || ev->atom != xatom[XembedInfo] ||
|
||||
!(flags = getatomprop(i, xatom[XembedInfo], xatom[XembedInfo])))
|
||||
return;
|
||||
|
||||
if (flags & XEMBED_MAPPED && !i->tags) {
|
||||
i->tags = 1;
|
||||
code = XEMBED_WINDOW_ACTIVATE;
|
||||
XMapRaised(dpy, i->win);
|
||||
setclientstate(i, NormalState);
|
||||
}
|
||||
else if (!(flags & XEMBED_MAPPED) && i->tags) {
|
||||
i->tags = 0;
|
||||
code = XEMBED_WINDOW_DEACTIVATE;
|
||||
XUnmapWindow(dpy, i->win);
|
||||
setclientstate(i, WithdrawnState);
|
||||
}
|
||||
else
|
||||
return;
|
||||
sendevent(i->win, xatom[Xembed], StructureNotifyMask, CurrentTime, code, 0,
|
||||
systray->win, XEMBED_EMBEDDED_VERSION);
|
||||
}
|
||||
|
||||
Client *
|
||||
wintosystrayicon(Window w)
|
||||
{
|
||||
if (!systray)
|
||||
return NULL;
|
||||
Client *i = NULL;
|
||||
if (!showsystray || !w)
|
||||
return i;
|
||||
for (i = systray->icons; i && i->win != w; i = i->next);
|
||||
return i;
|
||||
}
|
||||
|
||||
41
dwm/patch/bar_systray.h
Normal file
41
dwm/patch/bar_systray.h
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
#define SYSTEM_TRAY_REQUEST_DOCK 0
|
||||
#define _NET_SYSTEM_TRAY_ORIENTATION_HORZ 0
|
||||
|
||||
/* XEMBED messages */
|
||||
#define XEMBED_EMBEDDED_NOTIFY 0
|
||||
#define XEMBED_WINDOW_ACTIVATE 1
|
||||
#define XEMBED_FOCUS_IN 4
|
||||
#define XEMBED_MODALITY_ON 10
|
||||
|
||||
#define XEMBED_MAPPED (1 << 0)
|
||||
#define XEMBED_WINDOW_ACTIVATE 1
|
||||
#define XEMBED_WINDOW_DEACTIVATE 2
|
||||
|
||||
#define VERSION_MAJOR 0
|
||||
#define VERSION_MINOR 0
|
||||
#define XEMBED_EMBEDDED_VERSION (VERSION_MAJOR << 16) | VERSION_MINOR
|
||||
|
||||
/* enums */
|
||||
enum { Manager, Xembed, XembedInfo, XLast }; /* Xembed atoms */
|
||||
|
||||
typedef struct Systray Systray;
|
||||
struct Systray {
|
||||
Window win;
|
||||
Client *icons;
|
||||
Bar *bar;
|
||||
int h;
|
||||
};
|
||||
|
||||
/* bar integration */
|
||||
static int width_systray(Bar *bar, BarArg *a);
|
||||
static int draw_systray(Bar *bar, BarArg *a);
|
||||
static int click_systray(Bar *bar, Arg *arg, BarArg *a);
|
||||
|
||||
/* function declarations */
|
||||
static void removesystrayicon(Client *i);
|
||||
static void resizerequest(XEvent *e);
|
||||
static void updatesystrayicongeom(Client *i, int w, int h);
|
||||
static void updatesystrayiconstate(Client *i, XPropertyEvent *ev);
|
||||
static Client *wintosystrayicon(Window w);
|
||||
|
||||
|
||||
258
dwm/patch/bar_tabgroups.c
Normal file
258
dwm/patch/bar_tabgroups.c
Normal file
|
|
@ -0,0 +1,258 @@
|
|||
/* Bartabgroups properties, you can override these in your config.h if you want. */
|
||||
#ifndef BARTAB_BORDERS
|
||||
#define BARTAB_BORDERS 1 // 0 = off, 1 = on
|
||||
#endif
|
||||
#ifndef BARTAB_SHOWFLOATING
|
||||
#define BARTAB_SHOWFLOATING 0 // whether to show titles for floating windows, hidden clients are always shown
|
||||
#endif
|
||||
#ifndef BARTAB_STACKWEIGHT
|
||||
#define BARTAB_STACKWEIGHT 1 // stack weight compared to hidden and floating window titles
|
||||
#endif
|
||||
#ifndef BARTAB_HIDDENWEIGHT
|
||||
#define BARTAB_HIDDENWEIGHT 1 // hidden window title weight
|
||||
#endif
|
||||
#ifndef BARTAB_FLOATWEIGHT
|
||||
#define BARTAB_FLOATWEIGHT 1 // floating window title weight, set to 0 to not show floating windows
|
||||
#endif
|
||||
|
||||
int
|
||||
width_bartabgroups(Bar *bar, BarArg *a)
|
||||
{
|
||||
return a->w;
|
||||
}
|
||||
|
||||
int
|
||||
draw_bartabgroups(Bar *bar, BarArg *a)
|
||||
{
|
||||
drw_rect(drw, a->x, a->y, a->w, a->h, 1, 1);
|
||||
return bartabcalculate(bar->mon, a->x, a->w, -1, bartabdraw, NULL, a);
|
||||
}
|
||||
|
||||
int
|
||||
click_bartabgroups(Bar *bar, Arg *arg, BarArg *a)
|
||||
{
|
||||
bartabcalculate(bar->mon, 0, a->w, a->x, bartabclick, arg, a);
|
||||
return ClkWinTitle;
|
||||
}
|
||||
|
||||
void
|
||||
bartabdraw(Monitor *m, Client *c, int unused, int x, int w, int groupactive, Arg *arg, BarArg *a)
|
||||
{
|
||||
if (!c)
|
||||
return;
|
||||
int i, nclienttags = 0, nviewtags = 0;
|
||||
int tpad = lrpad / 2;
|
||||
#if BAR_WINICON_PATCH
|
||||
int ipad = c->icon ? c->icw + ICONSPACING : 0;
|
||||
#endif // BAR_WINICON_PATCH
|
||||
#if BAR_CENTEREDWINDOWNAME_PATCH
|
||||
int cpad = 0;
|
||||
#endif // BAR_CENTEREDWINDOWNAME_PATCH
|
||||
int tx = x;
|
||||
int tw = w;
|
||||
|
||||
drw_setscheme(drw, scheme[
|
||||
m->sel == c
|
||||
#ifdef HIDDEN
|
||||
&& HIDDEN(c)
|
||||
? SchemeHidSel
|
||||
: HIDDEN(c)
|
||||
? SchemeHidNorm
|
||||
: m->sel == c
|
||||
#endif
|
||||
? SchemeSel
|
||||
: groupactive
|
||||
? SchemeTitleSel
|
||||
: SchemeTitleNorm
|
||||
]);
|
||||
if (w <= TEXTW("A") - lrpad + tpad) // reduce text padding if wintitle is too small
|
||||
tpad = (w - TEXTW("A") + lrpad < 0 ? 0 : (w - TEXTW("A") + lrpad) / 2);
|
||||
#if BAR_WINICON_PATCH && BAR_CENTEREDWINDOWNAME_PATCH
|
||||
else if (TEXTW(c->name) + ipad < w)
|
||||
cpad = (w - TEXTW(c->name) - ipad) / 2;
|
||||
#elif BAR_CENTEREDWINDOWNAME_PATCH
|
||||
else if (TEXTW(c->name) < w)
|
||||
cpad = (w - TEXTW(c->name)) / 2;
|
||||
#endif // BAR_CENTEREDWINDOWNAME_PATCH
|
||||
|
||||
XSetForeground(drw->dpy, drw->gc, drw->scheme[ColBg].pixel);
|
||||
XFillRectangle(drw->dpy, drw->drawable, drw->gc, x, a->y, w, a->h);
|
||||
|
||||
#if BAR_CENTEREDWINDOWNAME_PATCH
|
||||
/* Apply center padding, if any */
|
||||
tx += cpad;
|
||||
tw -= cpad;
|
||||
#endif // BAR_CENTEREDWINDOWNAME_PATCH
|
||||
|
||||
tx += tpad;
|
||||
tw -= lrpad;
|
||||
|
||||
#if BAR_WINICON_PATCH
|
||||
if (ipad) {
|
||||
drw_pic(drw, tx, a->y + (a->h - c->ich) / 2, c->icw, c->ich, c->icon);
|
||||
tx += ipad;
|
||||
tw -= ipad;
|
||||
}
|
||||
#endif // BAR_WINICON_PATCH
|
||||
|
||||
drw_text(drw, tx, a->y, tw, a->h, 0, c->name, 0, False);
|
||||
|
||||
drawstateindicator(m, c, 1, x, a->y, w, a->h, 0, 0, c->isfixed);
|
||||
|
||||
if (BARTAB_BORDERS) {
|
||||
XSetForeground(drw->dpy, drw->gc, scheme[SchemeSel][ColBorder].pixel);
|
||||
XFillRectangle(drw->dpy, drw->drawable, drw->gc, x, a->y, 1, a->h);
|
||||
XFillRectangle(drw->dpy, drw->drawable, drw->gc, x + w - (x + w >= a->w ? 1 : 0), a->y, 1, a->h);
|
||||
}
|
||||
/* Optional tags icons */
|
||||
for (i = 0; i < NUMTAGS; i++) {
|
||||
if ((m->tagset[m->seltags] >> i) & 1)
|
||||
nviewtags++;
|
||||
if ((c->tags >> i) & 1)
|
||||
nclienttags++;
|
||||
}
|
||||
|
||||
if (TAGSINDICATOR == 2 || nclienttags > 1 || nviewtags > 1)
|
||||
drawindicator(m, c, 1, x, a->y, w, a->h, 0, 0, 0, INDICATOR_RIGHT_TAGS);
|
||||
}
|
||||
|
||||
#ifndef HIDDEN
|
||||
#define HIDDEN(C) 0
|
||||
#endif
|
||||
|
||||
void
|
||||
bartabclick(Monitor *m, Client *c, int passx, int x, int w, int unused, Arg *arg, BarArg *barg)
|
||||
{
|
||||
if (passx >= x && passx <= x + w)
|
||||
arg->v = c;
|
||||
}
|
||||
|
||||
int
|
||||
bartabcalculate(
|
||||
Monitor *m, int offx, int tabw, int passx,
|
||||
void(*tabfn)(Monitor *, Client *, int, int, int, int, Arg *arg, BarArg *barg),
|
||||
Arg *arg, BarArg *barg
|
||||
) {
|
||||
Client *c;
|
||||
int
|
||||
i, clientsnmaster = 0, clientsnstack = 0, clientsnfloating = 0, clientsnhidden = 0,
|
||||
masteractive = 0, fulllayout = 0,
|
||||
x = offx, w, r, num = 0, den, tgactive;
|
||||
|
||||
for (i = 0; i < LENGTH(bartabmonfns); i++)
|
||||
if (m ->lt[m->sellt]->arrange == bartabmonfns[i]) {
|
||||
fulllayout = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
for (i = 0, c = m->clients; c; c = c->next) {
|
||||
if (!ISVISIBLE(c))
|
||||
continue;
|
||||
if (HIDDEN(c)) {
|
||||
clientsnhidden++;
|
||||
continue;
|
||||
}
|
||||
if (c->isfloating) {
|
||||
clientsnfloating++;
|
||||
continue;
|
||||
}
|
||||
if (m->sel == c)
|
||||
masteractive = i < m->nmaster;
|
||||
if (i < m->nmaster)
|
||||
clientsnmaster++;
|
||||
else
|
||||
clientsnstack++;
|
||||
i++;
|
||||
}
|
||||
|
||||
if (clientsnmaster + clientsnstack + clientsnfloating + clientsnhidden == 0)
|
||||
return 0;
|
||||
|
||||
tgactive = 1;
|
||||
num = tabw;
|
||||
/* floating mode */
|
||||
if ((fulllayout && BARTAB_FLOATWEIGHT) || clientsnmaster + clientsnstack == 0 || !m->lt[m->sellt]->arrange) {
|
||||
den = clientsnmaster + clientsnstack + clientsnfloating + clientsnhidden;
|
||||
r = num % den;
|
||||
w = num / den;
|
||||
for (c = m->clients, i = 0; c; c = c->next) {
|
||||
if (!ISVISIBLE(c))
|
||||
continue;
|
||||
tabfn(m, c, passx, x, w + (i < r ? 1 : 0), tgactive, arg, barg);
|
||||
x += w + (i < r ? 1 : 0);
|
||||
i++;
|
||||
}
|
||||
/* no master and stack mode, e.g. monocole, grid layouts, fibonacci */
|
||||
} else if (fulllayout) {
|
||||
den = clientsnmaster + clientsnstack + clientsnhidden;
|
||||
r = num % den;
|
||||
w = num / den;
|
||||
for (c = m->clients, i = 0; c; c = c->next) {
|
||||
if (!ISVISIBLE(c) || (c->isfloating && !HIDDEN(c)))
|
||||
continue;
|
||||
tabfn(m, c, passx, x, w + (i < r ? 1 : 0), tgactive, arg, barg);
|
||||
x += w + (i < r ? 1 : 0);
|
||||
i++;
|
||||
}
|
||||
/* tiled mode */
|
||||
} else {
|
||||
den = clientsnmaster;
|
||||
c = m->clients;
|
||||
i = 0;
|
||||
if (den) {
|
||||
if (clientsnstack + clientsnfloating * BARTAB_FLOATWEIGHT + clientsnhidden) {
|
||||
tgactive = masteractive;
|
||||
num = tabw * m->mfact;
|
||||
}
|
||||
r = num % den;
|
||||
w = num / den;
|
||||
for (; c && i < m->nmaster; c = c->next) { // tiled master
|
||||
if (!ISVISIBLE(c) || c->isfloating || HIDDEN(c))
|
||||
continue;
|
||||
tabfn(m, c, passx, x, w + (i < r ? 1 : 0), tgactive, arg, barg);
|
||||
x += w + (i < r ? 1 : 0);
|
||||
i++;
|
||||
}
|
||||
tgactive = !tgactive;
|
||||
num = tabw - num;
|
||||
}
|
||||
|
||||
den = clientsnstack * BARTAB_STACKWEIGHT + clientsnfloating * BARTAB_FLOATWEIGHT + clientsnhidden * BARTAB_HIDDENWEIGHT;
|
||||
if (!den)
|
||||
return 1;
|
||||
|
||||
r = num % den;
|
||||
w = num / den;
|
||||
#if BARTAB_STACKWEIGHT
|
||||
for (; c; c = c->next) { // tiled stack
|
||||
if (!ISVISIBLE(c) || HIDDEN(c) || c->isfloating)
|
||||
continue;
|
||||
tabfn(m, c, passx, x, w * BARTAB_STACKWEIGHT + (i - m->nmaster < r ? 1 : 0), tgactive, arg, barg);
|
||||
x += w * BARTAB_STACKWEIGHT + (i - m->nmaster < r ? 1 : 0);
|
||||
i++;
|
||||
}
|
||||
#endif // BARTAB_STACKWEIGHT
|
||||
|
||||
#if BARTAB_HIDDENWEIGHT
|
||||
for (c = m->clients; c; c = c->next) { // hidden windows
|
||||
if (!ISVISIBLE(c) || !HIDDEN(c))
|
||||
continue;
|
||||
tabfn(m, c, passx, x, w * BARTAB_HIDDENWEIGHT + (i - m->nmaster < r ? 1 : 0), tgactive, arg, barg);
|
||||
x += w * BARTAB_HIDDENWEIGHT + (i - m->nmaster < r ? 1 : 0);
|
||||
i++;
|
||||
}
|
||||
#endif // BARTAB_HIDDENWEIGHT
|
||||
|
||||
#if BARTAB_FLOATWEIGHT
|
||||
for (c = m->clients; c; c = c->next) { // floating windows
|
||||
if (!ISVISIBLE(c) || HIDDEN(c) || !c->isfloating)
|
||||
continue;
|
||||
tabfn(m, c, passx, x, w * BARTAB_FLOATWEIGHT + (i - m->nmaster < r ? 1 : 0), tgactive, arg, barg);
|
||||
x += w * BARTAB_FLOATWEIGHT + (i - m->nmaster < r ? 1 : 0);
|
||||
i++;
|
||||
}
|
||||
#endif // BARTAB_FLOATWEIGHT
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
8
dwm/patch/bar_tabgroups.h
Normal file
8
dwm/patch/bar_tabgroups.h
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
static int width_bartabgroups(Bar *bar, BarArg *a);
|
||||
static int draw_bartabgroups(Bar *bar, BarArg *a);
|
||||
static int click_bartabgroups(Bar *bar, Arg *arg, BarArg *a);
|
||||
|
||||
static void bartabdraw(Monitor *m, Client *c, int unused, int x, int w, int groupactive, Arg *arg, BarArg *barg);
|
||||
static void bartabclick(Monitor *m, Client *c, int passx, int x, int w, int unused, Arg *arg, BarArg *barg);
|
||||
static int bartabcalculate(Monitor *m, int offx, int w, int passx, void(*tabfn)(Monitor *, Client *, int, int, int, int, Arg *arg, BarArg *barg), Arg *arg, BarArg *barg);
|
||||
|
||||
150
dwm/patch/bar_taggrid.c
Normal file
150
dwm/patch/bar_taggrid.c
Normal file
|
|
@ -0,0 +1,150 @@
|
|||
int
|
||||
width_taggrid(Bar *bar, BarArg *a)
|
||||
{
|
||||
return (a->h / 2) * (NUMTAGS / tagrows + ((NUMTAGS % tagrows > 0) ? 1 : 0)) + lrpad;
|
||||
}
|
||||
|
||||
int
|
||||
draw_taggrid(Bar *bar, BarArg *a)
|
||||
{
|
||||
unsigned int x, y, h, max_x = 0, columns, occ = 0;
|
||||
int invert, i,j, k;
|
||||
Client *c;
|
||||
|
||||
for (c = bar->mon->clients; c; c = c->next)
|
||||
occ |= c->tags;
|
||||
|
||||
max_x = x = a->x + lrpad / 2;
|
||||
h = a->h / tagrows - 1;
|
||||
y = a->y;
|
||||
columns = NUMTAGS / tagrows + ((NUMTAGS % tagrows > 0) ? 1 : 0);
|
||||
|
||||
/* Firstly we will fill the borders of squares */
|
||||
XSetForeground(drw->dpy, drw->gc, scheme[SchemeTagsNorm][ColBg].pixel);
|
||||
XFillRectangle(dpy, drw->drawable, drw->gc, x, y, h*columns + 1, a->h);
|
||||
|
||||
/* We will draw NUMTAGS squares in tagraws raws. */
|
||||
for (j = 0, i = 0; j < tagrows; j++) {
|
||||
x = a->x + lrpad / 2;
|
||||
for (k = 0; k < columns; k++, i++) {
|
||||
if (i < NUMTAGS) {
|
||||
invert = bar->mon->tagset[bar->mon->seltags] & 1 << i ? 0 : 1;
|
||||
|
||||
/* Select active color for current square */
|
||||
XSetForeground(drw->dpy, drw->gc, !invert ? scheme[SchemeTagsSel][ColBg].pixel :
|
||||
scheme[SchemeTagsNorm][ColFg].pixel);
|
||||
XFillRectangle(dpy, drw->drawable, drw->gc, x+1, y+1, h-1, h-1);
|
||||
|
||||
/* Mark square if tag has client */
|
||||
if (occ & 1 << i) {
|
||||
XSetForeground(drw->dpy, drw->gc, !invert ? scheme[SchemeTagsSel][ColFg].pixel :
|
||||
scheme[SchemeTagsNorm][ColBg].pixel);
|
||||
XFillRectangle(dpy, drw->drawable, drw->gc, x + 1, y + 1,
|
||||
h / 2, h / 2);
|
||||
}
|
||||
} else {
|
||||
XSetForeground(drw->dpy, drw->gc, scheme[SchemeTagsNorm][ColBg].pixel);
|
||||
XFillRectangle(dpy, drw->drawable, drw->gc, x+1, y+1, h-1, h);
|
||||
}
|
||||
x += h;
|
||||
if (x > max_x) {
|
||||
max_x = x;
|
||||
}
|
||||
}
|
||||
y += h;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
int
|
||||
click_taggrid(Bar *bar, Arg *arg, BarArg *a)
|
||||
{
|
||||
unsigned int i, h, columns;
|
||||
|
||||
h = a->h / tagrows - 1;
|
||||
columns = NUMTAGS / tagrows + ((NUMTAGS % tagrows > 0) ? 1 : 0);
|
||||
i = (a->x - lrpad / 2) / h + columns * (a->y / h);
|
||||
if (i >= NUMTAGS) {
|
||||
i = NUMTAGS - 1;
|
||||
}
|
||||
arg->ui = 1 << i;
|
||||
return ClkTagBar;
|
||||
}
|
||||
|
||||
void
|
||||
switchtag(const Arg *arg)
|
||||
{
|
||||
unsigned int columns;
|
||||
unsigned int new_tagset = 0;
|
||||
unsigned int pos, i;
|
||||
int col, row;
|
||||
Arg new_arg;
|
||||
|
||||
columns = NUMTAGS / tagrows + ((NUMTAGS % tagrows > 0) ? 1 : 0);
|
||||
|
||||
for (i = 0; i < NUMTAGS; ++i) {
|
||||
if (!(selmon->tagset[selmon->seltags] & 1 << i)) {
|
||||
continue;
|
||||
}
|
||||
pos = i;
|
||||
row = pos / columns;
|
||||
col = pos % columns;
|
||||
if (arg->ui & SWITCHTAG_UP) { /* UP */
|
||||
row --;
|
||||
if (row < 0) {
|
||||
row = tagrows - 1;
|
||||
}
|
||||
do {
|
||||
pos = row * columns + col;
|
||||
row --;
|
||||
} while (pos >= NUMTAGS);
|
||||
}
|
||||
if (arg->ui & SWITCHTAG_DOWN) { /* DOWN */
|
||||
row ++;
|
||||
if (row >= tagrows) {
|
||||
row = 0;
|
||||
}
|
||||
pos = row * columns + col;
|
||||
if (pos >= NUMTAGS) {
|
||||
row = 0;
|
||||
}
|
||||
pos = row * columns + col;
|
||||
}
|
||||
if (arg->ui & SWITCHTAG_LEFT) { /* LEFT */
|
||||
col --;
|
||||
if (col < 0) {
|
||||
col = columns - 1;
|
||||
}
|
||||
do {
|
||||
pos = row * columns + col;
|
||||
col --;
|
||||
} while (pos >= NUMTAGS);
|
||||
}
|
||||
if (arg->ui & SWITCHTAG_RIGHT) { /* RIGHT */
|
||||
col ++;
|
||||
if (col >= columns) {
|
||||
col = 0;
|
||||
}
|
||||
pos = row * columns + col;
|
||||
if (pos >= NUMTAGS) {
|
||||
col = 0;
|
||||
pos = row * columns + col;
|
||||
}
|
||||
}
|
||||
new_tagset |= 1 << pos;
|
||||
}
|
||||
new_arg.ui = new_tagset;
|
||||
if (arg->ui & SWITCHTAG_TOGGLETAG) {
|
||||
toggletag(&new_arg);
|
||||
}
|
||||
if (arg->ui & SWITCHTAG_TAG) {
|
||||
tag(&new_arg);
|
||||
}
|
||||
if (arg->ui & SWITCHTAG_VIEW) {
|
||||
view (&new_arg);
|
||||
}
|
||||
if (arg->ui & SWITCHTAG_TOGGLEVIEW) {
|
||||
toggleview (&new_arg);
|
||||
}
|
||||
}
|
||||
|
||||
5
dwm/patch/bar_taggrid.h
Normal file
5
dwm/patch/bar_taggrid.h
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
static int width_taggrid(Bar *bar, BarArg *a);
|
||||
static int draw_taggrid(Bar *bar, BarArg *a);
|
||||
static int click_taggrid(Bar *bar, Arg *arg, BarArg *a);
|
||||
static void switchtag(const Arg *arg);
|
||||
|
||||
|
|
@ -1,9 +1,21 @@
|
|||
char *
|
||||
tagicon(Monitor *m, int tag)
|
||||
{
|
||||
#if BAR_ALTTAGSDECORATION_PATCH
|
||||
Client *c;
|
||||
#endif // BAR_ALTTAGSDECORATION_PATCH
|
||||
int tagindex = tag + NUMTAGS * m->num;
|
||||
if (tagindex >= LENGTH(tagicons[DEFAULT_TAGS]))
|
||||
tagindex = tagindex % LENGTH(tagicons[DEFAULT_TAGS]);
|
||||
#if BAR_ALTTAGSDECORATION_PATCH
|
||||
for (c = m->clients; c && (!(c->tags & 1 << tag) || HIDDEN(c)); c = c->next);
|
||||
if (c)
|
||||
return tagicons[ALT_TAGS_DECORATION][tagindex];
|
||||
#endif // BAR_ALTTAGSDECORATION_PATCH
|
||||
#if BAR_ALTERNATIVE_TAGS_PATCH
|
||||
if (m->alttag)
|
||||
return tagicons[ALTERNATIVE_TAGS][tagindex];
|
||||
#endif // BAR_ALTERNATIVE_TAGS_PATCH
|
||||
return tagicons[DEFAULT_TAGS][tagindex];
|
||||
}
|
||||
|
||||
|
|
|
|||
141
dwm/patch/bar_taglabels.c
Normal file
141
dwm/patch/bar_taglabels.c
Normal file
|
|
@ -0,0 +1,141 @@
|
|||
int
|
||||
width_taglabels(Bar *bar, BarArg *a)
|
||||
{
|
||||
int w, i;
|
||||
Client *c;
|
||||
Monitor *m = bar->mon;
|
||||
char *icon;
|
||||
unsigned int occ = 0;
|
||||
|
||||
for (c = m->clients; c; c = c->next)
|
||||
occ |= c->tags == 255 ? 0 : c->tags;
|
||||
|
||||
for (w = 0, i = 0; i < NUMTAGS; i++) {
|
||||
m->taglabel[i][0] = '\0';
|
||||
#if BAR_HIDEVACANTTAGS_PATCH
|
||||
if (!(occ & 1 << i || m->tagset[m->seltags] & 1 << i))
|
||||
continue;
|
||||
#endif // BAR_HIDEVACANTTAGS_PATCH
|
||||
icon = tagicon(m, i);
|
||||
XClassHint ch = { NULL, NULL };
|
||||
for (c = m->clients; c; c = c->next) {
|
||||
if (c->tags & (1 << i)) {
|
||||
XGetClassHint(dpy, c->win, &ch);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (ch.res_class) {
|
||||
if (lcaselbl)
|
||||
ch.res_class[0] = tolower(ch.res_class[0]);
|
||||
snprintf(m->taglabel[i], 64, ptagf, icon, ch.res_class);
|
||||
} else
|
||||
snprintf(m->taglabel[i], 64, etagf, icon);
|
||||
|
||||
w += TEXTW(m->taglabel[i]);
|
||||
}
|
||||
return w;
|
||||
}
|
||||
|
||||
int
|
||||
draw_taglabels(Bar *bar, BarArg *a)
|
||||
{
|
||||
int invert = 0;
|
||||
int w, x = a->x;
|
||||
unsigned int i, occ = 0, urg = 0;
|
||||
Client *c;
|
||||
Monitor *m = bar->mon;
|
||||
|
||||
for (c = m->clients; c; c = c->next)
|
||||
if (c->isurgent)
|
||||
urg |= c->tags;
|
||||
|
||||
for (i = 0; i < NUMTAGS; i++) {
|
||||
/* do not draw vacant tags */
|
||||
if (!m->taglabel[i][0])
|
||||
continue;
|
||||
drw_setscheme(drw, scheme[
|
||||
m->tagset[m->seltags] & 1 << i
|
||||
? SchemeTagsSel
|
||||
: urg & 1 << i
|
||||
? SchemeUrg
|
||||
: SchemeTagsNorm
|
||||
]);
|
||||
w = TEXTW(m->taglabel[i]);
|
||||
drw_text(drw, x, a->y, w, a->h, lrpad / 2, m->taglabel[i], invert, False);
|
||||
drawindicator(m, NULL, occ, x, a->y, w, a->h, i, -1, invert, tagindicatortype);
|
||||
#if BAR_UNDERLINETAGS_PATCH
|
||||
if (ulineall || m->tagset[m->seltags] & 1 << i)
|
||||
drw_rect(drw, x + ulinepad, a->y + bh - ulinestroke - ulinevoffset, w - (ulinepad * 2), ulinestroke, 1, 0);
|
||||
#endif // BAR_UNDERLINETAGS_PATCH
|
||||
x += w;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int
|
||||
click_taglabels(Bar *bar, Arg *arg, BarArg *a)
|
||||
{
|
||||
int i = 0, x = lrpad / 2;
|
||||
Monitor *m = bar->mon;
|
||||
|
||||
do {
|
||||
if (!m->taglabel[i][0])
|
||||
continue;
|
||||
x += TEXTW(m->taglabel[i]);
|
||||
} while (a->x >= x && ++i < NUMTAGS);
|
||||
if (i < NUMTAGS) {
|
||||
arg->ui = 1 << i;
|
||||
}
|
||||
#if BAR_TAGPREVIEW_PATCH
|
||||
if (selmon->previewshow != 0) {
|
||||
hidetagpreview(selmon);
|
||||
}
|
||||
#endif // BAR_TAGPREVIEW_PATCH
|
||||
return ClkTagBar;
|
||||
}
|
||||
|
||||
int
|
||||
hover_taglabels(Bar *bar, BarArg *a, XMotionEvent *ev)
|
||||
{
|
||||
#if BAR_TAGPREVIEW_PATCH
|
||||
int i = 0, x = lrpad / 2;
|
||||
int px, py;
|
||||
Monitor *m = bar->mon;
|
||||
#if VANITYGAPS_PATCH
|
||||
int ov = gappov;
|
||||
int oh = gappoh;
|
||||
#else
|
||||
int ov = 0;
|
||||
int oh = 0;
|
||||
#endif // VANITYGAPS_PATCH
|
||||
|
||||
do {
|
||||
if (!m->taglabel[i][0])
|
||||
continue;
|
||||
x += TEXTW(m->taglabel[i]);
|
||||
} while (a->x >= x && ++i < NUMTAGS);
|
||||
|
||||
if (i < NUMTAGS) {
|
||||
if ((i + 1) != selmon->previewshow && !(selmon->tagset[selmon->seltags] & 1 << i)) {
|
||||
if (bar->by > m->my + m->mh / 2) // bottom bar
|
||||
py = bar->by - m->mh / scalepreview - oh;
|
||||
else // top bar
|
||||
py = bar->by + bar->bh + oh;
|
||||
px = bar->bx + ev->x - m->mw / scalepreview / 2;
|
||||
if (px + m->mw / scalepreview > m->mx + m->mw)
|
||||
px = m->wx + m->ww - m->mw / scalepreview - ov;
|
||||
else if (px < bar->bx)
|
||||
px = m->wx + ov;
|
||||
selmon->previewshow = i + 1;
|
||||
showtagpreview(i, px, py);
|
||||
} else if (selmon->tagset[selmon->seltags] & 1 << i) {
|
||||
hidetagpreview(selmon);
|
||||
}
|
||||
} else if (selmon->previewshow != 0) {
|
||||
hidetagpreview(selmon);
|
||||
}
|
||||
#endif // BAR_TAGPREVIEW_PATCH
|
||||
|
||||
return 1;
|
||||
}
|
||||
6
dwm/patch/bar_taglabels.h
Normal file
6
dwm/patch/bar_taglabels.h
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
#include <ctype.h> /* for making tab label lowercase, very tiny standard library */
|
||||
|
||||
static int width_taglabels(Bar *bar, BarArg *a);
|
||||
static int draw_taglabels(Bar *bar, BarArg *a);
|
||||
static int click_taglabels(Bar *bar, Arg *arg, BarArg *a);
|
||||
static int hover_taglabels(Bar *bar, BarArg *a, XMotionEvent *ev);
|
||||
112
dwm/patch/bar_tagpreview.c
Normal file
112
dwm/patch/bar_tagpreview.c
Normal file
|
|
@ -0,0 +1,112 @@
|
|||
#include <Imlib2.h>
|
||||
|
||||
void
|
||||
createpreview(Monitor *m)
|
||||
{
|
||||
if (m->tagwin) {
|
||||
XMoveResizeWindow(
|
||||
dpy, m->tagwin,
|
||||
m->mx,
|
||||
m->bar->by + bh,
|
||||
m->mw / scalepreview,
|
||||
m->mh / scalepreview
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
XSetWindowAttributes wa = {
|
||||
.override_redirect = True,
|
||||
#if BAR_ALPHA_PATCH
|
||||
.background_pixel = 0,
|
||||
.border_pixel = 0,
|
||||
.colormap = cmap,
|
||||
#else
|
||||
.background_pixmap = ParentRelative,
|
||||
#endif // BAR_ALPHA_PATCH
|
||||
.event_mask = ButtonPressMask|ExposureMask
|
||||
};
|
||||
|
||||
m->tagwin = XCreateWindow(dpy, root, m->wx, m->bar->by + bh, m->mw / scalepreview, m->mh / scalepreview, 0,
|
||||
#if BAR_ALPHA_PATCH
|
||||
depth, CopyFromParent, visual,
|
||||
CWOverrideRedirect|CWBackPixel|CWBorderPixel|CWColormap|CWEventMask, &wa
|
||||
#else
|
||||
DefaultDepth(dpy, screen), CopyFromParent, DefaultVisual(dpy, screen),
|
||||
CWOverrideRedirect|CWBackPixmap|CWEventMask, &wa
|
||||
#endif // BAR_ALPHA_PATCH
|
||||
);
|
||||
XDefineCursor(dpy, m->tagwin, cursor[CurNormal]->cursor);
|
||||
XMapRaised(dpy, m->tagwin);
|
||||
XUnmapWindow(dpy, m->tagwin);
|
||||
}
|
||||
|
||||
void
|
||||
hidetagpreview(Monitor *m)
|
||||
{
|
||||
m->previewshow = 0;
|
||||
XUnmapWindow(dpy, m->tagwin);
|
||||
}
|
||||
|
||||
void
|
||||
showtagpreview(int tag, int x, int y)
|
||||
{
|
||||
Monitor *m = selmon;
|
||||
|
||||
if (!m->tagwin)
|
||||
return;
|
||||
|
||||
if (m->tagmap[tag]) {
|
||||
XSetWindowBackgroundPixmap(dpy, m->tagwin, m->tagmap[tag]);
|
||||
XCopyArea(dpy, m->tagmap[tag], m->tagwin, drw->gc, 0, 0, m->mw / scalepreview, m->mh / scalepreview, 0, 0);
|
||||
XMoveWindow(dpy, m->tagwin, x, y);
|
||||
XSync(dpy, False);
|
||||
XMapWindow(dpy, m->tagwin);
|
||||
} else
|
||||
XUnmapWindow(dpy, m->tagwin);
|
||||
}
|
||||
|
||||
void
|
||||
tagpreviewswitchtag(void)
|
||||
{
|
||||
int i;
|
||||
unsigned int occ = 0;
|
||||
Client *c;
|
||||
Imlib_Image image;
|
||||
Monitor *m = selmon;
|
||||
|
||||
if (!m->tagwin)
|
||||
createpreview(m);
|
||||
|
||||
for (c = m->clients; c; c = c->next)
|
||||
occ |= c->tags;
|
||||
for (i = 0; i < NUMTAGS; i++) {
|
||||
if (m->tagset[m->seltags] & 1 << i) {
|
||||
if (m->tagmap[i] != 0) {
|
||||
XFreePixmap(dpy, m->tagmap[i]);
|
||||
m->tagmap[i] = 0;
|
||||
}
|
||||
if (occ & 1 << i) {
|
||||
image = imlib_create_image(sw, sh);
|
||||
imlib_context_set_image(image);
|
||||
imlib_context_set_display(dpy);
|
||||
#if BAR_ALPHA_PATCH
|
||||
imlib_image_set_has_alpha(1);
|
||||
imlib_context_set_blend(0);
|
||||
imlib_context_set_visual(visual);
|
||||
#else
|
||||
imlib_context_set_visual(DefaultVisual(dpy, screen));
|
||||
#endif // BAR_ALPHA_PATCH
|
||||
imlib_context_set_drawable(root);
|
||||
imlib_copy_drawable_to_image(0, m->mx, m->my, m->mw ,m->mh, 0, 0, 1);
|
||||
#if BAR_ALPHA_PATCH
|
||||
m->tagmap[i] = XCreatePixmap(dpy, m->tagwin, m->mw / scalepreview, m->mh / scalepreview, depth);
|
||||
#else
|
||||
m->tagmap[i] = XCreatePixmap(dpy, m->tagwin, m->mw / scalepreview, m->mh / scalepreview, DefaultDepth(dpy, screen));
|
||||
#endif // BAR_ALPHA_PATCH
|
||||
imlib_context_set_drawable(m->tagmap[i]);
|
||||
imlib_render_image_part_on_drawable_at_size(0, 0, m->mw, m->mh, 0, 0, m->mw / scalepreview, m->mh / scalepreview);
|
||||
imlib_free_image();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
4
dwm/patch/bar_tagpreview.h
Normal file
4
dwm/patch/bar_tagpreview.h
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
static void createpreview(Monitor *m);
|
||||
static void hidetagpreview(Monitor *m);
|
||||
static void showtagpreview(int tag, int x, int y);
|
||||
static void tagpreviewswitchtag(void);
|
||||
|
|
@ -2,14 +2,18 @@ int
|
|||
width_tags(Bar *bar, BarArg *a)
|
||||
{
|
||||
int w, i;
|
||||
#if BAR_HIDEVACANTTAGS_PATCH
|
||||
Client *c;
|
||||
unsigned int occ = 0;
|
||||
for (c = bar->mon->clients; c; c = c->next)
|
||||
occ |= c->tags == 255 ? 0 : c->tags;
|
||||
#endif // BAR_HIDEVACANTTAGS_PATCH
|
||||
|
||||
for (w = 0, i = 0; i < NUMTAGS; i++) {
|
||||
#if BAR_HIDEVACANTTAGS_PATCH
|
||||
if (!(occ & 1 << i || bar->mon->tagset[bar->mon->seltags] & 1 << i))
|
||||
continue;
|
||||
#endif // BAR_HIDEVACANTTAGS_PATCH
|
||||
w += TEXTW(tagicon(bar->mon, i));
|
||||
}
|
||||
return w;
|
||||
|
|
@ -26,14 +30,20 @@ draw_tags(Bar *bar, BarArg *a)
|
|||
Monitor *m = bar->mon;
|
||||
|
||||
for (c = m->clients; c; c = c->next) {
|
||||
#if BAR_HIDEVACANTTAGS_PATCH
|
||||
occ |= c->tags == 255 ? 0 : c->tags;
|
||||
#else
|
||||
occ |= c->tags;
|
||||
#endif // BAR_HIDEVACANTTAGS_PATCH
|
||||
if (c->isurgent)
|
||||
urg |= c->tags;
|
||||
}
|
||||
for (i = 0; i < NUMTAGS; i++) {
|
||||
#if BAR_HIDEVACANTTAGS_PATCH
|
||||
/* do not draw vacant tags */
|
||||
if (!(occ & 1 << i || m->tagset[m->seltags] & 1 << i))
|
||||
continue;
|
||||
#endif // BAR_HIDEVACANTTAGS_PATCH
|
||||
|
||||
icon = tagicon(bar->mon, i);
|
||||
invert = 0;
|
||||
|
|
@ -47,6 +57,10 @@ draw_tags(Bar *bar, BarArg *a)
|
|||
]);
|
||||
drw_text(drw, x, a->y, w, a->h, lrpad / 2, icon, invert, False);
|
||||
drawindicator(m, NULL, occ, x, a->y, w, a->h, i, -1, invert, tagindicatortype);
|
||||
#if BAR_UNDERLINETAGS_PATCH
|
||||
if (ulineall || m->tagset[m->seltags] & 1 << i)
|
||||
drw_rect(drw, x + ulinepad, a->y + bh - ulinestroke - ulinevoffset, w - (ulinepad * 2), ulinestroke, 1, 0);
|
||||
#endif // BAR_UNDERLINETAGS_PATCH
|
||||
x += w;
|
||||
}
|
||||
|
||||
|
|
@ -57,25 +71,81 @@ int
|
|||
click_tags(Bar *bar, Arg *arg, BarArg *a)
|
||||
{
|
||||
int i = 0, x = 0;
|
||||
#if BAR_HIDEVACANTTAGS_PATCH
|
||||
Client *c;
|
||||
unsigned int occ = 0;
|
||||
for (c = bar->mon->clients; c; c = c->next)
|
||||
occ |= c->tags == 255 ? 0 : c->tags;
|
||||
#endif // BAR_HIDEVACANTTAGS_PATCH
|
||||
|
||||
do {
|
||||
#if BAR_HIDEVACANTTAGS_PATCH
|
||||
if (!(occ & 1 << i || bar->mon->tagset[bar->mon->seltags] & 1 << i))
|
||||
continue;
|
||||
#endif // BAR_HIDEVACANTTAGS_PATCH
|
||||
x += TEXTW(tagicon(bar->mon, i));
|
||||
} while (a->x >= x && ++i < NUMTAGS);
|
||||
if (i < NUMTAGS) {
|
||||
arg->ui = 1 << i;
|
||||
}
|
||||
#if BAR_TAGPREVIEW_PATCH
|
||||
if (selmon->previewshow != 0) {
|
||||
hidetagpreview(selmon);
|
||||
}
|
||||
#endif // BAR_TAGPREVIEW_PATCH
|
||||
return ClkTagBar;
|
||||
}
|
||||
|
||||
int
|
||||
hover_tags(Bar *bar, BarArg *a, XMotionEvent *ev)
|
||||
{
|
||||
#if BAR_TAGPREVIEW_PATCH
|
||||
int i = 0, x = lrpad / 2;
|
||||
int px, py;
|
||||
Monitor *m = bar->mon;
|
||||
#if VANITYGAPS_PATCH
|
||||
int ov = gappov;
|
||||
int oh = gappoh;
|
||||
#else
|
||||
int ov = 0;
|
||||
int oh = 0;
|
||||
#endif // VANITYGAPS_PATCH
|
||||
|
||||
#if BAR_HIDEVACANTTAGS_PATCH
|
||||
Client *c;
|
||||
unsigned int occ = 0;
|
||||
for (c = bar->mon->clients; c; c = c->next)
|
||||
occ |= c->tags == 255 ? 0 : c->tags;
|
||||
#endif // BAR_HIDEVACANTTAGS_PATCH
|
||||
|
||||
do {
|
||||
#if BAR_HIDEVACANTTAGS_PATCH
|
||||
if (!(occ & 1 << i || bar->mon->tagset[bar->mon->seltags] & 1 << i))
|
||||
continue;
|
||||
#endif // BAR_HIDEVACANTTAGS_PATCH
|
||||
x += TEXTW(tagicon(bar->mon, i));
|
||||
} while (a->x >= x && ++i < NUMTAGS);
|
||||
|
||||
if (i < NUMTAGS) {
|
||||
if ((i + 1) != selmon->previewshow && !(selmon->tagset[selmon->seltags] & 1 << i)) {
|
||||
if (bar->by > m->my + m->mh / 2) // bottom bar
|
||||
py = bar->by - m->mh / scalepreview - oh;
|
||||
else // top bar
|
||||
py = bar->by + bar->bh + oh;
|
||||
px = bar->bx + ev->x - m->mw / scalepreview / 2;
|
||||
if (px + m->mw / scalepreview > m->mx + m->mw)
|
||||
px = m->wx + m->ww - m->mw / scalepreview - ov;
|
||||
else if (px < bar->bx)
|
||||
px = m->wx + ov;
|
||||
selmon->previewshow = i + 1;
|
||||
showtagpreview(i, px, py);
|
||||
} else if (selmon->tagset[selmon->seltags] & 1 << i) {
|
||||
hidetagpreview(selmon);
|
||||
}
|
||||
} else if (selmon->previewshow != 0) {
|
||||
hidetagpreview(selmon);
|
||||
}
|
||||
#endif // BAR_TAGPREVIEW_PATCH
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
|
|
|||
69
dwm/patch/bar_vtcolors.c
Normal file
69
dwm/patch/bar_vtcolors.c
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
void
|
||||
get_vt_colors(void)
|
||||
{
|
||||
char *cfs[3] = {
|
||||
"/sys/module/vt/parameters/default_red",
|
||||
"/sys/module/vt/parameters/default_grn",
|
||||
"/sys/module/vt/parameters/default_blu",
|
||||
};
|
||||
char vtcs[16][8];
|
||||
char tk[] = ",";
|
||||
char cl[64];
|
||||
char *tp = NULL;
|
||||
FILE *fp;
|
||||
size_t r;
|
||||
int i, c, n, len;
|
||||
for (i = 0; i < 16; i++)
|
||||
strcpy(vtcs[i], "#000000");
|
||||
|
||||
for (i = 0, r = 0; i < 3; i++) {
|
||||
if ((fp = fopen(cfs[i], "r")) == NULL)
|
||||
continue;
|
||||
while ((cl[r] = fgetc(fp)) != EOF && cl[r] != '\n')
|
||||
r++;
|
||||
cl[r] = '\0';
|
||||
for (c = 0, tp = cl, n = 0; c < 16; c++, tp++) {
|
||||
if ((r = strcspn(tp, tk)) == -1)
|
||||
break;
|
||||
for (n = 0; r && *tp >= 48 && *tp < 58; r--, tp++)
|
||||
n = n * 10 - 48 + *tp;
|
||||
vtcs[c][i * 2 + 1] = n / 16 < 10 ? n / 16 + 48 : n / 16 + 87;
|
||||
vtcs[c][i * 2 + 2] = n % 16 < 10 ? n % 16 + 48 : n % 16 + 87;
|
||||
}
|
||||
fclose(fp);
|
||||
}
|
||||
|
||||
len = LENGTH(colors);
|
||||
if (len > LENGTH(color_ptrs))
|
||||
len = LENGTH(color_ptrs);
|
||||
for (i = 0; i < len; i++) {
|
||||
for (c = 0; c < ColCount; c++) {
|
||||
n = color_ptrs[i][c];
|
||||
if (n > -1 && strlen(colors[i][c]) >= strlen(vtcs[n]))
|
||||
memcpy(colors[i][c], vtcs[n], 7);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int get_luminance(char *r)
|
||||
{
|
||||
char *c = r;
|
||||
int n[3] = {0};
|
||||
int i = 0;
|
||||
|
||||
while (*c) {
|
||||
if (*c >= 48 && *c < 58)
|
||||
n[i / 2] = n[i / 2] * 16 - 48 + *c;
|
||||
else if (*c >= 65 && *c < 71)
|
||||
n[i / 2] = n[i / 2] * 16 - 55 + *c;
|
||||
else if (*c >= 97 && *c < 103)
|
||||
n[i / 2] = n[i / 2] * 16 - 87 + *c;
|
||||
else
|
||||
i--;
|
||||
i++;
|
||||
c++;
|
||||
}
|
||||
|
||||
return (0.299 * n[0] + 0.587 * n[1] + 0.114 * n[2]) / 2.55;
|
||||
}
|
||||
|
||||
3
dwm/patch/bar_vtcolors.h
Normal file
3
dwm/patch/bar_vtcolors.h
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
static void get_vt_colors(void);
|
||||
static int get_luminance(char *rgb);
|
||||
|
||||
145
dwm/patch/bar_winicon.c
Normal file
145
dwm/patch/bar_winicon.c
Normal file
|
|
@ -0,0 +1,145 @@
|
|||
static uint32_t prealpha(uint32_t p) {
|
||||
uint8_t a = p >> 24u;
|
||||
uint32_t rb = (a * (p & 0xFF00FFu)) >> 8u;
|
||||
uint32_t g = (a * (p & 0x00FF00u)) >> 8u;
|
||||
return (rb & 0xFF00FFu) | (g & 0x00FF00u) | (a << 24u);
|
||||
}
|
||||
|
||||
Picture
|
||||
geticonprop(Window win, unsigned int *picw, unsigned int *pich)
|
||||
{
|
||||
int format;
|
||||
unsigned long n, extra, *p = NULL;
|
||||
Atom real;
|
||||
|
||||
if (XGetWindowProperty(dpy, win, netatom[NetWMIcon], 0L, LONG_MAX, False, AnyPropertyType,
|
||||
&real, &format, &n, &extra, (unsigned char **)&p) != Success)
|
||||
return None;
|
||||
if (n == 0 || format != 32) { XFree(p); return None; }
|
||||
|
||||
unsigned long *bstp = NULL;
|
||||
uint32_t w, h, sz;
|
||||
{
|
||||
unsigned long *i; const unsigned long *end = p + n;
|
||||
uint32_t bstd = UINT32_MAX, d, m;
|
||||
for (i = p; i < end - 1; i += sz) {
|
||||
if ((w = *i++) >= 16384 || (h = *i++) >= 16384) { XFree(p); return None; }
|
||||
if ((sz = w * h) > end - i) break;
|
||||
if ((m = w > h ? w : h) >= ICONSIZE && (d = m - ICONSIZE) < bstd) { bstd = d; bstp = i; }
|
||||
}
|
||||
if (!bstp) {
|
||||
for (i = p; i < end - 1; i += sz) {
|
||||
if ((w = *i++) >= 16384 || (h = *i++) >= 16384) { XFree(p); return None; }
|
||||
if ((sz = w * h) > end - i) break;
|
||||
if ((d = ICONSIZE - (w > h ? w : h)) < bstd) { bstd = d; bstp = i; }
|
||||
}
|
||||
}
|
||||
if (!bstp) { XFree(p); return None; }
|
||||
}
|
||||
|
||||
if ((w = *(bstp - 2)) == 0 || (h = *(bstp - 1)) == 0) { XFree(p); return None; }
|
||||
|
||||
uint32_t icw, ich;
|
||||
if (w <= h) {
|
||||
ich = ICONSIZE; icw = w * ICONSIZE / h;
|
||||
if (icw == 0) icw = 1;
|
||||
}
|
||||
else {
|
||||
icw = ICONSIZE; ich = h * ICONSIZE / w;
|
||||
if (ich == 0) ich = 1;
|
||||
}
|
||||
*picw = icw; *pich = ich;
|
||||
|
||||
uint32_t i, *bstp32 = (uint32_t *)bstp;
|
||||
for (sz = w * h, i = 0; i < sz; ++i) bstp32[i] = prealpha(bstp[i]);
|
||||
|
||||
Picture ret = drw_picture_create_resized(drw, (char *)bstp, w, h, icw, ich);
|
||||
XFree(p);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
Picture
|
||||
drw_picture_create_resized(Drw *drw, char *src, unsigned int srcw, unsigned int srch, unsigned int dstw, unsigned int dsth) {
|
||||
Pixmap pm;
|
||||
Picture pic;
|
||||
GC gc;
|
||||
|
||||
if (srcw <= (dstw << 1u) && srch <= (dsth << 1u)) {
|
||||
XImage img = {
|
||||
srcw, srch, 0, ZPixmap, src,
|
||||
ImageByteOrder(drw->dpy), BitmapUnit(drw->dpy), BitmapBitOrder(drw->dpy), 32,
|
||||
32, 0, 32,
|
||||
0, 0, 0
|
||||
};
|
||||
XInitImage(&img);
|
||||
|
||||
pm = XCreatePixmap(drw->dpy, drw->root, srcw, srch, 32);
|
||||
gc = XCreateGC(drw->dpy, pm, 0, NULL);
|
||||
XPutImage(drw->dpy, pm, gc, &img, 0, 0, 0, 0, srcw, srch);
|
||||
XFreeGC(drw->dpy, gc);
|
||||
|
||||
pic = XRenderCreatePicture(drw->dpy, pm, XRenderFindStandardFormat(drw->dpy, PictStandardARGB32), 0, NULL);
|
||||
XFreePixmap(drw->dpy, pm);
|
||||
|
||||
XRenderSetPictureFilter(drw->dpy, pic, FilterBilinear, NULL, 0);
|
||||
XTransform xf;
|
||||
xf.matrix[0][0] = (srcw << 16u) / dstw; xf.matrix[0][1] = 0; xf.matrix[0][2] = 0;
|
||||
xf.matrix[1][0] = 0; xf.matrix[1][1] = (srch << 16u) / dsth; xf.matrix[1][2] = 0;
|
||||
xf.matrix[2][0] = 0; xf.matrix[2][1] = 0; xf.matrix[2][2] = 65536;
|
||||
XRenderSetPictureTransform(drw->dpy, pic, &xf);
|
||||
} else {
|
||||
Imlib_Image origin = imlib_create_image_using_data(srcw, srch, (DATA32 *)src);
|
||||
if (!origin) return None;
|
||||
imlib_context_set_image(origin);
|
||||
imlib_image_set_has_alpha(1);
|
||||
Imlib_Image scaled = imlib_create_cropped_scaled_image(0, 0, srcw, srch, dstw, dsth);
|
||||
imlib_free_image_and_decache();
|
||||
if (!scaled) return None;
|
||||
imlib_context_set_image(scaled);
|
||||
imlib_image_set_has_alpha(1);
|
||||
|
||||
XImage img = {
|
||||
dstw, dsth, 0, ZPixmap, (char *)imlib_image_get_data_for_reading_only(),
|
||||
ImageByteOrder(drw->dpy), BitmapUnit(drw->dpy), BitmapBitOrder(drw->dpy), 32,
|
||||
32, 0, 32,
|
||||
0, 0, 0
|
||||
};
|
||||
XInitImage(&img);
|
||||
|
||||
pm = XCreatePixmap(drw->dpy, drw->root, dstw, dsth, 32);
|
||||
gc = XCreateGC(drw->dpy, pm, 0, NULL);
|
||||
XPutImage(drw->dpy, pm, gc, &img, 0, 0, 0, 0, dstw, dsth);
|
||||
imlib_free_image_and_decache();
|
||||
XFreeGC(drw->dpy, gc);
|
||||
|
||||
pic = XRenderCreatePicture(drw->dpy, pm, XRenderFindStandardFormat(drw->dpy, PictStandardARGB32), 0, NULL);
|
||||
XFreePixmap(drw->dpy, pm);
|
||||
}
|
||||
|
||||
return pic;
|
||||
}
|
||||
|
||||
void
|
||||
drw_pic(Drw *drw, int x, int y, unsigned int w, unsigned int h, Picture pic)
|
||||
{
|
||||
if (!drw)
|
||||
return;
|
||||
XRenderComposite(drw->dpy, PictOpOver, pic, None, drw->picture, 0, 0, 0, 0, x, y, w, h);
|
||||
}
|
||||
|
||||
void
|
||||
freeicon(Client *c)
|
||||
{
|
||||
if (c->icon) {
|
||||
XRenderFreePicture(dpy, c->icon);
|
||||
c->icon = None;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
updateicon(Client *c)
|
||||
{
|
||||
freeicon(c);
|
||||
c->icon = geticonprop(c->win, &c->icw, &c->ich);
|
||||
}
|
||||
9
dwm/patch/bar_winicon.h
Normal file
9
dwm/patch/bar_winicon.h
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
#include <Imlib2.h>
|
||||
#include <limits.h>
|
||||
#include <stdint.h>
|
||||
|
||||
static Picture drw_picture_create_resized(Drw *drw, char *src, unsigned int src_w, unsigned int src_h, unsigned int dst_w, unsigned int dst_h);
|
||||
static void drw_pic(Drw *drw, int x, int y, unsigned int w, unsigned int h, Picture pic);
|
||||
static Picture geticonprop(Window w, unsigned int *icw, unsigned int *ich);
|
||||
static void freeicon(Client *c);
|
||||
static void updateicon(Client *c);
|
||||
|
|
@ -7,7 +7,15 @@ width_wintitle(Bar *bar, BarArg *a)
|
|||
int
|
||||
draw_wintitle(Bar *bar, BarArg *a)
|
||||
{
|
||||
#if BAR_TITLE_LEFT_PAD_PATCH && BAR_TITLE_RIGHT_PAD_PATCH
|
||||
int x = a->x + lrpad / 2, w = a->w - lrpad;
|
||||
#elif BAR_TITLE_LEFT_PAD_PATCH
|
||||
int x = a->x + lrpad / 2, w = a->w - lrpad / 2;
|
||||
#elif BAR_TITLE_RIGHT_PAD_PATCH
|
||||
int x = a->x, w = a->w - lrpad / 2;
|
||||
#else
|
||||
int x = a->x, w = a->w;
|
||||
#endif // BAR_TITLE_LEFT_PAD_PATCH | BAR_TITLE_RIGHT_PAD_PATCH
|
||||
Monitor *m = bar->mon;
|
||||
Client *c = m->sel;
|
||||
|
||||
|
|
@ -18,24 +26,56 @@ draw_wintitle(Bar *bar, BarArg *a)
|
|||
}
|
||||
|
||||
int tpad = lrpad / 2;
|
||||
#if BAR_WINICON_PATCH
|
||||
int ipad = c->icon ? c->icw + ICONSPACING : 0;
|
||||
#endif // BAR_WINICON_PATCH
|
||||
#if BAR_CENTEREDWINDOWNAME_PATCH
|
||||
int cpad = 0;
|
||||
#endif // BAR_CENTEREDWINDOWNAME_PATCH
|
||||
int tx = x;
|
||||
int tw = w;
|
||||
|
||||
drw_setscheme(drw, scheme[m == selmon ? SchemeTitleSel : SchemeTitleNorm]);
|
||||
#if BAR_IGNORE_XFT_ERRORS_WHEN_DRAWING_TEXT_PATCH
|
||||
XSetErrorHandler(xerrordummy);
|
||||
#endif // BAR_IGNORE_XFT_ERRORS_WHEN_DRAWING_TEXT_PATCH
|
||||
|
||||
if (w <= TEXTW("A") - lrpad + tpad) // reduce text padding if wintitle is too small
|
||||
tpad = (w - TEXTW("A") + lrpad < 0 ? 0 : (w - TEXTW("A") + lrpad) / 2);
|
||||
#if BAR_WINICON_PATCH && BAR_CENTEREDWINDOWNAME_PATCH
|
||||
else if (TEXTW(c->name) + ipad < w)
|
||||
cpad = (w - TEXTW(c->name) - ipad) / 2;
|
||||
#elif BAR_CENTEREDWINDOWNAME_PATCH
|
||||
else if (TEXTW(c->name) < w)
|
||||
cpad = (w - TEXTW(c->name)) / 2;
|
||||
#endif // BAR_CENTEREDWINDOWNAME_PATCH
|
||||
|
||||
XSetForeground(drw->dpy, drw->gc, drw->scheme[ColBg].pixel);
|
||||
XFillRectangle(drw->dpy, drw->drawable, drw->gc, x, a->y, w, a->h);
|
||||
|
||||
#if BAR_CENTEREDWINDOWNAME_PATCH
|
||||
/* Apply center padding, if any */
|
||||
tx += cpad;
|
||||
tw -= cpad;
|
||||
#endif // BAR_CENTEREDWINDOWNAME_PATCH
|
||||
|
||||
tx += tpad;
|
||||
tw -= lrpad;
|
||||
|
||||
#if BAR_WINICON_PATCH
|
||||
if (ipad) {
|
||||
drw_pic(drw, tx, a->y + (a->h - c->ich) / 2, c->icw, c->ich, c->icon);
|
||||
tx += ipad;
|
||||
tw -= ipad;
|
||||
}
|
||||
#endif // BAR_WINICON_PATCH
|
||||
|
||||
drw_text(drw, tx, a->y, tw, a->h, 0, c->name, 0, False);
|
||||
|
||||
#if BAR_IGNORE_XFT_ERRORS_WHEN_DRAWING_TEXT_PATCH
|
||||
XSync(dpy, False);
|
||||
XSetErrorHandler(xerror);
|
||||
#endif // BAR_IGNORE_XFT_ERRORS_WHEN_DRAWING_TEXT_PATCH
|
||||
drawstateindicator(m, c, 1, x, a->y, w, a->h, 0, 0, c->isfixed);
|
||||
return 1;
|
||||
}
|
||||
|
|
|
|||
46
dwm/patch/bar_wintitle_floating.c
Normal file
46
dwm/patch/bar_wintitle_floating.c
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
int
|
||||
width_wintitle_floating(Bar *bar, BarArg *a)
|
||||
{
|
||||
return a->w;
|
||||
}
|
||||
|
||||
int
|
||||
draw_wintitle_floating(Bar *bar, BarArg *a)
|
||||
{
|
||||
drw_rect(drw, a->x, a->y, a->w, a->h, 1, 1);
|
||||
return calc_wintitle_floating(bar->mon, a->x, a->w, -1, flextitledraw, NULL, a);
|
||||
}
|
||||
|
||||
int
|
||||
click_wintitle_floating(Bar *bar, Arg *arg, BarArg *a)
|
||||
{
|
||||
calc_wintitle_floating(bar->mon, 0, a->w, a->x, flextitleclick, arg, a);
|
||||
return ClkWinTitle;
|
||||
}
|
||||
|
||||
int
|
||||
calc_wintitle_floating(
|
||||
Monitor *m, int offx, int tabw, int passx,
|
||||
void(*tabfn)(Monitor *, Client *, int, int, int, int, Arg *arg, BarArg *barg),
|
||||
Arg *arg, BarArg *barg
|
||||
) {
|
||||
Client *c;
|
||||
int clientsnfloating = 0, w, r;
|
||||
int groupactive = GRP_FLOAT;
|
||||
|
||||
for (c = m->clients; c; c = c->next) {
|
||||
if (!ISVISIBLE(c) || HIDDEN(c))
|
||||
continue;
|
||||
if (c->isfloating)
|
||||
clientsnfloating++;
|
||||
}
|
||||
|
||||
if (!clientsnfloating)
|
||||
return 0;
|
||||
|
||||
w = tabw / clientsnfloating;
|
||||
r = tabw % clientsnfloating;
|
||||
c = flextitledrawarea(m, m->clients, offx, r, w, clientsnfloating, SCHEMEFOR(GRP_FLOAT), 0, 0, 1, passx, tabfn, arg, barg);
|
||||
return 1;
|
||||
}
|
||||
|
||||
9
dwm/patch/bar_wintitle_floating.h
Normal file
9
dwm/patch/bar_wintitle_floating.h
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
static int width_wintitle_floating(Bar *bar, BarArg *a);
|
||||
static int draw_wintitle_floating(Bar *bar, BarArg *a);
|
||||
static int click_wintitle_floating(Bar *bar, Arg *arg, BarArg *a);
|
||||
static int calc_wintitle_floating(
|
||||
Monitor *m, int offx, int tabw, int passx,
|
||||
void(*tabfn)(Monitor *, Client *, int, int, int, int, Arg *arg, BarArg *barg),
|
||||
Arg *arg, BarArg *barg
|
||||
);
|
||||
|
||||
46
dwm/patch/bar_wintitle_hidden.c
Normal file
46
dwm/patch/bar_wintitle_hidden.c
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
int
|
||||
width_wintitle_hidden(Bar *bar, BarArg *a)
|
||||
{
|
||||
return a->w;
|
||||
}
|
||||
|
||||
int
|
||||
draw_wintitle_hidden(Bar *bar, BarArg *a)
|
||||
{
|
||||
drw_rect(drw, a->x, a->y, a->w, a->h, 1, 1);
|
||||
return calc_wintitle_hidden(bar->mon, a->x, a->w, -1, flextitledraw, NULL, a);
|
||||
}
|
||||
|
||||
int
|
||||
click_wintitle_hidden(Bar *bar, Arg *arg, BarArg *a)
|
||||
{
|
||||
calc_wintitle_hidden(bar->mon, 0, a->w, a->x, flextitleclick, arg, a);
|
||||
return ClkWinTitle;
|
||||
}
|
||||
|
||||
int
|
||||
calc_wintitle_hidden(
|
||||
Monitor *m, int offx, int tabw, int passx,
|
||||
void(*tabfn)(Monitor *, Client *, int, int, int, int, Arg *arg, BarArg *barg),
|
||||
Arg *arg, BarArg *barg
|
||||
) {
|
||||
Client *c;
|
||||
int clientsnhidden = 0, w, r;
|
||||
int groupactive = GRP_HIDDEN;
|
||||
|
||||
for (c = m->clients; c; c = c->next) {
|
||||
if (!ISVISIBLE(c))
|
||||
continue;
|
||||
if (HIDDEN(c))
|
||||
clientsnhidden++;
|
||||
}
|
||||
|
||||
if (!clientsnhidden)
|
||||
return 0;
|
||||
|
||||
w = tabw / clientsnhidden;
|
||||
r = tabw % clientsnhidden;
|
||||
c = flextitledrawarea(m, m->clients, offx, r, w, clientsnhidden, SCHEMEFOR(GRP_HIDDEN), 0, 1, 0, passx, tabfn, arg, barg);
|
||||
return 1;
|
||||
}
|
||||
|
||||
9
dwm/patch/bar_wintitle_hidden.h
Normal file
9
dwm/patch/bar_wintitle_hidden.h
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
static int width_wintitle_hidden(Bar *bar, BarArg *a);
|
||||
static int draw_wintitle_hidden(Bar *bar, BarArg *a);
|
||||
static int click_wintitle_hidden(Bar *bar, Arg *arg, BarArg *a);
|
||||
static int calc_wintitle_hidden(
|
||||
Monitor *m, int offx, int tabw, int passx,
|
||||
void(*tabfn)(Monitor *, Client *, int, int, int, int, Arg *arg, BarArg *barg),
|
||||
Arg *arg, BarArg *barg
|
||||
);
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue