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

Commit

Permalink
vm_tools: Adds DoNothing function to sommelier-util
Browse files Browse the repository at this point in the history
Adds utility function which makes reading implementation/listener structs a bit easier to understand at a glance without having to dig further.

BUG=None
TEST=Unittests run (trivial change anyway)

Change-Id: I1c8d368b2c03e33d26308c777f916f12f2877252
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform2/+/4656151
Reviewed-by: Chloe Pelling <[email protected]>
Tested-by: Justin Huang <[email protected]>
Commit-Queue: Justin Huang <[email protected]>
  • Loading branch information
Justin Huang authored and Chromeos LUCI committed Jun 30, 2023
1 parent 20c3ff8 commit e327ad7
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 95 deletions.
9 changes: 2 additions & 7 deletions compositor/sommelier-drm.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#include "../sommelier.h" // NOLINT(build/include_directory)
#include "../sommelier-tracing.h" // NOLINT(build/include_directory)
#include "../sommelier-util.h" // NOLINT(build/include_directory)
#include "sommelier-dma-buf.h" // NOLINT(build/include_directory)

#include <assert.h>
Expand Down Expand Up @@ -259,14 +260,8 @@ static void sl_drm_format(void* data,
}
}

static void sl_drm_modifier(void* data,
struct zwp_linux_dmabuf_v1* linux_dmabuf,
uint32_t format,
uint32_t modifier_hi,
uint32_t modifier_lo) {}

static const struct zwp_linux_dmabuf_v1_listener sl_linux_dmabuf_listener = {
sl_drm_format, sl_drm_modifier};
sl_drm_format, /*modifier=*/DoNothing};

static void sl_drm_callback_done(void* data,
struct wl_callback* callback,
Expand Down
9 changes: 2 additions & 7 deletions compositor/sommelier-shm.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#include "../sommelier.h" // NOLINT(build/include_directory)
#include "../sommelier-tracing.h" // NOLINT(build/include_directory)
#include "../sommelier-util.h" // NOLINT(build/include_directory)

#include <assert.h>
#include <stdlib.h>
Expand Down Expand Up @@ -275,14 +276,8 @@ static void sl_drm_format(void* data,
}
}

static void sl_drm_modifier(void* data,
struct zwp_linux_dmabuf_v1* linux_dmabuf,
uint32_t format,
uint32_t modifier_hi,
uint32_t modifier_lo) {}

static const struct zwp_linux_dmabuf_v1_listener sl_linux_dmabuf_listener = {
sl_drm_format, sl_drm_modifier};
sl_drm_format, /*modifier=*/DoNothing};

static void sl_destroy_host_shm(struct wl_resource* resource) {
struct sl_host_shm* host =
Expand Down
20 changes: 3 additions & 17 deletions sommelier-gtk-shell.cc
Original file line number Diff line number Diff line change
Expand Up @@ -47,19 +47,9 @@ static void sl_gtk_surface_set_dbus_properties(
zaura_surface_set_application_id(host->proxy, application_id_str);
} // NOLINT(whitespace/indent)

static void sl_gtk_surface_set_modal(struct wl_client* client,
struct wl_resource* resource) {}

static void sl_gtk_surface_unset_modal(struct wl_client* client,
struct wl_resource* resource) {}

static void sl_gtk_surface_present(struct wl_client* client,
struct wl_resource* resource,
uint32_t time) {}

static const struct gtk_surface1_interface sl_gtk_surface_implementation = {
sl_gtk_surface_set_dbus_properties, sl_gtk_surface_set_modal,
sl_gtk_surface_unset_modal, sl_gtk_surface_present};
sl_gtk_surface_set_dbus_properties, /*set_modal=*/DoNothing,
/*unset_modal=*/DoNothing, /*present=*/DoNothing};

static void sl_destroy_host_gtk_surface(struct wl_resource* resource) {
struct sl_host_gtk_surface* host =
Expand Down Expand Up @@ -109,13 +99,9 @@ static void sl_gtk_shell_set_startup_id(struct wl_client* client,
zaura_surface_set_startup_id(surface->proxy, host->startup_id);
}

static void sl_gtk_shell_system_bell(struct wl_client* client,
struct wl_resource* resource,
struct wl_resource* surface_resource) {}

static const struct gtk_shell1_interface sl_gtk_shell_implementation = {
sl_gtk_shell_get_gtk_surface, sl_gtk_shell_set_startup_id,
sl_gtk_shell_system_bell};
/*system_bell=*/DoNothing};

static void sl_destroy_host_gtk_shell(struct wl_resource* resource) {
struct sl_host_gtk_shell* host =
Expand Down
29 changes: 4 additions & 25 deletions sommelier-output.cc
Original file line number Diff line number Diff line change
Expand Up @@ -557,21 +557,10 @@ static void sl_aura_output_device_scale_factor(void* data,
host->device_scale_factor = device_scale_factor;
}

static void sl_aura_output_insets(void* data,
struct zaura_output* output,
int top,
int left,
int bottom,
int right) {}

static void sl_aura_output_logical_transform(void* data,
struct zaura_output* output,
int transform) {}

static const struct zaura_output_listener sl_aura_output_listener = {
sl_aura_output_scale, sl_aura_output_connection,
sl_aura_output_device_scale_factor, sl_aura_output_insets,
sl_aura_output_logical_transform};
sl_aura_output_device_scale_factor, /*insets=*/DoNothing,
/*logical_transform=*/DoNothing};

