config.h: reorganize config.h and update documentation; key,c: make all keybinds except alt-tab optional

This commit is contained in:
Iris Lightshard 2021-03-07 23:35:01 -05:00
parent 943b4fd82a
commit 404424f518
Signed by: Iris Lightshard
GPG key ID: 3B7FBC22144E6398
2 changed files with 288 additions and 85 deletions

207
config.h
View file

@ -1,101 +1,44 @@
#define SHOLDCOL 0xC8C8C8
#define HOLDCOL 0x444444
/***********************
* RYUDO CONFIGURATION *
**********************/
/***************
* LOOK & FEEL *
**************/
/* Border colors */
#define SBORDERCOL 0x17736C
#define BORDERCOL 0x000000
/* Window sweep border color */
#define GHOSTCOL 0x797979
/* Hold mode border colors -- if you don't use 9term you don't need to
* care what these are
*/
#define SHOLDCOL 0xC8C8C8
#define HOLDCOL 0x444444
/* Border width in pixels */
#define BORDER 4
/* Should be even */
/* Gap size, in pixels, for pseudo-tiling. Should be even */
#define GAPSZ 4
/* Menu border width and color */
#define MENUBORDER 0
#define MBORDERCOL 0x000000
/* Normal menu colors */
#define MENUFGCOL 0x797979
#define MENUBGCOL 0x000000
/* Selected menu colors */
#define SMENUFGCOL 0x000000
#define SMENUBGCOL 0x1F9B92
/* This sets the size ratio for windows spawned via keyboard or
* center-snapped; CENTERNUM should be >= 2, so use 2/4 instead of 1/2
*/
#define CENTERNUM 2
#define CENTERDEN 3
/* Centered windows should maximize vertically by default?
* This is the behavior of new windows spawned with the launch shortcut
* and of centered windows with SHORTCUTMOD + SNAPCENTER_KEY --
* use SHORTCUTMOD + SHIFT + SNAPCENTER_KEY to get the other behavior.
*/
#define CENTERVMAX
/* Show 'Stick' menuitem? */
//#define SHOWSTICK
/* Notify on virtual desktop switch? */
#define VIRTNOTIFY
/* The summary and message to pass to the notifcation daeomon */
#define VIRTHEADER "virtual"
#define VIRTMSG "[%s]"
/* Modifier key and associated modifier bits;
* Shift = (1<<0)
* Lock = (1<<1)
* Control = (1<<2)
* Mod1 = (1<<3)
* Mod2 = (1<<4)
* Mod3 = (1<<5)
* Mod4 = (1<<6)
* Mod5 = (1<<7)
*/
#define SHORTCUTMOD Mod4Mask
#define MODBITS (1 << 6)
/* Shortcut keys */
#define MAX_KEY XK_m
#define ICON_KEY XK_i
#define UNHIDE_KEY XK_u
#define MOVE_KEY XK_v
#define RESIZE_KEY XK_r
#define DESTROY_KEY XK_d
#define STICK_KEY XK_s
#define ZOOM_KEY XK_z
#define STICKYTOFRONT_KEY XK_t
#define STICKYTOBACK_KEY XK_b
#define SNAPLEFT_KEY XK_h
#define SNAPRIGHT_KEY XK_l
#define SNAPTOP_KEY XK_k
#define SNAPBOTTOM_KEY XK_j
#define SNAPTOPLEFT_KEY XK_q
#define SNAPBOTTOMLEFT_KEY XK_w
#define SNAPBOTTOMRIGHT_KEY XK_o
#define SNAPTOPRIGHT_KEY XK_p
#define SNAPCENTER_KEY XK_c
#define NEXTVIRT_KEY XK_Right
#define PREVVIRT_KEY XK_Left
#define LAUNCH_KEY XK_slash
// clang-format off
/* List of window classes to spawn as sticky;
* Class values for currently open windows are conveniently shown in the last
* column of the 'xshove' command given with no arguments.
* Remember the backslash at the end of non-terminating lines!
*/
#define AUTOSTICK {\
"XOsview", \
"XClock", \
0 \
}
/* List of fonts to try, in order, for rendering the menus.
* Remember the backslash at the end of non-terminating lines!
*/
@ -133,3 +76,103 @@
}
// clang-format on
/************
* BEHAVIOR *
***********/
/* This sets the size ratio for windows spawned via keyboard or
* center-snapped; CENTERNUM should be >= 2, so use 2/4 instead of 1/2
*/
#define CENTERNUM 2
#define CENTERDEN 3
/* Centered windows should maximize vertically by default?
* This is the behavior of new windows spawned with the launch shortcut
* and of centered windows with SHORTCUTMOD + SNAPCENTER_KEY --
* use SHORTCUTMOD + SHIFT + SNAPCENTER_KEY to get the other behavior.
*/
#define CENTERVMAX
/* Show 'Stick' menuitem? */
//#define SHOWSTICK
/* Notify on virtual desktop switch? */
#define VIRTNOTIFY
/* The summary and message to pass to the notifcation daeomon */
#define VIRTHEADER "virtual"
#define VIRTMSG "[%s]"
// clang-format off
/* List of window classes to spawn as sticky;
* Class values for currently open windows are conveniently shown in the last
* column of the 'xshove' command given with no arguments.
* Remember the backslash at the end of non-terminating lines!
*/
/* You can remove/comment the entire macro to improve performance if you
* don't use this feature!
*/
#define AUTOSTICK {\
"XOsview", \
"XClock", \
0 \
}
// clang-format on
/***************
* KEYBINDINGS *
**************/
/* Modifier key and associated modifier bits;
* Shift = (1<<0)
* Lock = (1<<1)
* Control = (1<<2)
* Mod1 = (1<<3)
* Mod2 = (1<<4)
* Mod3 = (1<<5)
* Mod4 = (1<<6)
* Mod5 = (1<<7)
*/
#define SHORTCUTMOD Mod4Mask
#define MODBITS (1 << 6)
/* Shortcut keys */
/* Any of these can be commented out/omitted if you want to free up
* your keyboard shortcuts for other things. Alt-tab is always bound.
*/
#define MAX_KEY XK_m
#define ICON_KEY XK_i
#define UNHIDE_KEY XK_u
#define MOVE_KEY XK_v
#define RESIZE_KEY XK_r
#define DESTROY_KEY XK_d
#define STICK_KEY XK_s
#define ZOOM_KEY XK_z
#define SNAPLEFT_KEY XK_h
#define SNAPRIGHT_KEY XK_l
#define SNAPTOP_KEY XK_k
#define SNAPBOTTOM_KEY XK_j
#define SNAPTOPLEFT_KEY XK_q
#define SNAPBOTTOMLEFT_KEY XK_w
#define SNAPBOTTOMRIGHT_KEY XK_o
#define SNAPTOPRIGHT_KEY XK_p
#define SNAPCENTER_KEY XK_c
#define NEXTVIRT_KEY XK_Right
#define PREVVIRT_KEY XK_Left
#define LAUNCH_KEY XK_slash
// ignore these for now -- this is a feature in development
#define STICKYTOFRONT_KEY XK_t
#define STICKYTOBACK_KEY XK_b

