From 87964e5c7e4cfa96f34187a993d10cc5ec37e881 Mon Sep 17 00:00:00 2001 From: okan Date: Thu, 22 Jan 2009 19:01:56 +0000 Subject: [PATCH] now that pwin is gone gone gone, we no longer have to do the bwidth dance; xevents now able to deal with a border being set (which fixes those annoying movie-watching apps). ok todd@, oga@ --- client.c | 55 +++++++++++++++++++++++++---------------------------- mousefunc.c | 16 ++++------------ xevents.c | 17 +++++++++-------- 3 files changed, 39 insertions(+), 49 deletions(-) diff --git a/client.c b/client.c index 6495d01..cb226d5 100644 --- a/client.c +++ b/client.c @@ -103,7 +103,7 @@ client_new(Window win, struct screen_ctx *sc, int mapped) if ((wmhints = XGetWMHints(X_Dpy, cc->win)) != NULL) { if (wmhints->flags & StateHint) xu_setstate(cc, wmhints->initial_state); - + XFree(wmhints); } client_move(cc); @@ -265,8 +265,8 @@ client_maximize(struct client_ctx *cc) ymax = xine->height; } calc: - cc->geom.x = x_org + Conf.gap_left; - cc->geom.y = y_org + Conf.gap_top; + cc->geom.x = x_org - cc->bwidth + Conf.gap_left; + cc->geom.y = y_org - cc->bwidth + Conf.gap_top; cc->geom.height = ymax - (Conf.gap_top + Conf.gap_bottom); cc->geom.width = xmax - (Conf.gap_left + Conf.gap_right); cc->flags |= CLIENT_DOMAXIMIZE; @@ -297,7 +297,7 @@ client_vertmaximize(struct client_ctx *cc) ymax = xine->height; } calc: - cc->geom.y = y_org + cc->bwidth + Conf.gap_top; + cc->geom.y = y_org + Conf.gap_top; cc->geom.height = ymax - (cc->bwidth * 2) - (Conf.gap_top + Conf.gap_bottom); cc->flags |= CLIENT_DOVMAXIMIZE; @@ -320,16 +320,15 @@ client_resize(struct client_ctx *cc) cc->flags |= CLIENT_VMAXIMIZED; } - XMoveResizeWindow(X_Dpy, cc->win, cc->geom.x - cc->bwidth, - cc->geom.y - cc->bwidth, cc->geom.width, cc->geom.height); + XMoveResizeWindow(X_Dpy, cc->win, cc->geom.x, + cc->geom.y, cc->geom.width, cc->geom.height); xev_reconfig(cc); } void client_move(struct client_ctx *cc) { - XMoveWindow(X_Dpy, cc->win, - cc->geom.x - cc->bwidth, cc->geom.y - cc->bwidth); + XMoveWindow(X_Dpy, cc->win, cc->geom.x, cc->geom.y); xev_reconfig(cc); } @@ -419,6 +418,7 @@ client_draw_border(struct client_ctx *cc) } else pixl = sc->graypixl; + XSetWindowBorderWidth(X_Dpy, cc->win, cc->bwidth); XSetWindowBorder(X_Dpy, cc->win, pixl); } @@ -563,7 +563,7 @@ void client_placecalc(struct client_ctx *cc) { struct screen_ctx *sc = CCTOSC(cc); - int yslack, xslack; + int xslack, yslack; if (cc->size->flags & USPosition) { /* @@ -573,16 +573,12 @@ client_placecalc(struct client_ctx *cc) * XRandR bits mean that {x,y}max shouldn't be outside what's * currently there. */ - yslack = sc->ymax - cc->geom.height - cc->bwidth; - xslack = sc->xmax - cc->geom.width - cc->bwidth; - if (cc->size->x >= 0) - cc->geom.x = MAX(MIN(cc->size->x, xslack), cc->bwidth); - else - cc->geom.x = cc->bwidth; - if (cc->size->y >= 0) - cc->geom.y = MAX(MIN(cc->size->y, yslack), cc->bwidth); - else - cc->geom.y = cc->bwidth; + xslack = sc->xmax - cc->geom.width - cc->bwidth * 2; + yslack = sc->ymax - cc->geom.height - cc->bwidth * 2; + if (cc->size->x > 0) + cc->geom.x = MIN(cc->size->x, xslack); + if (cc->size->y > 0) + cc->geom.y = MIN(cc->size->y, yslack); } else { XineramaScreenInfo *info; int xmouse, ymouse, xorig, yorig; @@ -603,30 +599,31 @@ noxine: xmax = sc->xmax; ymax = sc->ymax; } - xmouse = MAX(xmouse, xorig + cc->bwidth) - cc->geom.width / 2; - ymouse = MAX(ymouse, yorig + cc->bwidth) - cc->geom.height / 2; + xmouse = MAX(xmouse, xorig) - cc->geom.width / 2; + ymouse = MAX(ymouse, yorig) - cc->geom.height / 2; - xmouse = MAX(xmouse, xorig + (int)cc->bwidth); - ymouse = MAX(ymouse, yorig + (int)cc->bwidth); + xmouse = MAX(xmouse, xorig); + ymouse = MAX(ymouse, yorig); + + xslack = xmax - cc->geom.width - cc->bwidth * 2; + yslack = ymax - cc->geom.height - cc->bwidth * 2; - xslack = xmax - cc->geom.width - cc->bwidth; - yslack = ymax - cc->geom.height - cc->bwidth; if (xslack >= xorig) { cc->geom.x = MAX(MIN(xmouse, xslack), - xorig + Conf.gap_left + cc->bwidth); + xorig + Conf.gap_left); if (cc->geom.x > (xslack - Conf.gap_right)) cc->geom.x -= Conf.gap_right; } else { - cc->geom.x = xorig + cc->bwidth + Conf.gap_left; + cc->geom.x = xorig + Conf.gap_left; cc->geom.width = xmax - Conf.gap_left; } if (yslack >= yorig) { cc->geom.y = MAX(MIN(ymouse, yslack), - yorig + Conf.gap_top + cc->bwidth); + yorig + Conf.gap_top); if (cc->geom.y > (yslack - Conf.gap_bottom)) cc->geom.y -= Conf.gap_bottom; } else { - cc->geom.y = yorig + cc->bwidth + Conf.gap_top; + cc->geom.y = yorig + Conf.gap_top; cc->geom.height = ymax - Conf.gap_top; } } diff --git a/mousefunc.c b/mousefunc.c index aa12722..a12d04a 100644 --- a/mousefunc.c +++ b/mousefunc.c @@ -33,8 +33,8 @@ _mousefunc_sweep_calc(struct client_ctx *cc, int x, int y, int mx, int my) { int width = cc->geom.width, height = cc->geom.height; - cc->geom.width = abs(x - mx); - cc->geom.height = abs(y - my); + cc->geom.width = abs(x - mx) - cc->bwidth; + cc->geom.height = abs(y - my) - cc->bwidth; if (cc->size->flags & PResizeInc) { cc->geom.width -= @@ -116,12 +116,7 @@ mousefunc_window_resize(struct client_ctx *cc, void *arg) ev.xmotion.x, ev.xmotion.y)) /* Recompute window output */ _mousefunc_sweep_draw(cc, dx, dy); - - XMoveResizeWindow(X_Dpy, cc->win, - cc->geom.x - cc->bwidth, - cc->geom.y - cc->bwidth, - cc->geom.width + cc->bwidth * 2, - cc->geom.height + cc->bwidth * 2); + client_resize(cc); break; case ButtonRelease: XUnmapWindow(X_Dpy, sc->menuwin); @@ -166,10 +161,7 @@ mousefunc_window_move(struct client_ctx *cc, void *arg) case MotionNotify: cc->geom.x = x + (ev.xmotion.x - mx); cc->geom.y = y + (ev.xmotion.y - my); - - XMoveWindow(X_Dpy, cc->win, - cc->geom.x - cc->bwidth, cc->geom.y - cc->bwidth); - + client_move(cc); break; case ButtonRelease: xu_ptr_ungrab(); diff --git a/xevents.c b/xevents.c index ee251dc..788086e 100644 --- a/xevents.c +++ b/xevents.c @@ -111,19 +111,19 @@ xev_handle_configurerequest(struct xevent *xev, XEvent *ee) cc->geom.x = e->x; if (e->value_mask & CWY) cc->geom.y = e->y; + if (e->value_mask & CWBorderWidth) + wc.border_width = e->border_width; - if (cc->geom.x == 0 && - cc->geom.width >= DisplayWidth(X_Dpy, sc->which)) + if (cc->geom.x == 0 && cc->geom.width >= sc->xmax) cc->geom.x -= cc->bwidth; - if (cc->geom.y == 0 && - cc->geom.height >= DisplayHeight(X_Dpy, sc->which)) + if (cc->geom.y == 0 && cc->geom.height >= sc->ymax) cc->geom.y -= cc->bwidth; - wc.x = cc->geom.x - cc->bwidth; - wc.y = cc->geom.y - cc->bwidth; - wc.width = cc->geom.width + cc->bwidth*2; - wc.height = cc->geom.height + cc->bwidth*2; + wc.x = cc->geom.x; + wc.y = cc->geom.y; + wc.width = cc->geom.width; + wc.height = cc->geom.height; wc.border_width = cc->bwidth; XConfigureWindow(X_Dpy, cc->win, e->value_mask, &wc); @@ -134,6 +134,7 @@ xev_handle_configurerequest(struct xevent *xev, XEvent *ee) wc.y = e->y; wc.width = e->width; wc.height = e->height; + wc.border_width = e->border_width; wc.stack_mode = Above; e->value_mask &= ~CWStackMode;