+ if (snap_to_windows) {
+ RectList rectlist;
+
+ Workspace *w = screen->getWorkspace(getWorkspaceNumber());
+ assert(w);
+
+ // add windows on the workspace to the rect list
+ const BlackboxWindowList& stack_list = w->getStackingList();
+ BlackboxWindowList::const_iterator st_it, st_end = stack_list.end();
+ for (st_it = stack_list.begin(); st_it != st_end; ++st_it)
+ if (*st_it != this) // don't snap to ourself
+ rectlist.push_back( (*st_it)->frameRect() );
+
+ // add the toolbar and the slit to the rect list.
+ // (only if they are not hidden)
+ Toolbar *tbar = screen->getToolbar();
+ Slit *slit = screen->getSlit();
+ Rect tbar_rect, slit_rect;
+ unsigned int bwidth = screen->getBorderWidth() * 2;
+
+ if (! (screen->doHideToolbar() || tbar->isHidden())) {
+ tbar_rect.setRect(tbar->getX(), tbar->getY(), tbar->getWidth() + bwidth,
+ tbar->getHeight() + bwidth);
+ rectlist.push_back(tbar_rect);
+ }
+
+ if (! slit->isHidden()) {
+ slit_rect.setRect(slit->getX(), slit->getY(), slit->getWidth() + bwidth,
+ slit->getHeight() + bwidth);
+ rectlist.push_back(slit_rect);
+ }
+
+ RectList::const_iterator it, end = rectlist.end();
+ for (it = rectlist.begin(); it != end; ++it) {
+ bool snapped = False;
+ const Rect &winrect = *it;
+ Rect offsetrect;
+ offsetrect.setCoords(winrect.left() - snap_offset,
+ winrect.top() - snap_offset,
+ winrect.right() + snap_offset,
+ winrect.bottom() + snap_offset);
+
+ if (snap_to_windows == BScreen::WindowResistance)
+ // if the window is already over top of this snap target, then
+ // resistance is futile, so just ignore it
+ if (winrect.intersects(moving))
+ continue;
+
+ int dleft, dright, dtop, dbottom;
+
+ // if the windows are in the same plane vertically
+ if (wtop >= (signed)(winrect.y() - frame.rect.height() + 1) &&
+ wtop < (signed)(winrect.y() + winrect.height() - 1)) {
+
+ if (snap_to_windows == BScreen::WindowResistance) {
+ dleft = wright - offsetrect.left();
+ dright = offsetrect.right() - wleft;
+
+ // snap left of other window?
+ if (dleft >= 0 && dleft < resistance_size &&
+ dleft < (wright - wleft)) {
+ dx = offsetrect.left() - frame.rect.width();
+ snapped = True;
+ }
+ // snap right of other window?
+ else if (dright >= 0 && dright < resistance_size &&
+ dright < (wright - wleft)) {
+ dx = offsetrect.right() + 1;
+ snapped = True;
+ }
+ } else { // BScreen::WindowSnap
+ dleft = abs(wright - offsetrect.left());
+ dright = abs(wleft - offsetrect.right());