166
key.c
View file

@ -30,26 +30,66 @@ static void alttab(int shift);
void keysetup(void) {
int i;
int tabcode = XKeysymToKeycode(dpy, XK_Tab);
#ifdef DESTROY_KEY
int dcode = XKeysymToKeycode(dpy, DESTROY_KEY);
#endif
#ifdef ICON_KEY
int icode = XKeysymToKeycode(dpy, ICON_KEY);
#endif
#ifdef UNHIDE_KEY
int ucode = XKeysymToKeycode(dpy, UNHIDE_KEY);
#endif
#ifdef MAX_KEY
int mcode = XKeysymToKeycode(dpy, MAX_KEY);
#endif
#ifdef MOVE_KEY
int vcode = XKeysymToKeycode(dpy, MOVE_KEY);
#endif
#ifdef RESIZE_KEY
int rcode = XKeysymToKeycode(dpy, RESIZE_KEY);
#endif
#ifdef STICK_KEY
int scode = XKeysymToKeycode(dpy, STICK_KEY);
#endif
#ifdef SNAPLEFT_KEY
int hcode = XKeysymToKeycode(dpy, SNAPLEFT_KEY);
#endif
#ifdef SNAPRIGHT_KEY
int lcode = XKeysymToKeycode(dpy, SNAPRIGHT_KEY);
#endif
#ifdef SNAPBOTTOM_KEY
int jcode = XKeysymToKeycode(dpy, SNAPBOTTOM_KEY);
#endif
#ifdef SNAPTOP_KEY
int kcode = XKeysymToKeycode(dpy, SNAPTOP_KEY);
#endif
#ifdef SNAPTOPLEFT_KEY
int qcode = XKeysymToKeycode(dpy, SNAPTOPLEFT_KEY);
#endif
#ifdef SNAPBOTTOMLEFT_KEY
int wcode = XKeysymToKeycode(dpy, SNAPBOTTOMLEFT_KEY);
#endif
#ifdef SNAPBOTTOMRIGHT_KEY
int ocode = XKeysymToKeycode(dpy, SNAPBOTTOMRIGHT_KEY);
#endif
#ifdef SNAPTOPRIGHT_KEY
int pcode = XKeysymToKeycode(dpy, SNAPTOPRIGHT_KEY);
#endif
#ifdef SNAPCENTER_KEY
int ccode = XKeysymToKeycode(dpy, SNAPCENTER_KEY);
#endif
#ifdef LAUNCH_KEY
int slcode = XKeysymToKeycode(dpy, LAUNCH_KEY);
#endif
#ifdef ZOOM_KEY
int zcode = XKeysymToKeycode(dpy, ZOOM_KEY);
#endif
#ifdef NEXTVIRT_KEY
int rightcode = XKeysymToKeycode(dpy, NEXTVIRT_KEY);
#endif
#ifdef PREVVIRT_KEY
int leftcode = XKeysymToKeycode(dpy, PREVVIRT_KEY);
#endif
#ifdef DEVEL
int tcode = XKeysymToKeycode(dpy, STICKYTOFRONT_KEY);
int bcode = XKeysymToKeycode(dpy, STICKYTOBACK_KEY);
@ -64,6 +104,7 @@ void keysetup(void) {
0,
GrabModeSync,
GrabModeAsync);
#ifdef DESTROY_KEY
XGrabKey(
dpy,
dcode,
@ -72,6 +113,8 @@ void keysetup(void) {
0,
GrabModeSync,
GrabModeAsync);
#endif
#ifdef ICON_KEY
XGrabKey(
dpy,
icode,
@ -80,6 +123,8 @@ void keysetup(void) {
0,
GrabModeSync,
GrabModeAsync);
#endif
#ifdef UNHIDE_KEY
XGrabKey(
dpy,
ucode,
@ -88,6 +133,8 @@ void keysetup(void) {
0,
GrabModeSync,
GrabModeAsync);
#endif
#ifdef RESIZE_KEY
XGrabKey(
dpy,
rcode,
@ -96,6 +143,8 @@ void keysetup(void) {
0,
GrabModeSync,
GrabModeAsync);
#endif
#ifdef MOVE_KEY
XGrabKey(
dpy,
vcode,
@ -104,6 +153,8 @@ void keysetup(void) {
0,
GrabModeSync,
GrabModeAsync);
#endif
#ifdef MAX_KEY
XGrabKey(
dpy,
mcode,
@ -112,6 +163,8 @@ void keysetup(void) {
0,
GrabModeSync,
GrabModeAsync);
#endif
#ifdef STICK_KEY
XGrabKey(
dpy,
scode,
@ -120,6 +173,8 @@ void keysetup(void) {
0,
GrabModeSync,
GrabModeAsync);
#endif
#ifdef SNAPLEFT_KEY
XGrabKey(
dpy,
hcode,
@ -128,6 +183,8 @@ void keysetup(void) {
0,
GrabModeSync,
GrabModeAsync);
#endif
#ifdef SNAPRIGHT_KEY
XGrabKey(
dpy,
lcode,
@ -136,6 +193,8 @@ void keysetup(void) {
0,
GrabModeSync,
GrabModeAsync);
#endif
#ifdef SNAPBOTTOM_KEY
XGrabKey(
dpy,
jcode,
@ -144,6 +203,8 @@ void keysetup(void) {
0,
GrabModeSync,
GrabModeAsync);
#endif
#ifdef SNAPTOP_KEY
XGrabKey(
dpy,
kcode,
@ -152,6 +213,8 @@ void keysetup(void) {
0,
GrabModeSync,
GrabModeAsync);
#endif
#ifdef SNAPTOPLEFT_KEY
XGrabKey(
dpy,
qcode,
@ -160,6 +223,8 @@ void keysetup(void) {
0,
GrabModeSync,
GrabModeAsync);
#endif
#ifdef SNAPBOTTOMLEFT_KEY
XGrabKey(
dpy,
wcode,
@ -168,6 +233,8 @@ void keysetup(void) {
0,
GrabModeSync,
GrabModeAsync);
#endif
#ifdef SNAPBOTTOMRIGHT_KEY
XGrabKey(
dpy,
ocode,
@ -176,6 +243,8 @@ void keysetup(void) {
0,
GrabModeSync,
GrabModeAsync);
#endif
#ifdef SNAPTOPRIGHT_KEY
XGrabKey(
dpy,
pcode,
@ -184,6 +253,8 @@ void keysetup(void) {
0,
GrabModeSync,
GrabModeAsync);
#endif
#ifdef SNAPCENTER_KEY
XGrabKey(
dpy,
ccode,
@ -200,6 +271,8 @@ void keysetup(void) {
0,
GrabModeSync,
GrabModeAsync);
#endif
#ifdef PREVVIRT_KEY
XGrabKey(
dpy,
leftcode,
@ -208,6 +281,8 @@ void keysetup(void) {
0,
GrabModeSync,
GrabModeAsync);
#endif
#ifdef NEXTVIRT_KEY
XGrabKey(
dpy,
rightcode,
@ -216,6 +291,8 @@ void keysetup(void) {
0,
GrabModeSync,
GrabModeAsync);
#endif
#ifdef LAUNCH_KEY
XGrabKey(
dpy,
slcode,
@ -224,6 +301,8 @@ void keysetup(void) {
0,
GrabModeSync,
GrabModeAsync);
#endif
#ifdef ZOOM_KEY
XGrabKey(
dpy,
zcode,
@ -232,6 +311,7 @@ void keysetup(void) {
0,
GrabModeSync,
GrabModeAsync);
#endif
XGrabKey(
dpy,
tabcode,
@ -272,26 +352,66 @@ void keypress(XKeyEvent* e) {
* process key press here
*/
int tabcode = XKeysymToKeycode(dpy, XK_Tab);
#ifdef DESTROY_KEY
int dcode = XKeysymToKeycode(dpy, DESTROY_KEY);
#endif
#ifdef ICON_KEY
int icode = XKeysymToKeycode(dpy, ICON_KEY);
#endif
#ifdef UNHIDE_KEY
int ucode = XKeysymToKeycode(dpy, UNHIDE_KEY);
#endif
#ifdef MAX_KEY
int mcode = XKeysymToKeycode(dpy, MAX_KEY);
#endif
#ifdef MOVE_KEY
int vcode = XKeysymToKeycode(dpy, MOVE_KEY);
#endif
#ifdef STICK_KEY
int scode = XKeysymToKeycode(dpy, STICK_KEY);
#endif
#ifdef RESIZE_KEY
int rcode = XKeysymToKeycode(dpy, RESIZE_KEY);
#endif
#ifdef LAUNCH_KEY
int slcode = XKeysymToKeycode(dpy, LAUNCH_KEY);
#endif
#ifdef ZOOM_KEY
int zcode = XKeysymToKeycode(dpy, ZOOM_KEY);
#endif
#ifdef SNAPLEFT_KEY
int hcode = XKeysymToKeycode(dpy, SNAPLEFT_KEY);
#endif
#ifdef SNAPRIGHT_KEY
int lcode = XKeysymToKeycode(dpy, SNAPRIGHT_KEY);
#endif
#ifdef SNAPBOTTOM_KEY
int jcode = XKeysymToKeycode(dpy, SNAPBOTTOM_KEY);
#endif
#ifdef SNAPTOP_KEY
int kcode = XKeysymToKeycode(dpy, SNAPTOP_KEY);
#endif
#ifdef SNAPTOPLEFT_KEY
int qcode = XKeysymToKeycode(dpy, SNAPTOPLEFT_KEY);
#endif
#ifdef SNAPBOTTOMLEFT_KEY
int wcode = XKeysymToKeycode(dpy, SNAPBOTTOMLEFT_KEY);
#endif
#ifdef SNAPBOTTOMRIGHT_KEY
int ocode = XKeysymToKeycode(dpy, SNAPBOTTOMRIGHT_KEY);
#endif
#ifdef SNAPTOPRIGHT_KEY
int pcode = XKeysymToKeycode(dpy, SNAPTOPRIGHT_KEY);
#endif
#ifdef SNAPCENTER_KEY
int ccode = XKeysymToKeycode(dpy, SNAPCENTER_KEY);
#endif
#ifdef NEXTVIRT_KEY
int rightcode = XKeysymToKeycode(dpy, NEXTVIRT_KEY);
#endif
#ifdef PREVVIRT_KEY
int leftcode = XKeysymToKeycode(dpy, PREVVIRT_KEY);
#endif
#ifdef DEVEL
int tcode = XKeysymToKeycode(dpy, STICKYTOFRONT_KEY);
int bcode = XKeysymToKeycode(dpy, STICKYTOBACK_KEY);
@ -303,16 +423,27 @@ void keypress(XKeyEvent* e) {
/* basic wm functionality */
if (e->keycode == tabcode && (e->state & Mod1Mask) == (1 << 3))
alttab(e->state & ShiftMask);
#ifdef DESTROY_KEY
else if (e->keycode == dcode && (e->state & SHORTCUTMOD) == (MODBITS))
delete (current, 0);
#endif
#ifdef ICON_KEY
else if (e->keycode == icode && (e->state & SHORTCUTMOD) == (MODBITS))
hide(current);
#endif
#ifdef UNHIDE_KEY
else if (e->keycode == ucode && (e->state & SHORTCUTMOD) == (MODBITS))
unhide(0, 1);
#endif
#ifdef MOVE_KEY
else if (e->keycode == vcode && (e->state & SHORTCUTMOD) == (MODBITS))
move(current, Button3);
#endif
#ifdef RESIZE_KEY
else if (e->keycode == rcode && (e->state & SHORTCUTMOD) == (MODBITS))
reshape(current, Button3, sweep, 0);
#endif
#ifdef MAX_KEY
else if (e->keycode == mcode && (e->state & SHORTCUTMOD) == (MODBITS))
quickreshape(
current,
@ -320,12 +451,18 @@ void keypress(XKeyEvent* e) {
-BORDER,
ra.width + 2 * BORDER,
ra.height + 2 * BORDER);
#endif
#ifdef STICK_KEY
else if (e->keycode == scode && (e->state & SHORTCUTMOD) == (MODBITS))
stick(current);
#endif
#ifdef ZOOM_KEY
else if (e->keycode == zcode && (e->state & SHORTCUTMOD) == (MODBITS))
zoom = !zoom;
#endif
/* half snap */
#ifdef SNAPLEFT_KEY
else if (e->keycode == hcode && (e->state & SHORTCUTMOD) == (MODBITS))
quickreshape(
current,
@ -333,6 +470,8 @@ void keypress(XKeyEvent* e) {
GAPSZ,
ra.width / 2 - 1.5 * GAPSZ,
ra.height - 2 * GAPSZ);
#endif
#ifdef SNAPRIGHT_KEY
else if (e->keycode == lcode && (e->state & SHORTCUTMOD) == (MODBITS))
quickreshape(
current,
@ -340,6 +479,8 @@ void keypress(XKeyEvent* e) {
GAPSZ,
ra.width / 2 - 1.5 * GAPSZ,
ra.height - 2 * GAPSZ);
#endif
#ifdef SNAPBOTTOM_KEY
else if (e->keycode == jcode && (e->state & SHORTCUTMOD) == (MODBITS))
quickreshape(
current,
@ -347,6 +488,8 @@ void keypress(XKeyEvent* e) {
ra.height / 2 + 0.5 * GAPSZ,
ra.width - 2 * GAPSZ,
ra.height / 2 - 1.5 * GAPSZ);
#endif
#ifdef SNAPTOP_KEY
else if (e->keycode == kcode && (e->state & SHORTCUTMOD) == (MODBITS))
quickreshape(
current,
@ -354,8 +497,10 @@ void keypress(XKeyEvent* e) {
GAPSZ,
ra.width - 2 * GAPSZ,
ra.height / 2 - 1.5 * GAPSZ);
#endif
/* quarter snap */
#ifdef SNAPTOPLEFT_KEY
else if (e->keycode == qcode && (e->state & SHORTCUTMOD) == (MODBITS))
quickreshape(
current,
@ -363,6 +508,8 @@ void keypress(XKeyEvent* e) {
GAPSZ,
ra.width / 2 - 1.5 * GAPSZ,
ra.height / 2 - 1.5 * GAPSZ);
#endif
#ifdef SNAPBOTTOMLEFT_KEY
else if (e->keycode == wcode && (e->state & SHORTCUTMOD) == (MODBITS))
quickreshape(
current,
@ -370,6 +517,8 @@ void keypress(XKeyEvent* e) {
ra.height / 2 + 0.5 * GAPSZ,
ra.width / 2 - 1.5 * GAPSZ,
ra.height / 2 - 1.5 * GAPSZ);
#endif
#ifdef SNAPBOTTOMRIGHT_KEY
else if (e->keycode == ocode && (e->state & SHORTCUTMOD) == (MODBITS))
quickreshape(
current,
@ -377,6 +526,8 @@ void keypress(XKeyEvent* e) {
ra.height / 2 + 0.5 * GAPSZ,
ra.width / 2 - 1.5 * GAPSZ,
ra.height / 2 - 1.5 * GAPSZ);
#endif
#ifdef SNAPTOPRIGHT_KEY
else if (e->keycode == pcode && (e->state & SHORTCUTMOD) == (MODBITS))
quickreshape(
current,
@ -384,8 +535,10 @@ void keypress(XKeyEvent* e) {
GAPSZ,
ra.width / 2 - 1.5 * GAPSZ,
ra.height / 2 - 1.5 * GAPSZ);
#endif
/* center snap */
#ifdef CENTERSNAP_KEY
else if (e->keycode == ccode && (e->state & SHORTCUTMOD) == (MODBITS)) {
if ((e->state & ShiftMask) == (1 << 0)) {
#ifdef CENTERVMAX
@ -401,6 +554,7 @@ void keypress(XKeyEvent* e) {
#endif
}
}
#endif
#ifdef DEVEL
/* manage autostuck windows */
@ -411,7 +565,8 @@ void keypress(XKeyEvent* e) {
#endif
/* launch */
if (e->keycode == slcode && (e->state & SHORTCUTMOD) == (MODBITS)) {
#ifdef LAUNCH_KEY
else if (e->keycode == slcode && (e->state & SHORTCUTMOD) == (MODBITS)) {
kbLaunch = 1;
if (fork() == 0) {
close(ConnectionNumber(dpy));
@ -431,21 +586,26 @@ void keypress(XKeyEvent* e) {
perror("ryudo: exec urxvt/9term/xterm failed");
}
}
#endif
/* switch virts */
if (e->keycode == rightcode && (e->state & SHORTCUTMOD) == (MODBITS))
#ifdef NEXTVIRT_KEY
else if (e->keycode == rightcode && (e->state & SHORTCUTMOD) == (MODBITS))
if (numvirtuals > 1)
if (virt < numvirtuals - 1)
switch_to(virt + 1);
else
switch_to(0);
#endif
if (e->keycode == leftcode && (e->state & SHORTCUTMOD) == (MODBITS))
#ifdef PREVVIRT_KEY
else if (e->keycode == leftcode && (e->state & SHORTCUTMOD) == (MODBITS))
if (numvirtuals > 1)
if (virt > 0)
switch_to(virt - 1);
else
switch_to(numvirtuals - 1);
#endif
XAllowEvents(dpy, SyncKeyboard, e->time);
}