Skip to content
This repository was archived by the owner on Jan 30, 2025. It is now read-only.

Commit

Permalink
Revert "Reland "Reland "vm_tools: Change output positioning in sommel…
Browse files Browse the repository at this point in the history
…ier to not overlap"""

This reverts commit f398dca18b6994f663e634227cc3e337287572f2.

Reason for revert: b/274540666

Original change's description:
> Reland "Reland "vm_tools: Change output positioning in sommelier to not overlap""
>
> Previously windows were being centered using unscaled output dimensions,
> this change scales the width/height of the output before it gets used to
> position windows.
>
> BUG=b:269053427
>
> TEST=Checked that everything still appears to work fine after changing the scaling percentages including this bug not replicating with VSCode
>
> This is a reland of commit 2e05b8c30343a760e5253c929dc5c0d8a04a3470
>
> Original change's description:
> > Reland "vm_tools: Change output positioning in sommelier to not overlap"
> >
> > This is a reland of commit d52d2c986614b0f85c8b8890cd57cf18633cdd79
> >
> > The change was breaking scaling of apps in Crostini due to the physical
> > dimensions not being scaled before being sent. This CL is now amended
> > to fix this.
> >
> > Original change's description:
> > > vm_tools: Change output positioning in sommelier to not overlap
> > >
> > > Outputs used to all be at (0,0). This CL changes it so that outputs are
> > > positioned in a row horizontally in order of their x position in exo
> > > space.
> > >
> > > BUG=b:246485823, b:208720580
> > > TEST=None
> > >
> > > Change-Id: I29dd90b4fa9a5b4f4f1d0c1aa1b06483ecc5d449
> > > Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform2/+/4063628
> > > Commit-Queue: Lucy Qu <[email protected]>
> > > Reviewed-by: Chloe Pelling <[email protected]>
> > > Tested-by: Lucy Qu <[email protected]>
> >
> > Bug: b:246485823, b:208720580
> > Change-Id: I9bbe824a74948aa616ed1c90aa9f3f8e2280633c
> > Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform2/+/4127481
> > Reviewed-by: David Munro <[email protected]>
> > Tested-by: Lucy Qu <[email protected]>
> > Commit-Queue: Lucy Qu <[email protected]>
> > Reviewed-by: Chloe Pelling <[email protected]>
>
> Bug: b:246485823, b:208720580
> Change-Id: I11fc660564e20b94cc0b0a4d1873fd8fac1945e6
> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform2/+/4247962
> Commit-Queue: Lucy Qu <[email protected]>
> Reviewed-by: David Munro <[email protected]>
> Tested-by: Lucy Qu <[email protected]>
> Reviewed-by: Chloe Pelling <[email protected]>

Bug: b:269053427
Bug: b:246485823, b:208720580
Change-Id: Id162f3987de67a0b00a731baa76bd626e4516cc7
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform2/+/4357597
Bot-Commit: Rubber Stamper <[email protected]>
Commit-Queue: Justin Huang <[email protected]>
Reviewed-by: Lucy Qu <[email protected]>
Reviewed-by: Chloe Pelling <[email protected]>
  • Loading branch information
Justin Huang authored and Chromeos LUCI committed Mar 21, 2023
1 parent 87bec6b commit fa86f5b
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 123 deletions.
108 changes: 14 additions & 94 deletions sommelier-output.cc
Original file line number Diff line number Diff line change
Expand Up @@ -268,86 +268,30 @@ void sl_output_get_dimensions_original(struct sl_host_output* host,
*out_height = height;
}

// Recalculates the virt_x coordinates of outputs when an output is
// add/removed/changed. skip_host is false if the host is being removed
// (as it should not exist in the list already) and true if it's being
// added/changed.
void sl_output_shift_output_x(struct sl_host_output* host, bool skip_host) {
// Outputs are positioned in a line from left to right ordered base on its
// x position.
struct sl_host_output* output;
int next_output_x = 0;
wl_list_for_each(output, &host->ctx->host_outputs, link) {
if (output->virt_x != next_output_x) {
output->virt_x = next_output_x;
// Skipping sending current output's details here if skip host is set
// as they are sent after this method.
if (!skip_host || output != host) {
// virt_physical_width/height may have not been set yet.
if (!output->virt_physical_width || !output->virt_physical_height) {
int scale;
int virt_physical_width;
int virt_physical_height;
int virt_width;
int virt_height;

if (host->ctx->use_direct_scale) {
sl_output_init_dimensions_direct(host, &scale, &virt_physical_width,
&virt_physical_height, &virt_width,
&virt_height);
} else {
sl_output_get_dimensions_original(
host, &scale, &virt_physical_width, &virt_physical_height,
&virt_width, &virt_height);
}
host->virt_physical_width = virt_physical_width;
host->virt_physical_height = virt_physical_height;
}

wl_output_send_geometry(output->resource, output->virt_x,
output->virt_y, output->virt_physical_width,
output->virt_physical_height, output->subpixel,
output->make, output->model, output->transform);
if (wl_resource_get_version(output->resource) >=
WL_OUTPUT_DONE_SINCE_VERSION)
wl_output_send_done(output->resource);
}
}
next_output_x += output->width;
}
}

void sl_output_send_host_output_state(struct sl_host_output* host) {
int scale;
int virt_physical_width;
int virt_physical_height;
int virt_width;
int virt_height;
int physical_width;
int physical_height;
int width;
int height;

if (host->ctx->use_direct_scale) {
sl_output_init_dimensions_direct(host, &scale, &virt_physical_width,
&virt_physical_height, &virt_width,
&virt_height);
sl_output_init_dimensions_direct(host, &scale, &physical_width,
&physical_height, &width, &height);
} else {
sl_output_get_dimensions_original(host, &scale, &virt_physical_width,
&virt_physical_height, &virt_width,
&virt_height);
sl_output_get_dimensions_original(host, &scale, &physical_width,
&physical_height, &width, &height);
}

host->virt_physical_width = virt_physical_width;
host->virt_physical_height = virt_physical_height;
host->virt_width = virt_width;
host->virt_height = virt_height;

// Shift all outputs that are to the right of host to the right if needed.
sl_output_shift_output_x(host, true);
host->virt_y = 0;
wl_output_send_geometry(host->resource, host->virt_x, host->virt_y,
host->virt_physical_width, host->virt_physical_height,
// X/Y are best left at origin as managed X windows are kept centered on
// the root window. The result is that all outputs are overlapping and
// pointer events can always be dispatched to the visible region of the
// window.
wl_output_send_geometry(host->resource, 0, 0, physical_width, physical_height,
host->subpixel, host->make, host->model,
host->transform);
wl_output_send_mode(host->resource, host->flags | WL_OUTPUT_MODE_CURRENT,
virt_width, virt_height, host->refresh);
width, height, host->refresh);
if (wl_resource_get_version(host->resource) >= WL_OUTPUT_SCALE_SINCE_VERSION)
wl_output_send_scale(host->resource, scale);
if (wl_resource_get_version(host->resource) >= WL_OUTPUT_DONE_SINCE_VERSION)
Expand Down Expand Up @@ -377,21 +321,6 @@ static void sl_output_geometry(void* data,
free(host->make);
host->make = strdup(make);
host->transform = transform;
// host_outputs is sorted by x. Delete then re-insert at the correct position.
wl_list_remove(&host->link);
// Insert at the end by default. If insert_at is not set in the loop,
// hosts's x is larger than all the ones in the list currently.
struct wl_list* insert_at = host->ctx->host_outputs.prev;
struct sl_host_output* iter;
wl_list_for_each(iter, &host->ctx->host_outputs, link) {
if (host->x < iter->x) {
// This is the first output whose x coordinate is to the right of host,
// therefore insert to the left of it.
insert_at = iter->link.prev;
break;
}
}
wl_list_insert(insert_at, &host->link);
}

static void sl_output_mode(void* data,
Expand Down Expand Up @@ -500,8 +429,6 @@ static void sl_destroy_host_output(struct wl_resource* resource) {
wl_list_remove(&host->link);
free(host->make);
free(host->model);
// Shift all outputs to the right of the deleted output to the left.
sl_output_shift_output_x(host, false);
delete host;
}

Expand Down Expand Up @@ -557,29 +484,22 @@ static void sl_bind_host_output(struct wl_client* client,
wl_display_get_registry(ctx->display), output->id, &wl_output_interface,
wl_resource_get_version(host->resource)));
wl_output_add_listener(host->proxy, &sl_output_listener, host);
output->host_output = host;
host->aura_output = NULL;
// We assume that first output is internal by default.
host->internal = wl_list_empty(&ctx->host_outputs);
host->x = 0;
host->y = 0;
host->virt_x = 0;
host->virt_y = 0;
host->logical_x = 0;
host->logical_y = 0;
host->physical_width = 0;
host->physical_height = 0;
host->virt_physical_width = 0;
host->virt_physical_height = 0;
host->subpixel = WL_OUTPUT_SUBPIXEL_UNKNOWN;
host->make = strdup("unknown");
host->model = strdup("unknown");
host->transform = WL_OUTPUT_TRANSFORM_NORMAL;
host->flags = 0;
host->width = 1024;
host->height = 768;
host->virt_width = 0;
host->virt_height = 0;
host->logical_width = 1024;
host->logical_height = 768;
host->refresh = 60000;
Expand Down
18 changes: 4 additions & 14 deletions sommelier-window.cc
Original file line number Diff line number Diff line change
Expand Up @@ -279,20 +279,10 @@ static void sl_internal_toplevel_configure(struct sl_window* window,
window->next_config.values[i++] = guest_y;
} else if (!(window->size_flags & (US_POSITION | P_POSITION))) {
window->next_config.mask |= XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y;
if (window->paired_surface && window->paired_surface->output) {
window->next_config.values[i++] =
window->paired_surface->output->virt_x +
(window->paired_surface->output->virt_width - width_in_pixels) / 2;
window->next_config.values[i++] =
window->paired_surface->output->virt_y +
(window->paired_surface->output->virt_height - height_in_pixels) /
2;
} else {
window->next_config.values[i++] =
window->ctx->screen->width_in_pixels / 2 - width_in_pixels / 2;
window->next_config.values[i++] =
window->ctx->screen->height_in_pixels / 2 - height_in_pixels / 2;
}
window->next_config.values[i++] =
window->ctx->screen->width_in_pixels / 2 - width_in_pixels / 2;
window->next_config.values[i++] =
window->ctx->screen->height_in_pixels / 2 - height_in_pixels / 2;
}
window->next_config.values[i++] = width_in_pixels;
window->next_config.values[i++] = height_in_pixels;
Expand Down
3 changes: 0 additions & 3 deletions sommelier.cc
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,6 @@ void sl_registry_handler(void* data,
output->version = MIN(3, version);
output->host_global = sl_output_global_create(output);
wl_list_insert(&ctx->outputs, &output->link);
output->host_output = NULL;
} else if (strcmp(interface, "wl_seat") == 0) {
struct sl_seat* seat =
static_cast<sl_seat*>(malloc(sizeof(struct sl_seat)));
Expand Down Expand Up @@ -883,8 +882,6 @@ static void sl_registry_remover(void* data,
wl_list_for_each(output, &ctx->outputs, link) {
if (output->id == id) {
sl_global_destroy(output->host_global);
if (output->host_output)
wl_resource_destroy(output->host_output->resource);
wl_list_remove(&output->link);
free(output);
return;
Expand Down
13 changes: 1 addition & 12 deletions sommelier.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2018 The ChromiumOS Authors
// Copyright 2018 The ChromiumOS Authors.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

Expand Down Expand Up @@ -212,7 +212,6 @@ struct sl_output {
uint32_t id;
uint32_t version;
struct sl_global* host_global;
struct sl_host_output* host_output;
struct wl_list link;
};

Expand All @@ -234,21 +233,13 @@ struct sl_host_output {
int y;
int physical_width;
int physical_height;
// The physical width/height after being scaled by
// sl_output_get_dimensions_original.
int virt_physical_width;
int virt_physical_height;
int subpixel;
char* make;
char* model;
int transform;
uint32_t flags;
int width;
int height;
// The width/height after being scaled by
// sl_output_get_dimensions_original.
int virt_width;
int virt_height;
int refresh;
int scale_factor;
int current_scale;
Expand All @@ -273,8 +264,6 @@ struct sl_host_output {
double virt_scale_y;
double xdg_scale_x;
double xdg_scale_y;
int virt_x;
int virt_y;
int32_t logical_width;
int32_t logical_height;
int32_t logical_x;
Expand Down

0 comments on commit fa86f5b

Please sign in to comment.