diff --git a/client.c b/client.c index afbf874..447cd97 100644 --- a/client.c +++ b/client.c @@ -79,6 +79,8 @@ client_init(Window win, struct screen_ctx *sc) cc->geom.y = wattr.y; cc->geom.w = wattr.width; cc->geom.h = wattr.height; + cc->savegeom = cc->geom; + cc->fullgeom = cc->geom; cc->colormap = wattr.colormap; cc->obwidth = wattr.border_width; cc->bwidth = Conf.bwidth; diff --git a/kbfunc.c b/kbfunc.c index 59b77b2..3b435f0 100644 --- a/kbfunc.c +++ b/kbfunc.c @@ -47,6 +47,7 @@ static void kbfunc_client_move_kb(void *, struct cargs *); static void kbfunc_client_move_mb(void *, struct cargs *); static void kbfunc_client_resize_kb(void *, struct cargs *); static void kbfunc_client_resize_mb(void *, struct cargs *); +static Bool kbfunc_discard_configurerequest(Display *, XEvent *, XPointer); void kbfunc_cwm_status(void *ctx, struct cargs *cargs) @@ -54,6 +55,17 @@ kbfunc_cwm_status(void *ctx, struct cargs *cargs) cwm_status = cargs->flag; } +static Bool +kbfunc_discard_configurerequest(Display *dpy, XEvent *ev, XPointer arg) +{ + Window *win = (Window *)arg; + + (void)dpy; + + return (ev->type == ConfigureRequest && + ev->xconfigurerequest.window == *win); +} + static void kbfunc_amount(int flags, int amt, int *mx, int *my) { @@ -242,6 +254,7 @@ kbfunc_client_resize_mb(void *ctx, struct cargs *cargs) { struct client_ctx *cc = ctx; XEvent ev; + XEvent cev; Time ltime = 0; struct screen_ctx *sc = cc->sc; int resize = 1; @@ -282,8 +295,19 @@ kbfunc_client_resize_mb(void *ctx, struct cargs *cargs) break; } } - if (ltime) + if (ltime) { + /* + * A newly mapped client can queue a ConfigureRequest while the + * resize loop is consuming only mouse events. Drop those stale + * requests so the final drag geometry is not immediately + * overwritten when the main event loop resumes. + */ + while (XCheckIfEvent(X_Dpy, &cev, + kbfunc_discard_configurerequest, + (XPointer)&cc->win)) + ; client_resize(cc, 1); + } screen_prop_win_destroy(sc); XUngrabPointer(X_Dpy, CurrentTime);