mirror of
https://github.com/labwc/labwc.git
synced 2026-03-17 05:33:47 -04:00
view: factor out view_compute_cascaded_position()
This commit is contained in:
parent
04cd38f251
commit
6a9e6dcae1
1 changed files with 16 additions and 8 deletions
24
src/view.c
24
src/view.c
|
|
@ -978,13 +978,16 @@ view_center(struct view *view, const struct wlr_box *ref)
|
||||||
* Algorithm based on KWin's implementation:
|
* Algorithm based on KWin's implementation:
|
||||||
* https://github.com/KDE/kwin/blob/df9f8f8346b5b7645578e37365dabb1a7b02ca5a/src/placement.cpp#L589
|
* https://github.com/KDE/kwin/blob/df9f8f8346b5b7645578e37365dabb1a7b02ca5a/src/placement.cpp#L589
|
||||||
*/
|
*/
|
||||||
static void
|
static bool
|
||||||
view_cascade(struct view *view)
|
view_compute_cascaded_position(struct view *view, struct wlr_box *geom)
|
||||||
{
|
{
|
||||||
/* "cascade" policy places a new view at center by default */
|
/* "cascade" policy places a new view at center by default */
|
||||||
struct wlr_box center = view->pending;
|
struct wlr_box center = *geom;
|
||||||
view_compute_centered_position(view, NULL,
|
if (!view_compute_centered_position(view, NULL, center.width,
|
||||||
center.width, center.height, ¢er.x, ¢er.y);
|
center.height, ¢er.x, ¢er.y)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
struct border margin = ssd_get_margin(view->ssd);
|
struct border margin = ssd_get_margin(view->ssd);
|
||||||
center.x -= margin.left;
|
center.x -= margin.left;
|
||||||
center.y -= margin.top;
|
center.y -= margin.top;
|
||||||
|
|
@ -1059,7 +1062,9 @@ view_cascade(struct view *view)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
view_move(view, candidate.x + margin.left, candidate.y + margin.top);
|
geom->x = candidate.x + margin.left;
|
||||||
|
geom->y = candidate.y + margin.top;
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
@ -1086,8 +1091,11 @@ view_place_by_policy(struct view *view, bool allow_cursor,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else if (policy == LAB_PLACE_CASCADE) {
|
} else if (policy == LAB_PLACE_CASCADE) {
|
||||||
view_cascade(view);
|
struct wlr_box geometry = view->pending;
|
||||||
return;
|
if (view_compute_cascaded_position(view, &geometry)) {
|
||||||
|
view_move(view, geometry.x, geometry.y);
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
view_center(view, NULL);
|
view_center(view, NULL);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue