- dtop = abs(wtop - winrect.top());
- dbottom = abs(wbottom - winrect.bottom());
- if (dtop < snap_distance && dtop <= dbottom)
- dy = winrect.top();
- else if (dbottom < snap_distance)
- dy = winrect.bottom() - frame.rect.height() + 1;
+ dtop = winrect.top() - wtop;
+ dbottom = wbottom - winrect.bottom();
+ if (dtop > 0 && dtop < resistance_size) {
+ // if we're already past the top edge, then don't provide
+ // resistance
+ if (moving.top() >= winrect.top())
+ dy = winrect.top();
+ } else if (dbottom > 0 && dbottom < resistance_size) {
+ // if we're already past the bottom edge, then don't provide
+ // resistance
+ if (moving.bottom() <= winrect.bottom())
+ dy = winrect.bottom() - frame.rect.height() + 1;
+ }