mirror of
https://github.com/labwc/labwc.git
synced 2026-03-09 05:33:53 -04:00
resistance: support negative strengths to indicate attractive snapping
This commit is contained in:
parent
57ea197e6c
commit
4181bb5335
2 changed files with 41 additions and 22 deletions
|
|
@ -196,15 +196,26 @@ this is for compatibility with Openbox.
|
||||||
|
|
||||||
## RESISTANCE
|
## RESISTANCE
|
||||||
|
|
||||||
*<resistance><screenEdgeStrength>*
|
*<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><windowEdgeStrength>*
|
*<resistance><windowEdgeStrength>*
|
||||||
Window-edge strength is the distance, in pixels, past the edge of any
|
Resist interactive moves and resizes of a window across screen edges or
|
||||||
other window the cursor must move before an interactive move or resize
|
the edges of any other window, respectively.
|
||||||
of a window will continue past the edge. Default is 20 pixels.
|
|
||||||
|
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
|
## FOCUS
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,20 +12,28 @@ static void
|
||||||
is_within_resistance_range(struct border view, struct border target,
|
is_within_resistance_range(struct border view, struct border target,
|
||||||
struct border other, struct border *flags, int strength)
|
struct border other, struct border *flags, int strength)
|
||||||
{
|
{
|
||||||
if (view.left >= other.left && target.left < other.left
|
if (view.left >= other.left) {
|
||||||
&& target.left >= other.left - strength) {
|
const int lo = other.left - abs(strength);
|
||||||
flags->left = 1;
|
const int hi = other.left - MIN(strength, 0);
|
||||||
} else if (view.right <= other.right && target.right > other.right
|
flags->left = target.left >= lo && target.left < hi;
|
||||||
&& target.right <= other.right + strength) {
|
|
||||||
flags->right = 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (view.top >= other.top && target.top < other.top
|
if (!flags->left && view.right <= other.right) {
|
||||||
&& target.top >= other.top - strength) {
|
const int lo = other.right + MIN(strength, 0);
|
||||||
flags->top = 1;
|
const int hi = other.right + abs(strength);
|
||||||
} else if (view.bottom <= other.bottom && target.bottom > other.bottom
|
flags->right = target.right > lo && target.right <= hi;
|
||||||
&& target.bottom <= other.bottom + strength) {
|
}
|
||||||
flags->bottom = 1;
|
|
||||||
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -75,7 +83,7 @@ static void
|
||||||
find_neighbor_edges(struct view *view, struct wlr_box new_geom,
|
find_neighbor_edges(struct view *view, struct wlr_box new_geom,
|
||||||
struct border *next_edges, bool move)
|
struct border *next_edges, bool move)
|
||||||
{
|
{
|
||||||
if (rc.window_edge_strength <= 0) {
|
if (rc.window_edge_strength == 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -118,7 +126,7 @@ static void
|
||||||
find_screen_edges(struct view *view, struct wlr_box new_geom,
|
find_screen_edges(struct view *view, struct wlr_box new_geom,
|
||||||
struct border *next_edges, bool move)
|
struct border *next_edges, bool move)
|
||||||
{
|
{
|
||||||
if (rc.screen_edge_strength <= 0) {
|
if (rc.screen_edge_strength == 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue