]> git.mdlowis.com Git - proto/anvil.git/commitdiff
fixed segfault on dragging floating windows and fixed logic for resizing tiled windows
authorMichael D. Lowis <mike@mdlowis.com>
Sat, 21 Mar 2020 03:57:08 +0000 (23:57 -0400)
committerMichael D. Lowis <mike@mdlowis.com>
Sat, 21 Mar 2020 03:57:08 +0000 (23:57 -0400)
anvil.h
mouse.c
tile.c

diff --git a/anvil.h b/anvil.h
index 4ede3efa46ec41690774a1a045fc18a0a372bcaf..466e1eab74030f1ac6f7880885dc8c63af402164 100644 (file)
--- a/anvil.h
+++ b/anvil.h
@@ -94,6 +94,7 @@ typedef struct {
 
 #define BORDER_WIDTH 5
 #define TITLE_HEIGHT (X.font_ext->max_logical_extent.height)
+#define MIN_HEIGHT   (TITLE_HEIGHT+BORDER_WIDTH)
 #define FONT_NAME    "-*-lucida-bold-r-normal-sans-14-*-*-*-p-*-iso10646-1"
 
 /* anvil.c */
diff --git a/mouse.c b/mouse.c
index a1dd7abcb752e67b570580025ea4231805d6a3f7..30b50590dda4bc1f5775b83474e3ff3184595d9c 100644 (file)
--- a/mouse.c
+++ b/mouse.c
@@ -107,7 +107,7 @@ void mouse_up(XButtonEvent* ev, Location* loc)
     (void)ev, (void)loc;
     /* TODO: handle button 1 drag to resize, reposition, and move windows */
     /* TODO: check if we clicked in frame originally or if we clicked in titlebar */
-    if (!loc->column->focused)
+    if (loc->column && !loc->column->focused)
     {
         stacked_addheight(loc->monitor, loc->column, loc->client, ev->y_root - X.start_y);
     }
diff --git a/tile.c b/tile.c
index 3abf7f1592ef47ebd6e2de2f18fcceaa39068d07..9cce23d8d04154be73f307d5845f7c856da003fb 100644 (file)
--- a/tile.c
+++ b/tile.c
@@ -103,20 +103,12 @@ void stacked_addheight(Monitor* mon, Column* col, Client* c, int amount)
     {
         amount = (amount == 0 ? (int)(-c->h * 0.25) : amount);
         int miny = (prev->y + TITLE_HEIGHT+BORDER_WIDTH);
-        int maxy = min((mon->y + mon->h) , (c->y + c->h)) - TITLE_HEIGHT+BORDER_WIDTH;
-        if (amount < 0)
-        {
-            c->y = max(miny, c->y + amount);
-            prev->h = c->y - prev->y;
-        }
-        else if (amount > 0)
-        {
-            c->y = min(maxy, c->y + amount);
-            prev->h = c->y - prev->y;
-        }
+        int maxy = min((mon->y + mon->h) , (c->y + c->h)) - MIN_HEIGHT;
+        c->y = max(miny, min(maxy, c->y + amount));
+        prev->h = c->y - prev->y;
         c->h = (c->next ? c->next->y : mon->y + mon->h) - c->y;
-        client_setshade(prev, (prev->h <= TITLE_HEIGHT+BORDER_WIDTH));
-        client_setshade(c, (c->h <= TITLE_HEIGHT+BORDER_WIDTH));
+        client_setshade(prev, (prev->h <= MIN_HEIGHT));
+        client_setshade(c, (c->h <= MIN_HEIGHT));
         client_adjust(prev);
         client_adjust(c);
     }