mirror of
https://github.com/labwc/labwc.git
synced 2026-03-12 05:33:53 -04:00
view: constrain window size to that of usable area
...on first map (when application is started). Fixes #1399
This commit is contained in:
parent
bce0c6ce56
commit
c646c7bd1b
4 changed files with 24 additions and 0 deletions
|
|
@ -407,6 +407,7 @@ void view_center(struct view *view, const struct wlr_box *ref);
|
||||||
* @view: view to be placed
|
* @view: view to be placed
|
||||||
*/
|
*/
|
||||||
void view_place_initial(struct view *view);
|
void view_place_initial(struct view *view);
|
||||||
|
void view_constrain_size_to_that_of_usable_area(struct view *view);
|
||||||
|
|
||||||
void view_restore_to(struct view *view, struct wlr_box geometry);
|
void view_restore_to(struct view *view, struct wlr_box geometry);
|
||||||
void view_set_untiled(struct view *view);
|
void view_set_untiled(struct view *view);
|
||||||
|
|
|
||||||
19
src/view.c
19
src/view.c
|
|
@ -731,6 +731,25 @@ view_place_initial(struct view *view)
|
||||||
view_center(view, NULL);
|
view_center(view, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
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 border margin = ssd_get_margin(view->ssd);
|
||||||
|
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),
|
||||||
|
};
|
||||||
|
view_move_resize(view, box);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
view_apply_natural_geometry(struct view *view)
|
view_apply_natural_geometry(struct view *view)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -420,6 +420,8 @@ position_xdg_toplevel_view(struct view *view)
|
||||||
struct wlr_xdg_toplevel *parent_xdg_toplevel =
|
struct wlr_xdg_toplevel *parent_xdg_toplevel =
|
||||||
xdg_toplevel_from_view(view)->parent;
|
xdg_toplevel_from_view(view)->parent;
|
||||||
|
|
||||||
|
view_constrain_size_to_that_of_usable_area(view);
|
||||||
|
|
||||||
if (parent_xdg_toplevel) {
|
if (parent_xdg_toplevel) {
|
||||||
/* Child views are center-aligned relative to their parents */
|
/* Child views are center-aligned relative to their parents */
|
||||||
struct view *parent = lookup_view_by_xdg_toplevel(
|
struct view *parent = lookup_view_by_xdg_toplevel(
|
||||||
|
|
|
||||||
|
|
@ -505,6 +505,8 @@ 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
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue