void scale_box(struct wlr_box *box, float scale);
void output_manager_init(struct server *server);
struct output *output_from_wlr_output(struct server *server, struct wlr_output *wlr_output);
-struct wlr_box *output_box_from_cursor_coords(struct server *server);
+struct wlr_box output_usable_area_in_layout_coords(struct output *output);
+struct wlr_box output_usable_area_from_cursor_coords(struct server *server);
void damage_all_outputs(struct server *server);
void damage_view_whole(struct view *view);
return NULL;
}
-struct wlr_box *
-output_box_from_cursor_coords(struct server *server)
+struct wlr_box
+output_usable_area_in_layout_coords(struct output *output)
+{
+ struct wlr_box box = output->usable_area;
+ double ox = 0, oy = 0;
+ wlr_output_layout_output_coords(output->server->output_layout,
+ output->wlr_output, &ox, &oy);
+ box.x -= ox;
+ box.y -= oy;
+ return box;
+}
+
+struct wlr_box
+output_usable_area_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);
- return wlr_output_layout_get_box(server->output_layout, wlr_output);
+ struct output *output = output_from_wlr_output(server, wlr_output);
+ return output_usable_area_in_layout_coords(output);
}
view->impl->map(view);
}
-/*
- * view_wlr_output - return the output that a view is mostly on
- */
+/* view_wlr_output - return the output that a view is mostly on */
static struct wlr_output *
view_wlr_output(struct view *view)
{
- struct wlr_output_layout *layout = view->server->output_layout;
- struct wlr_output *output;
-
- /* TODO: make this a bit more sophisticated */
- output = wlr_output_layout_output_at(layout, view->x + view->w / 2,
- view->y + view->h / 2);
- return output;
+ return wlr_output_layout_output_at(view->server->output_layout,
+ view->x + view->w / 2, view->y + view->h / 2);
}
static struct output *
view_move(view, center_x - view->w / 2, center_y - view->h / 2);
}
-static struct wlr_box
-usable_area_in_layout_coords(struct output *output)
-{
- struct wlr_box box = output->usable_area;
- double ox = 0, oy = 0;
- wlr_output_layout_output_coords(output->server->output_layout,
- output->wlr_output, &ox, &oy);
- box.x -= ox;
- box.y -= oy;
- return box;
-}
-
void
view_maximize(struct view *view, bool maximize)
{
view->unmaximized_geometry.height = view->h;
struct output *output = view_output(view);
- struct wlr_box box = usable_area_in_layout_coords(output);
+ struct wlr_box box = output_usable_area_in_layout_coords(output);
if (view->ssd.enabled) {
struct border border = ssd_thickness(view);
}
struct output *output = view_output(view);
struct border border = view_border(view);
- struct wlr_box usable = usable_area_in_layout_coords(output);
+ struct wlr_box usable = output_usable_area_in_layout_coords(output);
int x, y;
if (!strcasecmp(direction, "left")) {
position_xdg_toplevel_view(struct view *view)
{
if (istopmost(view)) {
- struct wlr_box *box = output_box_from_cursor_coords(view->server);
- view->x = box->x;
- view->y = box->y;
+ struct wlr_box box = output_usable_area_from_cursor_coords(view->server);
+ view->x = box.x;
+ view->y = box.y;
view->w = view->xdg_surface->geometry.width;
view->h = view->xdg_surface->geometry.height;
- view_center(view);
+ if (view->w && view->h) {
+ view_center(view);
+ }
} else {
/*
* If child-toplevel-views, we center-align relative to their
view->margin = ssd_thickness(view);
ssd_create(view);
}
+
update_padding(view);
position_xdg_toplevel_view(view);
parent_link) {
subsurface_create(view, subsurface);
}
+
view->been_mapped = true;
}
if (!view->been_mapped) {
view_maximize(view, false);
- struct wlr_box *box = output_box_from_cursor_coords(view->server);
- view->x = box->x;
- view->y = box->y;
+ struct wlr_box box = output_usable_area_from_cursor_coords(view->server);
+ view->x = box.x;
+ view->y = box.y;
view_center(view);
view->been_mapped = true;
}