commit e9e5dded8592ad7eca6dea9f38e6a59830f7594e
parent 72824b03c5b74b7982dd93453a79fe7c55203956
Author: wh1tepearl <wh1tepearl@gmail.com>
Date: Sat, 31 Jan 2026 21:16:32 +0000
Added support for enchanced toggle floating and made modules.def.h a bit more convenient.
Diffstat:
7 files changed, 154 insertions(+), 17 deletions(-)
diff --git a/config.def.h b/config.def.h
@@ -113,7 +113,7 @@ static const Key keys[] = {
{ MODKEY, XK_f, setlayout, {.v = &layouts[1]} },
{ MODKEY, XK_m, setlayout, {.v = &layouts[2]} },
{ MODKEY, XK_space, setlayout, {0} },
- { MODKEY, XK_q, togglefloating, {0} },
+ { MODKEY|ShiftMask, XK_space, togglefloating, {0} }, //default toggle floating bind.
{ MODKEY, XK_0, view, {.ui = ~0 } },
{ MODKEY|ShiftMask, XK_0, tag, {.ui = ~0 } },
{ MODKEY, XK_comma, focusmon, {.i = -1 } },
@@ -136,6 +136,9 @@ static const Key keys[] = {
#if FULLSCREEN
{ MODKEY|ShiftMask, XK_f, togglefullscr, {0} },
#endif
+#if ENCHANCED_TOGGLE_FLOATING
+ { MODKEY, XK_q, enchancedtogglefloating, {0} }, //enchanced toggle floating bind.
+#endif
};
/* button definitions */
diff --git a/modules.def.h b/modules.def.h
@@ -2,20 +2,41 @@
#define MODULES_H
/* vxwm compile-time options */
-#define BETTER_RESIZE 1 // yeah it's better resize support
-#define LOCK_MOVE_RESIZE_REFRESH_RATE 1 // recomended to use on every pc, because cpu (software) rendered apps like ST will lag when resizing even if you have a good pc.
-#define USE_RESIZECLIENT_FUNC 0 // use resizeclient function of instead of resize function, not recommended
-#define GAPS 0 // gaps support
-#define XRDB 0 //xrdb support
-#define ALT_CENTER_OF_BAR_COLOR 0 //changes center of bar color to a dark color
-#define BAR_HEIGHT 0 //support for changing bar height
-#define BAR_PADDING 0 //support for changing the bar padding
-#define FULLSCREEN 0 //support for toggling fullscreen
-#define MOVE_IN_TILED 0 //support for moving windows in tiled mode
-#define EWMH_TAGS 0 //support for EWMH tags, recommended if you want to use external bars with less pain
-#define ALWAYS_CENTER_NEW_FLOATING_WINDOWS 0 //so, basically, it does what it says
-#define WARP_TO_CLIENT 0 //it warps cursor, where? idk, but use it trust me bro
+
+/* Move/Resize */
+#define BETTER_RESIZE 1 // yeah it's better resize support.
+#define LOCK_MOVE_RESIZE_REFRESH_RATE 1 // Recomended to use on every pc, because cpu (software) rendered apps like ST will lagg when resizing even if you have a good pc.
+#define USE_RESIZECLIENT_FUNC 0 // Use resizeclient function of instead of resize function which ignores window's resize hints, not recommended.
+
+
+
+/* Kind of eye candy */
+#define GAPS 0 // Gaps support.
+#define XRDB 0 // Xrdb support.
+
+
+
+/* Bar */
+#define ALT_CENTER_OF_BAR_COLOR 0 // changes center of bar color to a dark color.
+#define BAR_HEIGHT 0 // Support for changing bar height.
+#define BAR_PADDING 0 // Support for changing the bar padding.
+
+
+
+/* Misc */
+#define FULLSCREEN 0 // Support for toggling fullscreen.
+#define MOVE_IN_TILED 0 // Support for moving windows in tiled mode.
+#define EWMH_TAGS 0 // Support for EWMH tags, recommended if you want to use external bars with less pain
+#define ALWAYS_CENTER_NEW_FLOATING_WINDOWS 0 //so, basically, it does what it says.
+#define WARP_TO_CLIENT 0 // It warps cursor, where? idk, but use it trust me bro.
#define WARP_TO_CLIENT_AFFECTED_BY_INCNMASTER 0
-#define TAG_TO_TAG 0 //if you switch to tag where you already are, it'll switch to previous tag
-#define FLOATING_LAYOUT_FLOATS_WINDOWS 1 //by default, in floating layout, windows appear to be floating, but, for dwm, they are not. Because of this, when switching to tiled layout after floating layout, windows will be tiled, enable this if you don't want that behaviour.
+#define TAG_TO_TAG 0 // If you switch to tag where you already are, it'll switch to previous tag.
+
+
+
+/* Floating */ // Recomended to use with ALWAYS_CENTER_NEW_FLOATING_WINDOWS set to 1.
+#define FLOATING_LAYOUT_FLOATS_WINDOWS 0 // By default, in floating layout, windows appear to be floating, but, for dwm, they are not. Because of this, when switching to tiled layout after floating layout, windows will be tiled, enable this if you don't want that behaviour.
+#define ENCHANCED_TOGGLE_FLOATING 0 // Support for enchanced toggle floating, when toggling floating window will resize to its natural size, and in floating layout, window will be tiled.
+#define RESTORE_SIZE_AND_POS_ETF 0 // Restore previous size and position of window when toggling floating
+
#endif
diff --git a/modules/etf/etf.c b/modules/etf/etf.c
@@ -0,0 +1,72 @@
+#if !RESTORE_SIZE_AND_POS_ETF
+void
+enchancedtogglefloating(const Arg *arg)
+{
+ if (!selmon->sel || selmon->sel->isfullscreen)
+ return;
+
+ Client *c = selmon->sel;
+ int prev = selmon->sellt;
+
+ c->isfloating = !c->isfloating;
+
+ if (c->isfloating) {
+ int w = c->sfw > 0 ? c->sfw : c->w;
+ int h = c->sfh > 0 ? c->sfh : c->h;
+ resize(c,
+ c->mon->wx + (c->mon->ww - w) / 2,
+ c->mon->wy + (c->mon->wh - h) / 2,
+ w, h, 0);
+ } else {
+ selmon->sellt = 0;
+ arrange(selmon);
+ selmon->sellt = prev;
+ }
+
+ arrange(selmon);
+}
+#else // fuck this shit i almost pulled out all my hair when i wrote this, but atleast it works lol
+void
+enchancedtogglefloating(const Arg *arg)
+{
+ if (!selmon->sel || selmon->sel->isfullscreen)
+ return;
+
+ Client *c = selmon->sel;
+ int wasfloating = c->isfloating;
+
+ Layout *prevlayout = selmon->lt[selmon->sellt];
+
+ c->isfloating = !c->isfloating;
+
+ if (c->isfloating) {
+ int w = c->sfw > 0 ? c->sfw : c->w;
+ int h = c->sfh > 0 ? c->sfh : c->h;
+
+ int x = c->sfx > 20 && c->sfy > 20 ? c->sfx : c->mon->wx + (c->mon->ww - w) / 2;
+ int y = c->sfx > 20 && c->sfy > 20 ? c->sfy : c->mon->wy + (c->mon->wh - h) / 2;
+
+ resize(c, x, y, w, h, 0);
+
+ c->sfx = c->x; c->sfy = c->y;
+ c->sfw = c->w; c->sfh = c->h;
+ } else {
+ c->sfx = c->x;
+ c->sfy = c->y;
+ c->sfw = c->w;
+ c->sfh = c->h;
+
+ selmon->sellt = 0;
+ arrange(selmon);
+
+ for (int i = 0; i < LENGTH(layouts); i++) {
+ if (selmon->lt[i] == prevlayout) {
+ selmon->sellt = i;
+ break;
+ }
+ }
+ }
+
+ arrange(selmon);
+}
+#endif
diff --git a/modules/etf/etf.h b/modules/etf/etf.h
@@ -0,0 +1 @@
+void enchancedtogglefloating(const Arg *arg);
diff --git a/modules/vxwm_includes.c b/modules/vxwm_includes.c
@@ -21,4 +21,8 @@
#include "warptoclient/warptoclient.c"
#endif
+#if ENCHANCED_TOGGLE_FLOATING
+#include "etf/etf.c"
+#endif
+
#endif
diff --git a/modules/vxwm_includes.h b/modules/vxwm_includes.h
@@ -21,4 +21,8 @@
#include "warptoclient/warptoclient.h"
#endif
+#if ENCHANCED_TOGGLE_FLOATING
+#include "etf/etf.h"
+#endif
+
#endif
diff --git a/vxwm.c b/vxwm.c
@@ -97,6 +97,9 @@ struct Client {
Client *snext;
Monitor *mon;
Window win;
+#if ENCHANCED_TOGGLE_FLOATING
+ int sfx, sfy, sfw, sfh;
+#endif
};
typedef struct {
@@ -1117,7 +1120,12 @@ manage(Window w, XWindowAttributes *wa)
c->w = c->oldw = wa->width;
c->h = c->oldh = wa->height;
c->oldbw = wa->border_width;
-
+#if ENCHANCED_TOGGLE_FLOATING
+ c->sfx = c->x;
+ c->sfy = c->y;
+ c->sfw = c->w;
+ c->sfh = c->h;
+#endif
updatetitle(c);
if (XGetTransientForHint(dpy, w, &trans) && (t = wintoclient(trans))) {
c->mon = t->mon;
@@ -1344,6 +1352,14 @@ movemouse(const Arg *arg)
selmon = m;
focus(NULL);
}
+#if ENCHANCED_TOGGLE_FLOATING && RESTORE_SIZE_AND_POS_ETF
+ if (c->isfloating) {
+ c->sfx = c->x;
+ c->sfy = c->y;
+ c->sfw = c->w;
+ c->sfh = c->h;
+ }
+#endif
}
Client *
@@ -1542,6 +1558,14 @@ resizemouse(const Arg *arg)
selmon = m;
focus(NULL);
}
+#if ENCHANCED_TOGGLE_FLOATING && RESTORE_SIZE_AND_POS_ETF
+ if (c->isfloating) {
+ c->sfx = c->x;
+ c->sfy = c->y;
+ c->sfw = c->w;
+ c->sfh = c->h;
+ }
+#endif
}
#else
void
@@ -1605,6 +1629,14 @@ resizemouse(const Arg *arg)
selmon = m;
focus(NULL);
}
+#if ENCHANCED_TOGGLE_FLOATING && RESTORE_SIZE_AND_POS_ETF
+ if (c->isfloating) {
+ c->sfx = c->x;
+ c->sfy = c->y;
+ c->sfw = c->w;
+ c->sfh = c->h;
+ }
+#endif
}
#endif //BETTER_RESIZE