diff --git a/client.c b/client.c index 378005d..03435a8 100644 --- a/client.c +++ b/client.c @@ -6,9 +6,9 @@ #include #include #include +#include "config.h" #include "dat.h" #include "fns.h" -#include "config.h" Client* clients; Client* current; diff --git a/config.h b/config.h index 9b70517..778a84c 100644 --- a/config.h +++ b/config.h @@ -16,12 +16,16 @@ #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 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 diff --git a/event.c b/event.c index 593457b..075c5df 100644 --- a/event.c +++ b/event.c @@ -12,10 +12,10 @@ #include #include #include +#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 @@ void newwindow(XCreateWindowEvent* e) { } 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; } } diff --git a/key.c b/key.c index 43dda62..6b9ae27 100644 --- a/key.c +++ b/key.c @@ -183,6 +183,14 @@ void keysetup(void) { 0, GrabModeSync, GrabModeAsync); + XGrabKey( + dpy, + ccode, + ShiftMask | SHORTCUTMOD, + screens[i].root, + 0, + GrabModeSync, + GrabModeAsync); XGrabKey( dpy, ccode, @@ -367,7 +375,19 @@ void keypress(XKeyEvent* e) { /* 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 @@ void quickreshape(Client* c, int x, int y, int dx, int 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) {