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/X.h>
#include <X11/Xlib.h> #include <X11/Xlib.h>
#include <X11/Xutil.h> #include <X11/Xutil.h>
#include "config.h"
#include "dat.h" #include "dat.h"
#include "fns.h" #include "fns.h"
#include "config.h"
Client* clients; Client* clients;
Client* current; Client* current;

View file

@ -16,12 +16,16 @@
#define SMENUBGCOL 0x1F9B92 #define SMENUBGCOL 0x1F9B92
/* This sets the size ratio for windows spawned via keyboard or /* 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 CENTERNUM 2
#define CENTERDEN 3 #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 #define CENTERVMAX
/* Show 'Stick' menuitem? */ /* Show 'Stick' menuitem? */
@ -80,21 +84,33 @@
#define LAUNCH_KEY XK_slash #define LAUNCH_KEY XK_slash
// clang-format off
/* List of window classes to spawn as sticky; /* List of window classes to spawn as sticky;
* Class values for currently open windows are conveniently shown in the last * Class values for currently open windows are conveniently shown in the last
* column of the 'xshove' command given with no arguments. * column of the 'xshove' command given with no arguments.
* Remember the backslash at the end of non-terminating lines! * Remember the backslash at the end of non-terminating lines!
*/ */
#define AUTOSTICK \ #define AUTOSTICK {\
{ "XOsview", "XClock", 0 } "XOsview", \
"XClock", \
0 \
}
/* List of fonts to try, in order, for rendering the menus. /* List of fonts to try, in order, for rendering the menus.
* Remember the backslash at the end of non-terminating lines! * Remember the backslash at the end of non-terminating lines!
*/ */
#define FONTLIST \ #define FONTLIST { \
{ \ "*-lucidatypewriter-medium-*-12-*-75-*",\
"*-lucidatypewriter-medium-*-12-*-75-*", "lucm.latin1.9", "blit", \ "lucm.latin1.9", \
"*-lucidatypewriter-bold-*-14-*-75-*", "9x15bold", "fixed", "*", 0 \ "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/Xutil.h>
#include <X11/Xatom.h> #include <X11/Xatom.h>
#include <X11/extensions/shape.h> #include <X11/extensions/shape.h>
#include "config.h"
#include "dat.h" #include "dat.h"
#include "fns.h" #include "fns.h"
#include "patchlevel.h" #include "patchlevel.h"
#include "config.h"
void mainloop(int shape_event) { void mainloop(int shape_event) {
XEvent ev; XEvent ev;
@ -280,12 +280,11 @@ void newwindow(XCreateWindowEvent* e) {
} }
if (kbLaunch) { if (kbLaunch) {
usleep(100000); usleep(100000);
quickreshape( #ifdef CENTERVMAX
c, centerclient(c, ra, 1);
ra.width / 6, #else
GAPSZ, centerclient(c, ra, 0);
2 * ra.width / 3, #endif
ra.height - 2 * GAPSZ);
kbLaunch = 0; kbLaunch = 0;
} }
} }

36
key.c
View file

@ -183,6 +183,14 @@ void keysetup(void) {
0, 0,
GrabModeSync, GrabModeSync,
GrabModeAsync); GrabModeAsync);
XGrabKey(
dpy,
ccode,
ShiftMask | SHORTCUTMOD,
screens[i].root,
0,
GrabModeSync,
GrabModeAsync);
XGrabKey( XGrabKey(
dpy, dpy,
ccode, ccode,
@ -367,7 +375,19 @@ void keypress(XKeyEvent* e) {
/* center snap */ /* center snap */
else if (e->keycode == ccode && (e->state & SHORTCUTMOD) == (MODBITS)) { 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 #ifdef DEVEL
@ -432,27 +452,27 @@ void quickreshape(Client* c, int x, int y, int dx, int dy) {
sendconfig(c); sendconfig(c);
} }
void centercurrent(XWindowAttributes ra) { void centerclient(Client* c, XWindowAttributes ra, int vmax) {
static int centeroffsetnum = static int centeroffsetnum =
CENTERNUM % 2 == 0 ? CENTERDEN - CENTERNUM : (CENTERDEN - CENTERNUM) / 2; CENTERNUM % 2 == 0 ? CENTERDEN - CENTERNUM : (CENTERDEN - CENTERNUM) / 2;
static int centeroffsetden = CENTERNUM % 2 == 0 ? CENTERDEN * 2 : CENTERDEN; static int centeroffsetden = CENTERNUM % 2 == 0 ? CENTERDEN * 2 : CENTERDEN;
#ifdef CENTERVMAX if (vmax) {
quickreshape( quickreshape(
current, c,
centeroffsetnum * ra.width / centeroffsetden, centeroffsetnum * ra.width / centeroffsetden,
GAPSZ, GAPSZ,
CENTERNUM * ra.width / CENTERDEN, CENTERNUM * ra.width / CENTERDEN,
ra.height - 2 * GAPSZ); ra.height - 2 * GAPSZ);
#else } else {
quickreshape( quickreshape(
current, c,
centeroffsetnum * ra.width / centerofsetden, centeroffsetnum * ra.width / centeroffsetden,
centeroffsetnum * ra.height / centeroffsetden, centeroffsetnum * ra.height / centeroffsetden,
CENTERNUM * ra.width / CENTERDEN, CENTERNUM * ra.width / CENTERDEN,
CENTERNUM * ra.height / CENTERDEN); CENTERNUM * ra.height / CENTERDEN);
#endif }
} }
static void alttab(int shift) { static void alttab(int shift) {