- configure(frame.move_x, frame.move_y, frame.width, frame.height);
- openbox.ungrab();
- } else {
- configure(frame.x, frame.y, frame.width, frame.height);
- }
- screen->hideGeometry();
- XUngrabPointer(display, CurrentTime);
- // if there are any left over motions from the move, drop them now cuz they
- // cause problems
- XEvent e;
- while (XCheckTypedWindowEvent(display, frame.window, MotionNotify, &e));
- cout << "END MOVE " << client.window << " " << client.title << endl;
-}
+ // snap top of other window?
+ if (dtop < snap_distance && dtop <= dbottom) {
+ dy = winrect.top() - frame.rect.height();
+
+ if (blackbox->getWindowCornerSnap()) {
+ // try corner-snap to its other sides
+ dleft = std::abs(wleft - winrect.left());
+ dright = std::abs(wright - winrect.right());
+ if (dleft < snap_distance && dleft <= dright)
+ dx = winrect.left();
+ else if (dright < snap_distance)
+ dx = winrect.right() - frame.rect.width();
+ }
+
+ continue;
+ }
+ // snap bottom of other window?
+ else if (dbottom < snap_distance) {
+ dy = winrect.bottom() + 1;
+
+ if (blackbox->getWindowCornerSnap()) {
+ // try corner-snap to its other sides
+ dleft = std::abs(wleft - winrect.left());
+ dright = std::abs(wright - winrect.right());
+ if (dleft < snap_distance && dleft <= dright)
+ dx = winrect.left();
+ else if (dright < snap_distance)
+ dx = winrect.right() - frame.rect.width();
+ }
+
+ continue;
+ }
+ }
+ }
+
+ // try snap to the screen's available area
+ Rect srect = screen->availableArea();
+
+ int dleft = std::abs(wleft - srect.left()),
+ dright = std::abs(wright - srect.right()),
+ dtop = std::abs(wtop - srect.top()),
+ dbottom = std::abs(wbottom - srect.bottom());
+
+ // snap left?
+ if (dleft < snap_distance && dleft <= dright)
+ dx = srect.left();
+ // snap right?
+ else if (dright < snap_distance)
+ dx = srect.right() - frame.rect.width() + 1;
+
+ // snap top?
+ if (dtop < snap_distance && dtop <= dbottom)
+ dy = srect.top();
+ // snap bottom?
+ else if (dbottom < snap_distance)
+ dy = srect.bottom() - frame.rect.height() + 1;
+
+ if (! screen->doFullMax()) {
+ srect = screen->getRect(); // now get the full screen
+
+ dleft = std::abs(wleft - srect.left()),
+ dright = std::abs(wright - srect.right()),
+ dtop = std::abs(wtop - srect.top()),
+ dbottom = std::abs(wbottom - srect.bottom());
+
+ // snap left?
+ if (dleft < snap_distance && dleft <= dright)
+ dx = srect.left();
+ // snap right?
+ else if (dright < snap_distance)
+ dx = srect.right() - frame.rect.width() + 1;
+
+ // snap top?
+ if (dtop < snap_distance && dtop <= dbottom)
+ dy = srect.top();
+ // snap bottom?
+ else if (dbottom < snap_distance)
+ dy = srect.bottom() - frame.rect.height() + 1;
+ }
+ }