rem: for (i=0; i<dock->max_icons; i++) { nicon = dock->icon_array[i]; if (nicon && nicon->xindex == ex_x && nicon->yindex == ex_y) { aicon = nicon; break; }
add: *ret_x = 0;  if (redocking) { int sig, done, closest;   if (abs(ex_x) > DOCK_DETTACH_THRESHOLD) return False;  if (ex_y >=0 && (aicon == icon || !aicon)) {  *ret_y = ex_y;  return True; }   if (ex_y*ICON_SIZE < (req_y + offset - dy)) sig = 1; else sig = -1;  closest = -1; done = 0;  for (i=0; i<(DOCK_DETTACH_THRESHOLD+1)*2 && !done; i++) { int j;  done = 1; closest = sig*(i/2) + ex_y;  if (closest >= 0) { for (j = 0; j<dock->max_icons; j++) { if (dock->icon_array[j] && dock->icon_array[j]->yindex==closest) {  if (dock->icon_array[j]!=icon) done = 0; break; } } } sig = -sig; } if (done && closest >= 0 && ((ex_y >= closest && ex_y - closest < DOCK_DETTACH_THRESHOLD+1) || (ex_y < closest && closest - ex_y <= DOCK_DETTACH_THRESHOLD+1))) {  *ret_y = closest;  return True; } } else {    if (!aicon && ex_x==0 && ex_y>=0) { *ret_y = ex_y; return True; } } } else {  int neighbours = 0;  for (i=0; i<dock->max_icons; i++) { nicon = dock->icon_array[i]; if (nicon && nicon->xindex == ex_x && nicon->yindex == ex_y) { aicon = nicon; break; } }  for (i=0; i<dock->max_icons; i++) { nicon = dock->icon_array[i]; if (nicon && nicon != icon &&  (abs(nicon->xindex - ex_x) <= CLIP_ATTACH_VICINITY && abs(nicon->yindex - ex_y) <= CLIP_ATTACH_VICINITY)) { neighbours = 1; break; } } if ((!redocking && neighbours && !aicon) || (redocking && neighbours && (aicon == icon || !aicon))) { *ret_x = ex_x; *ret_y = ex_y; return True; }
context: wDockSnapIcon(WDock *dock, WAppIcon *icon, int req_x, int req_y, 	      int *ret_x, int *ret_y, int redocking){    WScreen *scr = dock->screen_ptr;    int dx, dy;    int ex_x, ex_y;    int i, offset = ICON_SIZE/2;    int only_down = (dock->type == WM_DOCK);    WAppIcon *aicon = NULL;    WAppIcon *nicon = NULL;    dx = dock->x_pos;    dy = dock->y_pos;    /* if the dock is full */    if (!redocking &&        (dock->icon_count >= dock->max_icons)) {	return False;    }        /* exact position */    if (req_y < dy)        ex_y = (req_y - offset - dy)/ICON_SIZE;    else        ex_y = (req_y + offset - dy)/ICON_SIZE;    if (req_x < dx)        ex_x = (req_x - offset - dx)/ICON_SIZE;    else        ex_x = (req_x + offset - dx)/ICON_SIZE;    if ((ex_y < 1 || ex_x != 0) && only_down)        return False;    if (dock->x_pos + ex_x*ICON_SIZE < -ICON_SIZE+2 ||        dock->x_pos + ex_x*ICON_SIZE > scr->scr_width-1 ||        dock->y_pos + ex_y*ICON_SIZE < -ICON_SIZE+2 ||        dock->y_pos + ex_y*ICON_SIZE > scr->scr_height-1)        return False;    for (i=0; i<dock->max_icons; i++) {        nicon = dock->icon_array[i];        if (nicon && nicon->xindex == ex_x && nicon->yindex == ex_y) {            aicon = nicon;            break;        }    }    if (!only_down) {        int neighbours = 0;        for (i=0; i<dock->max_icons; i++) {            nicon = dock->icon_array[i];            if (nicon && nicon != icon && /* Icon can't be it's own neighbour */                (abs(nicon->xindex - ex_x) <= CLIP_ATTACH_VICINITY &&                 abs(nicon->yindex - ex_y) <= CLIP_ATTACH_VICINITY)) {                neighbours = 1;                break;            }        }        if ((!redocking && neighbours && !aicon) ||            (redocking && neighbours && (aicon == icon || !aicon))) {            *ret_x = ex_x;            *ret_y = ex_y;            return True;        }    }    else {        if ((!redocking && !aicon) ||            (redocking && (aicon==icon || !aicon))) {            *ret_x = 0;            *ret_y = ex_y;            return True;        }    }        return False;}