add: while (XCheckMaskEvent(dpy, ButtonMotionMask, &ev)) ;
context: dragItem(WEditMenu *menu, WEditMenuItem *item){    Display *dpy = W_VIEW_DISPLAY(menu->view);    WMScreen *scr = W_VIEW_SCREEN(menu->view);    int x, y;    int dx, dy;    Bool done = False;    Window blaw;    int blai;    unsigned blau;    Window win;    WMView *dview;    int orix, oriy;    Bool enteredMenu = False;    WMSize oldSize = item->view->size;    WEditMenuItem *dritem = item;    WEditMenu *dmenu = NULL;        if (item->flags.isTitle) {	WMRaiseWidget(menu);	dragMenu(menu);	return;    }        selectItem(menu, NULL);    win = scr->rootWin;        XTranslateCoordinates(dpy, W_VIEW_DRAWABLE(item->view), win,			  0, 0, &orix, &oriy, &blaw);    dview = W_CreateUnmanagedTopView(scr);    W_SetViewBackgroundColor(dview, scr->black);    W_ResizeView(dview, W_VIEW_WIDTH(item->view), W_VIEW_HEIGHT(item->view));    W_MoveView(dview, orix, oriy);    W_RealizeView(dview);        if (menu->flags.isFactory) {	dritem = duplicateItem(item);	W_ReparentView(dritem->view, dview, 0, 0);	WMResizeWidget(dritem, oldSize.width, oldSize.height);	WMRealizeWidget(dritem);	WMMapWidget(dritem);    } else {	W_ReparentView(item->view, dview, 0, 0);    }    W_MapView(dview);    dx = menu->dragX - orix;    dy = menu->dragY - oriy;        XGrabPointer(dpy, scr->rootWin, False,		 ButtonPressMask|ButtonReleaseMask|ButtonMotionMask,		 GrabModeAsync, GrabModeAsync, None, scr->defaultCursor,		 CurrentTime);    while (!done) {	XEvent ev;	WMNextEvent(dpy, &ev);	switch (ev.type) {	 case MotionNotify:	    XQueryPointer(dpy, win, &blaw, &blaw, &blai, &blai, &x, &y, &blau);	    dmenu = findMenuInWindow(dpy, win, x, y);			    if (dmenu) {		handleDragOver(dmenu, dview, dritem, x - dx, y - dy);		enteredMenu = True;	    } else {		if (enteredMenu) {		    W_ResizeView(dview, oldSize.width, oldSize.height);		    W_ResizeView(dritem->view, oldSize.width, oldSize.height);		    enteredMenu = False;		}		W_MoveView(dview, x - dx, y - dy);	    }	    	    break;	    	 case ButtonRelease:	    done = True;	    break;	    	 default:	    WMHandleEvent(&ev);	    break;	}    }    XUngrabPointer(dpy, CurrentTime);        if (!enteredMenu) {	Bool rem = True;		if (!menu->flags.isFactory) {	    W_UnmapView(dview);	    if (menu->delegate && menu->delegate->shouldRemoveItem) {		rem = (*menu->delegate->shouldRemoveItem)(menu->delegate,							  menu, item);	    }	    W_MapView(dview);	}	if (!rem || menu->flags.isFactory) {	    slideWindow(dpy, W_VIEW_DRAWABLE(dview), x-dx, y-dy, orix, oriy);	    if (!menu->flags.isFactory) {		WRemoveEditMenuItem(menu, dritem);		handleItemDrop(dmenu ? dmenu : menu, dritem, orix, oriy);	    }	} else {	    WRemoveEditMenuItem(menu, dritem);	}    } else {	WRemoveEditMenuItem(menu, dritem);	if (menu->delegate && menu->delegate->itemCloned	    && menu->flags.isFactory) {	    (*menu->delegate->itemCloned)(menu->delegate, menu,					  item, dritem);	}		handleItemDrop(dmenu, dritem, x-dy, y-dy);		if (item->submenu && menu->flags.isFactory) {	    WEditMenu *submenu;	    	    submenu = duplicateMenu(item->submenu);	    WSetEditMenuSubmenu(dmenu, dritem, submenu);	}    }    /* can't destroy now because we're being called from      * the event handler of the item. and destroying now,     * would mean destroying the item too in some cases.     */    WMAddIdleHandler((WMCallback*)W_DestroyView, dview);}