]> git.mdlowis.com Git - proto/anvil.git/commitdiff
refactored and added logic to detect difference between drag on frame and titlebar...
authorMichael D. Lowis <mike@mdlowis.com>
Sat, 21 Mar 2020 04:19:37 +0000 (00:19 -0400)
committerMichael D. Lowis <mike@mdlowis.com>
Sat, 21 Mar 2020 04:19:37 +0000 (00:19 -0400)
anvil.h
client.c
mouse.c
tile.c

diff --git a/anvil.h b/anvil.h
index 466e1eab74030f1ac6f7880885dc8c63af402164..a4719d2fa223706c6a3140fb25a1f69625a5dcb4 100644 (file)
--- a/anvil.h
+++ b/anvil.h
@@ -23,7 +23,9 @@
 enum {
     M_INIT,
     M_IDLE,
-    M_RESIZE
+    M_RESIZE,
+    M_TILE_RESIZE,
+    M_COL_RESIZE
 };
 
 typedef struct {
index 79c1dfd356e645a37d5872c251cde8dc952ddd8a..c2bbcdc4552e1cdd0857dc11f88ef053275d8347 100644 (file)
--- a/client.c
+++ b/client.c
@@ -41,8 +41,7 @@ Client* client_add(Window win, XWindowAttributes* attr)
     wa.event_mask = EnterWindowMask | PropertyChangeMask | FocusChangeMask;
     wa.do_not_propagate_mask = ButtonPressMask | ButtonReleaseMask;
     XChangeWindowAttributes(X.disp, c->win, CWEventMask | CWDontPropagate, &wa);
-    XReparentWindow(X.disp, c->win, c->frame,
-        BORDER_WIDTH, BORDER_WIDTH + TITLE_HEIGHT);
+    XReparentWindow(X.disp, c->win, c->frame, BORDER_WIDTH, MIN_HEIGHT);
 
     /* Map the window and draw the frame */
     XAddToSaveSet(X.disp, c->win);
@@ -105,11 +104,11 @@ void client_resize(Client* c, int xdiff, int ydiff)
 {
     c->w += xdiff;
     c->h += ydiff;
-    if (c->w < TITLE_HEIGHT+BORDER_WIDTH) c->w = TITLE_HEIGHT+BORDER_WIDTH;
-    if (c->h < TITLE_HEIGHT+BORDER_WIDTH) c->h = TITLE_HEIGHT+BORDER_WIDTH;
+    if (c->w < MIN_HEIGHT) c->w = MIN_HEIGHT;
+    if (c->h < MIN_HEIGHT) c->h = MIN_HEIGHT;
     if (c->flags & F_SHADED)
     {
-        XResizeWindow(X.disp, c->frame, c->w, TITLE_HEIGHT+BORDER_WIDTH);
+        XResizeWindow(X.disp, c->frame, c->w, MIN_HEIGHT);
     }
     else
     {
diff --git a/mouse.c b/mouse.c
index 30b50590dda4bc1f5775b83474e3ff3184595d9c..b02a2c55967099d4f318cfaf565244fcc34e732a 100644 (file)
--- a/mouse.c
+++ b/mouse.c
@@ -10,7 +10,7 @@ static inline int PRESSED(int mods, int btn)
 
 static void float_click(XButtonEvent* ev, Location* loc)
 {
-    if ((ev->button == Button1) && (ev->y > (TITLE_HEIGHT + BORDER_WIDTH)))
+    if ((ev->button == Button1) && (ev->y > MIN_HEIGHT))
     {
         X.mode = M_RESIZE;
         warp_mouse(loc->client);
@@ -60,7 +60,11 @@ static void monocled_click(XButtonEvent* ev, Location* loc)
 
 static void stacked_click(XButtonEvent* ev, Location* loc)
 {
-    if (ev->button == Button2)
+    if (ev->button == Button1)
+    {
+        X.mode = (ev->y > MIN_HEIGHT ? M_COL_RESIZE : M_TILE_RESIZE);
+    }
+    else if (ev->button == Button2)
     {
         client_close(loc->client);
     }
@@ -104,13 +108,17 @@ static void float_drag(XMotionEvent* ev, Location* loc)
 
 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 && !loc->column->focused)
+    if (X.mode == M_TILE_RESIZE)
     {
         stacked_addheight(loc->monitor, loc->column, loc->client, ev->y_root - X.start_y);
     }
+    else if (X.mode == M_COL_RESIZE)
+    {
+        puts("resize column");
+        /* TODO: resize column */
+    }
+    X.mode = M_IDLE;
 }
 
 static void monocled_drag(XMotionEvent* ev, Location* loc)
diff --git a/tile.c b/tile.c
index 9cce23d8d04154be73f307d5845f7c856da003fb..cc0c7ae47b9c2baae0a0cab9baa890eb6eb55fa6 100644 (file)
--- a/tile.c
+++ b/tile.c
@@ -102,7 +102,7 @@ void stacked_addheight(Monitor* mon, Column* col, Client* c, int amount)
     if (prev)
     {
         amount = (amount == 0 ? (int)(-c->h * 0.25) : amount);
-        int miny = (prev->y + TITLE_HEIGHT+BORDER_WIDTH);
+        int miny = (prev->y + MIN_HEIGHT);
         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;