static void sl_destroy_host_output(struct wl_resource* resource) {
struct sl_host_output* host =
Expand Down Expand Up @@ -616,20 +605,10 @@ static void sl_xdg_output_logical_size(void* data,
host->expecting_logical_size = false;
}

static void sl_xdg_output_done(void* data,
struct zxdg_output_v1* zxdg_output_v1) {}

static void sl_xdg_output_name(void* data,
struct zxdg_output_v1* zxdg_output_v1,
const char* name) {}

static void sl_xdg_output_desc(void* data,
struct zxdg_output_v1* zxdg_output_v1,
const char* desc) {}

static const struct zxdg_output_v1_listener sl_xdg_output_listener = {
sl_xdg_output_logical_position, sl_xdg_output_logical_size,
sl_xdg_output_done, sl_xdg_output_name, sl_xdg_output_desc};
/*done=*/DoNothing,
/*name=*/DoNothing, /*desc=*/DoNothing};

static void sl_bind_host_output(struct wl_client* client,
void* data,
Expand Down
10 changes: 10 additions & 0 deletions sommelier-util.h
Original file line number Diff line number Diff line change
Expand Up @@ -187,4 +187,14 @@ void ForwardEvent(void* data, T* resource, InArgs... args) {
wl_function(host->resource, args...);
}

// Utility templated function to help readability of unimplemented/ignored
// implementations of listener/implementation functions.
// Example usage:
// static const struct zaura_output_listener sl_aura_output_listener = {
// DoNothing, DoNothing, DoNothing,
// DoNothing, DoNothing
// }
template <typename... InArgs>
void DoNothing(InArgs... ignored) {}

#endif // VM_TOOLS_SOMMELIER_SOMMELIER_UTIL_H_
12 changes: 1 addition & 11 deletions sommelier-window.cc
Original file line number Diff line number Diff line change
Expand Up @@ -181,18 +181,8 @@ void sl_commit(struct sl_window* window, struct sl_host_surface* host_surface) {
}
}

static void sl_internal_xdg_popup_configure(void* data,
struct xdg_popup* xdg_popup,
int32_t x,
int32_t y,
int32_t width,
int32_t height) {}

static void sl_internal_xdg_popup_done(void* data,
struct xdg_popup* xdg_popup) {}

static const struct xdg_popup_listener sl_internal_xdg_popup_listener = {
sl_internal_xdg_popup_configure, sl_internal_xdg_popup_done};
/*configure=*/DoNothing, /*done=*/DoNothing};

static void sl_internal_xdg_surface_configure(void* data,
struct xdg_surface* xdg_surface,
Expand Down
35 changes: 7 additions & 28 deletions sommelier.cc
Original file line number Diff line number Diff line change
Expand Up @@ -432,26 +432,6 @@ static void sl_internal_data_device_data_offer(
&sl_internal_data_offer_listener, host_data_offer);
}

static void sl_internal_data_device_enter(void* data,
struct wl_data_device* data_device,
uint32_t serial,
struct wl_surface* surface,
wl_fixed_t x,
wl_fixed_t y,
struct wl_data_offer* data_offer) {}

static void sl_internal_data_device_leave(void* data,
struct wl_data_device* data_device) {}

static void sl_internal_data_device_motion(void* data,
struct wl_data_device* data_device,
uint32_t time,
wl_fixed_t x,
wl_fixed_t y) {}

static void sl_internal_data_device_drop(void* data,
struct wl_data_device* data_device) {}

static void sl_internal_data_device_selection(
void* data,
struct wl_data_device* data_device,
Expand All @@ -466,9 +446,12 @@ static void sl_internal_data_device_selection(
}

static const struct wl_data_device_listener sl_internal_data_device_listener = {
sl_internal_data_device_data_offer, sl_internal_data_device_enter,
sl_internal_data_device_leave, sl_internal_data_device_motion,
sl_internal_data_device_drop, sl_internal_data_device_selection};
sl_internal_data_device_data_offer,
/*enter=*/DoNothing,
/*leave=*/DoNothing,
/*motion=*/DoNothing,
/*drop=*/DoNothing,
sl_internal_data_device_selection};

void sl_host_seat_added(struct sl_host_seat* host) {
struct sl_context* ctx = host->seat->ctx;
Expand Down Expand Up @@ -2426,10 +2409,6 @@ void sl_handle_property_notify(struct sl_context* ctx,
}
}

static void sl_internal_data_source_target(void* data,
struct wl_data_source* data_source,
const char* mime_type) {}

static void sl_internal_data_source_send(void* data,
struct wl_data_source* data_source,
const char* mime_type,
Expand Down Expand Up @@ -2467,7 +2446,7 @@ static void sl_internal_data_source_cancelled(
}

static const struct wl_data_source_listener sl_internal_data_source_listener = {
sl_internal_data_source_target, sl_internal_data_source_send,
/*target=*/DoNothing, sl_internal_data_source_send,
sl_internal_data_source_cancelled};

char* sl_copy_atom_name(xcb_get_atom_name_reply_t* reply) {
Expand Down

0 comments on commit e327ad7

Please sign in to comment.