about summary refs log tree commit diff stats
path: root/patches/2-savefloats-20181212-b69c870.diff
blob: 77d4a3ee762b26fc4a5fa4fa53b5f753f2f1193c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
From 292887ff6e3d2da3c56046591c5248cea2eadd1e Mon Sep 17 00:00:00 2001
From: Acid Bong <acid-bong@cock.lt>
Date: Tue, 18 Oct 2022 11:59:44 +0300
Subject: [PATCH] patch: savefloats

---
 dwm.c | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/dwm.c b/dwm.c
index 02f3353..9780c41 100644
--- a/dwm.c
+++ b/dwm.c
@@ -88,6 +88,7 @@ struct Client {
 	char name[256];
 	float mina, maxa;
 	int x, y, w, h;
+	int sfx, sfy, sfw, sfh; /* stored float geometry, used on mode revert */
 	int oldx, oldy, oldw, oldh;
 	int basew, baseh, incw, inch, maxw, maxh, minw, minh, hintsvalid;
 	int bw, oldbw;
@@ -1059,6 +1060,10 @@ manage(Window w, XWindowAttributes *wa)
 	updatewindowtype(c);
 	updatesizehints(c);
 	updatewmhints(c);
+	c->sfx = c->x;
+	c->sfy = c->y;
+	c->sfw = c->w;
+	c->sfh = c->h;
 	c->x = c->mon->mx + (c->mon->mw - WIDTH(c)) / 2;
 	c->y = c->mon->my + (c->mon->mh - HEIGHT(c)) / 2;
 	XSelectInput(dpy, w, EnterWindowMask|FocusChangeMask|PropertyChangeMask|StructureNotifyMask);
@@ -1714,8 +1719,16 @@ togglefloating(const Arg *arg)
 		return;
 	selmon->sel->isfloating = !selmon->sel->isfloating || selmon->sel->isfixed;
 	if (selmon->sel->isfloating)
-		resize(selmon->sel, selmon->sel->x, selmon->sel->y,
-			selmon->sel->w, selmon->sel->h, 0);
+		/* restore last known float dimensions */
+		resize(selmon->sel, selmon->sel->sfx, selmon->sel->sfy,
+		       selmon->sel->sfw, selmon->sel->sfh, False);
+	else {
+		/* save last known float dimensions */
+		selmon->sel->sfx = selmon->sel->x;
+		selmon->sel->sfy = selmon->sel->y;
+		selmon->sel->sfw = selmon->sel->w;
+		selmon->sel->sfh = selmon->sel->h;
+	}
 	arrange(selmon);
 }
 
-- 
2.38.0
Client Client; typedef struct DC DC; typedef struct Fnt Fnt; union Arg { const char *cmd; int i; }; /* atoms */ enum { NetSupported, NetWMName, NetLast }; enum { WMProtocols, WMDelete, WMLast }; /* cursor */ enum { CurNormal, CurResize, CurMove, CurLast }; /* windowcorners */ typedef enum { TopLeft, TopRight, BotLeft, BotRight } Corner; struct Fnt { int ascent; int descent; int height; XFontSet set; XFontStruct *xfont; }; struct DC { /* draw context */ int x, y, w, h; unsigned long bg; unsigned long fg; unsigned long border; Drawable drawable; Fnt font; GC gc; }; struct Client { char name[256]; int proto; int x, y, w, h; int tx, ty, tw, th; /* title */ int basew, baseh, incw, inch, maxw, maxh, minw, minh; int grav; long flags; unsigned int border; Bool isfloat; Bool ismax; Bool *tags; Client *next; Client *prev; Window win; Window title; }; extern const char *tags[]; extern char stext[1024]; extern int screen, sx, sy, sw, sh, bx, by, bw, bh, mw; extern unsigned int ntags, numlockmask; extern void (*handler[LASTEvent])(XEvent *); extern void (*arrange)(Arg *); extern Atom wmatom[WMLast], netatom[NetLast]; extern Bool running, issel, *seltag; extern Client *clients, *sel; extern Cursor cursor[CurLast]; extern DC dc; extern Display *dpy; extern Window root, barwin; /* client.c */ extern void ban(Client *c); extern void focus(Client *c); extern void focusnext(Arg *arg); extern void focusprev(Arg *arg); extern Client *getclient(Window w); extern Client *getctitle(Window w); extern void gravitate(Client *c, Bool invert); extern void killclient(Arg *arg); extern void manage(Window w, XWindowAttributes *wa); extern void resize(Client *c, Bool sizehints, Corner sticky); extern void setsize(Client *c); extern void settitle(Client *c); extern void togglemax(Arg *arg); extern void unmanage(Client *c); extern void zoom(Arg *arg); /* draw.c */ extern void drawall(); extern void drawstatus(); extern void drawtitle(Client *c); extern unsigned long getcolor(const char *colstr); extern void setfont(const char *fontstr); extern unsigned int textw(const char *text); /* event.c */ extern void grabkeys(); extern void procevent(); /* main.c */ extern int getproto(Window w); extern void quit(Arg *arg); extern void sendevent(Window w, Atom a, long value); extern int xerror(Display *dsply, XErrorEvent *ee); /* tag.c */ extern void dofloat(Arg *arg); extern void dotile(Arg *arg); extern void initrregs(); extern Bool isvisible(Client *c); extern Client *getnext(Client *c); extern Client *getprev(Client *c); extern void restack(); extern void settags(Client *c); extern void tag(Arg *arg); extern void togglemode(Arg *arg); extern void toggletag(Arg *arg); extern void toggleview(Arg *arg); extern void view(Arg *arg); /* util.c */ extern void *emallocz(unsigned int size); extern void eprint(const char *errstr, ...); extern void *erealloc(void *ptr, unsigned int size); extern void spawn(Arg *arg);