From c107ea7e385703e2c1b86d3ccca403adb13a45f0 Mon Sep 17 00:00:00 2001 From: ARDiDo <90479315+ARDiDo@users.noreply.github.com> Date: Sat, 13 Nov 2021 13:47:12 -0500 Subject: [PATCH] resistance: check to see if the view is on the output before resisting --- src/resistance.c | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/src/resistance.c b/src/resistance.c index 236d9578..8ada157f 100644 --- a/src/resistance.c +++ b/src/resistance.c @@ -34,7 +34,11 @@ void resistance_move_apply(struct view *view, double *x, double *y) { struct server *server = view->server; - struct wlr_box mgeom; + struct wlr_box mgeom, intersection; + struct wlr_box vgeom = {.x = view->x, .y = view->y, .width = view->w, + .height = view->h}; + struct wlr_box tgeom = {.x = *x, .y = *y, .width = view->w, + .height = view->h}; struct output *output; struct border border = view_border(view); struct edges view_edges; /* The edges of the current view */ @@ -59,6 +63,12 @@ resistance_move_apply(struct view *view, double *x, double *y) wl_list_for_each(output, &server->outputs, link) { mgeom = output_usable_area_in_layout_coords(output); + if (!wlr_box_intersection(&intersection, &vgeom, &mgeom) + && !wlr_box_intersection(&intersection, &tgeom, + &mgeom)) { + continue; + } + other_edges.left = mgeom.x; other_edges.top = mgeom.y; other_edges.right = mgeom.x + mgeom.width; @@ -89,7 +99,11 @@ resistance_resize_apply(struct view *view, struct wlr_box *new_view_geo) { struct server *server = view->server; struct output *output; - struct wlr_box mgeom; + struct wlr_box mgeom, intersection; + struct wlr_box vgeom = {.x = view->x, .y = view->y, .width = view->w, + .height = view->h}; + struct wlr_box tgeom = {.x = new_view_geo->x, .y = new_view_geo->y, + .width = new_view_geo->width, .height = new_view_geo->height}; struct border border = view_border(view); struct edges view_edges; /* The edges of the current view */ struct edges target_edges; /* The desired edges */ @@ -112,7 +126,15 @@ resistance_resize_apply(struct view *view, struct wlr_box *new_view_geo) return; } wl_list_for_each(output, &server->outputs, link) { + mgeom = output_usable_area_in_layout_coords(output); + + if (!wlr_box_intersection(&intersection, &vgeom, &mgeom) + && !wlr_box_intersection(&intersection, &tgeom, + &mgeom)) { + continue; + } + other_edges.left = mgeom.x; other_edges.top = mgeom.y; other_edges.right = mgeom.x + mgeom.width;