fix first mouse resize

This commit is contained in:
Ryan Goniwiecha
2026-04-19 17:12:51 -04:00
parent 00f6b03503
commit 9618137422
2 changed files with 27 additions and 1 deletions

View File

@@ -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;

View File

@@ -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);