Closed ysl2 closed 10 months ago
The sendmoncenter patch naturally assumes that the client is floating.
I suppose you could try something like this:
@@ -1418,6 +1418,8 @@ sendmon(Client *c, Monitor *m)
detachstack(c);
c->mon = m;
c->tags = m->tagset[m->seltags]; /* assign tags of target monitor */
+ c->x = m->mx + (m->mw - WIDTH(c)) / 2;
+ c->y = m->my + (m->mh - HEIGHT(c)) / 2;
+ c->sfx = m->mx + (m->mw - c->sfw - 2 * c->bw) / 2;
+ c->sfy = m->my + (m->mh - c->sfh - 2 * c->bw) / 2;
attach(c);
attachstack(c);
focus(NULL);
I suspect that there are many edge cases though that may not work well.
Thank you for instruction, however this seems not work ...
I tried this and it seemed to work for me
diff --git a/dwm.c b/dwm.c
index c3c6292..8b0a262 100644
--- a/dwm.c
+++ b/dwm.c
@@ -3383,6 +3383,10 @@ sendmon(Client *c, Monitor *m)
#else
c->tags = m->tagset[m->seltags]; /* assign tags of target monitor */
#endif // EMPTYVIEW_PATCH
+ c->x = m->mx + (m->mw - WIDTH(c)) / 2;
+ c->y = m->my + (m->mh - HEIGHT(c)) / 2;
+ c->sfx = m->mx + (m->mw - c->sfw - 2 * c->bw) / 2;
+ c->sfy = m->my + (m->mh - c->sfh - 2 * c->bw) / 2;
#if ATTACHABOVE_PATCH || ATTACHASIDE_PATCH || ATTACHBELOW_PATCH || ATTACHBOTTOM_PATCH
attachx(c);
#else
Ah, I patched this in wrong place. After correction by following your newest reply, it works! Thank you bakkeby!!! :-)
https://dwm.suckless.org/patches/sendmoncenter/
I tried to directly patch this, but it cannot work well with savefloats patch.
If I directly enable the savefloats patch, and patch the sendmoncenter above:
When sending a tiling client to another monitor, then togglefloat it, the client cannot be in center.
NOTE: I also enabled the alwayscenter patch.