]> git.mdlowis.com Git - proto/anvil.git/commitdiff
added debug print statements for event handling.
authorMichael D. Lowis <mike@mdlowis.com>
Fri, 27 Mar 2020 20:23:05 +0000 (16:23 -0400)
committerMichael D. Lowis <mike@mdlowis.com>
Fri, 27 Mar 2020 20:23:05 +0000 (16:23 -0400)
anvil.c
client.c
mons.c
tile.c

diff --git a/anvil.c b/anvil.c
index e3c45756a92cbd3e033e74622fe628d0c0af465f..ed0b085957ae28c7362841d7744a2f1b7025ffa9 100644 (file)
--- a/anvil.c
+++ b/anvil.c
@@ -14,6 +14,7 @@ static void check_for_wm(void)
 static void xbtnpress(XEvent* e)
 {
     XButtonEvent* ev = &(e->xbutton);
+    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;
     Location loc;
@@ -47,6 +48,7 @@ static void xbtnpress(XEvent* e)
 static void xbtnrelease(XEvent* e)
 {
     XButtonEvent* ev = &(e->xbutton);
+    printf("BTN_UP(w: 0x%lx x: %d y: %d rx: %d ry: %d)\n", ev->window, ev->x, ev->y, ev->x_root, ev->y_root);
     Location loc;
     Client* c = client_get(e->xbutton.window, &loc);
     if (c && (ev->window == c->frame))
@@ -60,6 +62,7 @@ static void xbtnmotion(XEvent* e)
 {
     /* make sure we get just the latest event */
     XMotionEvent *ev = &e->xmotion;
+    printf("BTN_MV(w: 0x%lx x: %d y: %d rx: %d ry: %d)\n", ev->window, ev->x, ev->y, ev->x_root, ev->y_root);
     while (XCheckTypedWindowEvent(X.disp, ev->window, ev->type, e));
     Location loc;
     Client* c = client_get(ev->window, &loc);
@@ -73,6 +76,7 @@ static void xbtnmotion(XEvent* e)
 static void xconfigrequest(XEvent* e)
 {
     XConfigureRequestEvent* ev = &(e->xconfigurerequest);
+    printf("CONF(w: 0x%lx x: %d y: %d w: %d h: %d)\n", ev->window, ev->x, ev->y, ev->width, ev->height);
     XWindowChanges wc;
     wc.x = ev->x;
     wc.y = ev->y;
@@ -98,6 +102,7 @@ static void xconfigrequest(XEvent* e)
 static void xmaprequest(XEvent* e)
 {
     XMapRequestEvent* ev = &(e->xmaprequest);
+    printf("MAP(w: 0x%lx)\n", ev->window);
     XWindowAttributes attr;
     if (!client_get(ev->window, NULL))
     {
@@ -111,6 +116,7 @@ static void xmaprequest(XEvent* e)
 static void xunmapnotify(XEvent* e)
 {
     XUnmapEvent* ev = &(e->xunmap);
+    printf("UNMAP(w: 0x%lx)\n", ev->window);
     Client* c = client_get(ev->window, NULL);
     if (c && c->win == ev->window && !(c->flags & F_SHADED))
     {
@@ -121,6 +127,7 @@ static void xunmapnotify(XEvent* e)
 static void xdestroynotify(XEvent* e)
 {
     XDestroyWindowEvent* ev = &(e->xdestroywindow);
+    printf("DESTROY(w: 0x%lx)\n", ev->window);
     Client* c = client_get(ev->window, NULL);
     if (c)
     {
@@ -140,6 +147,7 @@ static void xclientmsg(XEvent* e)
 static void xpropnotify(XEvent* e)
 {
     XPropertyEvent* ev = &(e->xproperty);
+    printf("PROP_NOTIFY(w: 0x%lx)\n", ev->window);
     Client* c = client_get(ev->window, NULL);
     if (c)
     {
@@ -152,6 +160,7 @@ static void xenternotify(XEvent* e)
 {
     XCrossingEvent* ev = &(e->xcrossing);
     Client* c = client_get(ev->window, NULL);
+    printf("ENTER(w: 0x%lx c: 0x%lx)\n", ev->window, c ? c->win : 0);
     if (c)
     {
         client_focus(c);
@@ -160,9 +169,11 @@ static void xenternotify(XEvent* e)
 
 static void xexpose(XEvent* e)
 {
-    if (e->xexpose.count == 0)
+    XExposeEvent* ev = &(e->xexpose);
+//    printf("EXPOSE(w: 0x%lx)\n", ev->window);
+    if (ev->count == 0)
     {
-        Client* c = client_get(e->xexpose.window, NULL);
+        Client* c = client_get(ev->window, NULL);
         if (c)
         {
             client_draw(c);
@@ -172,7 +183,9 @@ static void xexpose(XEvent* e)
 
 static void xkeypress(XEvent* e)
 {
-    keys_run(&(e->xkey));
+    XKeyEvent* ev = &(e->xkey);
+    printf("KEY_DN(w: 0x%lx)\n", ev->window);
+    keys_run(ev);
 }
 
 static void init_cursors(void)
index 19f476bf2b28aca341f65bdc62273d8fa1ba77d1..56f2802369f4320bf46d1e98fa8348931b486d3d 100644 (file)
--- a/client.c
+++ b/client.c
@@ -23,6 +23,7 @@ void client_initall(void)
 
 Client* client_add(Window win, XWindowAttributes* attr)
 {
+    printf("ADD(w: %lx)\n", win);
     Client* c = ecalloc(1, sizeof(Client));
     c->win = win;
     c->x = attr->x;
@@ -50,7 +51,7 @@ Client* client_add(Window win, XWindowAttributes* attr)
     client_show(c, 1);
     XSync(X.disp, False);
     client_draw(c);
-
+    printf("PLACE(w: %lx x: %d y: %d w: %d h: %d)\n", win, c->x, c->y, c->w, c->y);
     return c;
 }
 
@@ -136,6 +137,7 @@ void client_close(Client* c)
 
 void client_focus(Client* c)
 {
+    printf("SET_FOCUS(w: 0x%lx c: 0x%lx)\n", c->frame, c->win);
     Client* prev = Focused;
     Focused = c;
     XSetInputFocus(X.disp, c->win, RevertToPointerRoot, CurrentTime);
@@ -217,5 +219,6 @@ void client_setshade(Client* c, int shade)
 
 void client_warpmouse(Client* c)
 {
-    XWarpPointer(X.disp, None, c->frame, 0, 0, 0, 0, (c->w/2), (MIN_HEIGHT/2));
+    (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 f074785a8ea2fcf31ddb067e42bd92119d2f947c..00926d19bae7ee17ad5e700cd295264b2aa4ecef 100644 (file)
--- a/mons.c
+++ b/mons.c
@@ -328,8 +328,6 @@ void mons_tilemove(Location* loc, int hdiff)
     {
         stacked_addheight(loc->monitor, loc->column, loc->client, hdiff);
     }
-    client_warpmouse(loc->client);
-    client_focus(loc->client);
 }
 
 static Monitor* pickmon(void)
diff --git a/tile.c b/tile.c
index db0ece271e4ded7a9f533a9239c1318e330c59d3..7b693dc1a8d41b36db4bf1f91f276171ad9e7f1f 100644 (file)
--- a/tile.c
+++ b/tile.c
@@ -135,15 +135,17 @@ void stacked_addheight(Monitor* mon, Column* col, Client* c, int amount)
     for (; prev && prev->next != c; prev = prev->next);
     if (prev)
     {
-        amount = (amount == 0 ? min((int)(-c->h * 0.25), -2*MIN_HEIGHT) : amount);
+        amount = (abs(amount) < BORDER_WIDTH ? 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));
         prev->h = c->y - prev->y;
         c->h = (c->next ? c->next->y : mon->y + mon->h) - c->y;
+        printf("ADD_HEIGHT1(w: %lx x: %d y: %d w: %d h: %d)\n", c->frame, c->x, c->y, c->w, c->h);
         client_setshade(prev, (prev->h <= MIN_HEIGHT));
         client_setshade(c, (c->h <= MIN_HEIGHT));
         client_adjust(prev);
+        client_warpmouse(c);
         client_adjust(c);
     }
 }