aboutsummaryrefslogtreecommitdiff
path: root/dwm.c
diff options
context:
space:
mode:
Diffstat (limited to 'dwm.c')
-rw-r--r--dwm.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/dwm.c b/dwm.c
index bce09fd..6470b69 100644
--- a/dwm.c
+++ b/dwm.c
@@ -2072,15 +2072,25 @@ sendmon(Client *c, Monitor *m)
{
if (c->mon == m)
return;
+
+ int hadfocus = (c == selmon->sel);
+
unfocus(c, 1);
detach(c);
detachstack(c);
+ arrange(c->mon);
c->mon = m;
c->tags = m->tagset[m->seltags]; /* assign tags of target monitor */
attach(c);
attachstack(c);
- focus(NULL);
- arrange(NULL);
+ arrange(m);
+
+ if (hadfocus) {
+ focus(c);
+ restack(m);
+ } else {
+ focus(NULL);
+ }
}
void