aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStivvo <stivvo01@gmail.com>2020-09-12 00:13:05 +0200
committerStivvo <stivvo01@gmail.com>2020-09-12 00:21:58 +0200
commit537ad7e3fdc23602254ba00ba869eab891be7966 (patch)
treea97a5662046eb758ca75945312e987bbdedf0b35
parent0bb25a73ecfbf4c8f613e1a1b96be5ea683bf12a (diff)
Restore floating win position after mon add
Compensate the coordinate changes when adding a new monitor. Every test so far confirms that monitors are always added to the left, on top of the list, so every floating window's x coordinate has to be incremented by the width of the new monitor.
-rw-r--r--dwl.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/dwl.c b/dwl.c
index 414aa59..23a7211 100644
--- a/dwl.c
+++ b/dwl.c
@@ -195,6 +195,7 @@ static void applyexclusive(struct wlr_box *usable_area, uint32_t anchor,
int32_t margin_bottom, int32_t margin_left);
static void applyrules(Client *c);
static void arrange(Monitor *m);
+static void arrangefloat(Monitor *m, int sign);
static void arrangelayer(Monitor *m, struct wl_list *list,
struct wlr_box *usable_area, bool exclusive);
static void arrangelayers(Monitor *m);
@@ -470,6 +471,17 @@ arrange(Monitor *m)
}
void
+arrangefloat(Monitor *m, int sign)
+{
+ Client *c;
+ wl_list_for_each(c, &clients, link) {
+ if (c->isfloating)
+ resize(c, c->geom.x + m->w.width * sign, c->geom.y,
+ c->geom.width, c->geom.height, 0);
+ }
+}
+
+void
arrangelayer(Monitor *m, struct wl_list *list, struct wlr_box *usable_area, bool exclusive)
{
LayerSurface *layersurface;
@@ -693,6 +705,7 @@ cleanupmon(struct wl_listener *listener, void *data)
free(m);
updatemons();
+ arrangefloat(m, -1);
}
void
@@ -821,6 +834,11 @@ createmon(struct wl_listener *listener, void *data)
/* When adding monitors, the geometries of all monitors must be updated */
updatemons();
+ wl_list_for_each(m, &mons, link) {
+ /* the first monitor in the list is the most recently added */
+ arrangefloat(m, 1);
+ return;
+ }
}
void