overlay: take into account <core><gap> for edge overlay

This also deduplicates get_edge_snap_box() in interactive.c and
view_get_edge_snap_box() in view.c.
This commit is contained in:
tokyo4j 2025-07-05 16:06:38 +09:00 committed by Johan Malm
parent ca8d98e80f
commit 38e57891b5
5 changed files with 23 additions and 35 deletions

View file

@ -114,31 +114,13 @@ show_region_overlay(struct seat *seat, struct region *region)
show_overlay(seat, &seat->overlay.region_rect, &region->geo);
}
/* TODO: share logic with view_get_edge_snap_box() */
static struct wlr_box get_edge_snap_box(enum view_edge edge, struct output *output)
{
struct wlr_box box = output_usable_area_in_layout_coords(output);
switch (edge) {
case VIEW_EDGE_RIGHT:
box.x += box.width / 2;
/* fallthrough */
case VIEW_EDGE_LEFT:
box.width /= 2;
break;
case VIEW_EDGE_DOWN:
box.y += box.height / 2;
/* fallthrough */
case VIEW_EDGE_UP:
box.height /= 2;
break;
case VIEW_EDGE_CENTER:
/* <topMaximize> */
break;
default:
/* not reached */
assert(false);
if (edge == VIEW_EDGE_UP && rc.snap_top_maximize) {
return output_usable_area_in_layout_coords(output);
} else {
return view_get_edge_snap_box(NULL, output, edge);
}
return box;
}
static int