exposay: add margins to centralize exposay

The exposay is being rendered in the top-left corner of the
screen. Add margins to render it in the center, making it
more visually pleasant.

Signed-off-by: Leandro Ribeiro <leandrohr@riseup.net>
dev
Leandro Ribeiro 5 years ago committed by Daniel Stone
parent 33e29d88cc
commit 048c628139
  1. 27
      desktop-shell/exposay.c

@ -230,6 +230,15 @@ exposay_surface_and_inner_pad_size(pixman_rectangle32_t exposay_area, struct exp
eoutput->surface_size = exposay_area.height / 2; eoutput->surface_size = exposay_area.height / 2;
} }
/* Compute the exposay top/left margin in order to centralize it */
static void
exposay_margin_size(struct desktop_shell *shell, pixman_rectangle32_t exposay_area,
int row_size, int column_size, int *left_margin, int *top_margin)
{
(*left_margin) = exposay_area.x + (exposay_area.width - row_size) / 2;
(*top_margin) = exposay_area.y + (exposay_area.height - column_size) / 2;
}
/* Pretty lame layout for now; just tries to make a square. Should take /* Pretty lame layout for now; just tries to make a square. Should take
* aspect ratio into account really. Also needs to be notified of surface * aspect ratio into account really. Also needs to be notified of surface
* addition and removal and adjust layout/animate accordingly. * addition and removal and adjust layout/animate accordingly.
@ -252,7 +261,8 @@ exposay_layout(struct desktop_shell *shell, struct shell_output *shell_output)
struct weston_view *view; struct weston_view *view;
struct exposay_surface *esurface, *highlight = NULL; struct exposay_surface *esurface, *highlight = NULL;
pixman_rectangle32_t exposay_area; pixman_rectangle32_t exposay_area;
int pad; int pad, row_size, column_size, left_margin, top_margin;
int populated_rows;
int i; int i;
int last_row_removed = 0; int last_row_removed = 0;
@ -291,7 +301,16 @@ exposay_layout(struct desktop_shell *shell, struct shell_output *shell_output)
/* Compute each surface size and the inner padding between them */ /* Compute each surface size and the inner padding between them */
exposay_surface_and_inner_pad_size(exposay_area, eoutput); exposay_surface_and_inner_pad_size(exposay_area, eoutput);
/* Compute each row/column size */
pad = eoutput->surface_size + eoutput->padding_inner; pad = eoutput->surface_size + eoutput->padding_inner;
row_size = (pad * eoutput->grid_size) - eoutput->padding_inner;
/* We may have empty rows that should be desconsidered to compute
* column size */
populated_rows = ceil(eoutput->num_surfaces / (float) eoutput->grid_size);
column_size = (pad * populated_rows) - eoutput->padding_inner;
/* Compute a top/left margin to centralize the exposay */
exposay_margin_size(shell, exposay_area, row_size, column_size, &left_margin, &top_margin);
i = 0; i = 0;
wl_list_for_each(view, &workspace->layer.view_list.link, layer_link.link) { wl_list_for_each(view, &workspace->layer.view_list.link, layer_link.link) {
@ -316,10 +335,8 @@ exposay_layout(struct desktop_shell *shell, struct shell_output *shell_output)
esurface->row = i / eoutput->grid_size; esurface->row = i / eoutput->grid_size;
esurface->column = i % eoutput->grid_size; esurface->column = i % eoutput->grid_size;
esurface->x = exposay_area.x + eoutput->hpadding_outer; esurface->x = left_margin + (pad * esurface->column);
esurface->x += pad * esurface->column; esurface->y = top_margin + (pad * esurface->row);
esurface->y = exposay_area.y + eoutput->vpadding_outer;
esurface->y += pad * esurface->row;
if (esurface->row == eoutput->grid_size - 1) if (esurface->row == eoutput->grid_size - 1)
esurface->x += (eoutput->surface_size + eoutput->padding_inner) * last_row_removed / 2; esurface->x += (eoutput->surface_size + eoutput->padding_inner) * last_row_removed / 2;

Loading…
Cancel
Save