mirror of
https://github.com/labwc/labwc.git
synced 2025-11-04 13:30:07 -05:00
placement: consider gaps when placing new windows
This commit is contained in:
parent
11a35a7c20
commit
1b0f1a4c4e
1 changed files with 19 additions and 9 deletions
|
|
@ -418,18 +418,26 @@ placement_find_best(struct view *view, struct wlr_box *geometry)
|
|||
return false;
|
||||
}
|
||||
|
||||
/* Default placement is just the upper-left corner of the output */
|
||||
/* Default placement is upper-left corner, respecting gaps */
|
||||
struct wlr_box usable = output_usable_area_in_layout_coords(output);
|
||||
geometry->x = usable.x + margin.left;
|
||||
geometry->y = usable.y + margin.top;
|
||||
geometry->x = usable.x + margin.left + rc.gap;
|
||||
geometry->y = usable.y + margin.top + rc.gap;
|
||||
|
||||
/* Build the placement grid and overlap bitmap */
|
||||
struct overlap_bitmap bmp = { 0 };
|
||||
build_grid(&bmp, view);
|
||||
build_overlap(&bmp, view);
|
||||
|
||||
int height = geometry->height + margin.top + margin.bottom;
|
||||
int width = geometry->width + margin.left + margin.right;
|
||||
/* Dimensions include gap along all edges to ensure proper separation */
|
||||
int height = geometry->height + margin.top + margin.bottom + 2 * rc.gap;
|
||||
int width = geometry->width + margin.left + margin.right + 2 * rc.gap;
|
||||
|
||||
/*
|
||||
* Overlap search identifies corners of the target region; view
|
||||
* coordinates must by set in by the SSD margin and user gaps.
|
||||
*/
|
||||
int offset_x = margin.left + rc.gap;
|
||||
int offset_y = margin.top + rc.gap;
|
||||
|
||||
int min_overlap = INT_MAX;
|
||||
|
||||
|
|
@ -488,18 +496,20 @@ placement_find_best(struct view *view, struct wlr_box *geometry)
|
|||
|
||||
if (rt) {
|
||||
/* Extend window right from left edge */
|
||||
geometry->x = bmp.cols[j] + margin.left;
|
||||
geometry->x = bmp.cols[j] + offset_x;
|
||||
} else {
|
||||
/* Extend window left from right edge */
|
||||
geometry->x = bmp.cols[j + 1] - width + margin.left;
|
||||
geometry->x =
|
||||
bmp.cols[j + 1] - width + offset_x;
|
||||
}
|
||||
|
||||
if (dn) {
|
||||
/* Extend window down from top edge */
|
||||
geometry->y = bmp.rows[i] + margin.top;
|
||||
geometry->y = bmp.rows[i] + offset_y;
|
||||
} else {
|
||||
/* Extend window up from bottom edge */
|
||||
geometry->y = bmp.rows[i + 1] - height + margin.top;
|
||||
geometry->y =
|
||||
bmp.rows[i + 1] - height + offset_y;
|
||||
}
|
||||
|
||||
/* If there is no overlap, the search is done. */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue