]> git.mdlowis.com Git - proto/anvil.git/commitdiff
added warp pointer to window actions but focus is broken. Can't seem to figure it...
authorMichael D. Lowis <mike@mdlowis.com>
Wed, 25 Mar 2020 10:56:22 +0000 (06:56 -0400)
committerMichael D. Lowis <mike@mdlowis.com>
Wed, 25 Mar 2020 10:56:22 +0000 (06:56 -0400)
anvil.h
client.c
mons.c
mouse.c
tile.c

diff --git a/anvil.h b/anvil.h
index dd227972cce8bb94b43b8dc8d82c8a34878e169a..1433f225f8a08abe4fe3ba5c21f80ca579fe9561 100644 (file)
--- a/anvil.h
+++ b/anvil.h
@@ -130,6 +130,7 @@ void mons_lower(Monitor* mon, Client* c);
 void mons_colsplit(void);
 void mons_coljoin(void);
 void mons_coladjust(Monitor* mon, Column* col, int wdiff);
+void mons_tilemove(Location* loc, int hdiff);
 
 /* client.c */
 extern Client* Focused;
@@ -146,6 +147,7 @@ void client_show(Client* c, int show);
 void client_readprops(Client* c);
 void client_shade(Client* c);
 void client_setshade(Client* c, int shade);
+void client_warpmouse(Client* c);
 
 /* mouse.c */
 void mouse_down(XButtonEvent* ev, Location* loc);
index b5863563f4ee41c9866948cdd33764ec3c252279..19f476bf2b28aca341f65bdc62273d8fa1ba77d1 100644 (file)
--- a/client.c
+++ b/client.c
@@ -214,3 +214,8 @@ void client_setshade(Client* c, int shade)
         XUnmapWindow(X.disp, c->win);
     }
 }
+
+void client_warpmouse(Client* c)
+{
+    XWarpPointer(X.disp, None, c->frame, 0, 0, 0, 0, (c->w/2), (MIN_HEIGHT/2));
+}
diff --git a/mons.c b/mons.c
index f51f626f66357b331abed5eb0e36cce031bff218..f074785a8ea2fcf31ddb067e42bd92119d2f947c 100644 (file)
--- a/mons.c
+++ b/mons.c
@@ -91,6 +91,7 @@ void mons_addclient(Client* c)
 {
     Monitor* mon = pickmon();
     add_client(mon, c, PtrX);
+    client_warpmouse(c);
 }
 
 void mons_delclient(Client* c)
@@ -306,6 +307,31 @@ void mons_coladjust(Monitor* mon, Column* col, int wdiff)
     }
 }
 
+void mons_tilemove(Location* loc, int hdiff)
+{
+    Monitor* mon = pickmon();
+    Column* col = pickcol(mon->cspace->columns, PtrX);
+    if (loc->monitor != mon || loc->column != col)
+    {
+        remove_client(loc, loc->client);
+        client_setshade(loc->client, 0);
+        if (col->focused)
+        {
+            monocled_add(mon, col,loc->client);
+        }
+        else
+        {
+            stacked_add(mon, col, loc->client);
+        }
+    }
+    else
+    {
+        stacked_addheight(loc->monitor, loc->column, loc->client, hdiff);
+    }
+    client_warpmouse(loc->client);
+    client_focus(loc->client);
+}
+
 static Monitor* pickmon(void)
 {
     get_mouse(&PtrX, &PtrY);
@@ -317,7 +343,7 @@ static Monitor* pickmon(void)
             break;
         }
     }
-    assert(mon);
+    mon = (mon ? mon : Monitors);
     return mon;
 }
 
@@ -396,8 +422,12 @@ static void add_client(Monitor* mon, Client* c, int ptrx)
         for (; col && col->clients; col = col->next);
         if (!col)
         {
-            /* otherwise pick the current column */
+            /* otherwise pick the column to the right or current column */
             col = pickcol(mon->cspace->columns, ptrx - mon->x);
+            if (col->next)
+            {
+                col = col->next;
+            }
         }
         /* add in monocled or stacked mode */
         if (col->focused)
diff --git a/mouse.c b/mouse.c
index 37c6555f6380510ce4b254c0bb1521948e464245..6a3e51f5162703b6c1cb63947b6cd4d089a67385 100644 (file)
--- a/mouse.c
+++ b/mouse.c
@@ -70,7 +70,15 @@ static void stacked_click(XButtonEvent* ev, Location* loc)
     }
     else if (ev->button == Button3)
     {
-        monocled_set(loc->monitor, loc->column, loc->client);
+        if (PRESSED(ev->state, Button1))
+        {
+            /* TODO: implement expand in place */
+            puts("expand in place");
+        }
+        else
+        {
+            monocled_set(loc->monitor, loc->column, loc->client);
+        }
     }
 }
 
@@ -111,12 +119,15 @@ void mouse_up(XButtonEvent* ev, Location* loc)
     /* TODO: handle button 1 drag to resize, reposition, and move windows */
     if (X.mode == M_TILE_RESIZE)
     {
-        stacked_addheight(loc->monitor, loc->column, loc->client, ev->y_root - X.start_y);
+        mons_tilemove(loc, ev->y_root - X.start_y);
     }
     else if (X.mode == M_COL_RESIZE)
     {
         mons_coladjust(loc->monitor, loc->column, ev->x_root - X.start_x);
     }
+    else if (loc->column)
+    {
+    }
     X.mode = M_IDLE;
 }
 
diff --git a/tile.c b/tile.c
index 2788d8937b7cb7ba20316fa0c5c698c39f7c5979..db0ece271e4ded7a9f533a9239c1318e330c59d3 100644 (file)
--- a/tile.c
+++ b/tile.c
@@ -135,7 +135,7 @@ void stacked_addheight(Monitor* mon, Column* col, Client* c, int amount)
     for (; prev && prev->next != c; prev = prev->next);
     if (prev)
     {
-        amount = (amount == 0 ? (int)(-c->h * 0.25) : amount);
+        amount = (amount == 0 ? min((int)(-c->h * 0.25), -2*MIN_HEIGHT) : amount);
         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));