]> git.mdlowis.com Git - proto/anvil.git/commitdiff
added grab pointer to change cursor and control event delivery
authorMichael D. Lowis <mike@mdlowis.com>
Sat, 28 Mar 2020 19:06:59 +0000 (15:06 -0400)
committerMichael D. Lowis <mike@mdlowis.com>
Sat, 28 Mar 2020 19:06:59 +0000 (15:06 -0400)
anvil.c
anvil.h
client.c
mouse.c

diff --git a/anvil.c b/anvil.c
index ed0b085957ae28c7362841d7744a2f1b7025ffa9..e13db6432b794df4a32e8af6b50b7f71feb7fbab 100644 (file)
--- a/anvil.c
+++ b/anvil.c
@@ -14,6 +14,9 @@ static void check_for_wm(void)
 static void xbtnpress(XEvent* e)
 {
     XButtonEvent* ev = &(e->xbutton);
+    XGrabPointer(X.disp, ev->window, False,
+        ButtonPressMask | ButtonReleaseMask | ButtonMotionMask,
+        GrabModeAsync, GrabModeAsync, None, X.csr_move, CurrentTime);
     printf("BTN_DN(w: 0x%lx x: %d y: %d rx: %d ry: %d)\n", ev->window, ev->x, ev->y, ev->x_root, ev->y_root);
     X.start_x = ev->x_root, X.start_y = ev->y_root;
     X.last_x  = ev->x_root, X.last_y  = ev->y_root;
@@ -56,6 +59,7 @@ static void xbtnrelease(XEvent* e)
         mouse_up(ev, &loc);
     }
     X.mode = M_IDLE;
+    XUngrabPointer(X.disp, CurrentTime);
 }
 
 static void xbtnmotion(XEvent* e)
@@ -170,9 +174,9 @@ static void xenternotify(XEvent* e)
 static void xexpose(XEvent* e)
 {
     XExposeEvent* ev = &(e->xexpose);
-//    printf("EXPOSE(w: 0x%lx)\n", ev->window);
     if (ev->count == 0)
     {
+        printf("EXPOSE(w: 0x%lx)\n", ev->window);
         Client* c = client_get(ev->window, NULL);
         if (c)
         {
@@ -197,6 +201,8 @@ static void init_cursors(void)
     XAllocNamedColor(X.disp, cmap, "white", &white, &exact);
     X.csr_point = XCreateFontCursor(X.disp, XC_left_ptr);
     XRecolorCursor(X.disp, X.csr_point, &red, &white);
+    X.csr_move = XCreateFontCursor(X.disp, XC_fleur);
+    XRecolorCursor(X.disp, X.csr_move, &red, &white);
     XDefineCursor(X.disp, X.root, X.csr_root);
 }
 
diff --git a/anvil.h b/anvil.h
index 1433f225f8a08abe4fe3ba5c21f80ca579fe9561..c485a570679133d840a706283de403b2f0f562c4 100644 (file)
--- a/anvil.h
+++ b/anvil.h
@@ -17,8 +17,6 @@
 #define max(a,b) (a > b ? a : b)
 
 /* TODO: warp mouse pointer to title bars on new windows */
-/* TODO: implement mouse handling for tiling methods */
-/* TODO: add logic to add/del columns and retile */
 
 enum {
     M_INIT,
@@ -41,7 +39,7 @@ typedef struct {
     int screen, mode, edge, start_x, start_y, last_x, last_y;
     Window root;
     unsigned long black, white, gray;
-    Cursor csr_root, csr_point;
+    Cursor csr_root, csr_point, csr_move;
     XFontSet font;
     XFontSetExtents *font_ext;
     GC graphics;
index 56f2802369f4320bf46d1e98fa8348931b486d3d..7e23284a6be416d56ca6d44b5c9909c7884b83bb 100644 (file)
--- a/client.c
+++ b/client.c
@@ -220,5 +220,5 @@ void client_setshade(Client* c, int shade)
 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));
+    //XWarpPointer(X.disp, None, X.root, 0, 0, 0, 0, (c->x + c->w/2), c->y + (MIN_HEIGHT/2));
 }
diff --git a/mouse.c b/mouse.c
index 6a3e51f5162703b6c1cb63947b6cd4d089a67385..c781af3485a3f561b6e1b590945a42923301df03 100644 (file)
--- a/mouse.c
+++ b/mouse.c
@@ -116,7 +116,6 @@ static void float_drag(XMotionEvent* ev, Location* loc)
 
 void mouse_up(XButtonEvent* ev, Location* loc)
 {
-    /* TODO: handle button 1 drag to resize, reposition, and move windows */
     if (X.mode == M_TILE_RESIZE)
     {
         mons_tilemove(loc, ev->y_root - X.start_y);