all repos — openbox @ 39bd954b8bf197fa08f73ffade953fe531463796

openbox fork - make it a bit more like ryudo

window resistance complete
Dana Jansens danakj@orodu.net
commit

39bd954b8bf197fa08f73ffade953fe531463796

parent

c2b3dc9f7129d99e4fca9491ef0bd92be4e8af62

1 files changed, 33 insertions(+), 26 deletions(-)

jump to
M src/Window.ccsrc/Window.cc

@@ -3089,6 +3089,9 @@

// the amount of space away from the edge to provide resistance const int resistance_offset = screen->getEdgeSnapThreshold(); + // find the geomeetery where the moving window currently is + const Rect &moving = screen->doOpaqueMove() ? frame.rect : frame.changing; + // window corners const int wleft = dx, wright = dx + frame.rect.width() - 1,

@@ -3132,13 +3135,8 @@ const Rect &winrect = *it;

// if the window is already over top of this snap target, then // resistance is futile, so just ignore it - if (screen->doOpaqueMove()) { - if (winrect.intersects(frame.rect)) - continue; - } else { - if (winrect.intersects(frame.changing)) - continue; - } + if (winrect.intersects(moving)) + continue; int dleft = wright - winrect.left(), dright = winrect.right() - wleft,

@@ -3163,12 +3161,19 @@

if (snapped) { if (screen->getWindowCornerSnap()) { // try corner-snap to its other sides - dtop = abs(wtop - winrect.top()); - dbottom = abs(wbottom - winrect.bottom()); - if (dtop < resistance_size && dtop <= dbottom) - dy = winrect.top(); - else if (dbottom < resistance_size) - 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; + } } continue;

@@ -3193,12 +3198,19 @@

if (snapped) { if (screen->getWindowCornerSnap()) { // try corner-snap to its other sides - dleft = abs(wleft - winrect.left()); - dright = abs(wright - winrect.right()); - if (dleft < resistance_size && dleft <= dright) - dx = winrect.left(); - else if (dright < resistance_size) - dx = winrect.right() - frame.rect.width() + 1; + dleft = winrect.left() - wleft; + dright = wright - winrect.right(); + if (dleft > 0 && dleft < resistance_size) { + // if we're already past the left edge, then don't provide + // resistance + if (moving.left() >= winrect.left()) + dx = winrect.left(); + } else if (dright > 0 && dright < resistance_size) { + // if we're already past the right edge, then don't provide + // resistance + if (moving.right() <= winrect.right()) + dx = winrect.right() - frame.rect.width() + 1; + } } continue;

@@ -3224,13 +3236,8 @@ for (it = rectlist.begin(); it != end; ++it) {

const Rect &srect = *it; // if we're not in the rectangle then don't snap to it. - if (screen->doOpaqueMove()) { - if (! srect.contains(frame.rect)) - continue; - } else { - if (! srect.contains(frame.changing)) - continue; - } + if (! srect.contains(moving)) + continue; int dleft = srect.left() - wleft, dright = wright - srect.right(),