resistance: don't use gap value

This commit is contained in:
ARDiDo 2021-10-26 15:15:52 -04:00 committed by Johan Malm
parent 9d37860a40
commit 7730ece837
2 changed files with 29 additions and 31 deletions

View file

@ -161,8 +161,7 @@ Configuration must be wrapped in a <labwc_config> root-node.
*<resistance>screenEdgeStrength>*
Screen Edge Strength is how far past the screen's edge your cursor must
move before the window will move with it. Resistance is counted in
pixels. <core><gap> influences where the the screen's edge is at.
Default is 20 pixels.
pixels. Default is 20 pixels.
# SEE ALSO

View file

@ -42,15 +42,15 @@ resistance_move_apply(struct view *view, double *x, double *y)
struct edges other_edges; /* The edges of the monitor/other view */
struct edges flags; /* To be set in is_within_resistance_range() */
view_edges.left = view->x - border.left - rc.gap;
view_edges.top = view->y - border.top - rc.gap;
view_edges.right = view->x + view->w + border.right + rc.gap;
view_edges.bottom = view->y + view->h + border.bottom + rc.gap;
view_edges.left = view->x - border.left + 1;
view_edges.top = view->y - border.top + 1;
view_edges.right = view->x + view->w + border.right;
view_edges.bottom = view->y + view->h + border.bottom;
target_edges.left = *x - border.left - rc.gap;
target_edges.top = *y - border.top - rc.gap;
target_edges.right = *x + view->w + border.right + rc.gap;
target_edges.bottom = *y + view->h + border.bottom + rc.gap;
target_edges.left = *x - border.left;
target_edges.top = *y - border.top;
target_edges.right = *x + view->w + border.right;
target_edges.bottom = *y + view->h + border.bottom;
if (!rc.screen_edge_strength) {
return;
@ -68,17 +68,15 @@ resistance_move_apply(struct view *view, double *x, double *y)
other_edges, &flags, rc.screen_edge_strength);
if (flags.left == 1) {
*x = other_edges.left + border.left + rc.gap;
*x = other_edges.left + border.left;
} else if (flags.right == 1) {
*x = other_edges.right - view->w - border.right
- rc.gap;
*x = other_edges.right - view->w - border.right;
}
if (flags.top == 1) {
*y = other_edges.top + border.top + rc.gap;
*y = other_edges.top + border.top;
} else if (flags.bottom == 1) {
*y = other_edges.bottom - view->h - border.bottom
- rc.gap;
*y = other_edges.bottom - view->h - border.bottom;
}
/* reset the flags */
@ -98,17 +96,17 @@ resistance_resize_apply(struct view *view, struct wlr_box *new_view_geo)
struct edges other_edges; /* The edges of the monitor/other view */
struct edges flags; /* To be set in is_within_resistance_range() */
view_edges.left = view->x - border.left - rc.gap;
view_edges.top = view->y - border.top - rc.gap;
view_edges.right = view->x + view->w + border.right + rc.gap;
view_edges.bottom = view->y + view->h + border.bottom + rc.gap;
view_edges.left = view->x - border.left;
view_edges.top = view->y - border.top;
view_edges.right = view->x + view->w + border.right;
view_edges.bottom = view->y + view->h + border.bottom;
target_edges.left = new_view_geo->x - border.left - rc.gap;
target_edges.top = new_view_geo->y - border.top - rc.gap;
target_edges.left = new_view_geo->x - border.left;
target_edges.top = new_view_geo->y - border.top;
target_edges.right = new_view_geo->x + new_view_geo->width
+ border.right + rc.gap;
+ border.right;
target_edges.bottom = new_view_geo->y + new_view_geo->height
+ border.bottom + rc.gap;
+ border.bottom;
if (!rc.screen_edge_strength) {
return;
@ -126,30 +124,31 @@ resistance_resize_apply(struct view *view, struct wlr_box *new_view_geo)
if (server->resize_edges & WLR_EDGE_LEFT) {
if (flags.left == 1) {
new_view_geo->x = other_edges.left
+ border.left + rc.gap;
+ border.left;
new_view_geo->width = view->w;
}
} else if (server->resize_edges & WLR_EDGE_RIGHT) {
if (flags.right == 1) {
new_view_geo->width = other_edges.right
- view_edges.left
- (border.right + rc.gap) * 2 ;
- view_edges.left - border.right
- border.left;
}
}
if (server->resize_edges & WLR_EDGE_TOP) {
if (flags.top == 1) {
new_view_geo->y = other_edges.top + border.top
+ rc.gap;
new_view_geo->y = other_edges.top + border.top;
new_view_geo->height = view->h;
}
} else if (server->resize_edges & WLR_EDGE_BOTTOM) {
if (flags.bottom == 1) {
new_view_geo->height =
other_edges.bottom - view_edges.top
- border.bottom - border.top
- rc.gap * 2;
- border.bottom - border.top;
}
}
/* reset the flags */
flags.left = flags.top = flags.right = flags.bottom = 0;
}
}