void view_minimize(struct view *view, bool minimized);
struct output *view_output(struct view *view);
void view_store_natural_geometry(struct view *view);
-/* output is optional, defaults to current nearest output */
-void view_center(struct view *view, struct output *output,
- const struct wlr_box *ref);
+void view_center(struct view *view, const struct wlr_box *ref);
void view_restore_to(struct view *view, struct wlr_box geometry);
void view_set_untiled(struct view *view);
void view_maximize(struct view *view, bool maximize,
}
static bool
-view_compute_centered_position(struct view *view, struct output *output,
- const struct wlr_box *ref, int w, int h, int *x, int *y)
+view_compute_centered_position(struct view *view, const struct wlr_box *ref,
+ int w, int h, int *x, int *y)
{
if (w <= 0 || h <= 0) {
wlr_log(WLR_ERROR, "view has empty geometry, not centering");
return false;
}
+ struct output *output = view_output(view);
if (!output_is_usable(output)) {
- output = view_output(view);
- if (!output_is_usable(output)) {
- return false;
- }
+ return false;
}
struct border margin = ssd_get_margin(view->ssd);
{
view->natural_geometry.width = LAB_FALLBACK_WIDTH;
view->natural_geometry.height = LAB_FALLBACK_HEIGHT;
- view_compute_centered_position(view, NULL, NULL,
+ view_compute_centered_position(view, NULL,
view->natural_geometry.width,
view->natural_geometry.height,
&view->natural_geometry.x,
}
void
-view_center(struct view *view, struct output *output, const struct wlr_box *ref)
+view_center(struct view *view, const struct wlr_box *ref)
{
assert(view);
int x, y;
- if (view_compute_centered_position(view, output, ref,
- view->pending.width, view->pending.height, &x, &y)) {
+ if (view_compute_centered_position(view, ref, view->pending.width,
+ view->pending.height, &x, &y)) {
view_move(view, x, y);
}
}
} else {
/* reposition if original geometry is offscreen */
struct wlr_box box = view->natural_geometry;
- if (view_compute_centered_position(view, NULL, NULL,
- box.width, box.height, &box.x, &box.y)) {
+ if (view_compute_centered_position(view, NULL, box.width,
+ box.height, &box.x, &box.y)) {
view_move_resize(view, box);
}
}
if (!wlr_output_layout_intersects(
view->server->output_layout,
NULL, &view->pending)) {
- view_center(view, NULL, NULL);
+ view_center(view, NULL);
}
}
}
xdg_toplevel_from_view(view)->parent;
if (!parent_xdg_toplevel) {
- view_center(view, output_nearest_to_cursor(view->server), NULL);
+ view_center(view, NULL);
} else {
/*
* If child-toplevel-views, we center-align relative to their
struct view *parent = lookup_view_by_xdg_toplevel(
view->server, parent_xdg_toplevel);
assert(parent);
- view_center(view, view_output(parent), &parent->pending);
+ view->output = view_output(parent);
+ view_center(view, &parent->pending);
}
}