mirror of
https://github.com/labwc/labwc.git
synced 2025-11-01 22:58:47 -04:00
Merge pull request #1419 from ahesford/bond-james-bond
view, xwayland: fixes for new size constraints
This commit is contained in:
commit
67a984e9ae
2 changed files with 36 additions and 9 deletions
41
src/view.c
41
src/view.c
|
|
@ -737,15 +737,42 @@ view_constrain_size_to_that_of_usable_area(struct view *view)
|
|||
if (!view || !view->output) {
|
||||
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);
|
||||
|
||||
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 = {
|
||||
.x = view->pending.x,
|
||||
.y = view->pending.y,
|
||||
.width = MIN(usable_area->width - margin.left - margin.right,
|
||||
view->pending.width),
|
||||
.height = MIN(usable_area->height - margin.top - margin.bottom,
|
||||
view->pending.height),
|
||||
.x = x,
|
||||
.y = y,
|
||||
.width = width,
|
||||
.height = height,
|
||||
};
|
||||
view_move_resize(view, box);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -505,8 +505,6 @@ set_initial_position(struct view *view,
|
|||
XCB_ICCCM_SIZE_HINT_US_POSITION |
|
||||
XCB_ICCCM_SIZE_HINT_P_POSITION));
|
||||
|
||||
view_constrain_size_to_that_of_usable_area(view);
|
||||
|
||||
if (has_position) {
|
||||
/*
|
||||
* 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);
|
||||
}
|
||||
} else {
|
||||
view_constrain_size_to_that_of_usable_area(view);
|
||||
|
||||
if (view_is_floating(view)) {
|
||||
view_place_initial(view);
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue