config.h, main.c, key.c, manage.c, client.c: add zoom mode (fullscreen everything); event.c, menu.c: don't leave us out of focus when deleting windows

This commit is contained in:
Iris Lightshard 2021-03-05 23:55:13 -05:00
parent 8ce7319b08
commit 55d6921b45
8 changed files with 49 additions and 2 deletions

View file

@ -277,6 +277,9 @@ void dump_clients(void) {
void shuffle(int up) { void shuffle(int up) {
Client **l, *c; Client **l, *c;
static XWindowAttributes ra;
XGetWindowAttributes(dpy, DefaultRootWindow(dpy), &ra);
if (clients == 0 || clients->next == 0) if (clients == 0 || clients->next == 0)
return; return;
@ -297,6 +300,14 @@ void shuffle(int up) {
XMapRaised(dpy, c->parent); XMapRaised(dpy, c->parent);
top(c); top(c);
active(c); active(c);
if (zoom) {
quickreshape(
c,
-BORDER,
-BORDER,
ra.width + 2 * BORDER,
ra.height + 2 * BORDER);
}
} else { } else {
c = clients; c = clients;
for (l = &clients; *l; l = &(*l)->next) for (l = &clients; *l; l = &(*l)->next)

View file

@ -60,6 +60,7 @@
#define RESIZE_KEY XK_r #define RESIZE_KEY XK_r
#define DESTROY_KEY XK_d #define DESTROY_KEY XK_d
#define STICK_KEY XK_s #define STICK_KEY XK_s
#define ZOOM_KEY XK_z
#define STICKYTOFRONT_KEY XK_t #define STICKYTOFRONT_KEY XK_t
#define STICKYTOBACK_KEY XK_b #define STICKYTOBACK_KEY XK_b

1
dat.h
View file

@ -157,6 +157,7 @@ extern int solidsweep;
extern int numvirtuals; extern int numvirtuals;
extern int scrolling; extern int scrolling;
extern int ffm; /* focus follows mouse */ extern int ffm; /* focus follows mouse */
extern int zoom;
extern Atom exit_rio; extern Atom exit_rio;
extern Atom restart_rio; extern Atom restart_rio;

View file

@ -292,18 +292,23 @@ void newwindow(XCreateWindowEvent* e) {
void destroy(Window w) { void destroy(Window w) {
int i; int i;
Client* c; Client* c;
int v;
curtime = CurrentTime; curtime = CurrentTime;
c = getclient(w, 0); c = getclient(w, 0);
if (c == 0) if (c == 0)
return; return;
v = c->virt;
if (numvirtuals > 1) if (numvirtuals > 1)
for (i = 0; i < numvirtuals; i++) for (i = 0; i < numvirtuals; i++)
if (currents[i] == c) if (currents[i] == c)
currents[i] = 0; currents[i] = 0;
rmclient(c); rmclient(c);
if (v == virt) {
shuffle(0);
}
/* flush any errors generated by the window's sudden demise */ /* flush any errors generated by the window's sudden demise */
ignore_badwindow = 1; ignore_badwindow = 1;

12
key.c
View file

@ -47,6 +47,7 @@ void keysetup(void) {
int pcode = XKeysymToKeycode(dpy, SNAPTOPRIGHT_KEY); int pcode = XKeysymToKeycode(dpy, SNAPTOPRIGHT_KEY);
int ccode = XKeysymToKeycode(dpy, SNAPCENTER_KEY); int ccode = XKeysymToKeycode(dpy, SNAPCENTER_KEY);
int slcode = XKeysymToKeycode(dpy, LAUNCH_KEY); int slcode = XKeysymToKeycode(dpy, LAUNCH_KEY);
int zcode = XKeysymToKeycode(dpy, ZOOM_KEY);
int rightcode = XKeysymToKeycode(dpy, NEXTVIRT_KEY); int rightcode = XKeysymToKeycode(dpy, NEXTVIRT_KEY);
int leftcode = XKeysymToKeycode(dpy, PREVVIRT_KEY); int leftcode = XKeysymToKeycode(dpy, PREVVIRT_KEY);
#ifdef DEVEL #ifdef DEVEL
@ -223,6 +224,14 @@ void keysetup(void) {
0, 0,
GrabModeSync, GrabModeSync,
GrabModeAsync); GrabModeAsync);
XGrabKey(
dpy,
zcode,
SHORTCUTMOD,
screens[i].root,
0,
GrabModeSync,
GrabModeAsync);
XGrabKey( XGrabKey(
dpy, dpy,
tabcode, tabcode,
@ -271,6 +280,7 @@ void keypress(XKeyEvent* e) {
int scode = XKeysymToKeycode(dpy, STICK_KEY); int scode = XKeysymToKeycode(dpy, STICK_KEY);
int rcode = XKeysymToKeycode(dpy, RESIZE_KEY); int rcode = XKeysymToKeycode(dpy, RESIZE_KEY);
int slcode = XKeysymToKeycode(dpy, LAUNCH_KEY); int slcode = XKeysymToKeycode(dpy, LAUNCH_KEY);
int zcode = XKeysymToKeycode(dpy, ZOOM_KEY);
int hcode = XKeysymToKeycode(dpy, SNAPLEFT_KEY); int hcode = XKeysymToKeycode(dpy, SNAPLEFT_KEY);
int lcode = XKeysymToKeycode(dpy, SNAPRIGHT_KEY); int lcode = XKeysymToKeycode(dpy, SNAPRIGHT_KEY);
int jcode = XKeysymToKeycode(dpy, SNAPBOTTOM_KEY); int jcode = XKeysymToKeycode(dpy, SNAPBOTTOM_KEY);
@ -312,6 +322,8 @@ void keypress(XKeyEvent* e) {
ra.height + 2 * BORDER); ra.height + 2 * BORDER);
else if (e->keycode == scode && (e->state & SHORTCUTMOD) == (MODBITS)) else if (e->keycode == scode && (e->state & SHORTCUTMOD) == (MODBITS))
stick(current); stick(current);
else if (e->keycode == zcode && (e->state & SHORTCUTMOD) == (MODBITS))
zoom = !zoom;
/* half snap */ /* half snap */
else if (e->keycode == hcode && (e->state & SHORTCUTMOD) == (MODBITS)) else if (e->keycode == hcode && (e->state & SHORTCUTMOD) == (MODBITS))

1
main.c
View file

@ -43,6 +43,7 @@ int solidsweep = 0;
int numvirtuals = 0; int numvirtuals = 0;
int ffm = 0; int ffm = 0;
int kbLaunch = 0; int kbLaunch = 0;
int zoom = 0;
Atom exit_rio; Atom exit_rio;
Atom restart_rio; Atom restart_rio;

View file

@ -219,6 +219,16 @@ int manage(Client* c, int mapped) {
cmapfocus(current); cmapfocus(current);
c->init = 1; c->init = 1;
/* If we are in zoom mode, spawn the window maximized */
if (zoom) {
quickreshape(
c,
-BORDER,
-BORDER,
ra.width + 2 * BORDER,
ra.height + 2 * BORDER);
}
/* If the window is out of bounds of the screen, try to wrangle it */ /* If the window is out of bounds of the screen, try to wrangle it */
/* If it's bigger than the screen, try to set it maximized */ /* If it's bigger than the screen, try to set it maximized */

8
menu.c
View file

@ -260,10 +260,16 @@ void move(Client* c, int but) {
} }
void delete (Client* c, int shift) { void delete (Client* c, int shift) {
int v;
if (c == 0) if (c == 0)
return; return;
if ((c->proto & Pdelete) && !shift) v = c->virt;
if ((c->proto & Pdelete) && !shift) {
sendcmessage(c->window, wm_protocols, wm_delete, 0, 0); sendcmessage(c->window, wm_protocols, wm_delete, 0, 0);
if (v == virt) {
shuffle(0);
}
}
else else
XKillClient(dpy, c->window); /* let event clean up */ XKillClient(dpy, c->window); /* let event clean up */
} }