2019-12-02 18:23:00 +00:00
|
|
|
/*
|
2024-09-26 13:50:54 +00:00
|
|
|
* Copyright (c) 2019 Iris Lightshard, 2005 Russ Cox, 1994-1996 David Hogan
|
2019-12-02 18:23:00 +00:00
|
|
|
* see README for license details
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <signal.h>
|
2022-01-18 23:29:16 +00:00
|
|
|
#include <sys/wait.h>
|
2019-12-02 18:23:00 +00:00
|
|
|
#include <X11/X.h>
|
|
|
|
#include <X11/Xos.h>
|
|
|
|
#include <X11/Xlib.h>
|
|
|
|
#include <X11/Xutil.h>
|
|
|
|
#include <X11/Xatom.h>
|
|
|
|
#include <X11/keysym.h>
|
|
|
|
#include <X11/extensions/shape.h>
|
2022-02-27 17:18:17 +00:00
|
|
|
#include <X11/extensions/Xrandr.h>
|
2019-12-02 18:23:00 +00:00
|
|
|
#include "config.h"
|
|
|
|
#include "dat.h"
|
|
|
|
#include "fns.h"
|
|
|
|
#include "patchlevel.h"
|
|
|
|
|
2021-02-26 18:01:22 +00:00
|
|
|
enum { GrabAltTab, GrabAltAny };
|
2019-12-02 18:23:00 +00:00
|
|
|
|
|
|
|
/*static int tabcode = 0x17; */
|
|
|
|
/*static int altcode = 0x40; */
|
|
|
|
/*static int pgupcode = 0x63; */
|
|
|
|
/*static int pgdowncode = 0x69; */
|
|
|
|
|
|
|
|
static void alttab(int shift);
|
|
|
|
|
2021-02-26 19:50:23 +00:00
|
|
|
void keysetup(void) {
|
2021-02-26 18:01:22 +00:00
|
|
|
int i;
|
|
|
|
int tabcode = XKeysymToKeycode(dpy, XK_Tab);
|
2021-03-08 04:35:01 +00:00
|
|
|
#ifdef DESTROY_KEY
|
2021-02-26 18:01:22 +00:00
|
|
|
int dcode = XKeysymToKeycode(dpy, DESTROY_KEY);
|
2021-03-08 04:35:01 +00:00
|
|
|
#endif
|
|
|
|
#ifdef ICON_KEY
|
2021-02-26 18:01:22 +00:00
|
|
|
int icode = XKeysymToKeycode(dpy, ICON_KEY);
|
2021-03-08 04:35:01 +00:00
|
|
|
#endif
|
|
|
|
#ifdef UNHIDE_KEY
|
2021-02-26 18:01:22 +00:00
|
|
|
int ucode = XKeysymToKeycode(dpy, UNHIDE_KEY);
|
2021-03-08 04:35:01 +00:00
|
|
|
#endif
|
|
|
|
#ifdef MAX_KEY
|
2021-02-26 18:01:22 +00:00
|
|
|
int mcode = XKeysymToKeycode(dpy, MAX_KEY);
|
2021-03-08 04:35:01 +00:00
|
|
|
#endif
|
|
|
|
#ifdef MOVE_KEY
|
2021-02-26 18:01:22 +00:00
|
|
|
int vcode = XKeysymToKeycode(dpy, MOVE_KEY);
|
2021-03-08 04:35:01 +00:00
|
|
|
#endif
|
|
|
|
#ifdef RESIZE_KEY
|
2021-02-26 18:01:22 +00:00
|
|
|
int rcode = XKeysymToKeycode(dpy, RESIZE_KEY);
|
2021-03-08 04:35:01 +00:00
|
|
|
#endif
|
|
|
|
#ifdef STICK_KEY
|
2021-02-26 18:01:22 +00:00
|
|
|
int scode = XKeysymToKeycode(dpy, STICK_KEY);
|
2021-03-08 04:35:01 +00:00
|
|
|
#endif
|
2022-03-01 06:40:32 +00:00
|
|
|
#ifdef WRANGLE_KEY
|
|
|
|
int acode = XKeysymToKeycode(dpy, WRANGLE_KEY);
|
|
|
|
#endif
|
2021-03-08 04:35:01 +00:00
|
|
|
#ifdef SNAPLEFT_KEY
|
2021-02-26 18:01:22 +00:00
|
|
|
int hcode = XKeysymToKeycode(dpy, SNAPLEFT_KEY);
|
2021-03-08 04:35:01 +00:00
|
|
|
#endif
|
|
|
|
#ifdef SNAPRIGHT_KEY
|
2021-02-26 18:01:22 +00:00
|
|
|
int lcode = XKeysymToKeycode(dpy, SNAPRIGHT_KEY);
|
2021-03-08 04:35:01 +00:00
|
|
|
#endif
|
|
|
|
#ifdef SNAPBOTTOM_KEY
|
2021-02-26 18:01:22 +00:00
|
|
|
int jcode = XKeysymToKeycode(dpy, SNAPBOTTOM_KEY);
|
2021-03-08 04:35:01 +00:00
|
|
|
#endif
|
|
|
|
#ifdef SNAPTOP_KEY
|
2021-02-26 18:01:22 +00:00
|
|
|
int kcode = XKeysymToKeycode(dpy, SNAPTOP_KEY);
|
2021-03-08 04:35:01 +00:00
|
|
|
#endif
|
|
|
|
#ifdef SNAPTOPLEFT_KEY
|
2021-02-26 18:01:22 +00:00
|
|
|
int qcode = XKeysymToKeycode(dpy, SNAPTOPLEFT_KEY);
|
2021-03-08 04:35:01 +00:00
|
|
|
#endif
|
|
|
|
#ifdef SNAPBOTTOMLEFT_KEY
|
2021-02-26 18:01:22 +00:00
|
|
|
int wcode = XKeysymToKeycode(dpy, SNAPBOTTOMLEFT_KEY);
|
2021-03-08 04:35:01 +00:00
|
|
|
#endif
|
|
|
|
#ifdef SNAPBOTTOMRIGHT_KEY
|
2021-02-26 18:01:22 +00:00
|
|
|
int ocode = XKeysymToKeycode(dpy, SNAPBOTTOMRIGHT_KEY);
|
2021-03-08 04:35:01 +00:00
|
|
|
#endif
|
|
|
|
#ifdef SNAPTOPRIGHT_KEY
|
2021-02-26 18:01:22 +00:00
|
|
|
int pcode = XKeysymToKeycode(dpy, SNAPTOPRIGHT_KEY);
|
2021-03-08 04:35:01 +00:00
|
|
|
#endif
|
|
|
|
#ifdef SNAPCENTER_KEY
|
2021-02-26 18:01:22 +00:00
|
|
|
int ccode = XKeysymToKeycode(dpy, SNAPCENTER_KEY);
|
2021-03-08 04:35:01 +00:00
|
|
|
#endif
|
|
|
|
#ifdef LAUNCH_KEY
|
2021-02-26 18:01:22 +00:00
|
|
|
int slcode = XKeysymToKeycode(dpy, LAUNCH_KEY);
|
2021-03-08 04:35:01 +00:00
|
|
|
#endif
|
|
|
|
#ifdef ZOOM_KEY
|
2021-03-06 04:55:13 +00:00
|
|
|
int zcode = XKeysymToKeycode(dpy, ZOOM_KEY);
|
2021-03-08 04:35:01 +00:00
|
|
|
#endif
|
|
|
|
#ifdef NEXTVIRT_KEY
|
2021-02-26 18:01:22 +00:00
|
|
|
int rightcode = XKeysymToKeycode(dpy, NEXTVIRT_KEY);
|
2021-03-08 04:35:01 +00:00
|
|
|
#endif
|
|
|
|
#ifdef PREVVIRT_KEY
|
2021-02-26 18:01:22 +00:00
|
|
|
int leftcode = XKeysymToKeycode(dpy, PREVVIRT_KEY);
|
2021-03-08 04:35:01 +00:00
|
|
|
#endif
|
2021-02-21 23:13:58 +00:00
|
|
|
#ifdef DEVEL
|
2021-02-26 18:01:22 +00:00
|
|
|
int tcode = XKeysymToKeycode(dpy, STICKYTOFRONT_KEY);
|
|
|
|
int bcode = XKeysymToKeycode(dpy, STICKYTOBACK_KEY);
|
2021-02-21 23:13:58 +00:00
|
|
|
#endif
|
2019-12-02 18:23:00 +00:00
|
|
|
|
2021-02-26 18:01:22 +00:00
|
|
|
for (i = 0; i < num_screens; i++) {
|
|
|
|
XGrabKey(
|
2021-02-26 19:50:23 +00:00
|
|
|
dpy,
|
|
|
|
tabcode,
|
|
|
|
Mod1Mask,
|
|
|
|
screens[i].root,
|
|
|
|
0,
|
|
|
|
GrabModeSync,
|
|
|
|
GrabModeAsync);
|
2021-11-11 19:00:12 +00:00
|
|
|
XGrabKey(
|
|
|
|
dpy,
|
|
|
|
tabcode,
|
|
|
|
Mod1Mask | Mod2Mask,
|
|
|
|
screens[i].root,
|
|
|
|
0,
|
|
|
|
GrabModeSync,
|
|
|
|
GrabModeAsync);
|
2021-03-08 04:35:01 +00:00
|
|
|
#ifdef DESTROY_KEY
|
2021-02-26 18:01:22 +00:00
|
|
|
XGrabKey(
|
2021-02-26 19:50:23 +00:00
|
|
|
dpy,
|
|
|
|
dcode,
|
|
|
|
SHORTCUTMOD,
|
|
|
|
screens[i].root,
|
|
|
|
0,
|
|
|
|
GrabModeSync,
|
|
|
|
GrabModeAsync);
|
2021-11-11 19:00:12 +00:00
|
|
|
XGrabKey(
|
|
|
|
dpy,
|
|
|
|
dcode,
|
|
|
|
SHORTCUTMOD | Mod2Mask,
|
|
|
|
screens[i].root,
|
|
|
|
0,
|
|
|
|
GrabModeSync,
|
|
|
|
GrabModeAsync);
|
2021-03-08 04:35:01 +00:00
|
|
|
#endif
|
|
|
|
#ifdef ICON_KEY
|
2021-02-26 18:01:22 +00:00
|
|
|
XGrabKey(
|
2021-02-26 19:50:23 +00:00
|
|
|
dpy,
|
|
|
|
icode,
|
|
|
|
SHORTCUTMOD,
|
|
|
|
screens[i].root,
|
|
|
|
0,
|
|
|
|
GrabModeSync,
|
|
|
|
GrabModeAsync);
|
2021-11-11 19:00:12 +00:00
|
|
|
XGrabKey(
|
|
|
|
dpy,
|
|
|
|
icode,
|
|
|
|
SHORTCUTMOD | Mod2Mask,
|
|
|
|
screens[i].root,
|
|
|
|
0,
|
|
|
|
GrabModeSync,
|
|
|
|
GrabModeAsync);
|
2021-03-08 04:35:01 +00:00
|
|
|
#endif
|
|
|
|
#ifdef UNHIDE_KEY
|
2021-02-26 18:01:22 +00:00
|
|
|
XGrabKey(
|
2021-02-26 19:50:23 +00:00
|
|
|
dpy,
|
|
|
|
ucode,
|
|
|
|
SHORTCUTMOD,
|
|
|
|
screens[i].root,
|
|
|
|
0,
|
|
|
|
GrabModeSync,
|
|
|
|
GrabModeAsync);
|
2021-11-11 19:00:12 +00:00
|
|
|
XGrabKey(
|
|
|
|
dpy,
|
|
|
|
ucode,
|
|
|
|
SHORTCUTMOD | Mod2Mask,
|
|
|
|
screens[i].root,
|
|
|
|
0,
|
|
|
|
GrabModeSync,
|
|
|
|
GrabModeAsync);
|
2021-03-08 04:35:01 +00:00
|
|
|
#endif
|
|
|
|
#ifdef RESIZE_KEY
|
2021-02-26 18:01:22 +00:00
|
|
|
XGrabKey(
|
2021-02-26 19:50:23 +00:00
|
|
|
dpy,
|
|
|
|
rcode,
|
|
|
|
SHORTCUTMOD,
|
|
|
|
screens[i].root,
|
|
|
|
0,
|
|
|
|
GrabModeSync,
|
|
|
|
GrabModeAsync);
|
2021-11-11 19:00:12 +00:00
|
|
|
XGrabKey(
|
|
|
|
dpy,
|
|
|
|
rcode,
|
|
|
|
SHORTCUTMOD | Mod2Mask,
|
|
|
|
screens[i].root,
|
|
|
|
0,
|
|
|
|
GrabModeSync,
|
|
|
|
GrabModeAsync);
|
2021-03-08 04:35:01 +00:00
|
|
|
#endif
|
|
|
|
#ifdef MOVE_KEY
|
2021-02-26 18:01:22 +00:00
|
|
|
XGrabKey(
|
2021-02-26 19:50:23 +00:00
|
|
|
dpy,
|
|
|
|
vcode,
|
|
|
|
SHORTCUTMOD,
|
|
|
|
screens[i].root,
|
|
|
|
0,
|
|
|
|
GrabModeSync,
|
|
|
|
GrabModeAsync);
|
2021-11-11 19:00:12 +00:00
|
|
|
XGrabKey(
|
|
|
|
dpy,
|
|
|
|
vcode,
|
|
|
|
SHORTCUTMOD | Mod2Mask,
|
|
|
|
screens[i].root,
|
|
|
|
0,
|
|
|
|
GrabModeSync,
|
|
|
|
GrabModeAsync);
|
2021-03-08 04:35:01 +00:00
|
|
|
#endif
|
|
|
|
#ifdef MAX_KEY
|
2021-02-26 18:01:22 +00:00
|
|
|
XGrabKey(
|
2021-02-26 19:50:23 +00:00
|
|
|
dpy,
|
|
|
|
mcode,
|
|
|
|
SHORTCUTMOD,
|
|
|
|
screens[i].root,
|
|
|
|
0,
|
|
|
|
GrabModeSync,
|
|
|
|
GrabModeAsync);
|
2021-11-11 19:00:12 +00:00
|
|
|
XGrabKey(
|
|
|
|
dpy,
|
|
|
|
mcode,
|
|
|
|
SHORTCUTMOD | Mod2Mask,
|
|
|
|
screens[i].root,
|
|
|
|
0,
|
|
|
|
GrabModeSync,
|
|
|
|
GrabModeAsync);
|
2021-03-08 04:35:01 +00:00
|
|
|
#endif
|
|
|
|
#ifdef STICK_KEY
|
2021-02-26 18:01:22 +00:00
|
|
|
XGrabKey(
|
2021-02-26 19:50:23 +00:00
|
|
|
dpy,
|
|
|
|
scode,
|
|
|
|
SHORTCUTMOD,
|
|
|
|
screens[i].root,
|
|
|
|
0,
|
|
|
|
GrabModeSync,
|
|
|
|
GrabModeAsync);
|
2021-11-11 19:00:12 +00:00
|
|
|
XGrabKey(
|
|
|
|
dpy,
|
|
|
|
scode,
|
|
|
|
SHORTCUTMOD | Mod2Mask,
|
|
|
|
screens[i].root,
|
|
|
|
0,
|
|
|
|
GrabModeSync,
|
|
|
|
GrabModeAsync);
|
2021-03-08 04:35:01 +00:00
|
|
|
#endif
|
2022-03-01 06:40:32 +00:00
|
|
|
#ifdef WRANGLE_KEY
|
|
|
|
XGrabKey(
|
|
|
|
dpy,
|
|
|
|
acode,
|
|
|
|
SHORTCUTMOD,
|
|
|
|
screens[i].root,
|
|
|
|
0,
|
|
|
|
GrabModeSync,
|
|
|
|
GrabModeAsync);
|
|
|
|
XGrabKey(
|
|
|
|
dpy,
|
|
|
|
acode,
|
|
|
|
SHORTCUTMOD | Mod2Mask,
|
|
|
|
screens[i].root,
|
|
|
|
0,
|
|
|
|
GrabModeSync,
|
|
|
|
GrabModeAsync);
|
|
|
|
#endif
|
2021-03-08 04:35:01 +00:00
|
|
|
#ifdef SNAPLEFT_KEY
|
2021-02-26 18:01:22 +00:00
|
|
|
XGrabKey(
|
2021-02-26 19:50:23 +00:00
|
|
|
dpy,
|
|
|
|
hcode,
|
|
|
|
SHORTCUTMOD,
|
|
|
|
screens[i].root,
|
|
|
|
0,
|
|
|
|
GrabModeSync,
|
|
|
|
GrabModeAsync);
|
2021-11-11 19:00:12 +00:00
|
|
|
XGrabKey(
|
|
|
|
dpy,
|
|
|
|
hcode,
|
|
|
|
SHORTCUTMOD | Mod2Mask,
|
|
|
|
screens[i].root,
|
|
|
|
0,
|
|
|
|
GrabModeSync,
|
|
|
|
GrabModeAsync);
|
2021-03-08 04:35:01 +00:00
|
|
|
#endif
|
|
|
|
#ifdef SNAPRIGHT_KEY
|
2021-02-26 18:01:22 +00:00
|
|
|
XGrabKey(
|
2021-02-26 19:50:23 +00:00
|
|
|
dpy,
|
|
|
|
lcode,
|
|
|
|
SHORTCUTMOD,
|
|
|
|
screens[i].root,
|
|
|
|
0,
|
|
|
|
GrabModeSync,
|
|
|
|
GrabModeAsync);
|
2021-11-11 19:00:12 +00:00
|
|
|
XGrabKey(
|
|
|
|
dpy,
|
|
|
|
lcode,
|
|
|
|
SHORTCUTMOD | Mod2Mask,
|
|
|
|
screens[i].root,
|
|
|
|
0,
|
|
|
|
GrabModeSync,
|
|
|
|
GrabModeAsync);
|
2021-03-08 04:35:01 +00:00
|
|
|
#endif
|
|
|
|
#ifdef SNAPBOTTOM_KEY
|
2021-02-26 18:01:22 +00:00
|
|
|
XGrabKey(
|
2021-02-26 19:50:23 +00:00
|
|
|
dpy,
|
|
|
|
jcode,
|
|
|
|
SHORTCUTMOD,
|
|
|
|
screens[i].root,
|
|
|
|
0,
|
|
|
|
GrabModeSync,
|
|
|
|
GrabModeAsync);
|
2021-11-11 19:00:12 +00:00
|
|
|
XGrabKey(
|
|
|
|
dpy,
|
|
|
|
jcode,
|
|
|
|
SHORTCUTMOD | Mod2Mask,
|
|
|
|
screens[i].root,
|
|
|
|
0,
|
|
|
|
GrabModeSync,
|
|
|
|
GrabModeAsync);
|
2021-03-08 04:35:01 +00:00
|
|
|
#endif
|
|
|
|
#ifdef SNAPTOP_KEY
|
2021-02-26 18:01:22 +00:00
|
|
|
XGrabKey(
|
2021-02-26 19:50:23 +00:00
|
|
|
dpy,
|
|
|
|
kcode,
|
|
|
|
SHORTCUTMOD,
|
|
|
|
screens[i].root,
|
|
|
|
0,
|
|
|
|
GrabModeSync,
|
|
|
|
GrabModeAsync);
|
2021-11-11 19:00:12 +00:00
|
|
|
XGrabKey(
|
|
|
|
dpy,
|
|
|
|
kcode,
|
|
|
|
SHORTCUTMOD | Mod2Mask,
|
|
|
|
screens[i].root,
|
|
|
|
0,
|
|
|
|
GrabModeSync,
|
|
|
|
GrabModeAsync);
|
2021-03-08 04:35:01 +00:00
|
|
|
#endif
|
|
|
|
#ifdef SNAPTOPLEFT_KEY
|
2021-02-26 18:01:22 +00:00
|
|
|
XGrabKey(
|
2021-02-26 19:50:23 +00:00
|
|
|
dpy,
|
|
|
|
qcode,
|
|
|
|
SHORTCUTMOD,
|
|
|
|
screens[i].root,
|
|
|
|
0,
|
|
|
|
GrabModeSync,
|
|
|
|
GrabModeAsync);
|
2021-11-11 19:00:12 +00:00
|
|
|
XGrabKey(
|
|
|
|
dpy,
|
|
|
|
qcode,
|
|
|
|
SHORTCUTMOD | Mod2Mask,
|
|
|
|
screens[i].root,
|
|
|
|
0,
|
|
|
|
GrabModeSync,
|
|
|
|
GrabModeAsync);
|
2021-03-08 04:35:01 +00:00
|
|
|
#endif
|
|
|
|
#ifdef SNAPBOTTOMLEFT_KEY
|
2021-02-26 18:01:22 +00:00
|
|
|
XGrabKey(
|
2021-02-26 19:50:23 +00:00
|
|
|
dpy,
|
|
|
|
wcode,
|
|
|
|
SHORTCUTMOD,
|
|
|
|
screens[i].root,
|
|
|
|
0,
|
|
|
|
GrabModeSync,
|
|
|
|
GrabModeAsync);
|
2021-11-11 19:00:12 +00:00
|
|
|
XGrabKey(
|
|
|
|
dpy,
|
|
|
|
wcode,
|
|
|
|
SHORTCUTMOD | Mod2Mask,
|
|
|
|
screens[i].root,
|
|
|
|
0,
|
|
|
|
GrabModeSync,
|
|
|
|
GrabModeAsync);
|
2021-03-08 04:35:01 +00:00
|
|
|
#endif
|
|
|
|
#ifdef SNAPBOTTOMRIGHT_KEY
|
2021-02-26 18:01:22 +00:00
|
|
|
XGrabKey(
|
2021-02-26 19:50:23 +00:00
|
|
|
dpy,
|
|
|
|
ocode,
|
|
|
|
SHORTCUTMOD,
|
|
|
|
screens[i].root,
|
|
|
|
0,
|
|
|
|
GrabModeSync,
|
|
|
|
GrabModeAsync);
|
2021-11-11 19:00:12 +00:00
|
|
|
XGrabKey(
|
|
|
|
dpy,
|
|
|
|
ocode,
|
|
|
|
SHORTCUTMOD | Mod2Mask,
|
|
|
|
screens[i].root,
|
|
|
|
0,
|
|
|
|
GrabModeSync,
|
|
|
|
GrabModeAsync);
|
2021-03-08 04:35:01 +00:00
|
|
|
#endif
|
|
|
|
#ifdef SNAPTOPRIGHT_KEY
|
2021-02-26 18:01:22 +00:00
|
|
|
XGrabKey(
|
2021-02-26 19:50:23 +00:00
|
|
|
dpy,
|
|
|
|
pcode,
|
|
|
|
SHORTCUTMOD,
|
|
|
|
screens[i].root,
|
|
|
|
0,
|
|
|
|
GrabModeSync,
|
|
|
|
GrabModeAsync);
|
2021-11-11 19:00:12 +00:00
|
|
|
XGrabKey(
|
|
|
|
dpy,
|
|
|
|
pcode,
|
|
|
|
SHORTCUTMOD | Mod2Mask,
|
|
|
|
screens[i].root,
|
|
|
|
0,
|
|
|
|
GrabModeSync,
|
|
|
|
GrabModeAsync);
|
2021-03-08 04:35:01 +00:00
|
|
|
#endif
|
|
|
|
#ifdef SNAPCENTER_KEY
|
2021-02-26 22:18:39 +00:00
|
|
|
XGrabKey(
|
|
|
|
dpy,
|
|
|
|
ccode,
|
|
|
|
ShiftMask | SHORTCUTMOD,
|
|
|
|
screens[i].root,
|
|
|
|
0,
|
|
|
|
GrabModeSync,
|
|
|
|
GrabModeAsync);
|
2021-02-26 18:01:22 +00:00
|
|
|
XGrabKey(
|
2021-02-26 19:50:23 +00:00
|
|
|
dpy,
|
|
|
|
ccode,
|
|
|
|
SHORTCUTMOD,
|
|
|
|
screens[i].root,
|
|
|
|
0,
|
|
|
|
GrabModeSync,
|
|
|
|
GrabModeAsync);
|
2021-11-11 19:00:12 +00:00
|
|
|
XGrabKey(
|
|
|
|
dpy,
|
|
|
|
ccode,
|
|
|
|
ShiftMask | SHORTCUTMOD | Mod2Mask,
|
|
|
|
screens[i].root,
|
|
|
|
0,
|
|
|
|
GrabModeSync,
|
|
|
|
GrabModeAsync);
|
|
|
|
XGrabKey(
|
|
|
|
dpy,
|
|
|
|
ccode,
|
|
|
|
SHORTCUTMOD | Mod2Mask,
|
|
|
|
screens[i].root,
|
|
|
|
0,
|
|
|
|
GrabModeSync,
|
|
|
|
GrabModeAsync);
|
2021-03-08 04:35:01 +00:00
|
|
|
#endif
|
|
|
|
#ifdef PREVVIRT_KEY
|
2021-02-26 18:01:22 +00:00
|
|
|
XGrabKey(
|
|
|
|
dpy,
|
|
|
|
leftcode,
|
|
|
|
SHORTCUTMOD,
|
|
|
|
screens[i].root,
|
|
|
|
0,
|
|
|
|
GrabModeSync,
|
|
|
|
GrabModeAsync);
|
2021-11-11 19:00:12 +00:00
|
|
|
XGrabKey(
|
|
|
|
dpy,
|
|
|
|
leftcode,
|
|
|
|
SHORTCUTMOD | Mod2Mask,
|
|
|
|
screens[i].root,
|
|
|
|
0,
|
|
|
|
GrabModeSync,
|
|
|
|
GrabModeAsync);
|
2021-03-08 04:35:01 +00:00
|
|
|
#endif
|
|
|
|
#ifdef NEXTVIRT_KEY
|
2021-02-26 18:01:22 +00:00
|
|
|
XGrabKey(
|
|
|
|
dpy,
|
|
|
|
rightcode,
|
|
|
|
SHORTCUTMOD,
|
|
|
|
screens[i].root,
|
|
|
|
0,
|
|
|
|
GrabModeSync,
|
|
|
|
GrabModeAsync);
|
2021-11-11 19:00:12 +00:00
|
|
|
XGrabKey(
|
|
|
|
dpy,
|
|
|
|
rightcode,
|
|
|
|
SHORTCUTMOD | Mod2Mask,
|
|
|
|
screens[i].root,
|
|
|
|
0,
|
|
|
|
GrabModeSync,
|
|
|
|
GrabModeAsync);
|
2021-03-08 04:35:01 +00:00
|
|
|
#endif
|
|
|
|
#ifdef LAUNCH_KEY
|
2021-02-26 18:01:22 +00:00
|
|
|
XGrabKey(
|
|
|
|
dpy,
|
|
|
|
slcode,
|
|
|
|
SHORTCUTMOD,
|
|
|
|
screens[i].root,
|
|
|
|
0,
|
|
|
|
GrabModeSync,
|
|
|
|
GrabModeAsync);
|
2021-11-11 19:00:12 +00:00
|
|
|
XGrabKey(
|
|
|
|
dpy,
|
|
|
|
slcode,
|
|
|
|
SHORTCUTMOD | Mod2Mask,
|
|
|
|
screens[i].root,
|
|
|
|
0,
|
|
|
|
GrabModeSync,
|
|
|
|
GrabModeAsync);
|
2021-03-08 04:35:01 +00:00
|
|
|
#endif
|
|
|
|
#ifdef ZOOM_KEY
|
2021-03-06 04:55:13 +00:00
|
|
|
XGrabKey(
|
|
|
|
dpy,
|
|
|
|
zcode,
|
|
|
|
SHORTCUTMOD,
|
|
|
|
screens[i].root,
|
|
|
|
0,
|
|
|
|
GrabModeSync,
|
|
|
|
GrabModeAsync);
|
2021-11-11 19:00:12 +00:00
|
|
|
XGrabKey(
|
|
|
|
dpy,
|
|
|
|
zcode,
|
|
|
|
SHORTCUTMOD | Mod2Mask,
|
|
|
|
screens[i].root,
|
|
|
|
0,
|
|
|
|
GrabModeSync,
|
|
|
|
GrabModeAsync);
|
2021-03-08 04:35:01 +00:00
|
|
|
#endif
|
2021-02-26 18:01:22 +00:00
|
|
|
XGrabKey(
|
|
|
|
dpy,
|
|
|
|
tabcode,
|
|
|
|
Mod1Mask | ShiftMask,
|
|
|
|
screens[i].root,
|
|
|
|
0,
|
|
|
|
GrabModeSync,
|
|
|
|
GrabModeAsync);
|
2021-11-11 19:00:12 +00:00
|
|
|
XGrabKey(
|
|
|
|
dpy,
|
|
|
|
tabcode,
|
|
|
|
Mod1Mask | ShiftMask | Mod2Mask,
|
|
|
|
screens[i].root,
|
|
|
|
0,
|
|
|
|
GrabModeSync,
|
|
|
|
GrabModeAsync);
|
2021-02-21 23:13:58 +00:00
|
|
|
#ifdef DEVEL
|
2021-02-26 18:01:22 +00:00
|
|
|
XGrabKey(
|
2021-02-26 19:50:23 +00:00
|
|
|
dpy,
|
|
|
|
tcode,
|
|
|
|
SHORTCUTMOD,
|
|
|
|
screens[i].root,
|
|
|
|
0,
|
|
|
|
GrabModeSync,
|
|
|
|
GrabModeAsync);
|
2021-02-26 18:01:22 +00:00
|
|
|
XGrabKey(
|
2021-02-26 19:50:23 +00:00
|
|
|
dpy,
|
|
|
|
bcode,
|
|
|
|
SHORTCUTMOD,
|
|
|
|
screens[i].root,
|
|
|
|
0,
|
|
|
|
GrabModeSync,
|
|
|
|
GrabModeAsync);
|
2021-11-11 19:00:12 +00:00
|
|
|
XGrabKey(
|
|
|
|
dpy,
|
|
|
|
tcode,
|
|
|
|
SHORTCUTMOD | Mod2Mask,
|
|
|
|
screens[i].root,
|
|
|
|
0,
|
|
|
|
GrabModeSync,
|
|
|
|
GrabModeAsync);
|
|
|
|
XGrabKey(
|
|
|
|
dpy,
|
|
|
|
bcode,
|
|
|
|
SHORTCUTMOD | Mod2Mask,
|
|
|
|
screens[i].root,
|
|
|
|
0,
|
|
|
|
GrabModeSync,
|
|
|
|
GrabModeAsync);
|
2021-02-21 23:13:58 +00:00
|
|
|
#endif
|
2021-02-26 18:01:22 +00:00
|
|
|
/* XGrabKey(dpy, pgupcode, Mod1Mask, screens[i].root, 0, GrabModeSync,
|
|
|
|
* GrabModeAsync); */
|
|
|
|
/* XGrabKey(dpy, pgdowncode, Mod1Mask, screens[i].root, 0, GrabModeSync,
|
|
|
|
* GrabModeAsync); */
|
|
|
|
/* XGrabKey(dpy, altcode, 0, screens[i].root, 0, GrabModeSync,
|
|
|
|
* GrabModeAsync); */
|
|
|
|
}
|
2019-12-02 18:23:00 +00:00
|
|
|
}
|
|
|
|
|
2021-02-26 19:50:23 +00:00
|
|
|
void keypress(XKeyEvent* e) {
|
2021-02-26 18:01:22 +00:00
|
|
|
/*
|
|
|
|
* process key press here
|
|
|
|
*/
|
2022-03-01 06:40:32 +00:00
|
|
|
static int m;
|
|
|
|
static XRRMonitorInfo monitor;
|
|
|
|
|
|
|
|
static int tabcode;
|
2021-03-08 04:35:01 +00:00
|
|
|
#ifdef DESTROY_KEY
|
2022-03-01 06:40:32 +00:00
|
|
|
static int dcode;
|
2021-03-08 04:35:01 +00:00
|
|
|
#endif
|
|
|
|
#ifdef ICON_KEY
|
2022-03-01 06:40:32 +00:00
|
|
|
static int icode;
|
2021-03-08 04:35:01 +00:00
|
|
|
#endif
|
|
|
|
#ifdef UNHIDE_KEY
|
2022-03-01 06:40:32 +00:00
|
|
|
static int ucode;
|
2021-03-08 04:35:01 +00:00
|
|
|
#endif
|
|
|
|
#ifdef MAX_KEY
|
2022-03-01 06:40:32 +00:00
|
|
|
static int mcode;
|
2021-03-08 04:35:01 +00:00
|
|
|
#endif
|
|
|
|
#ifdef MOVE_KEY
|
2022-03-01 06:40:32 +00:00
|
|
|
static int vcode;
|
2021-03-08 04:35:01 +00:00
|
|
|
#endif
|
|
|
|
#ifdef STICK_KEY
|
2022-03-01 06:40:32 +00:00
|
|
|
static int scode;
|
|
|
|
#endif
|
|
|
|
#ifdef WRANGLE_KEY
|
|
|
|
static int acode;
|
2021-03-08 04:35:01 +00:00
|
|
|
#endif
|
|
|
|
#ifdef RESIZE_KEY
|
2022-03-01 06:40:32 +00:00
|
|
|
static int rcode;
|
2021-03-08 04:35:01 +00:00
|
|
|
#endif
|
|
|
|
#ifdef LAUNCH_KEY
|
2022-03-01 06:40:32 +00:00
|
|
|
static int slcode;
|
2021-03-08 04:35:01 +00:00
|
|
|
#endif
|
|
|
|
#ifdef ZOOM_KEY
|
2022-03-01 06:40:32 +00:00
|
|
|
static int zcode;
|
2021-03-08 04:35:01 +00:00
|
|
|
#endif
|
|
|
|
#ifdef SNAPLEFT_KEY
|
2022-03-01 06:40:32 +00:00
|
|
|
static int hcode;
|
2021-03-08 04:35:01 +00:00
|
|
|
#endif
|
|
|
|
#ifdef SNAPRIGHT_KEY
|
2022-03-01 06:40:32 +00:00
|
|
|
static int lcode;
|
2021-03-08 04:35:01 +00:00
|
|
|
#endif
|
|
|
|
#ifdef SNAPBOTTOM_KEY
|
2022-03-01 06:40:32 +00:00
|
|
|
static int jcode;
|
2021-03-08 04:35:01 +00:00
|
|
|
#endif
|
|
|
|
#ifdef SNAPTOP_KEY
|
2022-03-01 06:40:32 +00:00
|
|
|
int kcode;
|
2021-03-08 04:35:01 +00:00
|
|
|
#endif
|
|
|
|
#ifdef SNAPTOPLEFT_KEY
|
2022-03-01 06:40:32 +00:00
|
|
|
static int qcode;
|
2021-03-08 04:35:01 +00:00
|
|
|
#endif
|
|
|
|
#ifdef SNAPBOTTOMLEFT_KEY
|
2022-03-01 06:40:32 +00:00
|
|
|
static int wcode;
|
2021-03-08 04:35:01 +00:00
|
|
|
#endif
|
|
|
|
#ifdef SNAPBOTTOMRIGHT_KEY
|
2022-03-01 06:40:32 +00:00
|
|
|
static int ocode;
|
2021-03-08 04:35:01 +00:00
|
|
|
#endif
|
|
|
|
#ifdef SNAPTOPRIGHT_KEY
|
2022-03-01 06:40:32 +00:00
|
|
|
static int pcode;
|
2021-03-08 04:35:01 +00:00
|
|
|
#endif
|
|
|
|
#ifdef SNAPCENTER_KEY
|
2022-03-01 06:40:32 +00:00
|
|
|
static int ccode;
|
2021-03-08 04:35:01 +00:00
|
|
|
#endif
|
|
|
|
#ifdef NEXTVIRT_KEY
|
2022-03-01 06:40:32 +00:00
|
|
|
static int rightcode;
|
2021-03-08 04:35:01 +00:00
|
|
|
#endif
|
|
|
|
#ifdef PREVVIRT_KEY
|
2022-03-01 06:40:32 +00:00
|
|
|
static int leftcode;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
tabcode = XKeysymToKeycode(dpy, XK_Tab);
|
|
|
|
#ifdef DESTROY_KEY
|
|
|
|
dcode = XKeysymToKeycode(dpy, DESTROY_KEY);
|
|
|
|
#endif
|
|
|
|
#ifdef ICON_KEY
|
|
|
|
icode = XKeysymToKeycode(dpy, ICON_KEY);
|
|
|
|
#endif
|
|
|
|
#ifdef UNHIDE_KEY
|
|
|
|
ucode = XKeysymToKeycode(dpy, UNHIDE_KEY);
|
|
|
|
#endif
|
|
|
|
#ifdef MAX_KEY
|
|
|
|
mcode = XKeysymToKeycode(dpy, MAX_KEY);
|
|
|
|
#endif
|
|
|
|
#ifdef MOVE_KEY
|
|
|
|
vcode = XKeysymToKeycode(dpy, MOVE_KEY);
|
|
|
|
#endif
|
|
|
|
#ifdef STICK_KEY
|
|
|
|
scode = XKeysymToKeycode(dpy, STICK_KEY);
|
|
|
|
#endif
|
|
|
|
#ifdef WRANGLE_KEY
|
2022-03-01 19:22:14 +00:00
|
|
|
acode = XKeysymToKeycode(dpy, WRANGLE_KEY);
|
2022-03-01 06:40:32 +00:00
|
|
|
#endif
|
|
|
|
#ifdef RESIZE_KEY
|
|
|
|
rcode = XKeysymToKeycode(dpy, RESIZE_KEY);
|
|
|
|
#endif
|
|
|
|
#ifdef LAUNCH_KEY
|
|
|
|
slcode = XKeysymToKeycode(dpy, LAUNCH_KEY);
|
|
|
|
#endif
|
|
|
|
#ifdef ZOOM_KEY
|
|
|
|
zcode = XKeysymToKeycode(dpy, ZOOM_KEY);
|
|
|
|
#endif
|
|
|
|
#ifdef SNAPLEFT_KEY
|
|
|
|
hcode = XKeysymToKeycode(dpy, SNAPLEFT_KEY);
|
|
|
|
#endif
|
|
|
|
#ifdef SNAPRIGHT_KEY
|
|
|
|
lcode = XKeysymToKeycode(dpy, SNAPRIGHT_KEY);
|
|
|
|
#endif
|
|
|
|
#ifdef SNAPBOTTOM_KEY
|
|
|
|
jcode = XKeysymToKeycode(dpy, SNAPBOTTOM_KEY);
|
|
|
|
#endif
|
|
|
|
#ifdef SNAPTOP_KEY
|
|
|
|
kcode = XKeysymToKeycode(dpy, SNAPTOP_KEY);
|
|
|
|
#endif
|
|
|
|
#ifdef SNAPTOPLEFT_KEY
|
|
|
|
qcode = XKeysymToKeycode(dpy, SNAPTOPLEFT_KEY);
|
|
|
|
#endif
|
|
|
|
#ifdef SNAPBOTTOMLEFT_KEY
|
|
|
|
wcode = XKeysymToKeycode(dpy, SNAPBOTTOMLEFT_KEY);
|
|
|
|
#endif
|
|
|
|
#ifdef SNAPBOTTOMRIGHT_KEY
|
|
|
|
ocode = XKeysymToKeycode(dpy, SNAPBOTTOMRIGHT_KEY);
|
|
|
|
#endif
|
|
|
|
#ifdef SNAPTOPRIGHT_KEY
|
|
|
|
pcode = XKeysymToKeycode(dpy, SNAPTOPRIGHT_KEY);
|
|
|
|
#endif
|
|
|
|
#ifdef SNAPCENTER_KEY
|
|
|
|
ccode = XKeysymToKeycode(dpy, SNAPCENTER_KEY);
|
|
|
|
#endif
|
|
|
|
#ifdef NEXTVIRT_KEY
|
|
|
|
rightcode = XKeysymToKeycode(dpy, NEXTVIRT_KEY);
|
|
|
|
#endif
|
|
|
|
#ifdef PREVVIRT_KEY
|
|
|
|
leftcode = XKeysymToKeycode(dpy, PREVVIRT_KEY);
|
2021-03-08 04:35:01 +00:00
|
|
|
#endif
|
2021-02-21 23:13:58 +00:00
|
|
|
#ifdef DEVEL
|
2021-02-26 18:01:22 +00:00
|
|
|
int tcode = XKeysymToKeycode(dpy, STICKYTOFRONT_KEY);
|
|
|
|
int bcode = XKeysymToKeycode(dpy, STICKYTOBACK_KEY);
|
2021-02-21 23:13:58 +00:00
|
|
|
#endif
|
2019-12-02 18:23:00 +00:00
|
|
|
|
2022-03-01 06:40:32 +00:00
|
|
|
m = current ? getmonitorbyclient(current) : getmonitorbymouse();
|
|
|
|
|
|
|
|
monitor = monitorinfo[m];
|
2019-12-02 18:23:00 +00:00
|
|
|
|
2021-02-26 18:01:22 +00:00
|
|
|
/* basic wm functionality */
|
|
|
|
if (e->keycode == tabcode && (e->state & Mod1Mask) == (1 << 3))
|
|
|
|
alttab(e->state & ShiftMask);
|
2021-03-08 04:35:01 +00:00
|
|
|
#ifdef DESTROY_KEY
|
2021-02-26 18:01:22 +00:00
|
|
|
else if (e->keycode == dcode && (e->state & SHORTCUTMOD) == (MODBITS))
|
|
|
|
delete (current, 0);
|
2021-03-08 04:35:01 +00:00
|
|
|
#endif
|
|
|
|
#ifdef ICON_KEY
|
2021-02-26 18:01:22 +00:00
|
|
|
else if (e->keycode == icode && (e->state & SHORTCUTMOD) == (MODBITS))
|
|
|
|
hide(current);
|
2021-03-08 04:35:01 +00:00
|
|
|
#endif
|
|
|
|
#ifdef UNHIDE_KEY
|
2021-02-26 18:01:22 +00:00
|
|
|
else if (e->keycode == ucode && (e->state & SHORTCUTMOD) == (MODBITS))
|
|
|
|
unhide(0, 1);
|
2021-03-08 04:35:01 +00:00
|
|
|
#endif
|
|
|
|
#ifdef MOVE_KEY
|
2021-02-26 18:01:22 +00:00
|
|
|
else if (e->keycode == vcode && (e->state & SHORTCUTMOD) == (MODBITS))
|
|
|
|
move(current, Button3);
|
2021-03-08 04:35:01 +00:00
|
|
|
#endif
|
|
|
|
#ifdef RESIZE_KEY
|
2021-02-26 18:01:22 +00:00
|
|
|
else if (e->keycode == rcode && (e->state & SHORTCUTMOD) == (MODBITS))
|
|
|
|
reshape(current, Button3, sweep, 0);
|
2021-03-08 04:35:01 +00:00
|
|
|
#endif
|
|
|
|
#ifdef MAX_KEY
|
2021-02-26 18:01:22 +00:00
|
|
|
else if (e->keycode == mcode && (e->state & SHORTCUTMOD) == (MODBITS))
|
|
|
|
quickreshape(
|
2021-02-26 19:50:23 +00:00
|
|
|
current,
|
2022-03-01 06:40:32 +00:00
|
|
|
monitor.x,
|
|
|
|
monitor.y,
|
|
|
|
monitor.width,
|
|
|
|
monitor.height,
|
|
|
|
1);
|
2021-03-08 04:35:01 +00:00
|
|
|
#endif
|
|
|
|
#ifdef STICK_KEY
|
2021-02-26 18:01:22 +00:00
|
|
|
else if (e->keycode == scode && (e->state & SHORTCUTMOD) == (MODBITS))
|
|
|
|
stick(current);
|
2021-05-27 04:43:57 +00:00
|
|
|
#endif
|
2022-03-01 19:22:14 +00:00
|
|
|
|
|
|
|
/* move to another monitor */
|
|
|
|
|
2022-03-01 06:40:32 +00:00
|
|
|
#ifdef WRANGLE_KEY
|
|
|
|
else if (e->keycode == acode && (e->state & SHORTCUTMOD) == (MODBITS)) {
|
2022-03-01 19:22:14 +00:00
|
|
|
wrangle(current, m < nmonitors - 1 ? monitorinfo[++m] : monitorinfo[0]);
|
2022-03-01 06:40:32 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2022-03-01 19:22:14 +00:00
|
|
|
/* toggle zoom mode */
|
2021-03-08 04:35:01 +00:00
|
|
|
#ifdef ZOOM_KEY
|
2021-03-10 05:22:21 +00:00
|
|
|
else if (e->keycode == zcode && (e->state & SHORTCUTMOD) == (MODBITS)) {
|
2021-03-06 04:55:13 +00:00
|
|
|
zoom = !zoom;
|
2021-03-10 05:22:21 +00:00
|
|
|
if (zoom) {
|
|
|
|
quickreshape(
|
2021-04-29 04:41:36 +00:00
|
|
|
current,
|
2022-03-01 06:40:32 +00:00
|
|
|
monitor.x,
|
|
|
|
monitor.y,
|
|
|
|
monitor.width,
|
|
|
|
monitor.height,
|
|
|
|
1);
|
2021-03-10 05:22:21 +00:00
|
|
|
}
|
|
|
|
}
|
2021-03-08 04:35:01 +00:00
|
|
|
#endif
|
2019-12-02 18:23:00 +00:00
|
|
|
|
2021-02-26 18:01:22 +00:00
|
|
|
/* half snap */
|
2021-03-08 04:35:01 +00:00
|
|
|
#ifdef SNAPLEFT_KEY
|
2021-02-26 18:01:22 +00:00
|
|
|
else if (e->keycode == hcode && (e->state & SHORTCUTMOD) == (MODBITS))
|
|
|
|
quickreshape(
|
2021-02-26 19:50:23 +00:00
|
|
|
current,
|
2022-03-01 06:40:32 +00:00
|
|
|
monitor.x + GAPSZ,
|
|
|
|
monitor.y + GAPSZ,
|
|
|
|
monitor.width / 2 - 1.5 * GAPSZ,
|
|
|
|
monitor.height - 2 * GAPSZ,
|
|
|
|
0);
|
2021-03-08 04:35:01 +00:00
|
|
|
#endif
|
|
|
|
#ifdef SNAPRIGHT_KEY
|
2021-02-26 18:01:22 +00:00
|
|
|
else if (e->keycode == lcode && (e->state & SHORTCUTMOD) == (MODBITS))
|
|
|
|
quickreshape(
|
|
|
|
current,
|
2022-03-01 06:40:32 +00:00
|
|
|
monitor.x + monitor.width / 2 + 0.5 * GAPSZ,
|
|
|
|
monitor.y + GAPSZ,
|
|
|
|
monitor.width / 2 - 1.5 * GAPSZ,
|
|
|
|
monitor.height - 2 * GAPSZ,
|
|
|
|
0);
|
2021-03-08 04:35:01 +00:00
|
|
|
#endif
|
|
|
|
#ifdef SNAPBOTTOM_KEY
|
2021-02-26 18:01:22 +00:00
|
|
|
else if (e->keycode == jcode && (e->state & SHORTCUTMOD) == (MODBITS))
|
|
|
|
quickreshape(
|
|
|
|
current,
|
2022-03-01 06:40:32 +00:00
|
|
|
monitor.x + GAPSZ,
|
|
|
|
monitor.y + monitor.height / 2 + 0.5 * GAPSZ,
|
|
|
|
monitor.width - 2 * GAPSZ,
|
|
|
|
monitor.height / 2 - 1.5 * GAPSZ,
|
|
|
|
0);
|
2021-03-08 04:35:01 +00:00
|
|
|
#endif
|
|
|
|
#ifdef SNAPTOP_KEY
|
2021-02-26 18:01:22 +00:00
|
|
|
else if (e->keycode == kcode && (e->state & SHORTCUTMOD) == (MODBITS))
|
|
|
|
quickreshape(
|
2021-02-26 19:50:23 +00:00
|
|
|
current,
|
2022-03-01 06:40:32 +00:00
|
|
|
monitor.x + GAPSZ,
|
|
|
|
monitor.y + GAPSZ,
|
|
|
|
monitor.width - 2 * GAPSZ,
|
|
|
|
monitor.height / 2 - 1.5 * GAPSZ,
|
|
|
|
0);
|
2021-03-08 04:35:01 +00:00
|
|
|
#endif
|
2019-12-02 18:23:00 +00:00
|
|
|
|
2021-04-29 04:41:36 +00:00
|
|
|
/* quarter snap */
|
2021-03-08 04:35:01 +00:00
|
|
|
#ifdef SNAPTOPLEFT_KEY
|
2021-02-26 18:01:22 +00:00
|
|
|
else if (e->keycode == qcode && (e->state & SHORTCUTMOD) == (MODBITS))
|
|
|
|
quickreshape(
|
|
|
|
current,
|
2022-03-01 06:40:32 +00:00
|
|
|
monitor.x + GAPSZ,
|
|
|
|
monitor.y + GAPSZ,
|
|
|
|
monitor.width / 2 - 1.5 * GAPSZ,
|
|
|
|
monitor.height / 2 - 1.5 * GAPSZ,
|
|
|
|
0);
|
2021-03-08 04:35:01 +00:00
|
|
|
#endif
|
|
|
|
#ifdef SNAPBOTTOMLEFT_KEY
|
2021-02-26 18:01:22 +00:00
|
|
|
else if (e->keycode == wcode && (e->state & SHORTCUTMOD) == (MODBITS))
|
|
|
|
quickreshape(
|
|
|
|
current,
|
2022-03-01 06:40:32 +00:00
|
|
|
monitor.x + GAPSZ,
|
|
|
|
monitor.y + monitor.height / 2 + 0.5 * GAPSZ,
|
|
|
|
monitor.width / 2 - 1.5 * GAPSZ,
|
|
|
|
monitor.height / 2 - 1.5 * GAPSZ,
|
|
|
|
0);
|
2021-03-08 04:35:01 +00:00
|
|
|
#endif
|
|
|
|
#ifdef SNAPBOTTOMRIGHT_KEY
|
2021-02-26 18:01:22 +00:00
|
|
|
else if (e->keycode == ocode && (e->state & SHORTCUTMOD) == (MODBITS))
|
|
|
|
quickreshape(
|
|
|
|
current,
|
2022-03-01 06:40:32 +00:00
|
|
|
monitor.x + monitor.width / 2 + 0.5 * GAPSZ,
|
|
|
|
monitor.y + monitor.height / 2 + 0.5 * GAPSZ,
|
|
|
|
monitor.width / 2 - 1.5 * GAPSZ,
|
|
|
|
monitor.height / 2 - 1.5 * GAPSZ,
|
|
|
|
0);
|
2021-03-08 04:35:01 +00:00
|
|
|
#endif
|
|
|
|
#ifdef SNAPTOPRIGHT_KEY
|
2021-02-26 18:01:22 +00:00
|
|
|
else if (e->keycode == pcode && (e->state & SHORTCUTMOD) == (MODBITS))
|
|
|
|
quickreshape(
|
|
|
|
current,
|
2022-03-01 06:40:32 +00:00
|
|
|
monitor.x + monitor.width / 2 + 0.5 * GAPSZ,
|
|
|
|
monitor.y + GAPSZ,
|
|
|
|
monitor.width / 2 - 1.5 * GAPSZ,
|
|
|
|
monitor.height / 2 - 1.5 * GAPSZ,
|
|
|
|
0);
|
2021-03-08 04:35:01 +00:00
|
|
|
#endif
|
2019-12-02 18:23:00 +00:00
|
|
|
|
2021-04-29 04:41:36 +00:00
|
|
|
/* center snap */
|
2021-03-09 05:34:00 +00:00
|
|
|
#ifdef SNAPCENTER_KEY
|
2021-02-26 18:01:22 +00:00
|
|
|
else if (e->keycode == ccode && (e->state & SHORTCUTMOD) == (MODBITS)) {
|
2021-02-26 22:18:39 +00:00
|
|
|
if ((e->state & ShiftMask) == (1 << 0)) {
|
|
|
|
#ifdef CENTERVMAX
|
2022-03-01 06:40:32 +00:00
|
|
|
centerclient(current, monitor, 0);
|
2021-02-26 22:18:39 +00:00
|
|
|
#else
|
2022-03-01 06:40:32 +00:00
|
|
|
centerclient(current, monitor, 1);
|
2021-02-26 22:18:39 +00:00
|
|
|
#endif
|
|
|
|
} else {
|
|
|
|
#ifdef CENTERVMAX
|
2022-03-01 06:40:32 +00:00
|
|
|
centerclient(current, monitor, 1);
|
2021-02-26 22:18:39 +00:00
|
|
|
#else
|
2022-03-01 06:40:32 +00:00
|
|
|
centerclient(current, monitor, 0);
|
2021-02-26 22:18:39 +00:00
|
|
|
#endif
|
|
|
|
}
|
2021-02-26 18:01:22 +00:00
|
|
|
}
|
2021-03-08 04:35:01 +00:00
|
|
|
#endif
|
2021-02-26 18:01:22 +00:00
|
|
|
|
2021-02-21 23:13:58 +00:00
|
|
|
#ifdef DEVEL
|
2021-02-26 18:01:22 +00:00
|
|
|
/* manage autostuck windows */
|
|
|
|
if (e->keycode == tcode && (e->state & SHORTCUTMOD) == (MODBITS))
|
2021-02-21 23:13:58 +00:00
|
|
|
stickystack(1);
|
2021-02-26 18:01:22 +00:00
|
|
|
if (e->keycode == bcode && (e->state & SHORTCUTMOD) == (MODBITS))
|
2021-02-21 23:13:58 +00:00
|
|
|
stickystack(0);
|
|
|
|
#endif
|
2019-12-02 18:23:00 +00:00
|
|
|
|
2021-04-29 04:41:36 +00:00
|
|
|
/* launch */
|
2021-03-08 04:35:01 +00:00
|
|
|
#ifdef LAUNCH_KEY
|
|
|
|
else if (e->keycode == slcode && (e->state & SHORTCUTMOD) == (MODBITS)) {
|
2021-02-26 18:01:22 +00:00
|
|
|
kbLaunch = 1;
|
|
|
|
if (fork() == 0) {
|
2022-01-18 23:29:16 +00:00
|
|
|
if (fork() == 0) {
|
|
|
|
// this code doesn't seem necessary
|
|
|
|
// close(ConnectionNumber(dpy));
|
|
|
|
// if (dpy != '\0')
|
|
|
|
// putenv(dpy);
|
|
|
|
signal(SIGINT, SIG_DFL);
|
|
|
|
signal(SIGTERM, SIG_DFL);
|
|
|
|
signal(SIGHUP, SIG_DFL);
|
|
|
|
if (termprog != NULL) {
|
|
|
|
execl(shell, shell, "-c", termprog, (char*)0);
|
|
|
|
fprintf(stderr, "ryudo: exec %s", shell);
|
|
|
|
perror(" failed");
|
|
|
|
}
|
|
|
|
execlp("urxvt", "urxvt", (char*)0);
|
|
|
|
execlp("9term", "9term", scrolling ? "-ws" : "-w", (char*)0);
|
|
|
|
execlp("xterm", "xterm", "-ut", (char*)0);
|
|
|
|
perror("ryudo: exec urxvt/9term/xterm failed");
|
|
|
|
exit(1);
|
2021-02-26 18:01:22 +00:00
|
|
|
}
|
2022-01-18 23:29:16 +00:00
|
|
|
exit(0);
|
2021-02-26 18:01:22 +00:00
|
|
|
}
|
2022-01-18 23:29:16 +00:00
|
|
|
wait((int*)0);
|
2019-12-02 18:23:00 +00:00
|
|
|
}
|
2021-03-08 04:35:01 +00:00
|
|
|
#endif
|
2019-12-02 18:23:00 +00:00
|
|
|
|
2021-02-26 18:01:22 +00:00
|
|
|
/* switch virts */
|
2021-03-08 04:35:01 +00:00
|
|
|
#ifdef NEXTVIRT_KEY
|
2021-03-09 05:34:00 +00:00
|
|
|
else if (e->keycode == rightcode && (e->state & SHORTCUTMOD) == (MODBITS)) {
|
2021-02-26 18:01:22 +00:00
|
|
|
if (numvirtuals > 1)
|
|
|
|
if (virt < numvirtuals - 1)
|
|
|
|
switch_to(virt + 1);
|
|
|
|
else
|
|
|
|
switch_to(0);
|
2021-03-09 05:34:00 +00:00
|
|
|
}
|
2021-03-08 04:35:01 +00:00
|
|
|
#endif
|
2020-08-07 03:50:28 +00:00
|
|
|
|
2021-03-08 04:35:01 +00:00
|
|
|
#ifdef PREVVIRT_KEY
|
2021-03-09 05:34:00 +00:00
|
|
|
else if (e->keycode == leftcode && (e->state & SHORTCUTMOD) == (MODBITS)) {
|
2021-02-26 18:01:22 +00:00
|
|
|
if (numvirtuals > 1)
|
|
|
|
if (virt > 0)
|
|
|
|
switch_to(virt - 1);
|
|
|
|
else
|
|
|
|
switch_to(numvirtuals - 1);
|
2021-03-09 05:34:00 +00:00
|
|
|
}
|
2021-03-08 04:35:01 +00:00
|
|
|
#endif
|
2019-12-02 18:23:00 +00:00
|
|
|
|
2021-02-26 18:01:22 +00:00
|
|
|
XAllowEvents(dpy, SyncKeyboard, e->time);
|
2019-12-02 18:23:00 +00:00
|
|
|
}
|
|
|
|
|
2021-02-26 19:50:23 +00:00
|
|
|
void keyrelease(XKeyEvent* e) { XAllowEvents(dpy, SyncKeyboard, e->time); }
|
2019-12-02 18:23:00 +00:00
|
|
|
|
2022-03-01 06:40:32 +00:00
|
|
|
void quickreshape(Client* c, int x, int y, int dx, int dy, int max) {
|
2021-02-26 19:50:23 +00:00
|
|
|
if (c == 0)
|
|
|
|
return;
|
2021-02-26 18:01:22 +00:00
|
|
|
XMoveResizeWindow(dpy, c->parent, x, y, dx, dy);
|
2022-03-01 06:40:32 +00:00
|
|
|
if (max)
|
|
|
|
c->border = 0;
|
|
|
|
else
|
|
|
|
c->border = BORDER;
|
|
|
|
|
|
|
|
c->x = x + c->border;
|
|
|
|
c->y = y + c->border;
|
|
|
|
c->dx = dx - 2 * c->border;
|
|
|
|
c->dy = dy - 2 * c->border;
|
|
|
|
XMoveResizeWindow(dpy, c->window, c->border, c->border, c->dx, c->dy);
|
2021-02-26 18:01:22 +00:00
|
|
|
sendconfig(c);
|
2019-12-02 18:23:00 +00:00
|
|
|
}
|
|
|
|
|
2022-03-01 06:40:32 +00:00
|
|
|
void centerclient(Client* c, XRRMonitorInfo monitor, int vmax) {
|
2021-02-26 18:01:22 +00:00
|
|
|
static int centeroffsetnum =
|
|
|
|
CENTERNUM % 2 == 0 ? CENTERDEN - CENTERNUM : (CENTERDEN - CENTERNUM) / 2;
|
2021-02-26 05:36:37 +00:00
|
|
|
|
2021-02-26 18:01:22 +00:00
|
|
|
static int centeroffsetden = CENTERNUM % 2 == 0 ? CENTERDEN * 2 : CENTERDEN;
|
2021-02-26 05:36:37 +00:00
|
|
|
|
2021-02-26 22:18:39 +00:00
|
|
|
if (vmax) {
|
|
|
|
quickreshape(
|
|
|
|
c,
|
2022-03-01 06:40:32 +00:00
|
|
|
monitor.x + centeroffsetnum * monitor.width / centeroffsetden,
|
|
|
|
monitor.y + GAPSZ,
|
|
|
|
CENTERNUM * monitor.width / CENTERDEN,
|
|
|
|
monitor.height - 2 * GAPSZ,
|
|
|
|
0);
|
2021-02-26 22:18:39 +00:00
|
|
|
} else {
|
|
|
|
quickreshape(
|
|
|
|
c,
|
2022-03-01 06:40:32 +00:00
|
|
|
monitor.x + centeroffsetnum * monitor.width / centeroffsetden,
|
|
|
|
monitor.y + centeroffsetnum * monitor.height / centeroffsetden,
|
|
|
|
CENTERNUM * monitor.width / CENTERDEN,
|
|
|
|
CENTERNUM * monitor.height / CENTERDEN,
|
|
|
|
0);
|
2021-02-26 22:18:39 +00:00
|
|
|
}
|
2021-02-26 05:36:37 +00:00
|
|
|
}
|
|
|
|
|
2021-02-26 19:50:23 +00:00
|
|
|
static void alttab(int shift) {
|
2022-03-01 06:40:32 +00:00
|
|
|
static int monitor;
|
|
|
|
|
|
|
|
if (!shift) {
|
|
|
|
shuffle(0);
|
|
|
|
} else {
|
|
|
|
monitor = getmonitorbyclient(current);
|
|
|
|
if (monitor == nmonitors - 1) {
|
|
|
|
monitor = 0;
|
|
|
|
} else {
|
|
|
|
monitor++;
|
|
|
|
}
|
|
|
|
shuffleonmonitor(monitor);
|
|
|
|
}
|
2019-12-02 18:23:00 +00:00
|
|
|
}
|
|
|
|
|
2021-02-21 23:13:58 +00:00
|
|
|
#ifdef DEVEL
|
2021-02-26 19:50:23 +00:00
|
|
|
void stickystack(int toTop) {
|
2021-02-26 18:01:22 +00:00
|
|
|
Client* c;
|
|
|
|
if (toTop) {
|
|
|
|
for (c = clients; c->next; c = c->next) {
|
2021-02-26 19:50:23 +00:00
|
|
|
if (c && isautostick(c))
|
|
|
|
top(c);
|
2021-02-21 23:13:58 +00:00
|
|
|
}
|
2021-02-26 18:01:22 +00:00
|
|
|
} else {
|
|
|
|
for (c = clients; c->next; c = c->next) {
|
2021-02-26 19:50:23 +00:00
|
|
|
if (c && !isautostick(c))
|
|
|
|
top(c);
|
2021-02-21 23:13:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|