chore: chase wlr_output_layout_get_box() update

https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/3439
This commit is contained in:
Kirill Primak 2022-01-29 23:11:54 +03:00 committed by Simon Ser
parent 69b430201c
commit ee7668c1f2
7 changed files with 53 additions and 49 deletions

View file

@ -788,15 +788,15 @@ static struct cmd_results *cmd_move_to_position_pointer(
struct wlr_output *output = wlr_output_layout_output_at( struct wlr_output *output = wlr_output_layout_output_at(
root->output_layout, cursor->x, cursor->y); root->output_layout, cursor->x, cursor->y);
if (output) { if (output) {
struct wlr_box *box = struct wlr_box box;
wlr_output_layout_get_box(root->output_layout, output); wlr_output_layout_get_box(root->output_layout, output, &box);
lx = fmax(lx, box->x); lx = fmax(lx, box.x);
ly = fmax(ly, box->y); ly = fmax(ly, box.y);
if (lx + container->pending.width > box->x + box->width) { if (lx + container->pending.width > box.x + box.width) {
lx = box->x + box->width - container->pending.width; lx = box.x + box.width - container->pending.width;
} }
if (ly + container->pending.height > box->y + box->height) { if (ly + container->pending.height > box.y + box.height) {
ly = box->y + box->height - container->pending.height; ly = box.y + box.height - container->pending.height;
} }
} }

View file

@ -546,12 +546,12 @@ bool apply_output_config(struct output_config *oc, struct sway_output *output) {
} }
// Update output->{lx, ly, width, height} // Update output->{lx, ly, width, height}
struct wlr_box *output_box = struct wlr_box output_box;
wlr_output_layout_get_box(root->output_layout, wlr_output); wlr_output_layout_get_box(root->output_layout, wlr_output, &output_box);
output->lx = output_box->x; output->lx = output_box.x;
output->ly = output_box->y; output->ly = output_box.y;
output->width = output_box->width; output->width = output_box.width;
output->height = output_box->height; output->height = output_box.height;
if (!output->enabled) { if (!output->enabled) {
output_enable(output); output_enable(output);

View file

@ -6,10 +6,11 @@ void desktop_damage_surface(struct wlr_surface *surface, double lx, double ly,
bool whole) { bool whole) {
for (int i = 0; i < root->outputs->length; ++i) { for (int i = 0; i < root->outputs->length; ++i) {
struct sway_output *output = root->outputs->items[i]; struct sway_output *output = root->outputs->items[i];
struct wlr_box *output_box = wlr_output_layout_get_box( struct wlr_box output_box;
root->output_layout, output->wlr_output); wlr_output_layout_get_box(root->output_layout,
output_damage_surface(output, lx - output_box->x, output->wlr_output, &output_box);
ly - output_box->y, surface, whole); output_damage_surface(output, lx - output_box.x,
ly - output_box.y, surface, whole);
} }
} }

View file

@ -737,14 +737,15 @@ static void update_output_manager_config(struct sway_server *server) {
} }
struct wlr_output_configuration_head_v1 *config_head = struct wlr_output_configuration_head_v1 *config_head =
wlr_output_configuration_head_v1_create(config, output->wlr_output); wlr_output_configuration_head_v1_create(config, output->wlr_output);
struct wlr_box *output_box = wlr_output_layout_get_box( struct wlr_box output_box;
root->output_layout, output->wlr_output); wlr_output_layout_get_box(root->output_layout,
output->wlr_output, &output_box);
// We mark the output enabled even if it is switched off by DPMS // We mark the output enabled even if it is switched off by DPMS
config_head->state.enabled = output->current_mode != NULL && output->enabled; config_head->state.enabled = output->current_mode != NULL && output->enabled;
config_head->state.mode = output->current_mode; config_head->state.mode = output->current_mode;
if (output_box) { if (!wlr_box_empty(&output_box)) {
config_head->state.x = output_box->x; config_head->state.x = output_box.x;
config_head->state.y = output_box->y; config_head->state.y = output_box.y;
} }
} }

View file

