center patch: adding options to center transient windows

This commit is contained in:
bakkeby 2020-07-04 21:40:29 +02:00
parent 8f06f9a2d5
commit 9fcb63164d
2 changed files with 24 additions and 0 deletions

7
dwm.c
View File

@ -2318,6 +2318,13 @@ manage(Window w, XWindowAttributes *wa)
c->bw = borderpx; c->bw = borderpx;
#endif // SETBORDERPX_PATCH #endif // SETBORDERPX_PATCH
#endif // FLOATPOS_PATCH #endif // FLOATPOS_PATCH
#if CENTER_TRANSIENT_WINDOWS_BY_PARENT_PATCH
c->x = t->x + WIDTH(t) / 2 - WIDTH(c) / 2;
c->y = t->y + HEIGHT(t) / 2 - HEIGHT(c) / 2;
#elif CENTER_TRANSIENT_WINDOWS_PATCH
c->x = c->mon->wx + (c->mon->ww - WIDTH(c)) / 2;
c->y = c->mon->wy + (c->mon->wh - HEIGHT(c)) / 2;
#endif // CENTER_TRANSIENT_WINDOWS_PATCH | CENTER_TRANSIENT_WINDOWS_BY_PARENT_PATCH
} else { } else {
c->mon = selmon; c->mon = selmon;
#if FLOATPOS_PATCH #if FLOATPOS_PATCH

View File

@ -103,6 +103,23 @@
*/ */
#define CENTER_PATCH 0 #define CENTER_PATCH 0
/* A transient window is one that is meant to be short lived and is usually raised by a
* parent window. Such windows are typically dialog boxes and the like.
* It should be noted that in dwm transient windows are not subject to normal client rules
* and they are always floating by default.
* This patch centers transient windows on the screen like the center patch does. Note that
* the 6.2 center patch piggy-backed on the updatewindowtype function to ensure that all
* dialog boxes were centered, transient or not. This function was removed in relation to
* adding wintype as a client rule filter, hence this no longer works out of the box. This
* patch restores previous behaviour with the center patch.
*/
#define CENTER_TRANSIENT_WINDOWS_PATCH 0
/* As above, except that the transient window is centered within the position of the parent
* window, rather than at the center of the screen. This takes precedence over the above patch.
*/
#define CENTER_TRANSIENT_WINDOWS_BY_PARENT_PATCH 0
/* This patch centers the WM_NAME of the currently selected window on the status bar. /* This patch centers the WM_NAME of the currently selected window on the status bar.
* Both fancybar and awesomebar patches take precedence over this patch. * Both fancybar and awesomebar patches take precedence over this patch.
* https://dwm.suckless.org/patches/centeredwindowname/ * https://dwm.suckless.org/patches/centeredwindowname/