+ tl = RECT_LEFT(target);
+ tt = RECT_TOP(target);
+ tr = RECT_RIGHT(target);
+ tb = RECT_BOTTOM(target);
+
+ if (!snapx) {
+ /* horizontal snapping */
+ if (t < tb && b > tt) {
+ switch (dir) {
+ case OB_DIRECTION_EAST:
+ case OB_DIRECTION_NORTHEAST:
+ case OB_DIRECTION_SOUTHEAST:
+ case OB_DIRECTION_NORTH:
+ case OB_DIRECTION_SOUTH:
+ dlt = l;
+ drb = r + *w - orgw;
+ if (r < tl && drb >= tl &&
+ drb < tl + resist)
+ *w = tl - l, snapx = TRUE;
+ break;
+ case OB_DIRECTION_WEST:
+ case OB_DIRECTION_NORTHWEST:
+ case OB_DIRECTION_SOUTHWEST:
+ dlt = l - *w + orgw;
+ drb = r;
+ if (l > tr && dlt <= tr &&
+ dlt > tr - resist)
+ *w = r - tr, snapx = TRUE;
+ break;
+ }
+ }
+ }
+
+ if (!snapy) {
+ /* vertical snapping */
+ if (l < tr && r > tl) {
+ switch (dir) {
+ case OB_DIRECTION_SOUTH:
+ case OB_DIRECTION_SOUTHWEST:
+ case OB_DIRECTION_SOUTHEAST:
+ case OB_DIRECTION_EAST:
+ case OB_DIRECTION_WEST:
+ dlt = t;
+ drb = b + *h - orgh;
+ if (b < tt && drb >= tt &&
+ drb < tt + resist)
+ *h = tt - t, snapy = TRUE;
+ break;
+ case OB_DIRECTION_NORTH:
+ case OB_DIRECTION_NORTHWEST:
+ case OB_DIRECTION_NORTHEAST:
+ dlt = t - *h + orgh;
+ drb = b;
+ if (t > tb && dlt <= tb &&
+ dlt > tb - resist)
+ *h = b - tb, snapy = TRUE;
+ break;
+ }
+ }
+ }
+
+ /* snapped both ways */
+ return snapx && snapy;
+}
+
+void resist_size_windows(ObClient *c, gint resist, gint *w, gint *h,
+ ObDirection dir)
+{
+ GList *it;
+ ObClient *target; /* target */
+ Rect dock_area;
+
+ if (!resist) return;