]> git.mdlowis.com Git - proto/anvil.git/commitdiff
moved mouse warping functions to mouse.c
authorMichael D. Lowis <mike@mdlowis.com>
Sun, 5 Apr 2020 18:54:17 +0000 (14:54 -0400)
committerMichael D. Lowis <mike@mdlowis.com>
Sun, 5 Apr 2020 18:54:17 +0000 (14:54 -0400)
anvil.c
anvil.h
client.c
mons.c
mouse.c
tile.c
util.c

diff --git a/anvil.c b/anvil.c
index b5d6cf18f6ba97b73be029014b1afac0e94d9ba1..f533c858bebf9aee09d79fb52073ec6c0de7e2d8 100644 (file)
--- a/anvil.c
+++ b/anvil.c
@@ -95,7 +95,7 @@ static void xconfigrequest(XEvent* e)
         client_adjust(loc.client);
         if (X.mode == M_RESIZE && Focused == loc.client)
         {
-            warp_mouse(loc.client);
+            mouse_tocorner(loc.client);
         }
     }
     else
diff --git a/anvil.h b/anvil.h
index db027759791db30a98970c5da7b0c3fbe6a03efe..4cf1199d455577e62e8f3ef5916600c0433d610f 100644 (file)
--- a/anvil.h
+++ b/anvil.h
@@ -169,12 +169,13 @@ 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);
 void mouse_up(XButtonEvent* ev, Location* loc);
 void mouse_drag(XMotionEvent* ev, Location* loc);
+void mouse_tocorner(Client* c);
+void mouse_totitle(Client* c);
 
 /* tile.c */
 void monocled_add(Monitor* mon, Column* col, Client* c);
@@ -198,5 +199,4 @@ void* ecalloc(size_t n, size_t sz);
 void xfree(void* p);
 Atom atom(char* str);
 void sendmsg(Window win, Atom proto, Atom type);
-void warp_mouse(Client* c);
 void get_mouse(int* ptrx, int* ptry);
index 3be402220556f282ad2b3eb18fa81a9e5be55b89..ccc8dc97f78dcaae38d46d7d61ea22f0d0c21e04 100644 (file)
--- a/client.c
+++ b/client.c
@@ -204,9 +204,3 @@ void client_setshade(Client* c, int shade)
         XUnmapWindow(X.disp, c->win);
     }
 }
-
-void client_warpmouse(Client* c)
-{
-    (void)c;
-//    XWarpPointer(X.disp, None, X.root, 0, 0, 0, 0, (c->x + c->w/2), c->y + (MIN_HEIGHT/2));
-}
diff --git a/mons.c b/mons.c
index 93002ddf1828550c460322ba1145bcc1ec9237e7..acb113238bb642b1c1e252e925c3c475ad950c74 100644 (file)
--- a/mons.c
+++ b/mons.c
@@ -94,7 +94,7 @@ void mons_addclient(Client* c)
 {
     Monitor* mon = pickmon();
     add_client(mon, c, PtrX);
-    client_warpmouse(c);
+    mouse_totitle(c);
 }
 
 void mons_delclient(Location* loc)
@@ -346,6 +346,7 @@ void mons_tilemove(Location* loc, int hdiff)
     {
         stacked_addheight(loc->monitor, loc->column, loc->client, hdiff);
     }
+    mouse_totitle(loc->client);
 }
 
 void mons_activate(Window win)
diff --git a/mouse.c b/mouse.c
index 548a77d49c84960acbf6ebc66b82b047ffcd34a9..e666709c9a1949a7e0db1e019fde19ff98bd3f1b 100644 (file)
--- a/mouse.c
+++ b/mouse.c
@@ -15,7 +15,7 @@ static void float_click(XButtonEvent* ev, Location* loc)
     if ((ev->button == Button1) && (ev->y > MIN_HEIGHT))
     {
         X.mode = M_RESIZE;
-        warp_mouse(loc->client);
+        mouse_tocorner(loc->client);
     }
     else if (ev->button == Button2)
     {
@@ -165,3 +165,19 @@ void mouse_drag(XMotionEvent* ev, Location* loc)
         float_drag(ev, loc);
     }
 }
+
+void mouse_tocorner(Client* c)
+{
+    int new_w = c->w - BORDER_WIDTH/2;
+    int new_h = c->h - BORDER_WIDTH/2;
+    XWarpPointer(X.disp, None, c->frame, 0, 0, 0, 0, new_w, new_h);
+    X.last_x = c->x + new_w;
+    X.last_y = c->y + new_h;
+}
+
+void mouse_totitle(Client* c)
+{
+    XWarpPointer(X.disp, None, X.root, 0, 0, 0, 0, (c->x + c->w/2), c->y + (MIN_HEIGHT/2));
+}
+
+
diff --git a/tile.c b/tile.c
index af2b20526498f267d4f9b1fee78064db99a38f06..742d0318d35c0106bd0a09f582b7fa05abbe2c6f 100644 (file)
--- a/tile.c
+++ b/tile.c
@@ -156,7 +156,7 @@ void stacked_addheight(Monitor* mon, Column* col, Client* c, int amount)
         client_setshade(prev, (prev->h <= MIN_HEIGHT));
         client_setshade(c, (c->h <= MIN_HEIGHT));
         client_adjust(prev);
-        client_warpmouse(c);
+        mouse_totitle(c);
         client_adjust(c);
     }
 }
diff --git a/util.c b/util.c
index 08c6989fa502af9d4843c00bb8e54d0ac6c856e2..8b0b77ca7b52a01bd5bccd35b19f231cca7c0c4a 100644 (file)
--- a/util.c
+++ b/util.c
@@ -51,15 +51,6 @@ void sendmsg(Window win, Atom proto, Atom type)
     XSync(X.disp, False);
 }
 
-void warp_mouse(Client* c)
-{
-    int new_w = c->w - BORDER_WIDTH/2;
-    int new_h = c->h - BORDER_WIDTH/2;
-    XWarpPointer(X.disp, None, c->frame, 0, 0, 0, 0, new_w, new_h);
-    X.last_x = c->x + new_w;
-    X.last_y = c->y + new_h;
-}
-
 void get_mouse(int* ptrx, int* ptry)
 {
     Window root = 0, child = 0;