void view_moved(struct view *view);
void view_minimize(struct view *view, bool minimized);
void view_store_natural_geometry(struct view *view);
-void view_center(struct view *view);
+/* output is optional, defaults to current nearest output */
+void view_center(struct view *view, struct output *output);
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,
bool store_natural_geometry);
+/* output is optional, defaults to current nearest output */
void view_set_fullscreen(struct view *view, bool fullscreen,
struct output *output);
void view_toggle_maximize(struct view *view);
return box;
}
-struct wlr_box
-output_usable_area_from_cursor_coords(struct server *server)
+struct output *
+output_from_cursor_coords(struct server *server)
{
struct wlr_output *wlr_output;
wlr_output = wlr_output_layout_output_at(server->output_layout,
server->seat.cursor->x, server->seat.cursor->y);
- struct output *output = output_from_wlr_output(server, wlr_output);
- return output_usable_area_in_layout_coords(output);
+ return output_from_wlr_output(server, wlr_output);
}
void
}
static bool
-view_compute_centered_position(struct view *view, int w, int h, int *x, int *y)
+view_compute_centered_position(struct view *view, struct output *output,
+ 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) {
- return false;
- }
- struct wlr_output *wlr_output = output->wlr_output;
- if (!wlr_output) {
- return false;
+ if (!output_is_usable(output)) {
+ output = view_output(view);
+ if (!output_is_usable(output)) {
+ 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,
+ view_compute_centered_position(view, NULL,
view->natural_geometry.width,
view->natural_geometry.height,
&view->natural_geometry.x,
}
void
-view_center(struct view *view)
+view_center(struct view *view, struct output *output)
{
assert(view);
int x, y;
- if (view_compute_centered_position(view, view->pending.width,
+ if (view_compute_centered_position(view, output, 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, 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);
}
}
/* reposition view if it's offscreen */
if (!wlr_output_layout_intersects(view->server->output_layout,
NULL, &view->pending)) {
- view_center(view);
+ view_center(view, NULL);
}
}
if (view->toplevel.handle) {