rem: if (!WFLAGP(wwin, no_titlebar))
add: if (HAS_TITLEBAR(wwin))
context: wMouseResizeWindow(WWindow *wwin, XEvent *ev){    XEvent event;    WScreen *scr = wwin->screen_ptr;    Window root = scr->root_win;    int vert_border = wwin->frame->top_width + wwin->frame->bottom_width;    int fw = wwin->frame->core->width;    int fh = wwin->frame->core->height;    int fx = wwin->frame_x;    int fy = wwin->frame_y;    int is_resizebar = (wwin->frame->resizebar                        && ev->xany.window==wwin->frame->resizebar->window);    int orig_x, orig_y;    int started;    int dw, dh;    int rw = fw, rh = fh;    int rx1, ry1, rx2, ry2;    int res = 0;    KeyCode shiftl, shiftr;    int h = 0;    int orig_fx = fx;    int orig_fy = fy;    int orig_fw = fw;    int orig_fh = fh;    if (wwin->flags.shaded) {        wwarning("internal error: tryein");        return;    }    orig_x = ev->xbutton.x_root;    orig_y = ev->xbutton.y_root;    started = 0;#ifdef DEBUG    puts("Resizing window");#endif    wUnselectWindows(scr);    rx1 = fx;    rx2 = fx + fw - 1;    ry1 = fy;    ry2 = fy + fh - 1;    shiftl = XKeysymToKeycode(dpy, XK_Shift_L);    shiftr = XKeysymToKeycode(dpy, XK_Shift_R);    if (!WFLAGP(wwin, no_titlebar))        h = WMFontHeight(wwin->screen_ptr->title_font) + (wPreferences.window_title_clearance + TITLEBAR_EXTEND_SPACE) * 2;    else        h = 0;    while (1) {        WMMaskEvent(dpy, KeyPressMask | ButtonMotionMask                    | ButtonReleaseMask | PointerMotionHintMask                    | ButtonPressMask | ExposureMask, &event);        if (!checkMouseSamplingRate(&event))            continue;        switch (event.type) {        case KeyPress:            showGeometry(wwin, fx, fy, fx + fw, fy + fh, res);            if ((event.xkey.keycode == shiftl || event.xkey.keycode == shiftr)                && started) {                drawTransparentFrame(wwin, fx, fy, fw, fh);                cycleGeometryDisplay(wwin, fx, fy, fw, fh, res);                drawTransparentFrame(wwin, fx, fy, fw, fh);            }            showGeometry(wwin, fx, fy, fx + fw, fy + fh, res);            break;        case MotionNotify:            if (started) {                while (XCheckMaskEvent(dpy, ButtonMotionMask, &event)) ;                dw = 0;                dh = 0;                orig_fx = fx;                orig_fy = fy;                orig_fw = fw;                orig_fh = fh;                if (res & LEFT)                    dw = orig_x - event.xmotion.x_root;                else if (res & RIGHT)                    dw = event.xmotion.x_root - orig_x;                if (res & UP)                    dh = orig_y - event.xmotion.y_root;                else if (res & DOWN)                    dh = event.xmotion.y_root - orig_y;                orig_x = event.xmotion.x_root;                orig_y = event.xmotion.y_root;                rw += dw;                rh += dh;                fw = rw;                fh = rh - vert_border;                wWindowConstrainSize(wwin, &fw, &fh);                fh += vert_border;                if (res & LEFT)                    fx = rx2 - fw + 1;                else if (res & RIGHT)                    fx = rx1;                if (res & UP)                    fy = ry2 - fh + 1;                else if (res & DOWN)                    fy = ry1;            } else if (abs(orig_x - event.xmotion.x_root) >= MOVE_THRESHOLD                       || abs(orig_y - event.xmotion.y_root) >= MOVE_THRESHOLD) {                int tx, ty;                Window junkw;                int flags;                XTranslateCoordinates(dpy, root, wwin->frame->core->window,                                      orig_x, orig_y, &tx, &ty, &junkw);                /* check if resizing through resizebar */                if (is_resizebar)                    flags = RESIZEBAR;                else                    flags = 0;                if (is_resizebar && ((ev->xbutton.state & ShiftMask)                                     || abs(orig_y - event.xmotion.y_root) < HRESIZE_THRESHOLD))                    flags |= HCONSTRAIN;                res = getResizeDirection(wwin, tx, ty,                                         orig_x - event.xmotion.x_root,                                         orig_y - event.xmotion.y_root, flags);                if (res == (UP|LEFT))                    XChangeActivePointerGrab(dpy, ButtonMotionMask                                             | ButtonReleaseMask | ButtonPressMask,                                             wCursor[WCUR_TOPLEFTRESIZE], CurrentTime);                else if (res == (UP|RIGHT))                    XChangeActivePointerGrab(dpy, ButtonMotionMask                                             | ButtonReleaseMask | ButtonPressMask,                                             wCursor[WCUR_TOPRIGHTRESIZE], CurrentTime);                else if (res == (DOWN|LEFT))                    XChangeActivePointerGrab(dpy, ButtonMotionMask                                             | ButtonReleaseMask | ButtonPressMask,                                             wCursor[WCUR_BOTTOMLEFTRESIZE], CurrentTime);                else if (res == (DOWN|RIGHT))                    XChangeActivePointerGrab(dpy, ButtonMotionMask                                             | ButtonReleaseMask | ButtonPressMask,                                             wCursor[WCUR_BOTTOMRIGHTRESIZE], CurrentTime);                else if (res == DOWN || res == UP)                    XChangeActivePointerGrab(dpy, ButtonMotionMask                                             | ButtonReleaseMask | ButtonPressMask,                                             wCursor[WCUR_VERTICALRESIZE], CurrentTime);                else if (res & (DOWN|UP))                    XChangeActivePointerGrab(dpy, ButtonMotionMask                                             | ButtonReleaseMask | ButtonPressMask,                                             wCursor[WCUR_VERTICALRESIZE], CurrentTime);                else if (res & (LEFT|RIGHT))                    XChangeActivePointerGrab(dpy, ButtonMotionMask                                             | ButtonReleaseMask | ButtonPressMask,                                             wCursor[WCUR_HORIZONRESIZE], CurrentTime);                XGrabKeyboard(dpy, root, False, GrabModeAsync, GrabModeAsync,                              CurrentTime);                XGrabServer(dpy);                /* Draw the resize frame for the first time. */                mapGeometryDisplay(wwin, fx, fy, fw, fh);                drawTransparentFrame(wwin, fx, fy, fw, fh);                showGeometry(wwin, fx, fy, fx + fw, fy + fh, res);                started = 1;            }            if (started) {                if (wPreferences.size_display == WDIS_FRAME_CENTER) {                    drawTransparentFrame(wwin, orig_fx, orig_fy,                                         orig_fw, orig_fh);                    moveGeometryDisplayCentered(scr, fx + fw / 2, fy + fh / 2);                    drawTransparentFrame(wwin, fx, fy, fw, fh);                } else {                    drawTransparentFrame(wwin, orig_fx, orig_fy,                                         orig_fw, orig_fh);                    drawTransparentFrame(wwin, fx, fy, fw, fh);                }                if (fh != orig_fh || fw != orig_fw) {                    if (wPreferences.size_display == WDIS_NEW) {                        showGeometry(wwin, orig_fx, orig_fy, orig_fx + orig_fw,                                     orig_fy + orig_fh, res);                    }                    showGeometry(wwin, fx, fy, fx + fw, fy + fh, res);                }            }            break;        case ButtonPress:            break;        case ButtonRelease:            if (event.xbutton.button != ev->xbutton.button)                break;            if (started) {                showGeometry(wwin, fx, fy, fx + fw, fy + fh, res);                drawTransparentFrame(wwin, fx, fy, fw, fh);                XUngrabKeyboard(dpy, CurrentTime);                WMUnmapWidget(scr->gview);                XUngrabServer(dpy);                if (wwin->client.width != fw)                    wwin->flags.user_changed_width = 1;                if (wwin->client.height != fh - vert_border)                    wwin->flags.user_changed_height = 1;                wWindowConfigure(wwin, fx, fy, fw, fh - vert_border);            }#ifdef DEBUG            puts("End resize window");#endif            return;        default:            WMHandleEvent(&event);        }    }}