cient, event, key, fns, config: fix two client centering styles, always include config.h before dat.h, update config.h

This commit is contained in:
Iris Lightshard 2021-02-26 17:18:39 -05:00
parent b0fb6654c8
commit 98ed00f38c
Signed by: Iris Lightshard
GPG key ID: 3B7FBC22144E6398
4 changed files with 68 additions and 33 deletions

View file

@ -6,9 +6,9 @@
#include <X11/X.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include "config.h"
#include "dat.h"
#include "fns.h"
#include "config.h"
Client* clients;
Client* current;

View file

@ -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

13
event.c
View file

@ -12,10 +12,10 @@
#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 @@ 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;
}
}

54
key.c
View file

@ -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) {