@ -0,0 +1,20 @@ | |||
pre,textarea,body,input,td,tr,p { | |||
background-color: black !important; | |||
background-image: none !important; | |||
color: #e0e0e0 !important; | |||
} | |||
div { | |||
background-color: #202020 !important; | |||
background-image: none !important; | |||
color: #e0e0e0 !important; | |||
} | |||
h1,h2,h3,h4 { | |||
background-color: black !important; | |||
color: #e02020 !important; | |||
} | |||
a { | |||
color: #5050f0 !important; | |||
} |
@ -1,2 +0,0 @@ | |||
#!/bin/bash | |||
@ -1,33 +0,0 @@ | |||
/* See LICENSE file for copyright and license details. */ | |||
#include <X11/XF86keysym.h> | |||
/* appearance */ | |||
static const int rmaster = 0; /* 1 = master at right*/ | |||
static const unsigned int systraypinning = 0; /* 0: sloppy systray follows selected monitor, >0: pin systray to monitor X */ | |||
static const unsigned int systrayspacing = 2; /* systray spacing */ | |||
static const int systraypinningfailfirst = 1; /* 1: if pinning fails, display systray on the first monitor, False: display systray on the last monitor*/ | |||
static const int showsystray = 1; /* 0 means no systray */ | |||
static const int tag_padding = 0; | |||
static const int vertpad = 0; /* vertical padding of bar */ | |||
static const int sidepad = 0; /* horizontal padding of bar */ | |||
/* tagging */ | |||
static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9", "0"}; | |||
//static const char *alttags[] = { "", "", "", ""}; | |||
/* layout(s) */ | |||
static const float mfact = 0.5; /* factor of master area size [0.05..0.95] */ | |||
static const int nmaster = 1; /* number of clients in master area */ | |||
static const int resizehints = 0; /* 1 means respect size hints in tiled resizals */ | |||
static const Layout layouts[] = { | |||
/* symbol arrange function */ | |||
{ "鉶", tile }, /* first entry is default */ | |||
/* { "", dwindle }, */ | |||
{ "ﱖ", grid }, | |||
{ "", centeredmaster }, | |||
{ "", centeredfloatingmaster }, | |||
{ "[M]", monocle }, | |||
{ "[D]", deck }, | |||
{ NULL, NULL }, | |||
}; |
@ -0,0 +1,229 @@ | |||
/* See LICENSE file for copyright and license details. */ | |||
typedef struct { | |||
const char *name; | |||
const void *cmd; | |||
} Sp; | |||
/* appearance */ | |||
static const unsigned int borderpx = 1; /* border pixel of windows */ | |||
static const unsigned int snap = 32; /* snap pixel */ | |||
static const unsigned int gappih = 20; /* horiz inner gap between windows */ | |||
static const unsigned int gappiv = 10; /* vert inner gap between windows */ | |||
static const unsigned int gappoh = 10; /* horiz outer gap between windows and screen edge */ | |||
static const unsigned int gappov = 30; /* vert outer gap between windows and screen edge */ | |||
static int smartgaps = 0; /* 1 means no outer gap when there is only one window */ | |||
static const int showbar = 1; /* 0 means no bar */ | |||
static const int topbar = 1; /* 0 means bottom bar */ | |||
static const int user_bh = 0; /* 0 means that dwm will calculate bar height, >= 1 means dwm will user_bh as bar height */ | |||
static const int horizpadbar = 2; /* horizontal padding for statusbar */ | |||
static const int vertpadbar = 0; /* vertical padding for statusbar */ | |||
static const int vertpad = 10; /* vertical padding of bar */ | |||
static const int sidepad = 10; /* horizontal padding of bar */ | |||
static int floatposgrid_x = 5; /* float grid columns */ | |||
static int floatposgrid_y = 5; /* float grid rows */ | |||
static const char *fonts[] = { "CaskaydiaCove Nerd Font:size=10" }; | |||
static const char dmenufont[] = "monospace:size=10"; | |||
static const char col_gray1[] = "#222222"; | |||
static const char col_gray2[] = "#444444"; | |||
static const char col_gray3[] = "#bbbbbb"; | |||
static const char col_gray4[] = "#eeeeee"; | |||
static const char col_cyan[] = "#005577"; | |||
static const char *colors[][3] = { | |||
/* fg bg border */ | |||
[SchemeNorm] = { col_gray3, col_gray1, col_gray2 }, | |||
[SchemeSel] = { col_gray4, col_cyan, col_cyan }, | |||
[SchemeStatus] = { col_gray3, col_gray1, "#000000" }, // Statusbar right {text,background,not used but cannot be empty} | |||
[SchemeTagsSel] = { col_gray4, col_cyan, "#000000" }, // Tagbar left selected {text,background,not used but cannot be empty} | |||
[SchemeTagsNorm] = { col_gray3, col_gray1, "#000000" }, // Tagbar left unselected {text,background,not used but cannot be empty} | |||
[SchemeInfoSel] = { col_gray4, col_cyan, "#000000" }, // infobar middle selected {text,background,not used but cannot be empty} | |||
[SchemeInfoNorm] = { col_gray3, col_gray1, "#000000" }, // infobar middle unselected {text,background,not used but cannot be empty} | |||
}; | |||
/* tagging */ | |||
static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" }; | |||
static const Rule rules[] = { | |||
/* xprop(1): | |||
* WM_CLASS(STRING) = instance, class | |||
* WM_NAME(STRING) = title | |||
*/ | |||
/* class instance title tags mask isfloating floatpos monitor */ | |||
{ "Gimp", NULL, NULL, 0, 1, NULL, -1 }, | |||
{ "Firefox", NULL, NULL, 1 << 8, 0, NULL, -1 }, | |||
}; | |||
/* layout(s) */ | |||
static const float mfact = 0.55; /* factor of master area size [0.05..0.95] */ | |||
static const int nmaster = 1; /* number of clients in master area */ | |||
static const int resizehints = 0; /* 1 means respect size hints in tiled resizals */ | |||
#define FORCE_VSPLIT 1 /* nrowgrid layout: force two clients to always split vertically */ | |||
#include "vanitygaps.c" | |||
static const Layout layouts[] = { | |||
/* symbol arrange function */ | |||
{ "[]=", tile }, /* first entry is default */ | |||
{ "[M]", monocle }, | |||
{ "[@]", spiral }, | |||
{ "[\\]", dwindle }, | |||
{ "H[]", deck }, | |||
{ "TTT", bstack }, | |||
{ "===", bstackhoriz }, | |||
{ "HHH", grid }, | |||
{ "###", nrowgrid }, | |||
{ "---", horizgrid }, | |||
{ ":::", gaplessgrid }, | |||
{ "|M|", centeredmaster }, | |||
{ ">M>", centeredfloatingmaster }, | |||
{ "><>", NULL }, /* no layout function means floating behavior */ | |||
{ NULL, NULL }, | |||
}; | |||
/* key definitions */ | |||
#define MODKEY Mod4Mask | |||
#define TAGKEYS(KEY,TAG) \ | |||
{ MODKEY, KEY, view, {.ui = 1 << TAG} }, \ | |||
{ MODKEY|ControlMask, KEY, toggleview, {.ui = 1 << TAG} }, \ | |||
{ MODKEY|ShiftMask, KEY, tag, {.ui = 1 << TAG} }, \ | |||
{ MODKEY|ControlMask|ShiftMask, KEY, toggletag, {.ui = 1 << TAG} }, | |||
/* helper for spawning shell commands in the pre dwm-5.0 fashion */ | |||
#define SHCMD(cmd) { .v = (const char*[]){ "/bin/sh", "-c", cmd, NULL } } | |||
#define STATUSBAR "dwmblocks" | |||
/* commands */ | |||
static char dmenumon[2] = "0"; /* component of dmenucmd, manipulated in spawn() */ | |||
static const char *dmenucmd[] = { "dmenu_run", NULL }; | |||
static const char *termcmd[] = { "st", NULL }; | |||
static const char *layoutmenu_cmd = "layoutmenu.sh"; | |||
const char *spcmd1[] = {"st", "-n", "spterm", "-g", "120x34", NULL }; | |||
const char *spcmd2[] = {"st", "-n", "spfm", "-g", "144x41", "-e", "ranger", NULL }; | |||
const char *spcmd3[] = {"keepassxc", NULL }; | |||
static Sp scratchpads[] = { | |||
/* name cmd */ | |||
{"spterm", spcmd1}, | |||
{"spranger", spcmd2}, | |||
{"keepassxc", spcmd3}, | |||
}; | |||
#include "movestack.c" | |||
static Key keys[] = { | |||
/* modifier key function argument */ | |||
{ MODKEY, XK_d, spawn, {.v = dmenucmd } }, | |||
{ MODKEY, XK_Return, spawn, {.v = termcmd } }, | |||
{ MODKEY, XK_b, togglebar, {0} }, | |||
{ MODKEY, XK_j, focusstack, {.i = +1 } }, | |||
{ MODKEY, XK_k, focusstack, {.i = -1 } }, | |||
{ MODKEY, XK_i, incnmaster, {.i = +1 } }, | |||
{ MODKEY, XK_d, incnmaster, {.i = -1 } }, | |||
{ MODKEY, XK_h, setmfact, {.f = -0.05} }, | |||
{ MODKEY, XK_l, setmfact, {.f = +0.05} }, | |||
{ MODKEY|ShiftMask, XK_j, movestack, {.i = +1 } }, | |||
{ MODKEY|ShiftMask, XK_k, movestack, {.i = -1 } }, | |||
{ MODKEY, XK_Return, zoom, {0} }, | |||
{ MODKEY|Mod4Mask, XK_u, incrgaps, {.i = +1 } }, | |||
{ MODKEY|Mod4Mask|ShiftMask, XK_u, incrgaps, {.i = -1 } }, | |||
{ MODKEY|Mod4Mask, XK_i, incrigaps, {.i = +1 } }, | |||
{ MODKEY|Mod4Mask|ShiftMask, XK_i, incrigaps, {.i = -1 } }, | |||
{ MODKEY|Mod4Mask, XK_o, incrogaps, {.i = +1 } }, | |||
{ MODKEY|Mod4Mask|ShiftMask, XK_o, incrogaps, {.i = -1 } }, | |||
{ MODKEY|Mod4Mask, XK_6, incrihgaps, {.i = +1 } }, | |||
{ MODKEY|Mod4Mask|ShiftMask, XK_6, incrihgaps, {.i = -1 } }, | |||
{ MODKEY|Mod4Mask, XK_7, incrivgaps, {.i = +1 } }, | |||
{ MODKEY|Mod4Mask|ShiftMask, XK_7, incrivgaps, {.i = -1 } }, | |||
{ MODKEY|Mod4Mask, XK_8, incrohgaps, {.i = +1 } }, | |||
{ MODKEY|Mod4Mask|ShiftMask, XK_8, incrohgaps, {.i = -1 } }, | |||
{ MODKEY|Mod4Mask, XK_9, incrovgaps, {.i = +1 } }, | |||
{ MODKEY|Mod4Mask|ShiftMask, XK_9, incrovgaps, {.i = -1 } }, | |||
{ MODKEY|Mod4Mask, XK_0, togglegaps, {0} }, | |||
{ MODKEY|Mod4Mask|ShiftMask, XK_0, defaultgaps, {0} }, | |||
{ MODKEY, XK_Tab, view, {0} }, | |||
{ MODKEY, XK_q, killclient, {0} }, | |||
{ MODKEY, XK_t, setlayout, {.v = &layouts[0]} }, | |||
{ MODKEY, XK_f, setlayout, {.v = &layouts[1]} }, | |||
{ MODKEY, XK_m, setlayout, {.v = &layouts[2]} }, | |||
{ MODKEY|ControlMask, XK_comma, cyclelayout, {.i = -1 } }, | |||
{ MODKEY|ControlMask, XK_period, cyclelayout, {.i = +1 } }, | |||
{ MODKEY, XK_space, setlayout, {0} }, | |||
{ MODKEY|ShiftMask, XK_space, togglefloating, {0} }, | |||
{ MODKEY|ShiftMask, XK_f, togglefullscr, {0} }, | |||
{ MODKEY, XK_0, view, {.ui = ~0 } }, | |||
{ MODKEY|ShiftMask, XK_0, tag, {.ui = ~0 } }, | |||
{ MODKEY, XK_comma, focusmon, {.i = -1 } }, | |||
{ MODKEY, XK_period, focusmon, {.i = +1 } }, | |||
{ MODKEY|ShiftMask, XK_comma, tagmon, {.i = -1 } }, | |||
{ MODKEY|ShiftMask, XK_period, tagmon, {.i = +1 } }, | |||
/* Client position is limited to monitor window area */ | |||
{ Mod4Mask, XK_u, floatpos, {.v = "-26x -26y" } }, // ↖ | |||
{ Mod4Mask, XK_i, floatpos, {.v = " 0x -26y" } }, // ↑ | |||
{ Mod4Mask, XK_o, floatpos, {.v = " 26x -26y" } }, // ↗ | |||
{ Mod4Mask, XK_j, floatpos, {.v = "-26x 0y" } }, // ← | |||
{ Mod4Mask, XK_l, floatpos, {.v = " 26x 0y" } }, // → | |||
{ Mod4Mask, XK_m, floatpos, {.v = "-26x 26y" } }, // ↙ | |||
{ Mod4Mask, XK_comma, floatpos, {.v = " 0x 26y" } }, // ↓ | |||
{ Mod4Mask, XK_period, floatpos, {.v = " 26x 26y" } }, // ↘ | |||
/* Absolute positioning (allows moving windows between monitors) */ | |||
{ Mod4Mask|ControlMask, XK_u, floatpos, {.v = "-26a -26a" } }, // ↖ | |||
{ Mod4Mask|ControlMask, XK_i, floatpos, {.v = " 0a -26a" } }, // ↑ | |||
{ Mod4Mask|ControlMask, XK_o, floatpos, {.v = " 26a -26a" } }, // ↗ | |||
{ Mod4Mask|ControlMask, XK_j, floatpos, {.v = "-26a 0a" } }, // ← | |||
{ Mod4Mask|ControlMask, XK_l, floatpos, {.v = " 26a 0a" } }, // → | |||
{ Mod4Mask|ControlMask, XK_m, floatpos, {.v = "-26a 26a" } }, // ↙ | |||
{ Mod4Mask|ControlMask, XK_comma, floatpos, {.v = " 0a 26a" } }, // ↓ | |||
{ Mod4Mask|ControlMask, XK_period, floatpos, {.v = " 26a 26a" } }, // ↘ | |||
/* Resize client, client center position is fixed which means that client expands in all directions */ | |||
{ Mod4Mask|ShiftMask, XK_u, floatpos, {.v = "-26w -26h" } }, // ↖ | |||
{ Mod4Mask|ShiftMask, XK_i, floatpos, {.v = " 0w -26h" } }, // ↑ | |||
{ Mod4Mask|ShiftMask, XK_o, floatpos, {.v = " 26w -26h" } }, // ↗ | |||
{ Mod4Mask|ShiftMask, XK_j, floatpos, {.v = "-26w 0h" } }, // ← | |||
{ Mod4Mask|ShiftMask, XK_k, floatpos, {.v = "800W 800H" } }, // · | |||
{ Mod4Mask|ShiftMask, XK_l, floatpos, {.v = " 26w 0h" } }, // → | |||
{ Mod4Mask|ShiftMask, XK_m, floatpos, {.v = "-26w 26h" } }, // ↙ | |||
{ Mod4Mask|ShiftMask, XK_comma, floatpos, {.v = " 0w 26h" } }, // ↓ | |||
{ Mod4Mask|ShiftMask, XK_period, floatpos, {.v = " 26w 26h" } }, // ↘ | |||
/* Client is positioned in a floating grid, movement is relative to client's current position */ | |||
{ Mod4Mask|Mod1Mask, XK_u, floatpos, {.v = "-1p -1p" } }, // ↖ | |||
{ Mod4Mask|Mod1Mask, XK_i, floatpos, {.v = " 0p -1p" } }, // ↑ | |||
{ Mod4Mask|Mod1Mask, XK_o, floatpos, {.v = " 1p -1p" } }, // ↗ | |||
{ Mod4Mask|Mod1Mask, XK_j, floatpos, {.v = "-1p 0p" } }, // ← | |||
{ Mod4Mask|Mod1Mask, XK_k, floatpos, {.v = " 0p 0p" } }, // · | |||
{ Mod4Mask|Mod1Mask, XK_l, floatpos, {.v = " 1p 0p" } }, // → | |||
{ Mod4Mask|Mod1Mask, XK_m, floatpos, {.v = "-1p 1p" } }, // ↙ | |||
{ Mod4Mask|Mod1Mask, XK_comma, floatpos, {.v = " 0p 1p" } }, // ↓ | |||
{ Mod4Mask|Mod1Mask, XK_period, floatpos, {.v = " 1p 1p" } }, // ↘ | |||
TAGKEYS( XK_1, 0) | |||
TAGKEYS( XK_2, 1) | |||
TAGKEYS( XK_3, 2) | |||
TAGKEYS( XK_4, 3) | |||
TAGKEYS( XK_5, 4) | |||
TAGKEYS( XK_6, 5) | |||
TAGKEYS( XK_7, 6) | |||
TAGKEYS( XK_8, 7) | |||
TAGKEYS( XK_9, 8) | |||
{ MODKEY|ShiftMask, XK_q, quit, {0} }, | |||
}; | |||
/* button definitions */ | |||
/* click can be ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle, ClkClientWin, or ClkRootWin */ | |||
static Button buttons[] = { | |||
/* click event mask button function argument */ | |||
{ ClkLtSymbol, 0, Button1, setlayout, {0} }, | |||
{ ClkLtSymbol, 0, Button3, layoutmenu, {0} }, | |||
{ ClkStatusText, 0, Button1, sigdwmblocks, {.i = 1} }, | |||
{ ClkStatusText, 0, Button2, sigdwmblocks, {.i = 2} }, | |||
{ ClkStatusText, 0, Button3, sigdwmblocks, {.i = 3} }, | |||
{ ClkClientWin, MODKEY, Button1, movemouse, {0} }, | |||
{ ClkClientWin, MODKEY, Button2, togglefloating, {0} }, | |||
{ ClkClientWin, MODKEY, Button3, resizemouse, {0} }, | |||
{ ClkTagBar, 0, Button1, view, {0} }, | |||
{ ClkTagBar, 0, Button3, toggleview, {0} }, | |||
{ ClkTagBar, MODKEY, Button1, tag, {0} }, | |||
{ ClkTagBar, MODKEY, Button3, toggletag, {0} }, | |||
}; | |||
@ -1,345 +0,0 @@ | |||
#!/bin/bash | |||
KEEP_FILES=0 | |||
ECHO_COMMANDS=0 | |||
RUN_SCRIPT=0 | |||
DIRECTORY=. | |||
OUTPUT_DIRECTORY= | |||
KEEP_GITFILES=0 | |||
DEBUG=0 | |||
if [[ $# = 0 ]]; then | |||
set -- '-h' | |||
fi | |||
while (( $# )); do | |||
case "$1" in | |||
-d|--directory) | |||
shift | |||
DIRECTORY=$1 # source directory | |||
shift | |||
;; | |||
-o|--output) | |||
shift | |||
OUTPUT_DIRECTORY=$1 | |||
shift | |||
;; | |||
--debug) | |||
shift | |||
DEBUG=1 | |||
;; | |||
-r|--run) | |||
shift | |||
RUN_SCRIPT=1 | |||
;; | |||
-e|--echo) | |||
shift | |||
ECHO_COMMANDS=1 | |||
;; | |||
-k|--keep) | |||
shift | |||
KEEP_FILES=1 | |||
;; | |||
-g|--git) | |||
shift | |||
KEEP_GITFILES=1 | |||
;; | |||
-h|--help) | |||
shift | |||
fmt=" %-31s%s\n" | |||
printf "%s" "Usage: $(basename ${BASH_SOURCE[0]}) [OPTION?]" | |||
printf "\n" | |||
printf "\nThis is a custom pre-processor designed to remove unused flexipatch patches and create a final build." | |||
printf "\n\n" | |||
printf "$fmt" "-r, --run" "include this flag to confirm that you really do want to run this script" | |||
printf "\n" | |||
printf "$fmt" "-d, --directory <dir>" "the flexipatch source directory to process (defaults to current directory)" | |||
printf "$fmt" "-o, --output <dir>" "the output directory to store the processed files" | |||
printf "$fmt" "-h, --help" "display this help section" | |||
printf "$fmt" "-k, --keep" "keep temporary files and do not replace the original ones" | |||
printf "$fmt" "-g, --git" "keep .git files" | |||
printf "$fmt" "-e, --echo" "echo commands that will be run rather than running them" | |||
printf "$fmt" " --debug" "prints additional debug information to stderr" | |||
printf "\nWarning! This script alters and removes files within the source directory." | |||
printf "\nWarning! This process is irreversible! Use with care. Do make a backup before running this." | |||
printf "\n\n" | |||
exit | |||
;; | |||
*) | |||
echo "Ignoring unknown argument ($1)" | |||
shift | |||
;; | |||
esac | |||
done | |||
if [[ $RUN_SCRIPT = 0 ]]; then | |||
echo "Re-run this command with the --run option to confirm that you really want to run this script." | |||
echo "The changes this script makes are irreversible." | |||
exit 1 | |||
fi | |||
if [[ -z ${OUTPUT_DIRECTORY} ]]; then | |||
echo "Output directory not specified, see -o" | |||
exit 1 | |||
fi | |||
DIRECTORY=$(readlink -f "${DIRECTORY}") | |||
OUTPUT_DIRECTORY=$(readlink -f "${OUTPUT_DIRECTORY}") | |||
if [[ $DIRECTORY != $OUTPUT_DIRECTORY ]]; then | |||
mkdir -p "${OUTPUT_DIRECTORY}" | |||
cp -r -f "${DIRECTORY}/." -t "${OUTPUT_DIRECTORY}" | |||
DIRECTORY=${OUTPUT_DIRECTORY} | |||
fi | |||
if [[ ! -e ${DIRECTORY}/patches.h ]]; then | |||
printf "No patches.h file found. Make sure you run this script within a flexipatch source directory." | |||
exit 1 | |||
fi | |||
FILES_TO_DELETE=$(find $DIRECTORY -name "*.c" -o -name "*.h" | awk -v DEBUG="$DEBUG" -v DIRECTORY="$DIRECTORY" ' | |||
function istrue(f) { | |||
ret = 0 | |||
for ( i = 2; i in f; i++ ) { | |||
if ( f[i] == "||" ) { | |||
if ( ret == -1 ) { | |||
ret = 0 | |||
} else if ( ret == 1 ) { | |||
break | |||
} | |||
continue | |||
} else if ( f[i] == "&&" ) { | |||
if ( ret == 0 ) { | |||
ret = -1 | |||
} | |||
continue | |||
} else if ( ret == -1 ) { | |||
continue | |||
} else if ( f[i] !~ /_(PATCH|LAYOUT)$/ ) { | |||
ret = 1 | |||
} else if ( f[i] ~ /^!/ ) { | |||
ret = !patches[substr(f[i],2)] | |||
} else { | |||
ret = patches[f[i]] | |||
} | |||
} | |||
if ( ret == -1 ) { | |||
ret = 0 | |||
} | |||
return ret | |||
} | |||
function schedule_delete(file) { | |||
# Skip duplicates | |||
for ( i = 1; i in files_to_delete; i++ ) { | |||
if ( files_to_delete[i] == file) { | |||
return | |||
} | |||
} | |||
if (DEBUG) { | |||
print "Scheduling file " file " for deletion." > "/dev/stderr" | |||
} | |||
files_to_delete[i] = file | |||
} | |||
function is_flexipatch(patch) { | |||
return patch ~ /_(PATCH|LAYOUT)$/ | |||
} | |||
BEGIN { | |||
# Read patches.h and store patch settings in the patches associative array | |||
if (DEBUG) { | |||
print "Reading file " DIRECTORY "/patches.h" > "/dev/stderr" | |||
} | |||
while (( getline line < (DIRECTORY"/patches.h") ) > 0 ) { | |||
split(line,f) | |||
if ( f[1] ~ /^#define$/ ) { | |||
if ( f[3] == 0 || f[3] == 1 ) { | |||
patches[f[2]] = f[3] | |||
} else { | |||
patches[f[2]] = istrue(f) | |||
} | |||
if (DEBUG) { | |||
print "Found " f[2] " = " patches[f[2]] > "/dev/stderr" | |||
} | |||
} | |||
} | |||
files_to_delete[0] = "" | |||
} | |||
{ | |||
level = 0 | |||
do_print[level] = 1 | |||
has_printed[level] = 0 | |||
condition[level] = "" | |||
while (( getline line < $0) > 0 ) { | |||
split(line,f) | |||
if ( f[1] ~ /^#if$/ ) { | |||
level++; | |||
do_print[level] = do_print[level-1] | |||
has_printed[level] = 0 | |||
condition[level] = f[2] | |||
if ( do_print[level] ) { | |||
if ( istrue(f) ) { | |||
has_printed[level] = 1 | |||
do_print[level] = 1 | |||
} else { | |||
do_print[level] = 0 | |||
} | |||
} | |||
if ( is_flexipatch(condition[level]) ) { | |||
continue | |||
} | |||
} else if ( f[1] ~ /^#ifdef$/ || f[1] ~ /^#ifndef$/ ) { | |||
level++; | |||
do_print[level] = do_print[level-1] | |||
has_printed[level] = 0 | |||
condition[level] = f[2] | |||
if ( do_print[level] ) { | |||
has_printed[level] = 1 | |||
do_print[level] = 1 | |||
} | |||
if ( is_flexipatch(condition[level]) ) { | |||
continue | |||
} | |||
} else if ( f[1] ~ /^#elif$/ ) { | |||
if ( (!is_flexipatch(condition[level]) || has_printed[level] == 0) && do_print[level-1] == 1 ) { | |||
if ( istrue(f) ) { | |||
has_printed[level] = 1 | |||
do_print[level] = 1 | |||
} else { | |||
do_print[level] = 0 | |||
} | |||
} else { | |||
do_print[level] = 0 | |||
} | |||
if ( is_flexipatch(f[2]) ) { | |||
continue | |||
} | |||
} else if ( f[1] ~ /^#else$/ ) { | |||
if ( (!is_flexipatch(condition[level]) || has_printed[level] == 0) && do_print[level-1] == 1 ) { | |||
has_printed[level] = 1 | |||
do_print[level] = 1 | |||
} else { | |||
do_print[level] = 0 | |||
} | |||
if ( is_flexipatch(condition[level]) ) { | |||
continue | |||
} | |||
} else if ( f[1] ~ /^#include$/ && f[2] ~ /^"/ && (do_print[level] == 0 || f[2] == "\"patches.h\"") ) { | |||
dir = "" | |||
if ( $0 ~ /\// ) { | |||
dir = $0 | |||
sub("/[^/]+$", "/", dir) | |||
} | |||
schedule_delete(dir substr(f[2], 2, length(f[2]) - 2)) | |||
continue | |||
} else if ( f[1] ~ /^#endif$/ ) { | |||
if ( is_flexipatch(condition[level]) ) { | |||
level-- | |||
continue | |||
} | |||
level-- | |||
} | |||
if ( do_print[level] ) { | |||
print line > $0 ".~" | |||
} | |||
} | |||
} | |||
END { | |||
for ( i = 1; i in files_to_delete; i++ ) { | |||
print files_to_delete[i] | |||
} | |||
} | |||
') | |||
# Chmod and replace files | |||
for FILE in $(find $DIRECTORY -name "*.~"); do | |||
chmod --reference=${FILE%%.~} ${FILE} | |||
if [[ $KEEP_FILES = 0 ]] || [[ $ECHO_COMMANDS = 1 ]]; then | |||
if [[ $ECHO_COMMANDS = 1 ]]; then | |||
echo "mv ${FILE} ${FILE%%.~}" | |||
else | |||
mv ${FILE} ${FILE%%.~} | |||
fi | |||
fi | |||
done | |||
# Delete unnecessary files | |||
if [[ $KEEP_FILES = 0 ]] || [[ $ECHO_COMMANDS = 1 ]]; then | |||
# Remove dwmc shell script if patch not enabled | |||
if [[ -f ${DIRECTORY}/patch/dwmc ]] && [[ $(grep -cE '^#define DWMC_PATCH +0 *$' ${DIRECTORY}/patches.h) > 0 ]]; then | |||
if [[ $ECHO_COMMANDS = 1 ]]; then | |||
echo "rm ${DIRECTORY}/patch/dwmc" | |||
echo "sed -r -i -e '/cp -f patch\/dwmc/d' \"${DIRECTORY}/Makefile\"" | |||
else | |||
rm "${DIRECTORY}/patch/dwmc" | |||
sed -r -i -e '/cp -f patch\/dwmc/d' "${DIRECTORY}/Makefile" | |||
fi | |||
fi | |||
# Remove layoutmenu.sh shell script if patch not enabled | |||
if [[ -f ${DIRECTORY}/patch/layoutmenu.sh ]] && [[ $(grep -cE '^#define BAR_LAYOUTMENU_PATCH +0 *$' ${DIRECTORY}/patches.h) > 0 ]]; then | |||
if [[ $ECHO_COMMANDS = 1 ]]; then | |||
echo "rm ${DIRECTORY}/patch/layoutmenu.sh" | |||
else | |||
rm "${DIRECTORY}/patch/layoutmenu.sh" | |||
fi | |||
fi | |||
for FILE in $FILES_TO_DELETE ${DIRECTORY}/patches.def.h; do | |||
if [[ $ECHO_COMMANDS = 1 ]]; then | |||
echo "rm $FILE" | |||
else | |||
rm "$FILE" | |||
fi | |||
done | |||
if [[ -f $DIRECTORY/README.md ]]; then | |||
if [[ $ECHO_COMMANDS = 1 ]]; then | |||
echo "rm $DIRECTORY/README.md" | |||
else | |||
rm $DIRECTORY/README.md | |||
fi | |||
fi | |||
if [[ $KEEP_GITFILES = 0 ]]; then | |||
rm -rf $DIRECTORY/.git* | |||
fi | |||
# Remove empty include files | |||
INCLUDE_RE='*patch/*include.[hc]' | |||
if [[ $ECHO_COMMANDS = 1 ]]; then | |||
INCLUDE_RE='*patch/*include.[hc][.]~' | |||
fi | |||
for FILE in $(find $DIRECTORY -path "$INCLUDE_RE"); do | |||
if [[ $(grep -c "#include " $FILE) = 0 ]]; then | |||
if [[ $ECHO_COMMANDS = 1 ]]; then | |||
echo "rm ${FILE%%.~}" | |||
else | |||
rm "$FILE" | |||
fi | |||
for LINE in $(grep -Ern "#include \"patch/$(basename ${FILE%%.~})\"" $DIRECTORY | grep -v '.~:' | awk -F":" '{print $1 ":" $2 }'); do | |||
INCFILE=$(echo $LINE | cut -d":" -f1) | |||
LINE_NO=$(echo $LINE | cut -d":" -f2) | |||
if [[ $ECHO_COMMANDS = 1 ]]; then | |||
echo "sed -i \"${LINE_NO}d\" ${INCFILE}" | |||
else | |||
sed -i "${LINE_NO}d" ${INCFILE} | |||
fi | |||
done | |||
fi | |||
done | |||
fi | |||
# Clean up the Makefile | |||
sed -r -i -e 's/ patches.h$//' -e '/^patches.h:$/{N;N;d;}' "${DIRECTORY}/Makefile" |
@ -1,24 +0,0 @@ | |||
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); | |||
} |
@ -1 +0,0 @@ | |||
static void aspectresize(const Arg *arg); |
@ -1,42 +0,0 @@ | |||
void | |||
attachx(Client *c) | |||
{ | |||
#if ATTACHABOVE_PATCH | |||
Client *at; | |||
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 | |||
Client *at; | |||
unsigned int n; | |||
for (at = c->mon->clients, n = 0; at; at = at->next) | |||
if (!at->isfloating && ISVISIBLEONTAG(at, c->tags)) | |||
if (++n >= c->mon->nmaster) | |||
break; | |||
if (at && c->mon->nmaster) { | |||
c->next = at->next; | |||
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 | |||
Client *at; | |||
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) | |||
} |
@ -1 +0,0 @@ | |||
static void attachx(Client *c); |
@ -1,83 +0,0 @@ | |||
void | |||
runautostart(void) | |||
{ | |||
char *pathpfx; | |||
char *path; | |||
char *xdgdatahome; | |||
char *home; | |||
if ((home = getenv("HOME")) == NULL) | |||
/* this is almost impossible */ | |||
return; | |||
/* if $XDG_DATA_HOME is defined, use $XDG_DATA_HOME/dwm, | |||
* otherwise use ~/.local/share/dwm as autostart script directory | |||
*/ | |||
if ((xdgdatahome = getenv("XDG_DATA_HOME")) != NULL) { | |||
/* space for path segments, separators and nul */ | |||
if ((pathpfx = malloc(strlen(xdgdatahome) + strlen(dwmdir) + 2)) == NULL) | |||
return; | |||
if (sprintf(pathpfx, "%s/%s", xdgdatahome, dwmdir) <= 0) { | |||
free(pathpfx); | |||
return; | |||
} | |||
} else { | |||
/* space for path segments, separators and nul */ | |||
if ((pathpfx = malloc(strlen(home) + strlen(localshare) + strlen(dwmdir) + 3)) == NULL) | |||
return; | |||
if (sprintf(pathpfx, "%s/%s/%s", home, localshare, dwmdir) < 0) { | |||
free(pathpfx); | |||
return; | |||
} | |||
} | |||
/* check if the autostart script directory exists */ | |||
struct stat sb; | |||
if (! (stat(pathpfx, &sb) == 0 && S_ISDIR(sb.st_mode))) { | |||
/* the XDG conformant path does not exist or are not directories | |||
* so we try ~/.dwm instead | |||
*/ | |||
if (realloc(pathpfx, strlen(home) + strlen(dwmdir) + 3) == NULL) { | |||
free(pathpfx); | |||
return; | |||
} | |||
if (sprintf(pathpfx, "%s/.%s", home, dwmdir) <= 0) { | |||
free(pathpfx); | |||
return; | |||
} | |||
} | |||
/* try the blocking script first */ | |||
if ((path = malloc(strlen(pathpfx) + strlen(autostartblocksh) + 2)) == NULL) { | |||
free(pathpfx); | |||
return; | |||
} else | |||
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 ((path = realloc(path, strlen(pathpfx) + strlen(autostartsh) + 4)) == NULL) { | |||
free(pathpfx); | |||
free(path); | |||
return; | |||
} else | |||
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); | |||
} | |||
} |
@ -1 +0,0 @@ | |||
static void runautostart(void); |
@ -1,42 +0,0 @@ | |||
static int useargb = 0; | |||
static Visual *visual; | |||
static int depth; | |||
static Colormap cmap; | |||
void | |||
xinitvisual() | |||
{ | |||
XVisualInfo *infos; | |||
XRenderPictFormat *fmt; | |||
int nitems; | |||
int i; | |||
XVisualInfo tpl = { | |||
.screen = screen, | |||
.depth = 32, | |||
.class = TrueColor | |||
}; | |||
long masks = VisualScreenMask | VisualDepthMask | VisualClassMask; | |||
infos = XGetVisualInfo(dpy, masks, &tpl, &nitems); | |||
visual = NULL; | |||
for (i = 0; i < nitems; i ++) { | |||
fmt = XRenderFindVisualFormat(dpy, infos[i].visual); | |||
if (fmt->type == PictTypeDirect && fmt->direct.alphaMask) { | |||
visual = infos[i].visual; | |||
depth = infos[i].depth; | |||
cmap = XCreateColormap(dpy, root, visual, AllocNone); | |||
useargb = 1; | |||
break; | |||
} | |||
} | |||
XFree(infos); | |||
if (!visual) { | |||
visual = DefaultVisual(dpy, screen); | |||
depth = DefaultDepth(dpy, screen); | |||
cmap = DefaultColormap(dpy, screen); | |||
} | |||
} |
@ -1,3 +0,0 @@ | |||
#define OPAQUE 0xffU | |||
static void xinitvisual(); |
@ -1,6 +0,0 @@ | |||
void | |||
togglealttag() | |||
{ | |||
selmon->alttag = !selmon->alttag; | |||
drawbar(selmon); | |||
} |
@ -1 +0,0 @@ | |||
static void togglealttag(); |
@ -1,82 +0,0 @@ | |||
void | |||
managealtbar(Window win, XWindowAttributes *wa) | |||
{ | |||
Monitor *m; | |||
Bar *bar; | |||
int i; | |||
if (!(m = recttomon(wa->x, wa->y, wa->width, wa->height))) | |||
return; | |||
for (i = 0, bar = m->bar; bar && bar->win && bar->next; bar = bar->next, ++i); // find last bar | |||
if (!bar) { | |||
bar = m->bar = ecalloc(1, sizeof(Bar)); | |||
bar->topbar = topbar; | |||
} else if (bar && bar->win) { | |||
bar->next = ecalloc(1, sizeof(Bar)); | |||
bar->next->topbar = !bar->topbar; | |||
bar = bar->next; | |||
} | |||
bar->external = 1; | |||
bar->showbar = 1; | |||
bar->mon = m; | |||
bar->idx = i; | |||
bar->borderpx = 0; | |||
bar->win = win; | |||
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, wa->width, 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; | |||
if (!m) | |||
return; | |||
for (bar = m->bar; bar && bar->win; bar = bar->next) | |||
if (bar->win == w) { | |||
bar->win = 0; | |||
bar->by = 0; | |||
bar->bh = 0; | |||
break; | |||
} | |||
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; | |||
} |
@ -1,4 +0,0 @@ | |||
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); |
@ -1,79 +0,0 @@ | |||
int | |||
width_awesomebar(Bar *bar, BarArg *a) | |||
{ | |||
return a->w; | |||
} | |||
int | |||
draw_awesomebar(Bar *bar, BarArg *a) | |||
{ | |||
int n = 0, scm, remainder = 0, tabw, pad; | |||
unsigned int i; | |||
#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) | |||
scm = SchemeTitleSel; | |||
else if (HIDDEN(c)) | |||
scm = SchemeHid; | |||
else | |||
scm = SchemeTitleNorm; | |||
pad = lrpad / 2; | |||
#if BAR_CENTEREDWINDOWNAME_PATCH | |||
if (TEXTW(c->name) < tabw) | |||
pad = (tabw - TEXTW(c->name) + lrpad) / 2; | |||
#endif // BAR_CENTEREDWINDOWNAME_PATCH | |||
drw_setscheme(drw, scheme[scm]); | |||
drw_text(drw, x, a->y, tabw + (i < remainder ? 1 : 0), a->h, pad, 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; | |||
} |
@ -1,3 +0,0 @@ | |||
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); |
@ -1,31 +0,0 @@ | |||
static int dwmblockssig; | |||
pid_t dwmblockspid = 0; | |||
int | |||
getdwmblockspid() | |||
{ | |||
char buf[16]; | |||
FILE *fp = popen("pidof -s dwmblocks", "r"); | |||
if (fgets(buf, sizeof(buf), fp)); | |||
pid_t pid = strtoul(buf, NULL, 10); | |||
pclose(fp); | |||
dwmblockspid = pid; | |||
return pid != 0 ? 0 : -1; | |||
} | |||
void | |||
sigdwmblocks(const Arg *arg) | |||
{ | |||
union sigval sv; | |||
sv.sival_int = (dwmblockssig << 8) | arg->i; | |||
if (!dwmblockspid) | |||
if (getdwmblockspid() == -1) | |||
return; | |||
if (sigqueue(dwmblockspid, SIGUSR1, sv) == -1) { | |||
if (errno == ESRCH) { | |||
if (!getdwmblockspid()) | |||
sigqueue(dwmblockspid, SIGUSR1, sv); | |||
} | |||
} | |||
} |
@ -1,2 +0,0 @@ | |||
static int getdwmblockspid(); | |||
static void sigdwmblocks(const Arg *arg); |
@ -1,52 +0,0 @@ | |||
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); | |||
} |
@ -1,6 +0,0 @@ | |||
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); |
@ -1,70 +0,0 @@ | |||
int | |||
width_fancybar(Bar *bar, BarArg *a) | |||
{ | |||
return a->w; | |||
} | |||
int | |||
draw_fancybar(Bar *bar, BarArg *a) | |||
{ | |||
int ftw, mw, ew = 0, n = 0; | |||
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) { | |||
ftw = TEXTW(m->sel->name); | |||
mw = (ftw >= w || n == 1) ? 0 : (w - ftw) / (n - 1); | |||
i = 0; | |||
for (c = m->clients; c; c = c->next) { | |||
if (!ISVISIBLE(c) || c == m->sel) | |||
continue; | |||
ftw = TEXTW(c->name); | |||
if (ftw < mw) | |||
ew += (mw - ftw); | |||
else | |||
i++; | |||
} | |||
if (i > 0) | |||
mw += ew / i; | |||
for (c = m->clients; c; c = c->next) { | |||
if (!ISVISIBLE(c)) | |||
continue; | |||
ftw = MIN(m->sel == c ? w : mw, TEXTW(c->name)); | |||
drw_setscheme(drw, scheme[m->sel == c ? SchemeTitleSel : SchemeTitleNorm]); | |||
if (ftw > 0) /* trap special handling of 0 in drw_text */ | |||
drw_text(drw, x, a->y, ftw, a->h, lrpad / 2, c->name, 0, False); | |||
drawstateindicator(c->mon, c, 1, x, a->y, ftw, a->h, 0, 0, c->isfixed); | |||
x += ftw; | |||
w -= ftw; | |||
} | |||
} | |||
return n; | |||
} | |||
int | |||
click_fancybar(Bar *bar, Arg *arg, BarArg *a) | |||
{ | |||
return ClkWinTitle; | |||
} | |||
@ -1,3 +0,0 @@ | |||
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); |
@ -1,436 +0,0 @@ | |||
/* 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 SchemeHid; | |||
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 *barg) | |||
{ | |||
if (!c) | |||
return; | |||
int i, nclienttags = 0, nviewtags = 0, pad = lrpad / 2; | |||
int clientscheme = ( | |||
c == selmon->sel | |||
? getselschemefor(tabscheme) | |||
: HIDDEN(c) | |||
? SchemeHid | |||
: c->isurgent | |||
? SchemeUrg | |||
: tabscheme | |||
); | |||
drw_setscheme(drw, scheme[clientscheme]); | |||
XSetWindowBorder(dpy, c->win, scheme[clientscheme][ColBorder].pixel); | |||
if (w <= TEXTW("A") - lrpad + pad) // reduce text padding if wintitle is too small | |||
pad = (w - TEXTW("A") + lrpad < 0 ? 0 : (w - TEXTW("A") + lrpad) / 2); | |||
#if BAR_CENTEREDWINDOWNAME_PATCH | |||
else if (TEXTW(c->name) < w) | |||
pad = (w - TEXTW(c->name) + lrpad) / 2; | |||
#endif // BAR_CENTEREDWINDOWNAME_PATCH | |||
drw_text(drw, x, barg->y, w, barg->h, pad, c->name, 0, False); | |||
drawstateindicator(m, c, 1, x + 2, barg->y, w, barg->h, 0, 0, 0); | |||
if (FLEXWINTITLE_BORDERS) { | |||
XSetForeground(drw->dpy, drw->gc, scheme[SchemeSel][ColBorder].pixel); | |||
XFillRectangle(drw->dpy, drw->drawable, drw->gc, x, barg->y, 1, barg->h); | |||
XFillRectangle(drw->dpy, drw->drawable, drw->gc, x + w - (x + w >= barg->w ? 1 : 0), barg->y, 1, barg->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, barg->y, w, barg->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; | |||
} |
@ -1,10 +0,0 @@ | |||
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); |
@ -1,37 +0,0 @@ | |||
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); | |||
} | |||
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); | |||
arrange(selmon); | |||
} | |||
#if COMBO_PATCH | |||
combo = 0; | |||
#endif // COMBO_PATCH | |||
} |
@ -1,2 +0,0 @@ | |||
static void keyrelease(XEvent *e); | |||
static void holdbar(const Arg *arg); |
@ -1,110 +0,0 @@ | |||
/* Indicator properties, you can override these in your config.h if you want. */ | |||
#ifndef TAGSINDICATOR | |||
#define TAGSINDICATOR 1 // 0 = off, 1 = on if >1 client/view tag, 2 = always on | |||
#endif | |||
#ifndef TAGSPX | |||
#define TAGSPX 5 // # pixels for tag grid boxes | |||
#endif | |||
#ifndef TAGSROWS | |||
#define TAGSROWS 3 // # rows in tag grid (9 tags, e.g. 3x3) | |||
#endif | |||
void | |||
drawindicator(Monitor *m, Client *c, unsigned int occ, int x, int y, int w, int h, unsigned int tag, int filled, int invert, int type) | |||
{ | |||
int i, boxw, boxs, indn = 0; | |||
if (!(occ & 1 << tag) || type == INDICATOR_NONE) | |||
return; | |||
boxs = drw->fonts->h / 9; | |||
boxw = drw->fonts->h / 6 + 2; | |||
if (filled == -1) | |||
filled = m == selmon && m->sel && m->sel->tags & 1 << tag; | |||
switch (type) { | |||
default: | |||
case INDICATOR_TOP_LEFT_SQUARE: | |||
drw_rect(drw, x + boxs, y + boxs, boxw, boxw, filled, invert); | |||
break; | |||
case INDICATOR_TOP_LEFT_LARGER_SQUARE: | |||
drw_rect(drw, x + boxs + 2, y + boxs+1, boxw+1, boxw+1, filled, invert); | |||
break; | |||
case INDICATOR_TOP_BAR: | |||
drw_rect(drw, x + boxw, y, w - ( 2 * boxw + 1), boxw/2, filled, invert); | |||
break; | |||
case INDICATOR_TOP_BAR_SLIM: | |||
drw_rect(drw, x + boxw, y, w - ( 2 * boxw + 1), 1, 0, invert); | |||
break; | |||
case INDICATOR_BOTTOM_BAR: | |||
drw_rect(drw, x + boxw, y + h - boxw/2, w - ( 2 * boxw + 1), boxw/2, filled, invert); | |||
break; | |||
case INDICATOR_BOTTOM_BAR_SLIM: | |||
drw_rect(drw, x + boxw, y + h - 1, w - ( 2 * boxw + 1), 1, 0, invert); | |||
break; | |||
case INDICATOR_BOX: | |||
drw_rect(drw, x + boxw, y, w - 2 * boxw, h, 0, invert); | |||
break; | |||
case INDICATOR_BOX_WIDER: | |||
drw_rect(drw, x + boxw/2, y, w - boxw, h, 0, invert); | |||
break; | |||
case INDICATOR_BOX_FULL: | |||
drw_rect(drw, x, y, w - 2, h, 0, invert); | |||
break; | |||
case INDICATOR_CLIENT_DOTS: | |||
for (c = m->clients; c; c = c->next) { | |||
if (c->tags & (1 << tag)) { | |||
drw_rect(drw, x, 1 + (indn * 2), m->sel == c ? 6 : 1, 1, 1, invert); | |||
indn++; | |||
} | |||
if (h <= 1 + (indn * 2)) { | |||
indn = 0; | |||
x += 2; | |||
} | |||
} | |||
break; | |||
case INDICATOR_RIGHT_TAGS: | |||
if (!c) | |||
break; | |||
for (i = 0; i < NUMTAGS; i++) { | |||
drw_rect(drw, | |||
( x + w - 2 - ((NUMTAGS / TAGSROWS) * TAGSPX) | |||
- (i % (NUMTAGS/TAGSROWS)) + ((i % (NUMTAGS / TAGSROWS)) * TAGSPX) | |||
), | |||
( y + 2 + ((i / (NUMTAGS/TAGSROWS)) * TAGSPX) | |||
- ((i / (NUMTAGS/TAGSROWS))) | |||
), | |||
TAGSPX, TAGSPX, (c->tags >> i) & 1, 0 | |||
); | |||
} | |||
break; | |||
case INDICATOR_PLUS_AND_LARGER_SQUARE: | |||
boxs += 2; | |||
boxw += 2; | |||
/* falls through */ | |||
case INDICATOR_PLUS_AND_SQUARE: | |||
drw_rect(drw, x + boxs, y + boxs, boxw % 2 ? boxw : boxw + 1, boxw % 2 ? boxw : boxw + 1, filled, invert); | |||
/* falls through */ | |||
case INDICATOR_PLUS: | |||
if (!(boxw % 2)) | |||
boxw += 1; | |||
drw_rect(drw, x + boxs + boxw / 2, y + boxs, 1, boxw, filled, invert); // | | |||
drw_rect(drw, x + boxs, y + boxs + boxw / 2, boxw + 1, 1, filled, invert); // ‒ | |||
break; | |||
} | |||
} | |||
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 | |||
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); | |||
} |
@ -1,20 +0,0 @@ | |||
enum { | |||
INDICATOR_NONE, | |||
INDICATOR_TOP_LEFT_SQUARE, | |||
INDICATOR_TOP_LEFT_LARGER_SQUARE, | |||
INDICATOR_TOP_BAR, | |||
INDICATOR_TOP_BAR_SLIM, | |||
INDICATOR_BOTTOM_BAR, | |||
INDICATOR_BOTTOM_BAR_SLIM, | |||
INDICATOR_BOX, | |||
INDICATOR_BOX_WIDER, | |||
INDICATOR_BOX_FULL, | |||
INDICATOR_CLIENT_DOTS, | |||
INDICATOR_RIGHT_TAGS, | |||
INDICATOR_PLUS, | |||
INDICATOR_PLUS_AND_SQUARE, | |||
INDICATOR_PLUS_AND_LARGER_SQUARE, | |||
}; | |||
static void drawindicator(Monitor *m, Client *c, unsigned int occ, int x, int y, int w, int h, unsigned int tag, int filled, int invert, int type); | |||
static void drawstateindicator(Monitor *m, Client *c, unsigned int occ, int x, int y, int w, int h, unsigned int tag, int filled, int invert); |
@ -1,18 +0,0 @@ | |||
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') | |||
return; | |||
i = atoi(c); | |||
setlayout(&((Arg) { .v = &layouts[i] })); | |||
} | |||
@ -1 +0,0 @@ | |||
static void layoutmenu(const Arg *arg); |
@ -1,17 +0,0 @@ | |||
int | |||
width_ltsymbol(Bar *bar, BarArg *a) | |||
{ | |||
return TEXTW(bar->mon->ltsymbol); | |||
} | |||
int | |||
draw_ltsymbol(Bar *bar, BarArg *a) | |||
{ | |||
return drw_text(drw, a->x, a->y, a->w, a->h, lrpad / 2, bar->mon->ltsymbol, 0, False); | |||
} | |||
int | |||
click_ltsymbol(Bar *bar, Arg *arg, BarArg *a) | |||
{ | |||
return ClkLtSymbol; | |||
} |
@ -1,3 +0,0 @@ | |||
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); |
@ -1,121 +0,0 @@ | |||
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; | |||
} |
@ -1,11 +0,0 @@ | |||
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); |
@ -1,106 +0,0 @@ | |||
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; | |||
} | |||
return ClkTagBar; | |||
} |
@ -1,3 +0,0 @@ | |||
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); |
@ -1,33 +0,0 @@ | |||
int | |||
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) | |||
{ | |||
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) | |||
{ | |||
return ClkStatusText; | |||
} |
@ -1,9 +0,0 @@ | |||
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); |
@ -1,262 +0,0 @@ | |||
#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) | |||
{ | |||
int width; | |||
#if BAR_EXTRASTATUS_PATCH || BAR_STATUSCMD_PATCH | |||
width = status2dtextlength(rawstext); | |||
#else | |||
width = status2dtextlength(stext); | |||
#endif // #if BAR_EXTRASTATUS_PATCH | BAR_STATUSCMD_PATCH | |||
return width ? width + lrpad : 0; | |||
} | |||
#if BAR_EXTRASTATUS_PATCH | |||
int | |||
width_status2d_es(Bar *bar, BarArg *a) | |||
{ | |||
int width; | |||
#if BAR_STATUSCMD_PATCH | |||
width = status2dtextlength(rawestext); | |||
#else | |||
width = status2dtextlength(estext); | |||
#endif // BAR_STATUSCMD_PATCH | |||
return width ? width + lrpad : 0; | |||
} | |||
#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) + 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 | |||
x += lrpad / 2; | |||
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; | |||
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; | |||
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; | |||
i=-1; | |||
isCode = 0; | |||
} | |||
} | |||
if (!isCode) { | |||
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 len - 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; | |||
} |
@ -1,13 +0,0 @@ | |||
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); |
@ -1,17 +0,0 @@ | |||
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; | |||
} |
@ -1,3 +0,0 @@ | |||
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); |
@ -1,74 +0,0 @@ | |||
#if !BAR_DWMBLOCKS_PATCH | |||
static const char statusexport[] = "export BUTTON=-;"; | |||
static int statuscmdn; | |||
static int 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 | |||
dwmblockssig = -1; | |||
#else | |||
statuscmdn = 0; | |||
#endif // BAR_DWMBLOCKS_PATCH | |||
while (text[++i]) { | |||
if ((unsigned char)text[i] < ' ') { | |||
ch = text[i]; | |||
text[i] = '\0'; | |||
#if BAR_STATUS2D_PATCH && !BAR_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 && dwmblockssig != -1) | |||
break; | |||
dwmblockssig = ch; | |||
#else | |||
if (x >= rel_x) | |||
break; | |||
if (ch <= LENGTH(statuscmds)) | |||
statuscmdn = ch - 1; | |||
#endif // BAR_DWMBLOCKS_PATCH | |||
} | |||
} | |||
#if BAR_DWMBLOCKS_PATCH | |||
if (dwmblockssig == -1) | |||
dwmblockssig = 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'; | |||
} |
@ -1,6 +0,0 @@ | |||
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); |
@ -1,23 +0,0 @@ | |||
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; | |||
} |
@ -1,197 +0,0 @@ | |||
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); | |||
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, bar->by + a->y + (a->h - systray->h) / 2, 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, bar->by + a->y + (a->h - systray->h) / 2, 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; | |||
} | |||
XMoveResizeWindow(dpy, systray->win, bar->bx + a->x + lrpad / 2, (w ? bar->by + a->y + (a->h - systray->h) / 2: -bar->by - a->y), 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; | |||
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]))) | |||
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; | |||
} |
@ -1,41 +0,0 @@ | |||
#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 Atom getatomprop(Client *c, Atom prop); | |||
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); | |||
@ -1,220 +0,0 @@ | |||
/* 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 *barg) | |||
{ | |||
if (!c) | |||
return; | |||
int i, nclienttags = 0, nviewtags = 0, pad = lrpad / 2; | |||
drw_setscheme(drw, scheme[ | |||
m->sel == c | |||
? SchemeSel | |||
#ifdef HIDDEN | |||
: HIDDEN(c) | |||
? SchemeHid | |||
#endif | |||
: groupactive | |||
? SchemeTitleSel | |||
: SchemeTitleNorm | |||
]); | |||
if (w <= TEXTW("A") - lrpad + pad) // reduce text padding if wintitle is too small | |||
pad = (w - TEXTW("A") + lrpad < 0 ? 0 : (w - TEXTW("A") + lrpad) / 2); | |||
#if BAR_CENTEREDWINDOWNAME_PATCH | |||
else if (TEXTW(c->name) < w) | |||
pad = (w - TEXTW(c->name) + lrpad) / 2; | |||
#endif // BAR_CENTEREDWINDOWNAME_PATCH | |||
drw_text(drw, x, barg->y, w, barg->h, pad, c->name, 0, False); | |||
drawstateindicator(m, c, 1, x, barg->y, w, barg->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, barg->y, 1, barg->h); | |||
XFillRectangle(drw->dpy, drw->drawable, drw->gc, x + w - (x + w >= barg->w ? 1 : 0), barg->y, 1, barg->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, barg->y, w, barg->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; | |||
} |
@ -1,7 +0,0 @@ | |||
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); |
@ -1,149 +0,0 @@ | |||
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); | |||
} | |||
} |
@ -1,4 +0,0 @@ | |||
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,20 +0,0 @@ | |||
char * | |||
tagicon(Monitor *m, int tag) | |||
{ | |||
#if BAR_ALTTAGSDECORATION_PATCH | |||
Client *c; | |||
#endif // BAR_ALTTAGSDECORATION_PATCH | |||
int tagindex = tag + NUMTAGS * m->index; | |||
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]; | |||
} |
@ -1,7 +0,0 @@ | |||
enum { | |||
DEFAULT_TAGS, | |||
ALTERNATIVE_TAGS, | |||
ALT_TAGS_DECORATION, | |||
}; | |||
static char * tagicon(Monitor *m, int tag); |
@ -1,88 +0,0 @@ | |||
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; | |||
} | |||
int | |||
draw_tags(Bar *bar, BarArg *a) | |||
{ | |||
int invert; | |||
int w, x = a->x; | |||
unsigned int i, occ = 0, urg = 0; | |||
char *icon; | |||
Client *c; | |||
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; | |||
w = TEXTW(icon); | |||
drw_setscheme(drw, scheme[ | |||
m->tagset[m->seltags] & 1 << i | |||
? SchemeTagsSel | |||
: urg & 1 << i | |||
? SchemeUrg | |||
: SchemeTagsNorm | |||
]); | |||
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); | |||
x += w; | |||
} | |||
return 1; | |||
} | |||
int | |||
click_tags(Bar *bar, Arg *arg, BarArg *a) | |||
{ | |||
int i = 0, x = lrpad / 2; | |||
#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; | |||
} | |||
return ClkTagBar; | |||
} |
@ -1,3 +0,0 @@ | |||
static int width_tags(Bar *bar, BarArg *a); | |||
static int draw_tags(Bar *bar, BarArg *a); | |||
static int click_tags(Bar *bar, Arg *arg, BarArg *a); |
@ -1,68 +0,0 @@ | |||
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; | |||
} |
@ -1,2 +0,0 @@ | |||
static void get_vt_colors(void); | |||
static int get_luminance(char *rgb); |
@ -1,51 +0,0 @@ | |||
int | |||
width_wintitle(Bar *bar, BarArg *a) | |||
{ | |||
return a->w; | |||
} | |||
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; | |||
int pad = lrpad / 2; | |||
if (!m->sel) { | |||
drw_setscheme(drw, scheme[SchemeTitleNorm]); | |||
drw_rect(drw, x, a->y, w, a->h, 1, 1); | |||
return 0; | |||
} | |||
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 BAR_CENTEREDWINDOWNAME_PATCH | |||
if (TEXTW(m->sel->name) < w) | |||
pad = (w - TEXTW(m->sel->name) + lrpad) / 2; | |||
#endif // BAR_CENTEREDWINDOWNAME_PATCH | |||
drw_text(drw, x, a->y, w, a->h, pad, m->sel->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, m->sel, 1, x, a->y, w, a->h, 0, 0, m->sel->isfixed); | |||
return 1; | |||
} | |||
int | |||
click_wintitle(Bar *bar, Arg *arg, BarArg *a) | |||
{ | |||
return ClkWinTitle; | |||
} | |||
@ -1,3 +0,0 @@ | |||
static int width_wintitle(Bar *bar, BarArg *a); | |||
static int draw_wintitle(Bar *bar, BarArg *a); | |||
static int click_wintitle(Bar *bar, Arg *arg, BarArg *a); |
@ -1,45 +0,0 @@ | |||
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; | |||
} |
@ -1,8 +0,0 @@ | |||
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 | |||
); |
@ -1,45 +0,0 @@ | |||
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; | |||
} |
@ -1,8 +0,0 @@ | |||
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 | |||
); |
@ -1,93 +0,0 @@ | |||
void | |||
hide(Client *c) { | |||
Client *n; | |||
if (!c || HIDDEN(c)) | |||
return; | |||
Window w = c->win; | |||
static XWindowAttributes ra, ca; | |||
// more or less taken directly from blackbox's hide() function | |||
XGrabServer(dpy); | |||
XGetWindowAttributes(dpy, root, &ra); | |||
XGetWindowAttributes(dpy, w, &ca); | |||
// prevent UnmapNotify events | |||
XSelectInput(dpy, root, ra.your_event_mask & ~SubstructureNotifyMask); | |||
XSelectInput(dpy, w, ca.your_event_mask & ~StructureNotifyMask); | |||
XUnmapWindow(dpy, w); | |||
setclientstate(c, IconicState); | |||
XSelectInput(dpy, root, ra.your_event_mask); | |||
XSelectInput(dpy, w, ca.your_event_mask); | |||
XUngrabServer(dpy); | |||
if (c->isfloating || !c->mon->lt[c->mon->sellt]->arrange) { | |||
for (n = c->snext; n && (!ISVISIBLE(n) || HIDDEN(n)); n = n->snext); | |||
if (!n) | |||
for (n = c->mon->stack; n && (!ISVISIBLE(n) || HIDDEN(n)); n = n->snext); | |||
} else { | |||
n = nexttiled(c); | |||
if (!n) | |||
n = prevtiled(c); | |||
} | |||
focus(n); | |||
arrange(c->mon); | |||
} | |||
void | |||
show(Client *c) | |||
{ | |||
if (!c || !HIDDEN(c)) | |||
return; | |||
XMapWindow(dpy, c->win); | |||
setclientstate(c, NormalState); | |||
arrange(c->mon); | |||
} | |||
void | |||
togglewin(const Arg *arg) | |||
{ | |||
Client *c = (Client*)arg->v; | |||
if (!c) | |||
return; | |||
if (c == selmon->sel) | |||
hide(c); | |||
else { | |||
if (HIDDEN(c)) | |||
show(c); | |||
focus(c); | |||
restack(c->mon); | |||
} | |||
} | |||
Client * | |||
prevtiled(Client *c) | |||
{ | |||
Client *p, *i; | |||
for (p = NULL, i = c->mon->clients; c && i != c; i = i->next) | |||
if (ISVISIBLE(i) && !HIDDEN(i)) | |||
p = i; | |||
return p; | |||
} | |||
void | |||
showhideclient(const Arg *arg) | |||
{ | |||
Client *c = (Client*)arg->v; | |||
if (!c) | |||
c = selmon->sel; | |||
if (!c) | |||
return; | |||
#if WARP_PATCH | |||
force_warp = 1; | |||
#endif // WARP_PATCH | |||
if (HIDDEN(c)) { | |||
show(c); | |||
focus(c); | |||
restack(c->mon); | |||
} else { | |||
hide(c); | |||
} | |||
} |
@ -1,5 +0,0 @@ | |||
static void hide(Client *c); | |||
static void show(Client *c); | |||
static void togglewin(const Arg *arg); | |||
static Client * prevtiled(Client *c); | |||
static void showhideclient(const Arg *arg); |
@ -1,23 +0,0 @@ | |||
void | |||
setcfact(const Arg *arg) | |||
{ | |||
float f; | |||
Client *c; | |||
c = selmon->sel; | |||
if (!arg || !c || !selmon->lt[selmon->sellt]->arrange) | |||
return; | |||
if (!arg->f) | |||
f = 1.0; | |||
else if (arg->f > 4.0) // set fact absolutely | |||
f = arg->f - 4.0; | |||
else | |||
f = arg->f + c->cfact; | |||
if (f < 0.25) | |||
f = 0.25; | |||
else if (f > 4.0) | |||
f = 4.0; | |||
c->cfact = f; | |||
arrange(selmon); | |||
} |
@ -1 +0,0 @@ | |||
static void setcfact(const Arg *arg); |
@ -1,5 +0,0 @@ | |||
char* | |||
help(void) | |||
{ | |||
return "usage: dwm [-hv] [-fn font] [-nb color] [-nf color] [-sb color] [-sf color]\n[-df font] [-dnf color] [-dnb color] [-dsf color] [-dsb color]\n"; | |||
} |
@ -1 +0,0 @@ | |||
static char* help(); |
@ -1,49 +0,0 @@ | |||
static int combo = 0; | |||
#if !BAR_HOLDBAR_PATCH | |||
void | |||
keyrelease(XEvent *e) | |||
{ | |||
combo = 0; | |||
} | |||
#endif // !BAR_HOLDBAR_PATCH | |||
void | |||
combotag(const Arg *arg) | |||
{ | |||
if (selmon->sel && arg->ui & TAGMASK) { | |||
#if SWITCHTAG_PATCH | |||
if (selmon->sel->switchtag) | |||
selmon->sel->switchtag = 0; | |||
#endif // SWITCHTAG_PATCH | |||
if (combo) { | |||
selmon->sel->tags |= arg->ui & TAGMASK; | |||
} else { | |||
combo = 1; | |||
selmon->sel->tags = arg->ui & TAGMASK; | |||
} | |||
focus(NULL); | |||
arrange(selmon); | |||
} | |||
} | |||
void | |||
comboview(const Arg *arg) | |||
{ | |||
unsigned newtags = arg->ui & TAGMASK; | |||
if (combo) { | |||
selmon->tagset[selmon->seltags] |= newtags; | |||
} else { | |||
selmon->seltags ^= 1; /*toggle tagset*/ | |||
combo = 1; | |||
if (newtags) { | |||
#if PERTAG_PATCH | |||
pertagview(&((Arg) { .ui = newtags })); | |||
#else | |||
selmon->tagset[selmon->seltags] = newtags; | |||
#endif // PERTAG_PATCH | |||
} | |||
} | |||
focus(NULL); | |||
arrange(selmon); | |||
} |
@ -1,5 +0,0 @@ | |||
#if !BAR_HOLDBAR_PATCH | |||
static void keyrelease(XEvent *e); | |||
#endif // !BAR_HOLDBAR_PATCH | |||
static void combotag(const Arg *arg); | |||
static void comboview(const Arg *arg); |
@ -1,28 +0,0 @@ | |||
/* dwm will keep pid's of processes from autostart array and kill them at quit */ | |||
static pid_t *autostart_pids; | |||
static size_t autostart_len; | |||
/* execute command from autostart array */ | |||
static void | |||
autostart_exec() | |||
{ | |||
const char *const *p; | |||
size_t i = 0; | |||
/* count entries */ | |||
for (p = autostart; *p; autostart_len++, p++) | |||
while (*++p); | |||
autostart_pids = malloc(autostart_len * sizeof(pid_t)); | |||
for (p = autostart; *p; i++, p++) { | |||
if ((autostart_pids[i] = fork()) == 0) { | |||
setsid(); | |||
execvp(*p, (char *const *)p); | |||
fprintf(stderr, "dwm: execvp %s\n", *p); | |||
perror(" failed"); | |||
_exit(EXIT_FAILURE); | |||
} | |||
/* skip arguments */ | |||
while (*++p); | |||
} | |||
} |
@ -1 +0,0 @@ | |||
static void autostart_exec(void); |
@ -1,17 +0,0 @@ | |||
void | |||
cyclelayout(const Arg *arg) | |||
{ | |||
Layout *l; | |||
for (l = (Layout *)layouts; l != selmon->lt[selmon->sellt]; l++); | |||
if (arg->i > 0) { | |||
if (l->symbol && (l + 1)->symbol) | |||
setlayout(&((Arg) { .v = (l + 1) })); | |||
else | |||
setlayout(&((Arg) { .v = layouts })); | |||
} else { | |||
if (l != layouts && (l - 1)->symbol) | |||
setlayout(&((Arg) { .v = (l - 1) })); | |||
else | |||
setlayout(&((Arg) { .v = &layouts[LENGTH(layouts) - 2] })); | |||
} | |||
} |
@ -1 +0,0 @@ | |||
static void cyclelayout(const Arg *arg); |
@ -1,38 +0,0 @@ | |||
static Atom motifatom; | |||
void | |||
updatemotifhints(Client *c) | |||
{ | |||
Atom real; | |||
int format; | |||
unsigned char *p = NULL; | |||
unsigned long n, extra; | |||
unsigned long *motif; | |||
int width, height; | |||
if (!decorhints) | |||
return; | |||
if (XGetWindowProperty(dpy, c->win, motifatom, 0L, 5L, False, motifatom, | |||
&real, &format, &n, &extra, &p) == Success && p != NULL) { | |||
motif = (unsigned long*)p; | |||
if (motif[MWM_HINTS_FLAGS_FIELD] & MWM_HINTS_DECORATIONS) { | |||
width = WIDTH(c); | |||
height = HEIGHT(c); | |||
if (motif[MWM_HINTS_DECORATIONS_FIELD] & MWM_DECOR_ALL || | |||
motif[MWM_HINTS_DECORATIONS_FIELD] & MWM_DECOR_BORDER || | |||
motif[MWM_HINTS_DECORATIONS_FIELD] & MWM_DECOR_TITLE) | |||
#if SETBORDERPX_PATCH | |||
c->bw = c->oldbw = c->mon->borderpx; | |||
#else | |||
c->bw = c->oldbw = borderpx; | |||
#endif // SETBORDERPX_PATCH | |||
else | |||
c->bw = c->oldbw = 0; | |||
resize(c, c->x, c->y, width - (2*c->bw), height - (2*c->bw), 0); | |||
} | |||
XFree(p); | |||
} | |||
} |
@ -1,8 +0,0 @@ | |||
#define MWM_HINTS_FLAGS_FIELD 0 | |||
#define MWM_HINTS_DECORATIONS_FIELD 2 | |||
#define MWM_HINTS_DECORATIONS (1 << 1) | |||
#define MWM_DECOR_ALL (1 << 0) | |||
#define MWM_DECOR_BORDER (1 << 1) | |||
#define MWM_DECOR_TITLE (1 << 3) | |||
static void updatemotifhints(Client *c); |
@ -1,82 +0,0 @@ | |||
void | |||
dragcfact(const Arg *arg) | |||
{ | |||
int prev_x, prev_y, dist_x, dist_y; | |||
float fact; | |||
Client *c; | |||
XEvent ev; | |||
Time lasttime = 0; | |||
if (!(c = selmon->sel)) | |||
return; | |||
if (c->isfloating) { | |||
resizemouse(arg); | |||
return; | |||
} | |||
#if !FAKEFULLSCREEN_PATCH | |||
#if FAKEFULLSCREEN_CLIENT_PATCH | |||
if (c->isfullscreen && !c->fakefullscreen) /* no support resizing fullscreen windows by mouse */ | |||
return; | |||
#else | |||
if (c->isfullscreen) /* no support resizing fullscreen windows by mouse */ | |||
return; | |||
#endif // FAKEFULLSCREEN_CLIENT_PATCH | |||
#endif // !FAKEFULLSCREEN_PATCH | |||
restack(selmon); | |||
if (XGrabPointer(dpy, root, False, MOUSEMASK, GrabModeAsync, GrabModeAsync, | |||
None, cursor[CurIronCross]->cursor, CurrentTime) != GrabSuccess) | |||
return; | |||
#if WARP_PATCH | |||
ignore_warp = 1; | |||
#endif // WARP_PATCH | |||
XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w/2, c->h/2); | |||
prev_x = prev_y = -999999; | |||
do { | |||
XMaskEvent(dpy, MOUSEMASK|ExposureMask|SubstructureRedirectMask, &ev); | |||
switch(ev.type) { | |||
case ConfigureRequest: | |||
case Expose: | |||
case MapRequest: | |||
handler[ev.type](&ev); | |||
break; | |||
case MotionNotify: | |||
if ((ev.xmotion.time - lasttime) <= (1000 / 60)) | |||
continue; | |||
lasttime = ev.xmotion.time; | |||
if (prev_x == -999999) { | |||
prev_x = ev.xmotion.x_root; | |||
prev_y = ev.xmotion.y_root; | |||
} | |||
dist_x = ev.xmotion.x - prev_x; | |||
dist_y = ev.xmotion.y - prev_y; | |||
if (abs(dist_x) > abs(dist_y)) { | |||
fact = (float) 4.0 * dist_x / c->mon->ww; | |||
} else { | |||
fact = (float) -4.0 * dist_y / c->mon->wh; | |||
} | |||
if (fact) | |||
setcfact(&((Arg) { .f = fact })); | |||
prev_x = ev.xmotion.x; | |||
prev_y = ev.xmotion.y; | |||
break; | |||
} | |||
} while (ev.type != ButtonRelease); | |||
#if WARP_PATCH | |||
ignore_warp = 0; | |||
#endif // WARP_PATCH | |||
XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w/2, c->h/2); | |||
XUngrabPointer(dpy, CurrentTime); | |||
while (XCheckMaskEvent(dpy, EnterWindowMask, &ev)); | |||
} |
@ -1 +0,0 @@ | |||
static void dragcfact(const Arg *arg); |
@ -1,231 +0,0 @@ | |||
void | |||
dragmfact(const Arg *arg) | |||
{ | |||
unsigned int n; | |||
int py, px; // pointer coordinates | |||
int ax, ay, aw, ah; // area position, width and height | |||
int center = 0, horizontal = 0, mirror = 0, fixed = 0; // layout configuration | |||
double fact; | |||
Monitor *m; | |||
XEvent ev; | |||
Time lasttime = 0; | |||
m = selmon; | |||
#if VANITYGAPS_PATCH | |||
int oh, ov, ih, iv; | |||
getgaps(m, &oh, &ov, &ih, &iv, &n); | |||
#else | |||
Client *c; | |||
for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++); | |||
#endif // VANITYGAPS_PATCH | |||
ax = m->wx; | |||
ay = m->wy; | |||
ah = m->wh; | |||
aw = m->ww; | |||
if (!n) | |||
return; | |||
#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 || layout == SPLIT_HORIZONTAL_DUAL_STACK) | |||
horizontal = 1; | |||
else if (layout == SPLIT_CENTERED_VERTICAL && (fixed || n - m->nmaster > 1)) | |||
center = 1; | |||
else if (layout == FLOATING_MASTER) { | |||
center = 1; | |||
if (aw < ah) | |||
horizontal = 1; | |||
} | |||
else if (layout == SPLIT_CENTERED_HORIZONTAL) { | |||
if (fixed || n - m->nmaster > 1) | |||
center = 1; | |||
horizontal = 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 | |||
#if BSTACK_LAYOUT | |||
else if (m->lt[m->sellt]->arrange == &bstack) | |||
horizontal = 1; | |||
#endif // BSTACK_LAYOUT | |||
#if BSTACKHORIZ_LAYOUT | |||
else if (m->lt[m->sellt]->arrange == &bstackhoriz) | |||
horizontal = 1; | |||
#endif // BSTACKHORIZ_LAYOUT | |||
/* do not allow mfact to be modified under certain conditions */ | |||
if (!m->lt[m->sellt]->arrange // floating layout | |||
|| (!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 | |||
) | |||
return; | |||
#if VANITYGAPS_PATCH | |||
ay += oh; | |||
ax += ov; | |||
aw -= 2*ov; | |||
ah -= 2*oh; | |||
#endif // VANITYGAPS_PATCH | |||
if (center) { | |||
if (horizontal) { | |||
px = ax + aw / 2; | |||
#if VANITYGAPS_PATCH | |||
py = ay + ah / 2 + (ah - 2*ih) * (m->mfact / 2.0) + ih / 2; | |||
#else | |||
py = ay + ah / 2 + ah * m->mfact / 2.0; | |||
#endif // VANITYGAPS_PATCH | |||
} else { // vertical split | |||
#if VANITYGAPS_PATCH | |||
px = ax + aw / 2 + (aw - 2*iv) * m->mfact / 2.0 + iv / 2; | |||
#else | |||
px = ax + aw / 2 + aw * m->mfact / 2.0; | |||
#endif // VANITYGAPS_PATCH | |||
py = ay + ah / 2; | |||
} | |||
} else if (horizontal) { | |||
px = ax + aw / 2; | |||
if (mirror) | |||
#if VANITYGAPS_PATCH | |||
py = ay + (ah - ih) * (1.0 - m->mfact) + ih / 2; | |||
#else | |||
py = ay + (ah * (1.0 - m->mfact)); | |||
#endif // VANITYGAPS_PATCH | |||
else | |||
#if VANITYGAPS_PATCH | |||
py = ay + ((ah - ih) * m->mfact) + ih / 2; | |||
#else | |||
py = ay + (ah * m->mfact); | |||
#endif // VANITYGAPS_PATCH | |||
} else { // vertical split | |||
if (mirror) | |||
#if VANITYGAPS_PATCH | |||
px = ax + (aw - iv) * (1.0 - m->mfact) + iv / 2; | |||
#else | |||
px = ax + (aw * m->mfact); | |||
#endif // VANITYGAPS_PATCH | |||
else | |||
#if VANITYGAPS_PATCH | |||
px = ax + ((aw - iv) * m->mfact) + iv / 2; | |||
#else | |||
px = ax + (aw * m->mfact); | |||
#endif // VANITYGAPS_PATCH | |||
py = ay + ah / 2; | |||
} | |||
if (XGrabPointer(dpy, root, False, MOUSEMASK, GrabModeAsync, GrabModeAsync, | |||
None, cursor[horizontal ? CurResizeVertArrow : CurResizeHorzArrow]->cursor, CurrentTime) != GrabSuccess) | |||
return; | |||
#if WARP_PATCH | |||
ignore_warp = 1; | |||
#endif // WARP_PATCH | |||
XWarpPointer(dpy, None, root, 0, 0, 0, 0, px, py); | |||
do { | |||
XMaskEvent(dpy, MOUSEMASK|ExposureMask|SubstructureRedirectMask, &ev); | |||
switch(ev.type) { | |||
case ConfigureRequest: | |||
case Expose: | |||
case MapRequest: | |||
handler[ev.type](&ev); | |||
break; | |||
case MotionNotify: | |||
if ((ev.xmotion.time - lasttime) <= (1000 / 40)) | |||
continue; | |||
if (lasttime != 0) { | |||
px = ev.xmotion.x; | |||
py = ev.xmotion.y; | |||
} | |||
lasttime = ev.xmotion.time; | |||
#if VANITYGAPS_PATCH | |||
if (center) | |||
if (horizontal) | |||
if (py - ay > ah / 2) | |||
fact = (double) 1.0 - (ay + ah - py - ih / 2) * 2 / (double) (ah - 2*ih); | |||
else | |||
fact = (double) 1.0 - (py - ay - ih / 2) * 2 / (double) (ah - 2*ih); | |||
else | |||
if (px - ax > aw / 2) | |||
fact = (double) 1.0 - (ax + aw - px - iv / 2) * 2 / (double) (aw - 2*iv); | |||
else | |||
fact = (double) 1.0 - (px - ax - iv / 2) * 2 / (double) (aw - 2*iv); | |||
else | |||
if (horizontal) | |||
fact = (double) (py - ay - ih / 2) / (double) (ah - ih); | |||
else | |||
fact = (double) (px - ax - iv / 2) / (double) (aw - iv); | |||
#else | |||
if (center) | |||
if (horizontal) | |||
if (py - ay > ah / 2) | |||
fact = (double) 1.0 - (ay + ah - py) * 2 / (double) ah; | |||
else | |||
fact = (double) 1.0 - (py - ay) * 2 / (double) ah; | |||
else | |||
if (px - ax > aw / 2) | |||
fact = (double) 1.0 - (ax + aw - px) * 2 / (double) aw; | |||
else | |||
fact = (double) 1.0 - (px - ax) * 2 / (double) aw; | |||
else | |||
if (horizontal) | |||
fact = (double) (py - ay) / (double) ah; | |||
else | |||
fact = (double) (px - ax) / (double) aw; | |||
#endif // VANITYGAPS_PATCH | |||
if (!center && mirror) | |||
fact = 1.0 - fact; | |||
setmfact(&((Arg) { .f = 1.0 + fact })); | |||
px = ev.xmotion.x; | |||
py = ev.xmotion.y; | |||
break; | |||
} | |||
} while (ev.type != ButtonRelease); | |||
#if WARP_PATCH | |||
ignore_warp = 0; | |||
#endif // WARP_PATCH | |||
XUngrabPointer(dpy, CurrentTime); | |||
while (XCheckMaskEvent(dpy, EnterWindowMask, &ev)); | |||
} |
@ -1 +0,0 @@ | |||
static void dragmfact(const Arg *arg); |
@ -1,129 +0,0 @@ | |||
#!/usr/bin/env bash | |||
signal() { | |||
xsetroot -name "fsignal:$*" | |||
} | |||
case $# in | |||
1) | |||
case $1 in | |||
focusurgent) ;& | |||
mirrorlayout) ;& | |||
mpdcontrol) ;& | |||
pushdown) ;& | |||
pushup) ;& | |||
self_restart) ;& | |||
setlayout) ;& | |||
setcfact) ;& | |||
switchcol) ;& | |||
view) ;& | |||
viewall) ;& | |||
viewtoleft) ;& | |||
viewtoright) ;& | |||
tagtoleft) ;& | |||
tagtoright) ;& | |||
tagandviewtoleft) ;& | |||
tagandviewtoright) ;& | |||
transfer) ;& | |||
transferall) ;& | |||
togglealttag) ;& | |||
togglebar) ;& | |||
togglefloating) ;& | |||
togglefullscreen) ;& | |||
fullscreen) ;& | |||
togglefakefullscreen) ;& | |||
togglesticky) ;& | |||
togglehorizontalmax) ;& | |||
toggleverticalmax) ;& | |||
togglemax) ;& | |||
togglegaps) ;& | |||
defaultgaps) ;& | |||
unfloatvisible) ;& | |||
winview) ;& | |||
xrdb) ;& | |||
zoom) ;& | |||
killclient) ;& | |||
quit) | |||
signal $1 | |||
;; | |||
*) | |||
echo "Unknown command ($1) or missing one argument." | |||
exit 1 | |||
;; | |||
esac | |||
;; | |||
2) | |||
case $1 in | |||
cyclelayout) ;& | |||
explace) ;& | |||
moveplace) ;& | |||
mpdchange) ;& | |||
setkeymode) ;& | |||
switchtag) ;& | |||
togglescratch) ;& | |||
view) | |||
signal $1 ui $2 | |||
;; | |||
viewex) ;& | |||
toggleviewex) ;& | |||
tagallmon) ;& | |||
tagswapmon) ;& | |||
tagex) ;& | |||
toggletagex) ;& | |||
setborderpx) ;& | |||
setgaps) ;& | |||
setlayoutex) ;& | |||
setlayoutaxisex) ;& | |||
swapfocus) ;& | |||
focusstack) ;& | |||
pushstack) ;& | |||
inplacerotate) ;& | |||
rotatestack) ;& | |||
rotatelayoutaxis) ;& | |||
incnmaster) ;& | |||
incnstack) ;& | |||
incrgaps) ;& | |||
incrigaps) ;& | |||
incrogaps) ;& | |||
incrihgaps) ;& | |||
incrivgaps) ;& | |||
incrohgaps) ;& | |||
incrovgaps) ;& | |||
movestack) ;& | |||
shiftview) ;& | |||
shiftviewclients) ;& | |||
focusmon) ;& | |||
tagmon) | |||
signal $1 i $2 | |||
;; | |||
setcfact) ;& | |||
setmfact) | |||
signal $1 f $2 | |||
;; | |||
*) | |||
echo "Unknown command ($1) or too many arguments" | |||
exit 1 | |||
;; | |||
esac | |||
;; | |||
5) | |||
case $1 in | |||
setgaps) | |||
# Expects "setgaps oh ov ih iv" where -1 means to keep existing values | |||
[ $2 = -1 ] && oh=128 || oh=$2 | |||
[ $3 = -1 ] && ov=128 || ov=$3 | |||
[ $4 = -1 ] && ih=128 || ih=$4 | |||
[ $5 = -1 ] && iv=128 || iv=$5 | |||
signal $1 i $(((oh << 24) + (ov << 16) + (ih << 8) + iv)) | |||
;; | |||
*) | |||
echo "Unknown command ($1) or too many arguments" | |||
exit 1 | |||
;; | |||
esac | |||
;; | |||
*) | |||
echo "Unknown command ($1) or too many arguments" | |||
exit 1 | |||
;; | |||
esac |
@ -1,100 +0,0 @@ | |||
void | |||
setlayoutex(const Arg *arg) | |||
{ | |||
setlayout(&((Arg) { .v = &layouts[arg->i] })); | |||
} | |||
void | |||
viewex(const Arg *arg) | |||
{ | |||
view(&((Arg) { .ui = 1 << arg->ui })); | |||
} | |||
void | |||
viewallex(const Arg *arg) | |||
{ | |||
#if SCRATCHPADS_PATCH | |||
view(&((Arg){.ui = ~SPTAGMASK})); | |||
#else | |||
view(&((Arg){.ui = ~0})); | |||
#endif // SCRATCHPADS_PATCH | |||
} | |||
void | |||
toggleviewex(const Arg *arg) | |||
{ | |||
toggleview(&((Arg) { .ui = 1 << arg->ui })); | |||
} | |||
void | |||
tagex(const Arg *arg) | |||
{ | |||
tag(&((Arg) { .ui = 1 << arg->ui })); | |||
} | |||
void | |||
toggletagex(const Arg *arg) | |||
{ | |||
toggletag(&((Arg) { .ui = 1 << arg->ui })); | |||
} | |||
void | |||
tagallex(const Arg *arg) | |||
{ | |||
#if SCRATCHPADS_PATCH | |||
tag(&((Arg){.ui = ~SPTAGMASK})); | |||
#else | |||
tag(&((Arg){.ui = ~0})); | |||
#endif // SCRATCHPADS_PATCH | |||
} | |||
int | |||
fake_signal(void) | |||
{ | |||
char fsignal[256]; | |||
char indicator[9] = "fsignal:"; | |||
char str_sig[50]; | |||
char param[16]; | |||
int i, len_str_sig, n, paramn; | |||
size_t len_fsignal, len_indicator = strlen(indicator); | |||
Arg arg; | |||
// Get root name property | |||
if (gettextprop(root, XA_WM_NAME, fsignal, sizeof(fsignal))) { | |||
len_fsignal = strlen(fsignal); | |||
// Check if this is indeed a fake signal | |||
if (len_indicator > len_fsignal ? 0 : strncmp(indicator, fsignal, len_indicator) == 0) { | |||
paramn = sscanf(fsignal+len_indicator, "%s%n%s%n", str_sig, &len_str_sig, param, &n); | |||
if (paramn == 1) arg = (Arg) {0}; | |||
else if (paramn > 2) return 1; | |||
else if (strncmp(param, "i", n - len_str_sig) == 0) | |||
#if IPC_PATCH | |||
sscanf(fsignal + len_indicator + n, "%li", &(arg.i)); | |||
#else | |||
sscanf(fsignal + len_indicator + n, "%i", &(arg.i)); | |||
#endif // IPC_PATCH | |||
else if (strncmp(param, "ui", n - len_str_sig) == 0) | |||
#if IPC_PATCH | |||
sscanf(fsignal + len_indicator + n, "%lu", &(arg.ui)); | |||
#else | |||
sscanf(fsignal + len_indicator + n, "%u", &(arg.ui)); | |||
#endif // IPC_PATCH | |||
else if (strncmp(param, "f", n - len_str_sig) == 0) | |||
sscanf(fsignal + len_indicator + n, "%f", &(arg.f)); | |||
else return 1; | |||
// Check if a signal was found, and if so handle it | |||
for (i = 0; i < LENGTH(signals); i++) | |||
if (strncmp(str_sig, signals[i].sig, len_str_sig) == 0 && signals[i].func) | |||
signals[i].func(&(arg)); | |||
// A fake signal was sent | |||
return 1; | |||
} | |||
} | |||
// No fake signal was sent, so proceed with update | |||
return 0; | |||
} |
@ -1,13 +0,0 @@ | |||
typedef struct { | |||
const char * sig; | |||
void (*func)(const Arg *); | |||
} Signal; | |||
static void setlayoutex(const Arg *arg); | |||
static void viewex(const Arg *arg); | |||
static void viewallex(const Arg *arg); | |||
static void toggleviewex(const Arg *arg); | |||
static void tagex(const Arg *arg); | |||
static void toggletagex(const Arg *arg); | |||
static void tagallex(const Arg *arg); | |||
static int fake_signal(void); |
@ -1,195 +0,0 @@ | |||
#define EXPAND_LEFT (1 << 0) | |||
#define EXPAND_RIGHT (1 << 2) | |||
#define EXPAND_UP (1 << 4) | |||
#define EXPAND_DOWN (1 << 6) | |||
#define IS_SET(q, w) ((q & w) != 0) | |||
#define IS_FORCED(q, w) IS_SET((q << 1), w) | |||
#define EXPANDALL (EXPAND_LEFT | EXPAND_RIGHT | EXPAND_UP | EXPAND_DOWN) | |||
#define UNEXPAND (EXPANDALL << 1) // Force all directions to 0 | |||
#define FORCE_EXPANDALL ~0 // Force expand in all directions | |||
void | |||
exresize(const Arg *arg) | |||
{ | |||
Client *c; | |||
int x, y, nx, ny, nw, nh; | |||
c = selmon->sel; | |||
if (!c || !arg) return; | |||
if (selmon->lt[selmon->sellt]->arrange && !c->isfloating) | |||
togglefloating(NULL); | |||
if (c->expandmask != 0) | |||
expand(UNEXPAND); | |||
x = ((int *)arg->v)[0]; | |||
y = ((int *)arg->v)[1]; | |||
nw = MIN(selmon->ww - c->bw*2, c->w + x); | |||
nh = MIN(selmon->wh - c->bw*2, c->h + y); | |||
nx = c->x - x/2; | |||
ny = c->y - y/2; | |||
if (!((abs(c->x + c->w/2 - (selmon->wx + selmon->ww/2)) < snap))) { | |||
if ((nw == selmon->ww) || | |||
(nx < selmon->wx) || | |||
(abs(selmon->wx - c->x) < snap)) | |||
nx = selmon->wx; | |||
else if ((nx+nw > (selmon->wx + selmon->ww)) || | |||
(abs((selmon->wx + selmon->ww) - (c->x + c->w)) < snap)) | |||
nx = (selmon->wx + selmon->ww) - nw - c->bw*2; | |||
} else | |||
nx = selmon->wx + selmon->ww/2 - nw/2; | |||
if (!((abs(c->y + c->h/2 - (selmon->wy + selmon->wh/2)) < snap))) { | |||
if ((nh == selmon->wh) || | |||
(ny < selmon->wy) || | |||
(abs(selmon->wy - c->y) < snap)) | |||
ny = selmon->wy; | |||
else if ((ny+nh > (selmon->wy + selmon->wh)) || | |||
(abs((selmon->wy + selmon->wh) - (c->y + c->h)) < snap)) | |||
ny = (selmon->wy + selmon->wh) - nh - c->bw*2; | |||
} else | |||
ny = selmon->wy + selmon->wh/2 - nh/2; | |||
resizeclient(c, nx, ny, MAX(nw, 32), MAX(nh, 32)); | |||
XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w/2, c->h/2); | |||
} | |||
void | |||
explace(const Arg *arg) | |||
{ | |||
Client *c; | |||
int nx, ny; | |||
c = selmon->sel; | |||
if (!c || (arg->ui >= 9)) return; | |||
if (selmon->lt[selmon->sellt]->arrange && !c->isfloating) | |||
togglefloating(NULL); | |||
nx = (arg->ui % 3) - 1; | |||
ny = (arg->ui / 3) - 1; | |||
if (nx < 0) nx = selmon->wx; | |||
else if (nx > 0) nx = selmon->wx + selmon->ww - c->w - c->bw*2; | |||
else nx = selmon->wx + selmon->ww/2 - c->w/2; | |||
if (ny < 0) ny = selmon->wy; | |||
else if (ny > 0) ny = selmon->wy + selmon->wh - c->h - c->bw*2; | |||
else ny = selmon->wy + selmon->wh/2 - c->h/2; | |||
resize(c, nx, ny, c->w, c->h, True); | |||
XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w/2, c->h/2); | |||
} | |||
int | |||
calculate_expand(unsigned char mask, unsigned char curmask, | |||
unsigned char *newmask, unsigned char key, | |||
int *reset_value, int new_reset_value, | |||
int max_value, int old_value) | |||
{ | |||
if (IS_SET(key, mask) || | |||
(IS_SET(key, curmask) && (!IS_SET(key, mask) && IS_FORCED(key, mask))) || | |||
(!IS_SET(key, curmask) && (IS_SET(key, mask) && IS_FORCED(key, mask)))) { | |||
if (IS_SET(key, mask) && (!IS_SET(key,curmask) || IS_FORCED(key,mask))) { | |||
if (!IS_SET(key, curmask)) | |||
*reset_value = new_reset_value; | |||
*newmask |= key; | |||
return max_value; | |||
} else if ((IS_SET(key,curmask) && IS_SET(key, mask)) || | |||
(!IS_SET(key, mask) && IS_FORCED(key, mask))) { | |||
*newmask &= ~key; | |||
return *reset_value; | |||
} else { | |||
*newmask &= ~key; | |||
return old_value; | |||
} | |||
} else | |||
return new_reset_value; | |||
} | |||
void | |||
expand(unsigned char mask) | |||
{ | |||
XEvent ev; | |||
int nx1, ny1, nx2, ny2; | |||
#if SETBORDERPX_PATCH | |||
int bp = selmon->borderpx; | |||
#else | |||
int bp = borderpx; | |||
#endif // SETBORDERPX_PATCH | |||
unsigned char curmask; | |||
unsigned char newmask; | |||
if (!selmon->sel || selmon->sel->isfixed) | |||
return; | |||
XRaiseWindow(dpy, selmon->sel->win); | |||
newmask = curmask = selmon->sel->expandmask; | |||
if (curmask == 0) { | |||
if(!selmon->lt[selmon->sellt]->arrange || selmon->sel->isfloating) | |||
selmon->sel->wasfloating = 1; | |||
else { | |||
togglefloating(NULL); | |||
selmon->sel->wasfloating = 0; | |||
} | |||
} | |||
nx1 = calculate_expand(mask, curmask, &newmask, | |||
EXPAND_LEFT, &selmon->sel->expandx1, | |||
selmon->sel->x, | |||
selmon->wx, | |||
selmon->sel->oldx); | |||
nx2 = calculate_expand(mask, curmask, &newmask, | |||
EXPAND_RIGHT, &selmon->sel->expandx2, | |||
selmon->sel->x + selmon->sel->w, | |||
selmon->wx + selmon->ww - 2*bp, | |||
selmon->sel->oldw + selmon->sel->x); | |||
ny1 = calculate_expand(mask, curmask, &newmask, | |||
EXPAND_UP, &selmon->sel->expandy1, | |||
selmon->sel->y, | |||
selmon->wy, | |||
selmon->sel->oldy); | |||
ny2 = calculate_expand(mask, curmask, &newmask, | |||
EXPAND_DOWN, &selmon->sel->expandy2, | |||
selmon->sel->y + selmon->sel->h, | |||
selmon->wy + selmon->wh - 2*bp, | |||
selmon->sel->oldh + selmon->sel->y); | |||
resizeclient(selmon->sel, nx1, ny1, MAX(nx2-nx1, 32), MAX(ny2-ny1, 32)); | |||
if ((newmask == 0) && (!selmon->sel->wasfloating)) | |||
togglefloating(NULL); | |||
selmon->sel->expandmask = newmask; | |||
drawbar(selmon); | |||
while(XCheckMaskEvent(dpy, EnterWindowMask, &ev)); | |||
} | |||
void | |||
togglemaximize(const Arg *arg) | |||
{ | |||
if (arg->i > 0) expand(FORCE_EXPANDALL); | |||
else if (arg->i < 0) expand(UNEXPAND); | |||
else expand(EXPANDALL); | |||
} | |||
void | |||
toggleverticalexpand(const Arg *arg) | |||
{ | |||
if (arg->i < 0) expand(EXPAND_DOWN); | |||
else if (arg->i > 0) expand(EXPAND_UP); | |||
else expand(EXPAND_DOWN | EXPAND_UP); | |||
} | |||
void | |||
togglehorizontalexpand(const Arg *arg) | |||
{ | |||
if (arg->i < 0) expand(EXPAND_LEFT); | |||
else if (arg->i > 0) expand(EXPAND_RIGHT); | |||
else expand(EXPAND_LEFT | EXPAND_RIGHT); | |||
} |
@ -1,8 +0,0 @@ | |||
enum { EX_NW, EX_N, EX_NE, EX_W, EX_C, EX_E, EX_SW, EX_S, EX_SE }; | |||
void expand(unsigned char mask); | |||
void togglemaximize(const Arg *arg); | |||
void toggleverticalexpand(const Arg *arg); | |||
void togglehorizontalexpand(const Arg *arg); | |||
void exresize(const Arg *arg); | |||
void explace(const Arg *arg); |
@ -1,18 +0,0 @@ | |||
void | |||
togglefakefullscreen(const Arg *arg) | |||
{ | |||
Client *c = selmon->sel; | |||
if (!c) | |||
return; | |||
if (c->fakefullscreen != 1 && c->isfullscreen) { // exit fullscreen --> fake fullscreen | |||
c->fakefullscreen = 2; | |||
setfullscreen(c, 0); | |||
} else if (c->fakefullscreen == 1) { | |||
setfullscreen(c, 0); | |||
c->fakefullscreen = 0; | |||
} else { | |||
c->fakefullscreen = 1; | |||
setfullscreen(c, 1); | |||
} | |||
} |
@ -1 +0,0 @@ | |||
static void togglefakefullscreen(const Arg *arg); |