Merge pull request #1419 from ahesford/bond-james-bond

view, xwayland: fixes for new size constraints
This commit is contained in:
Johan Malm 2024-01-09 21:56:45 +00:00 committed by GitHub
commit 67a984e9ae
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 36 additions and 9 deletions

View file

@ -737,15 +737,42 @@ view_constrain_size_to_that_of_usable_area(struct view *view)
if (!view || !view->output) { if (!view || !view->output) {
return; return;
} }
struct wlr_box *usable_area = &view->output->usable_area;
struct wlr_box usable_area =
output_usable_area_in_layout_coords(view->output);
struct border margin = ssd_get_margin(view->ssd); struct border margin = ssd_get_margin(view->ssd);
int available_width = usable_area.width - margin.left - margin.right;
int available_height = usable_area.height - margin.top - margin.bottom;
if (available_width <= 0 || available_height <= 0) {
return;
}
if (available_height >= view->pending.height &&
available_width >= view->pending.height) {
return;
}
int width = MIN(view->pending.width, available_width);
int height = MIN(view->pending.height, available_height);
int right_edge = usable_area.x + usable_area.width;
int bottom_edge = usable_area.y + usable_area.height;
int x =
MAX(usable_area.x + margin.left,
MIN(view->pending.x, right_edge - width - margin.right));
int y =
MAX(usable_area.y + margin.top,
MIN(view->pending.y, bottom_edge - height - margin.bottom));
struct wlr_box box = { struct wlr_box box = {
.x = view->pending.x, .x = x,
.y = view->pending.y, .y = y,
.width = MIN(usable_area->width - margin.left - margin.right, .width = width,
view->pending.width), .height = height,
.height = MIN(usable_area->height - margin.top - margin.bottom,
view->pending.height),
}; };
view_move_resize(view, box); view_move_resize(view, box);
} }

View file

@ -505,8 +505,6 @@ set_initial_position(struct view *view,
XCB_ICCCM_SIZE_HINT_US_POSITION | XCB_ICCCM_SIZE_HINT_US_POSITION |
XCB_ICCCM_SIZE_HINT_P_POSITION)); XCB_ICCCM_SIZE_HINT_P_POSITION));
view_constrain_size_to_that_of_usable_area(view);
if (has_position) { if (has_position) {
/* /*
* Make sure a floating view is onscreen. For a * Make sure a floating view is onscreen. For a
@ -518,6 +516,8 @@ set_initial_position(struct view *view,
view_adjust_for_layout_change(view); view_adjust_for_layout_change(view);
} }
} else { } else {
view_constrain_size_to_that_of_usable_area(view);
if (view_is_floating(view)) { if (view_is_floating(view)) {
view_place_initial(view); view_place_initial(view);
} else { } else {