@ -311,12 +311,13 @@ void arrange_output(struct sway_output *output) {
if (config->reloading) { if (config->reloading) {
return; return;
} }
const struct wlr_box *output_box = wlr_output_layout_get_box( struct wlr_box output_box;
root->output_layout, output->wlr_output); wlr_output_layout_get_box(root->output_layout,
output->lx = output_box->x; output->wlr_output, &output_box);
output->ly = output_box->y; output->lx = output_box.x;
output->width = output_box->width; output->ly = output_box.y;
output->height = output_box->height; output->width = output_box.width;
output->height = output_box.height;
for (int i = 0; i < output->workspaces->length; ++i) { for (int i = 0; i < output->workspaces->length; ++i) {
struct sway_workspace *workspace = output->workspaces->items[i]; struct sway_workspace *workspace = output->workspaces->items[i];
@ -328,12 +329,12 @@ void arrange_root(void) {
if (config->reloading) { if (config->reloading) {
return; return;
} }
const struct wlr_box *layout_box = struct wlr_box layout_box;
wlr_output_layout_get_box(root->output_layout, NULL); wlr_output_layout_get_box(root->output_layout, NULL, &layout_box);
root->x = layout_box->x; root->x = layout_box.x;
root->y = layout_box->y; root->y = layout_box.y;
root->width = layout_box->width; root->width = layout_box.width;
root->height = layout_box->height; root->height = layout_box.height;
if (root->fullscreen_global) { if (root->fullscreen_global) {
struct sway_container *fs = root->fullscreen_global; struct sway_container *fs = root->fullscreen_global;

View file

@ -695,12 +695,13 @@ void floating_calculate_constraints(int *min_width, int *max_width,
*min_height = config->floating_minimum_height; *min_height = config->floating_minimum_height;
} }
struct wlr_box *box = wlr_output_layout_get_box(root->output_layout, NULL); struct wlr_box box;
wlr_output_layout_get_box(root->output_layout, NULL, &box);
if (config->floating_maximum_width == -1) { // no maximum if (config->floating_maximum_width == -1) { // no maximum
*max_width = INT_MAX; *max_width = INT_MAX;
} else if (config->floating_maximum_width == 0) { // automatic } else if (config->floating_maximum_width == 0) { // automatic
*max_width = box->width; *max_width = box.width;
} else { } else {
*max_width = config->floating_maximum_width; *max_width = config->floating_maximum_width;
} }
@ -708,7 +709,7 @@ void floating_calculate_constraints(int *min_width, int *max_width,
if (config->floating_maximum_height == -1) { // no maximum if (config->floating_maximum_height == -1) { // no maximum
*max_height = INT_MAX; *max_height = INT_MAX;
} else if (config->floating_maximum_height == 0) { // automatic } else if (config->floating_maximum_height == 0) { // automatic
*max_height = box->height; *max_height = box.height;
} else { } else {
*max_height = config->floating_maximum_height; *max_height = config->floating_maximum_height;
} }
@ -740,9 +741,9 @@ void container_floating_resize_and_center(struct sway_container *con) {
return; return;
} }
struct wlr_box *ob = wlr_output_layout_get_box(root->output_layout, struct wlr_box ob;
ws->output->wlr_output); wlr_output_layout_get_box(root->output_layout, ws->output->wlr_output, &ob);
if (!ob) { if (wlr_box_empty(&ob)) {
// On NOOP output. Will be called again when moved to an output // On NOOP output. Will be called again when moved to an output
con->pending.x = 0; con->pending.x = 0;
con->pending.y = 0; con->pending.y = 0;
@ -754,8 +755,8 @@ void container_floating_resize_and_center(struct sway_container *con) {
floating_natural_resize(con); floating_natural_resize(con);
if (!con->view) { if (!con->view) {
if (con->pending.width > ws->width || con->pending.height > ws->height) { if (con->pending.width > ws->width || con->pending.height > ws->height) {
con->pending.x = ob->x + (ob->width - con->pending.width) / 2; con->pending.x = ob.x + (ob.width - con->pending.width) / 2;
con->pending.y = ob->y + (ob->height - con->pending.height) / 2; con->pending.y = ob.y + (ob.height - con->pending.height) / 2;
} else { } else {
con->pending.x = ws->x + (ws->width - con->pending.width) / 2; con->pending.x = ws->x + (ws->width - con->pending.width) / 2;
con->pending.y = ws->y + (ws->height - con->pending.height) / 2; con->pending.y = ws->y + (ws->height - con->pending.height) / 2;
@ -763,8 +764,8 @@ void container_floating_resize_and_center(struct sway_container *con) {
} else { } else {
if (con->pending.content_width > ws->width if (con->pending.content_width > ws->width
|| con->pending.content_height > ws->height) { || con->pending.content_height > ws->height) {
con->pending.content_x = ob->x + (ob->width - con->pending.content_width) / 2; con->pending.content_x = ob.x + (ob.width - con->pending.content_width) / 2;
con->pending.content_y = ob->y + (ob->height - con->pending.content_height) / 2; con->pending.content_y = ob.y + (ob.height - con->pending.content_height) / 2;
} else { } else {
con->pending.content_x = ws->x + (ws->width - con->pending.content_width) / 2; con->pending.content_x = ws->x + (ws->width - con->pending.content_width) / 2;
con->pending.content_y = ws->y + (ws->height - con->pending.content_height) / 2; con->pending.content_y = ws->y + (ws->height - con->pending.content_height) / 2;

View file

@ -301,10 +301,10 @@ struct sway_output *output_get_in_direction(struct sway_output *reference,
if (!sway_assert(direction, "got invalid direction: %d", direction)) { if (!sway_assert(direction, "got invalid direction: %d", direction)) {
return NULL; return NULL;
} }
struct wlr_box *output_box = struct wlr_box output_box;
wlr_output_layout_get_box(root->output_layout, reference->wlr_output); wlr_output_layout_get_box(root->output_layout, reference->wlr_output, &output_box);
int lx = output_box->x + output_box->width / 2; int lx = output_box.x + output_box.width / 2;
int ly = output_box->y + output_box->height / 2; int ly = output_box.y + output_box.height / 2;
struct wlr_output *wlr_adjacent = wlr_output_layout_adjacent_output( struct wlr_output *wlr_adjacent = wlr_output_layout_adjacent_output(
root->output_layout, direction, reference->wlr_output, lx, ly); root->output_layout, direction, reference->wlr_output, lx, ly);
if (!wlr_adjacent) { if (!wlr_adjacent) {