commit c3e1b19358bce24725cd29e479466720d5398c25
parent b40ef1223754e737975b80c85ffaa3f60df03c8c
Author: phillbush <phillbush@cock.li>
Date: Sun, 19 Sep 2021 10:37:39 -0300
fix tryattach; fix mouseretab; refactor code
That else case in tryattach could never been true; it should be
a separated if case.
The mouseretab() function called the function containerredecorate()
instead of containerdecorate(). That means that the decoration was
only redraw when the container was resized. But the container is never
resized during a mouseretab. Instead, we need to redraw when a row or
column was deleted. So I put a "redraw" variable that I set to 1 (true)
when a row or column is deleted, then redecorate the container when this
variable is 1. I also removed the call to rowstack(), so the user can
retab into a restacked column.
I removed commented out code. The calls to an outlinedraw() function
were there from a time when I was drawing a outline/frame of the
container while resizing it with the mouse instead of resizing the
container itself. For more information on how I changed it, see [1].
[1]: https://nixers.net/Thread-window-manager-development-thread#pid23137
Diffstat:
1 file changed, 9 insertions(+), 8 deletions(-)
diff --git a/shod.c b/shod.c
@@ -3140,7 +3140,8 @@ tryattach(struct Container *list, struct Tab *det, int xroot, int yroot)
}
rowy += rowh;
}
- } else if (xroot - c->x >= col->x + col->w - DROPPIXELS &&
+ }
+ if (xroot - c->x >= col->x + col->w - DROPPIXELS &&
xroot - c->x < col->x + col->w + visual.division + DROPPIXELS) {
nrow = rownew();
ncol = colnew();
@@ -3871,7 +3872,7 @@ mouseretab(struct Tab *t, int xroot, int yroot, int x, int y)
struct Row *row;
struct Winres res;
XEvent ev;
- int recalc;
+ int recalc, redraw;
row = t->row;
col = row->col;
@@ -3906,9 +3907,6 @@ mouseretab(struct Tab *t, int xroot, int yroot, int x, int y)
}
done:
XUngrabPointer(dpy, CurrentTime);
- if (col->maxrow != NULL) {
- rowstack(col, (col->maxrow == row) ? NULL : row);
- }
if (!tabattach(t, xroot, yroot)) {
mon = getmon(xroot - x, yroot - y);
if (mon == NULL)
@@ -3917,11 +3915,14 @@ done:
managecontainer(newc, t, mon->seldesk, 1);
}
recalc = 1;
+ redraw = 0;
if (row->ntabs == 0) {
rowdel(row);
+ redraw = 1;
}
if (col->nrows == 0) {
coldel(col);
+ redraw = 1;
}
if (c->ncols == 0) {
containerdel(c);
@@ -3930,7 +3931,9 @@ done:
if (recalc) {
containercalccols(c, 1);
containermoveresize(c);
- containerredecorate(c, NULL, NULL, 0);
+ if (redraw) {
+ containerdecorate(c, NULL, NULL, 0, 0);
+ }
}
}
@@ -4038,7 +4041,6 @@ mouseresize(struct Container *c, int xroot, int yroot, enum Octant o)
c->nh += dy;
}
}
- //outlinedraw(c->nx, c->ny, c->nw, c->nh);
if (ev.xmotion.time - lasttime > RESIZETIME) {
containercalccols(c, 1);
containermoveresize(c);
@@ -4051,7 +4053,6 @@ mouseresize(struct Container *c, int xroot, int yroot, enum Octant o)
}
}
done:
- //outlinedraw(0, 0, 0, 0);
containercalccols(c, 1);
containermoveresize(c);
containerdecorate(c, NULL, NULL, 0, 0);