mirror of
https://github.com/labwc/labwc.git
synced 2025-11-03 09:01:51 -05:00
view: set inter-view gap correctly in SnapToEdge
When arranging views side-by-side or above-below using SnapToEdge, the gap between views should be rc.gap rather than 2x rc.gap
This commit is contained in:
parent
455a1c4d2c
commit
bd1e6f3728
1 changed files with 24 additions and 8 deletions
32
src/view.c
32
src/view.c
|
|
@ -309,15 +309,31 @@ view_get_edge_snap_box(struct view *view, struct output *output, enum view_edge
|
||||||
struct border border = view_border(view);
|
struct border border = view_border(view);
|
||||||
struct wlr_box usable = output_usable_area_in_layout_coords(output);
|
struct wlr_box usable = output_usable_area_in_layout_coords(output);
|
||||||
|
|
||||||
int x_offset = edge == VIEW_EDGE_RIGHT ? usable.width / 2 : 0;
|
int x_offset = edge == VIEW_EDGE_RIGHT
|
||||||
int y_offset = edge == VIEW_EDGE_DOWN ? usable.height / 2 : 0;
|
? (usable.width + rc.gap) / 2 : rc.gap;
|
||||||
int base_width = (edge == VIEW_EDGE_LEFT || edge == VIEW_EDGE_RIGHT) ? usable.width / 2 : usable.width;
|
int y_offset = edge == VIEW_EDGE_DOWN
|
||||||
int base_height = (edge == VIEW_EDGE_UP || edge == VIEW_EDGE_DOWN) ? usable.height / 2 : usable.height;
|
? (usable.height + rc.gap) / 2 : rc.gap;
|
||||||
|
|
||||||
|
int base_width, base_height;
|
||||||
|
switch (edge) {
|
||||||
|
case VIEW_EDGE_LEFT:
|
||||||
|
case VIEW_EDGE_RIGHT:
|
||||||
|
base_width = (usable.width - 3 * rc.gap) / 2;
|
||||||
|
base_height = usable.height - 2 * rc.gap;
|
||||||
|
break;
|
||||||
|
case VIEW_EDGE_UP:
|
||||||
|
case VIEW_EDGE_DOWN:
|
||||||
|
base_width = usable.width - 2 * rc.gap;
|
||||||
|
base_height = (usable.height - 3 * rc.gap) / 2;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
struct wlr_box dst = {
|
struct wlr_box dst = {
|
||||||
.x = x_offset + usable.x + border.left + rc.gap,
|
.x = x_offset + usable.x + border.left,
|
||||||
.y = y_offset + usable.y + border.top + rc.gap,
|
.y = y_offset + usable.y + border.top,
|
||||||
.width = base_width - border.left - border.right - 2 * rc.gap,
|
.width = base_width - border.left - border.right,
|
||||||
.height = base_height - border.top - border.bottom - 2 * rc.gap,
|
.height = base_height - border.top - border.bottom,
|
||||||
};
|
};
|
||||||
|
|
||||||
return dst;
|
return dst;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue