cient, event, key, fns, config: fix two client centering styles, always include config.h before dat.h, update config.h
Iris Lightshard nilix@nilfm.cc
PGP Signature
-----BEGIN PGP SIGNATURE----- iQIzBAABCAAdFiEEkFh6dA+k/6CXFXU4O3+8IhROY5gFAmA5c78ACgkQO3+8IhRO Y5hrvhAAifaz2fXUym/ndbt+x6h9zFE8uvn3bC/ZhrJ14BjsrwOUzfVrcOHLVFP6 Oji/n02LtisJyX+mHWza7PHL3H31Rt57nGBhmCgMyq4rryIQwCNdso3cv5IRUBtg IxG98IeulvPrkkoFGiXC0wzeAJNJ6uqnA/n/iHAtTVgLcmr4lXe3AK7Y25rphVfb 0OXE1bcFn37lH7Xntk6wammUDV9ZaHJBojG4g5XTTFc5IWMWu4CpTRc8vBs9eQh6 TlutWKL3moktkf1DngLE65ogUJ1LoRZM/Fe/vWJ2tP4kCC76RrF6ocDIqzTPWv0r Nxi2IZK945YvOVcF3A1r1GhTS1ZN4ixT9PkpybljMJbouwiB0sc1V/jZKb9ETY+n leOzqkMBcKYD5yuCx++Gk12kKfgSzRZEYzkI6p9Y6TptCpLOJdaZUBj1ftUAtEbG pdCCSKsYVlAVjfGKxLgFz7LLIigvWiqIO9FiN7wUNSCj2wE3Sb8OB7Pgvb5wmZ7k qqwuPxohhxAMsrjB48Isi7uaDtFMSssxFScWyr5Z2+JFQuacyfpy8CviYgyiMsVk H9VmfX/IR4gV4gZN+gi33ipKu+C03C+QHUC8sgH8lAiFebtOxL4mCpP0m6hv7seC 1WWn2IT0bIhcG12HFfg/rcuA/MyAAmgI+RX3unCfNgGck365+n8= =Cuds -----END PGP SIGNATURE-----
M
config.h
→
config.h
@@ -16,12 +16,16 @@ #define SMENUFGCOL 0x000000
#define SMENUBGCOL 0x1F9B92 /* This sets the size ratio for windows spawned via keyboard or - * center-snapped + * 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? */ +/* 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? */@@ -80,21 +84,33 @@ #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 } +#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! */ -#define FONTLIST \ - { \ - "*-lucidatypewriter-medium-*-12-*-75-*", "lucm.latin1.9", "blit", \ - "*-lucidatypewriter-bold-*-14-*-75-*", "9x15bold", "fixed", "*", 0 \ +#define FONTLIST { \ + "*-lucidatypewriter-medium-*-12-*-75-*",\ + "lucm.latin1.9", \ + "blit", \ + "*-lucidatypewriter-bold-*-14-*-75-*", \ + "9x15bold", \ + "fixed", \ + "*", \ + 0 \ } + +// clang-format on
M
event.c
→
event.c
@@ -12,10 +12,10 @@ #include <X11/Xlib.h>
#include <X11/Xutil.h> #include <X11/Xatom.h> #include <X11/extensions/shape.h> +#include "config.h" #include "dat.h" #include "fns.h" #include "patchlevel.h" -#include "config.h" void mainloop(int shape_event) { XEvent ev;@@ -280,12 +280,11 @@ c->parent = c->screen->root;
} if (kbLaunch) { usleep(100000); - quickreshape( - c, - ra.width / 6, - GAPSZ, - 2 * ra.width / 3, - ra.height - 2 * GAPSZ); +#ifdef CENTERVMAX + centerclient(c, ra, 1); +#else + centerclient(c, ra, 0); +#endif kbLaunch = 0; } }
M
key.c
→
key.c
@@ -186,6 +186,14 @@ GrabModeAsync);
XGrabKey( dpy, ccode, + ShiftMask | SHORTCUTMOD, + screens[i].root, + 0, + GrabModeSync, + GrabModeAsync); + XGrabKey( + dpy, + ccode, SHORTCUTMOD, screens[i].root, 0,@@ -367,7 +375,19 @@ ra.height / 2 - 1.5 * GAPSZ);
/* center snap */ else if (e->keycode == ccode && (e->state & SHORTCUTMOD) == (MODBITS)) { - centercurrent(ra); + if ((e->state & ShiftMask) == (1 << 0)) { +#ifdef CENTERVMAX + centerclient(current, ra, 0); +#else + centerclient(current, ra, 1); +#endif + } else { +#ifdef CENTERVMAX + centerclient(current, ra, 1); +#else + centerclient(current, ra, 0); +#endif + } } #ifdef DEVEL@@ -432,27 +452,27 @@ XMoveResizeWindow(dpy, c->window, BORDER, BORDER, c->dx, c->dy);
sendconfig(c); } -void centercurrent(XWindowAttributes ra) { +void centerclient(Client* c, XWindowAttributes ra, int vmax) { static int centeroffsetnum = CENTERNUM % 2 == 0 ? CENTERDEN - CENTERNUM : (CENTERDEN - CENTERNUM) / 2; static int centeroffsetden = CENTERNUM % 2 == 0 ? CENTERDEN * 2 : CENTERDEN; -#ifdef CENTERVMAX - quickreshape( - current, - centeroffsetnum * ra.width / centeroffsetden, - GAPSZ, - CENTERNUM * ra.width / CENTERDEN, - ra.height - 2 * GAPSZ); -#else - quickreshape( - current, - centeroffsetnum * ra.width / centerofsetden, - centeroffsetnum * ra.height / centeroffsetden, - CENTERNUM * ra.width / CENTERDEN, - CENTERNUM * ra.height / CENTERDEN); -#endif + if (vmax) { + quickreshape( + c, + centeroffsetnum * ra.width / centeroffsetden, + GAPSZ, + CENTERNUM * ra.width / CENTERDEN, + ra.height - 2 * GAPSZ); + } else { + quickreshape( + c, + centeroffsetnum * ra.width / centeroffsetden, + centeroffsetnum * ra.height / centeroffsetden, + CENTERNUM * ra.width / CENTERDEN, + CENTERNUM * ra.height / CENTERDEN); + } } static void alttab(int shift) {