From: Michael D. Lowis Date: Fri, 27 Mar 2020 20:23:05 +0000 (-0400) Subject: added debug print statements for event handling. X-Git-Url: https://git.mdlowis.com/?a=commitdiff_plain;h=6c05b6f4487767198b41c5e79dddf225777bc81e;p=proto%2Fanvil.git added debug print statements for event handling. --- diff --git a/anvil.c b/anvil.c index e3c4575..ed0b085 100644 --- 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) diff --git a/client.c b/client.c index 19f476b..56f2802 100644 --- 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 f074785..00926d1 100644 --- 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 db0ece2..7b693dc 100644 --- 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); } }