## RESISTANCE
-*<resistance><screenEdgeStrength>*
- Screen-edge strength is the distance, in pixels, past the edge of a
- screen the cursor must move before an interactive move or resize of a
- window will continue past the edge. Default is 20 pixels.
-
+*<resistance><screenEdgeStrength>*++
*<resistance><windowEdgeStrength>*
- Window-edge strength is the distance, in pixels, past the edge of any
- other window the cursor must move before an interactive move or resize
- of a window will continue past the edge. Default is 20 pixels.
+ Resist interactive moves and resizes of a window across screen edges or
+ the edges of any other window, respectively.
+
+ When an edge strength is positive, it indicates a distance, in pixels,
+ that the cursor must move past any relevant encountered edge before an
+ interactive move or resize operation will continue across that edge.
+
+ When the strength is negative, any interactive move or resize operation
+ that brings the cursor within the absolute value of the specified
+ distance, in pixels, from any relevant edge will snap the operation to
+ that edge. Thus, as a move or resize approaches an edge, it will
+ "attract" the cursor to that edge within the specified distance. As the
+ move or resize continues past the edge, it will provide resistance until
+ the cursor has moved beyond the distance.
+
+ A strength of zero disables the corresponding resistance effect.
+
+ The default value for both parameters is 20 pixels.
## FOCUS
is_within_resistance_range(struct border view, struct border target,
struct border other, struct border *flags, int strength)
{
- if (view.left >= other.left && target.left < other.left
- && target.left >= other.left - strength) {
- flags->left = 1;
- } else if (view.right <= other.right && target.right > other.right
- && target.right <= other.right + strength) {
- flags->right = 1;
+ if (view.left >= other.left) {
+ const int lo = other.left - abs(strength);
+ const int hi = other.left - MIN(strength, 0);
+ flags->left = target.left >= lo && target.left < hi;
}
- if (view.top >= other.top && target.top < other.top
- && target.top >= other.top - strength) {
- flags->top = 1;
- } else if (view.bottom <= other.bottom && target.bottom > other.bottom
- && target.bottom <= other.bottom + strength) {
- flags->bottom = 1;
+ if (!flags->left && view.right <= other.right) {
+ const int lo = other.right + MIN(strength, 0);
+ const int hi = other.right + abs(strength);
+ flags->right = target.right > lo && target.right <= hi;
+ }
+
+ if (view.top >= other.top) {
+ const int lo = other.top - abs(strength);
+ const int hi = other.top - MIN(strength, 0);
+ flags->top = target.top >= lo && target.top < hi;
+ }
+
+ if (!flags->top && view.bottom <= other.bottom) {
+ const int lo = other.bottom + MIN(strength, 0);
+ const int hi = other.bottom + abs(strength);
+ flags->bottom = target.bottom > lo && target.bottom <= hi;
}
}
find_neighbor_edges(struct view *view, struct wlr_box new_geom,
struct border *next_edges, bool move)
{
- if (rc.window_edge_strength <= 0) {
+ if (rc.window_edge_strength == 0) {
return;
}
find_screen_edges(struct view *view, struct wlr_box new_geom,
struct border *next_edges, bool move)
{
- if (rc.screen_edge_strength <= 0) {
+ if (rc.screen_edge_strength == 0) {
return;
}