commit 5c692548d21955bfc9f81b89edcc73b1e538fb34
parent 10cb704b2b927f0751103ddd57c74a77b10e6e23
Author: wh1tepearl <wh1tepearl@gmail.com>
Date: Thu, 5 Feb 2026 23:09:36 +0000
Heavely optimized WINDOWMAP
Diffstat:
7 files changed, 59 insertions(+), 35 deletions(-)
diff --git a/Makefile b/Makefile
@@ -42,5 +42,6 @@ install: all
uninstall:
rm -f ${DESTDIR}${PREFIX}/bin/vxwm
+ rm -f ${DESTDIR}${PREFIX}/bin/rvx
.PHONY: all clean dist install uninstall
diff --git a/config.def.h b/config.def.h
@@ -1,3 +1,5 @@
+#pragma once
+
/* See LICENSE file for copyright and license details. */
/* appearance */
diff --git a/modules.def.h b/modules.def.h
@@ -1,5 +1,4 @@
-##ifndef MODULES_H
-#define MODULES_H
+#pragma once
/* vxwm compile-time options */
@@ -22,8 +21,9 @@
#define SLOWER_TAGS_ANIMATION 0 // This slows down tags animation speed, which results in smoother tags animations (requires picom to see any difference).
#define WINDOWMAP 0
/* This makes the windows get mapped or unmapped in X11. This results in certain
- behaviour being enabled, for example when you use a compositor like picom - your
- windows will fade in and out when you switch dwm tags. */
+ behaviour being enabled, some examples are: fix issues with some applications
+ losing input forever after a tag change or when you use a compositor like picom,
+ your windows will fade in and out when you switch dwm tags. */
#define PDWM_LIKE_TAGS_ANIMATION 0
/* This makes function showhide be like in pdwm, if using a compositor like picom,
@@ -72,5 +72,3 @@
REQUIRES "FLOATING_LAYOUT_FLOATS_WINDOWS" SET TO 1 TO WORK PROPERLY. */
#define RESTORE_SIZE_AND_POS_ETF 0 // Restore previous size and position of window when toggling floating
-
-#endif
diff --git a/modules/vxwm_includes.c b/modules/vxwm_includes.c
@@ -1,5 +1,4 @@
-#ifndef VXWM_INCLUDES_C
-#define VXWM_INCLUDES_C
+#pragma once
#if GAPS
#include "gaps/gaps.c"
@@ -32,5 +31,3 @@
#if WINDOWMAP
#include "windowmap/windowmap.c"
#endif
-
-#endif
diff --git a/modules/vxwm_includes.h b/modules/vxwm_includes.h
@@ -1,5 +1,4 @@
-#ifndef VXWM_INCLUDES_H
-#define VXWM_INCLUDES_H
+#pragma once
#if GAPS
#include "gaps/gaps.h"
@@ -28,5 +27,3 @@
#if WINDOWMAP
#include "windowmap/windowmap.h"
#endif
-
-#endif
diff --git a/modules/windowmap/windowmap.c b/modules/windowmap/windowmap.c
@@ -25,7 +25,6 @@ window_unmap(Display *dpy, Window win, Window root, int iconify)
{
static XWindowAttributes ca, ra;
- XGrabServer(dpy);
XGetWindowAttributes(dpy, root, &ra);
XGetWindowAttributes(dpy, win, &ca);
@@ -40,5 +39,4 @@ window_unmap(Display *dpy, Window win, Window root, int iconify)
XSelectInput(dpy, root, ra.your_event_mask);
XSelectInput(dpy, win, ca.your_event_mask);
- XUngrabServer(dpy);
}
diff --git a/vxwm.c b/vxwm.c
@@ -53,6 +53,27 @@ Solved issues:
#define TAGMASK ((1 << LENGTH(tags)) - 1)
#define TEXTW(X) (drw_fontset_getwidth(drw, (X)) + lrpad)
+#if !WINDOWMAP
+ #if !PDWM_LIKE_TAGS_ANIMATION
+ #if !SLOWER_TAGS_ANIMATION
+ #define SHOWHIDEPROFILE XMoveWindow(dpy, c->win, WIDTH(c) * -2, c->y); // Vanilla
+ #else
+ #define SHOWHIDEPROFILE XMoveWindow(dpy, c->win, WIDTH(c) * -1, c->y); // Slower vanilla
+ #endif
+ #else
+ #if !SLOWER_TAGS_ANIMATION
+ #define SHOWHIDEPROFILE XMoveWindow(dpy, c->win, c->mon->wx + c->mon->ww / 2, -(HEIGHT(c) * 3) / 2); // pdwm vanilla
+ #else
+ #define SHOWHIDEPROFILE XMoveWindow(dpy, c->win, c->mon->wx + c->mon->ww / 2, -(HEIGHT(c))); // Slower pdwm
+ #endif
+ #endif
+#else
+ #define SHOWHIDEPROFILE if (c->ismapped) { \
+ window_unmap(dpy, c->win, root, 1); \
+ c->ismapped = 0; \
+ }
+#endif
+
/* enums */
enum { CurNormal, CurResize, CurMove,
#if BETTER_RESIZE && BR_CHANGE_CURSOR
@@ -103,6 +124,9 @@ struct Client {
Client *snext;
Monitor *mon;
Window win;
+#if WINDOWMAP
+ int ismapped;
+#endif
#if ENHANCED_TOGGLE_FLOATING
int sfx, sfy, sfw, sfh;
#if RESTORE_SIZE_AND_POS_ETF
@@ -1147,6 +1171,9 @@ manage(Window w, XWindowAttributes *wa)
c = ecalloc(1, sizeof(Client));
c->win = w;
+#if WINDOWMAP
+ c->ismapped = 0;
+#endif
/* geometry */
c->x = c->oldx = wa->x;
c->y = c->oldy = wa->y;
@@ -1877,6 +1904,15 @@ showhide(Client *c)
{
if (!c)
return;
+
+#if WINDOWMAP
+ static int grabbed = 0;
+ if (!grabbed) {
+ XGrabServer(dpy);
+ grabbed = 1;
+ }
+#endif
+
if (ISVISIBLE(c)) {
/* show clients top down */
#if !WINDOWMAP
@@ -1884,30 +1920,25 @@ showhide(Client *c)
if ((!c->mon->lt[c->mon->sellt]->arrange || c->isfloating) && !c->isfullscreen)
resize(c, c->x, c->y, c->w, c->h, 0);
#else
- window_map(dpy, c, 1);
+ if (!c->ismapped) {
+ window_map(dpy, c, 1);
+ c->ismapped = 1;
+ }
#endif
- showhide(c->snext);
+ showhide(c->snext);
} else {
/* hide clients bottom up */
showhide(c->snext);
-#if !WINDOWMAP
- #if !PDWM_LIKE_TAGS_ANIMATION
- #if !SLOWER_TAGS_ANIMATION
- XMoveWindow(dpy, c->win, WIDTH(c) * -2, c->y); // fast
- #else
- XMoveWindow(dpy, c->win, WIDTH(c) * -1, c->y); // slow
- #endif // SLOWER_TAGS_ANIMATION
- #else // PDWM_LIKE_TAGS_ANIMATION
- #if !SLOWER_TAGS_ANIMATION
- XMoveWindow(dpy, c->win, c->mon->wx + c->mon->ww / 2, -(HEIGHT(c) * 3) / 2);
- #else
- XMoveWindow(dpy, c->win, c->mon->wx + c->mon->ww / 2, -(HEIGHT(c)));
- #endif // close SLOWER_TAGS_ANIMATION
- #endif // close PDWM_LIKE_TAGS_ANIMATION
-#else
- window_unmap(dpy, c->win, root, 1);
+ SHOWHIDEPROFILE
+ }
+
+#if WINDOWMAP
+ if (!c->snext && grabbed) {
+ XUngrabServer(dpy);
+ XSync(dpy, False);
+ grabbed = 0;
+ }
#endif
- }
}
void