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

Commit

Permalink
vm_tools: sommelier: no need to require xdg_wm_base version 3
Browse files Browse the repository at this point in the history
Requiring version 3 of the actual server seems to have been
unintentionally enforced when support for it was added to Sommelier.

I saw no internal reliance on version 3 in other aspects of Sommelier's
implementation, so we should remain flexible and only passthrough
requirements of the guest-side client, filtered by Sommelier's highest
level of support.

BUG=b:325125144
TEST=run sommelier with host-side sway as wayland server.
TEST=(in borealis vm) steam

Change-Id: Ic16080fdce66af5857efecafb143710d58863537
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform2/+/5293079
Reviewed-by: Max Lee <[email protected]>
Reviewed-by: Chloe Pelling <[email protected]>
Tested-by: Ryan Neph <[email protected]>
Commit-Queue: Ryan Neph <[email protected]>
  • Loading branch information
Ryan Neph authored and Chromeos LUCI committed Feb 22, 2024
1 parent 56c036d commit e76954e
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 11 deletions.
15 changes: 8 additions & 7 deletions sommelier-xdg-shell.cc
Original file line number Diff line number Diff line change
Expand Up @@ -440,17 +440,18 @@ static void sl_bind_host_xdg_shell(struct wl_client* client,
struct sl_context* ctx = (struct sl_context*)data;
struct sl_host_xdg_shell* host = new sl_host_xdg_shell();
host->ctx = ctx;
host->resource = wl_resource_create(client, &xdg_wm_base_interface,
std::min(version, XDG_SHELL_VERSION), id);
host->resource =
wl_resource_create(client, &xdg_wm_base_interface, version, id);
wl_resource_set_implementation(host->resource, &sl_xdg_shell_implementation,
host, sl_destroy_host_xdg_shell);
host->proxy = static_cast<xdg_wm_base*>(wl_registry_bind(
wl_display_get_registry(ctx->display), ctx->xdg_shell->id,
&xdg_wm_base_interface, std::min(version, XDG_SHELL_VERSION)));
host->proxy = static_cast<xdg_wm_base*>(
wl_registry_bind(wl_display_get_registry(ctx->display),
ctx->xdg_shell->id, &xdg_wm_base_interface, version));
xdg_wm_base_shim()->add_listener(host->proxy, &sl_xdg_shell_listener, host);
}

struct sl_global* sl_xdg_shell_global_create(struct sl_context* ctx) {
return sl_global_create(ctx, &xdg_wm_base_interface, XDG_SHELL_VERSION, ctx,
struct sl_global* sl_xdg_shell_global_create(struct sl_context* ctx,
uint32_t version) {
return sl_global_create(ctx, &xdg_wm_base_interface, version, ctx,
sl_bind_host_xdg_shell);
}
2 changes: 2 additions & 0 deletions sommelier-xdg-shell.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
#include "sommelier-util.h" // NOLINT(build/include_directory)
#include "xdg-shell-client-protocol.h" // NOLINT(build/include_directory)

#define SL_XDG_SHELL_MAX_VERSION 3u

struct sl_host_xdg_shell {
struct sl_context* ctx;
struct wl_resource* resource;
Expand Down
7 changes: 5 additions & 2 deletions sommelier.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "sommelier-tracing.h" // NOLINT(build/include_directory)
#include "sommelier-transform.h" // NOLINT(build/include_directory)
#include "sommelier-window.h" // NOLINT(build/include_directory)
#include "sommelier-xdg-shell.h" // NOLINT(build/include_directory)
#include "sommelier-xshape.h" // NOLINT(build/include_directory)
#ifdef GAMEPAD_SUPPORT
#include "libevdev/libevdev-shim.h"
Expand Down Expand Up @@ -597,17 +598,19 @@ void sl_registry_handler(void* data,
assert(xdg_shell);
xdg_shell->ctx = ctx;
xdg_shell->id = id;
xdg_shell->version = MIN(SL_XDG_SHELL_MAX_VERSION, version);
xdg_shell->internal = nullptr;
xdg_shell->host_global = nullptr;
assert(!ctx->xdg_shell);
ctx->xdg_shell = xdg_shell;
if (ctx->xwayland) {
xdg_shell->internal = static_cast<xdg_wm_base*>(wl_registry_bind(
registry, id, &xdg_wm_base_interface, XDG_SHELL_VERSION));
registry, id, &xdg_wm_base_interface, xdg_shell->version));
xdg_wm_base_add_listener(xdg_shell->internal,
&sl_internal_xdg_shell_listener, nullptr);
} else {
xdg_shell->host_global = sl_xdg_shell_global_create(ctx);
xdg_shell->host_global =
sl_xdg_shell_global_create(ctx, xdg_shell->version);
}
} else if (strcmp(interface, "zaura_shell") == 0) {
if (version >= MIN_AURA_SHELL_VERSION) {
Expand Down
5 changes: 3 additions & 2 deletions sommelier.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
#include "weak-resource-ptr.h" // NOLINT(build/include_directory)

#define SOMMELIER_VERSION "0.20"
#define XDG_SHELL_VERSION 3u
#define APPLICATION_ID_FORMAT_PREFIX "org.chromium.guest_os.%s"
#define NATIVE_WAYLAND_APPLICATION_ID_FORMAT \
APPLICATION_ID_FORMAT_PREFIX ".wayland.%s"
Expand Down Expand Up @@ -401,6 +400,7 @@ struct sl_viewporter {
struct sl_xdg_shell {
struct sl_context* ctx;
uint32_t id;
uint32_t version;
struct sl_global* host_global;
struct xdg_wm_base* internal;
};
Expand Down Expand Up @@ -565,7 +565,8 @@ struct sl_global* sl_data_device_manager_global_create(struct sl_context* ctx);

struct sl_global* sl_viewporter_global_create(struct sl_context* ctx);

struct sl_global* sl_xdg_shell_global_create(struct sl_context* ctx);
struct sl_global* sl_xdg_shell_global_create(struct sl_context* ctx,
uint32_t version);

struct sl_global* sl_gtk_shell_global_create(struct sl_context* ctx);

Expand Down

0 comments on commit e76954e

Please sign in to comment.