add: if (started && wPreferences.auto_arrange_icons && wXineramaHeads(scr)>1 && head != wGetHeadForWindow(wwin)) { wArrangeIcons(scr, True); }  #if defined(NETWM_HINTS) && defined(VIRTUAL_DESKTOP) if (started) wWorkspaceResizeViewPort(scr, scr->current_workspace); #endif
context: wMouseMoveWindow(WWindow *wwin, XEvent *ev){    WScreen *scr = wwin->screen_ptr;    XEvent event;    Window root = scr->root_win;    KeyCode shiftl, shiftr;    Bool done = False;    int started = 0;    int warped = 0;    /* This needs not to change while moving, else bad things can happen */    int opaqueMove = wPreferences.opaque_move;    MoveData moveData;#ifdef GHOST_WINDOW_MOVE    RImage *rimg;    rimg = InitGhostWindowMove(scr);#endif    if (wPreferences.opaque_move && !wPreferences.use_saveunders) {        XSetWindowAttributes attr;        attr.save_under = True;        XChangeWindowAttributes(dpy, wwin->frame->core->window,                                CWSaveUnder, &attr);    }    initMoveData(wwin, &moveData);    moveData.mouseX = ev->xmotion.x_root;    moveData.mouseY = ev->xmotion.y_root;    if (!wwin->flags.selected) {        /* this window is not selected, unselect others and move only wwin */        wUnselectWindows(scr);    }#ifdef DEBUG    puts("Moving window");#endif    shiftl = XKeysymToKeycode(dpy, XK_Shift_L);    shiftr = XKeysymToKeycode(dpy, XK_Shift_R);    while (!done) {        if (warped) {            int junk;            Window junkw;            /* XWarpPointer() doesn't seem to generate Motion events, so             * we've got to simulate them */            XQueryPointer(dpy, root, &junkw, &junkw, &event.xmotion.x_root,                          &event.xmotion.y_root, &junk, &junk,                          (unsigned *) &junk);        } else {            WMMaskEvent(dpy, KeyPressMask | ButtonMotionMask                        | PointerMotionHintMask                        | ButtonReleaseMask | ButtonPressMask | ExposureMask,                        &event);            if (event.type == MotionNotify) {                /* compress MotionNotify events */                while (XCheckMaskEvent(dpy, ButtonMotionMask, &event)) ;                if (!checkMouseSamplingRate(&event))                    continue;            }        }        switch (event.type) {        case KeyPress:            if ((event.xkey.keycode == shiftl || event.xkey.keycode == shiftr)                && started && !scr->selected_windows) {                if (!opaqueMove) {                    drawFrames(wwin, scr->selected_windows,                               moveData.realX - wwin->frame_x,                               moveData.realY - wwin->frame_y);                }                if (wPreferences.move_display == WDIS_NEW                    && !scr->selected_windows) {                    showPosition(wwin, moveData.realX, moveData.realY);                    XUngrabServer(dpy);                }                cyclePositionDisplay(wwin, moveData.realX, moveData.realY,                                     moveData.winWidth, moveData.winHeight);                if (wPreferences.move_display == WDIS_NEW                    && !scr->selected_windows) {                    XGrabServer(dpy);                    showPosition(wwin, moveData.realX, moveData.realY);                }                if (!opaqueMove) {                    drawFrames(wwin, scr->selected_windows,                               moveData.realX - wwin->frame_x,                               moveData.realY - wwin->frame_y);                }                /*} else {                 WMHandleEvent(&event); this causes problems needs fixing */            }            break;        case MotionNotify:            if (started) {                updateWindowPosition(wwin, &moveData,                                     scr->selected_windows == NULL                                     && wPreferences.edge_resistance > 0,                                     opaqueMove,                                     event.xmotion.x_root,                                     event.xmotion.y_root);                if (!warped && !wPreferences.no_autowrap) {                    int oldWorkspace = scr->current_workspace;                    if (wPreferences.move_display == WDIS_NEW                        && !scr->selected_windows) {                        showPosition(wwin, moveData.realX, moveData.realY);                        XUngrabServer(dpy);                    }                    if (!opaqueMove) {                        drawFrames(wwin, scr->selected_windows,                                   moveData.realX - wwin->frame_x,                                   moveData.realY - wwin->frame_y);                    }                    if (checkWorkspaceChange(wwin, &moveData, opaqueMove)) {                        if (scr->current_workspace != oldWorkspace                            && wPreferences.edge_resistance > 0                            && scr->selected_windows == NULL)                            updateMoveData(wwin, &moveData);                        warped = 1;                    }                    if (!opaqueMove) {                        drawFrames(wwin, scr->selected_windows,                                   moveData.realX - wwin->frame_x,                                   moveData.realY - wwin->frame_y);                    }                    if (wPreferences.move_display == WDIS_NEW                        && !scr->selected_windows) {                        XSync(dpy, False);                        showPosition(wwin, moveData.realX, moveData.realY);                        XGrabServer(dpy);                    }                } else {                    warped = 0;                }            } else if (abs(ev->xmotion.x_root - event.xmotion.x_root) >= MOVE_THRESHOLD                       || abs(ev->xmotion.y_root - event.xmotion.y_root) >= MOVE_THRESHOLD) {                XChangeActivePointerGrab(dpy, ButtonMotionMask                                         | ButtonReleaseMask | ButtonPressMask,                                         wCursor[WCUR_MOVE], CurrentTime);                started = 1;                XGrabKeyboard(dpy, root, False, GrabModeAsync, GrabModeAsync,                              CurrentTime);                if (!scr->selected_windows)                    mapPositionDisplay(wwin, moveData.realX, moveData.realY,                                       moveData.winWidth, moveData.winHeight);                if (started && !opaqueMove)                    drawFrames(wwin, scr->selected_windows, 0, 0);                if (!opaqueMove || (wPreferences.move_display==WDIS_NEW                                    && !scr->selected_windows)) {                    XGrabServer(dpy);                    if (wPreferences.move_display==WDIS_NEW)                        showPosition(wwin, moveData.realX, moveData.realY);                }            }            break;        case ButtonPress:            break;        case ButtonRelease:            if (event.xbutton.button != ev->xbutton.button)                break;            if (started) {                XEvent e;                if (!opaqueMove) {                    drawFrames(wwin, scr->selected_windows,                               moveData.realX - wwin->frame_x,                               moveData.realY - wwin->frame_y);                    XSync(dpy, 0);                    doWindowMove(wwin, scr->selected_windows,                                 moveData.realX - wwin->frame_x,                                 moveData.realY - wwin->frame_y);                }#ifndef CONFIGURE_WINDOW_WHILE_MOVING                wWindowSynthConfigureNotify(wwin);#endif                XUngrabKeyboard(dpy, CurrentTime);                XUngrabServer(dpy);                if (!opaqueMove) {                    wWindowChangeWorkspace(wwin, scr->current_workspace);                    wSetFocusTo(scr, wwin);                }                if (wPreferences.move_display == WDIS_NEW)                    showPosition(wwin, moveData.realX, moveData.realY);                /* discard all enter/leave events that happened until                 * the time the button was released */                while (XCheckTypedEvent(dpy, EnterNotify, &e)) {                    if (e.xcrossing.time > event.xbutton.time) {                        XPutBackEvent(dpy, &e);                        break;                    }                }                while (XCheckTypedEvent(dpy, LeaveNotify, &e)) {                    if (e.xcrossing.time > event.xbutton.time) {                        XPutBackEvent(dpy, &e);                        break;                    }                }                if (!scr->selected_windows) {                    /* get rid of the geometry window */                    WMUnmapWidget(scr->gview);                }            }#ifdef DEBUG            puts("End move window");#endif            done = True;            break;        default:            if (started && !opaqueMove) {                drawFrames(wwin, scr->selected_windows,                           moveData.realX - wwin->frame_x,                           moveData.realY - wwin->frame_y);                XUngrabServer(dpy);                WMHandleEvent(&event);                XSync(dpy, False);                XGrabServer(dpy);                drawFrames(wwin, scr->selected_windows,                           moveData.realX - wwin->frame_x,                           moveData.realY - wwin->frame_y);            } else {                WMHandleEvent(&event);            }            break;        }    }    if (wPreferences.opaque_move && !wPreferences.use_saveunders) {        XSetWindowAttributes attr;        attr.save_under = False;        XChangeWindowAttributes(dpy, wwin->frame->core->window,                                CWSaveUnder, &attr);    }    freeMoveData(&moveData);    return started;}