diff --git a/src/video/wayland/SDL_waylandvideo.c b/src/video/wayland/SDL_waylandvideo.c index 23fa606ce5..158a0e541b 100644 --- a/src/video/wayland/SDL_waylandvideo.c +++ b/src/video/wayland/SDL_waylandvideo.c @@ -394,7 +394,7 @@ static void Wayland_SortOutputs(SDL_VideoData *vid) Wayland_SortOutputsByPriorityHint(vid); } -static void display_handle_done(void *data, struct wl_output *output); +static void handle_wl_output_done(void *data, struct wl_output *output); // Initialization/Query functions static bool Wayland_VideoInit(SDL_VideoDevice *_this); @@ -719,8 +719,7 @@ VideoBootStrap Wayland_bootstrap = { false }; -static void xdg_output_handle_logical_position(void *data, struct zxdg_output_v1 *xdg_output, - int32_t x, int32_t y) +static void handle_xdg_output_logical_position(void *data, struct zxdg_output_v1 *xdg_output, int32_t x, int32_t y) { SDL_DisplayData *internal = (SDL_DisplayData *)data; @@ -729,8 +728,7 @@ static void xdg_output_handle_logical_position(void *data, struct zxdg_output_v1 internal->has_logical_position = true; } -static void xdg_output_handle_logical_size(void *data, struct zxdg_output_v1 *xdg_output, - int32_t width, int32_t height) +static void handle_xdg_output_logical_size(void *data, struct zxdg_output_v1 *xdg_output, int32_t width, int32_t height) { SDL_DisplayData *internal = (SDL_DisplayData *)data; @@ -739,7 +737,7 @@ static void xdg_output_handle_logical_size(void *data, struct zxdg_output_v1 *xd internal->has_logical_size = true; } -static void xdg_output_handle_done(void *data, struct zxdg_output_v1 *xdg_output) +static void handle_xdg_output_done(void *data, struct zxdg_output_v1 *xdg_output) { SDL_DisplayData *internal = data; @@ -748,12 +746,11 @@ static void xdg_output_handle_done(void *data, struct zxdg_output_v1 *xdg_output * A wl-output.done event will be emitted in version 3 or higher. */ if (zxdg_output_v1_get_version(internal->xdg_output) < 3) { - display_handle_done(data, internal->output); + handle_wl_output_done(data, internal->output); } } -static void xdg_output_handle_name(void *data, struct zxdg_output_v1 *xdg_output, - const char *name) +static void handle_xdg_output_name(void *data, struct zxdg_output_v1 *xdg_output, const char *name) { SDL_DisplayData *internal = (SDL_DisplayData *)data; @@ -765,8 +762,7 @@ static void xdg_output_handle_name(void *data, struct zxdg_output_v1 *xdg_output } } -static void xdg_output_handle_description(void *data, struct zxdg_output_v1 *xdg_output, - const char *description) +static void handle_xdg_output_description(void *data, struct zxdg_output_v1 *xdg_output, const char *description) { SDL_DisplayData *internal = (SDL_DisplayData *)data; @@ -780,11 +776,11 @@ static void xdg_output_handle_description(void *data, struct zxdg_output_v1 *xdg } static const struct zxdg_output_v1_listener xdg_output_listener = { - xdg_output_handle_logical_position, - xdg_output_handle_logical_size, - xdg_output_handle_done, - xdg_output_handle_name, - xdg_output_handle_description, + handle_xdg_output_logical_position, + handle_xdg_output_logical_size, + handle_xdg_output_done, + handle_xdg_output_name, + handle_xdg_output_description, }; static void AddEmulatedModes(SDL_DisplayData *dispdata, int native_width, int native_height) @@ -865,16 +861,9 @@ static void AddEmulatedModes(SDL_DisplayData *dispdata, int native_width, int na } } -static void display_handle_geometry(void *data, - struct wl_output *output, - int x, int y, - int physical_width, - int physical_height, - int subpixel, - const char *make, - const char *model, - int transform) - +static void handle_wl_output_geometry(void *data, struct wl_output *output, int x, int y, + int physical_width, int physical_height, int subpixel, + const char *make, const char *model, int transform) { SDL_DisplayData *internal = (SDL_DisplayData *)data; @@ -922,12 +911,8 @@ static void display_handle_geometry(void *data, #undef TF_CASE } -static void display_handle_mode(void *data, - struct wl_output *output, - uint32_t flags, - int width, - int height, - int refresh) +static void handle_wl_output_mode(void *data, struct wl_output *output, uint32_t flags, + int width, int height, int refresh) { SDL_DisplayData *internal = (SDL_DisplayData *)data; @@ -948,8 +933,7 @@ static void display_handle_mode(void *data, } } -static void display_handle_done(void *data, - struct wl_output *output) +static void handle_wl_output_done(void *data, struct wl_output *output) { const bool mode_emulation_enabled = SDL_GetHintBoolean(SDL_HINT_VIDEO_WAYLAND_MODE_EMULATION, true); SDL_DisplayData *internal = (SDL_DisplayData *)data; @@ -1099,15 +1083,13 @@ static void display_handle_done(void *data, } } -static void display_handle_scale(void *data, - struct wl_output *output, - int32_t factor) +static void handle_wl_output_scale(void *data, struct wl_output *output, int32_t factor) { SDL_DisplayData *internal = (SDL_DisplayData *)data; internal->scale_factor = factor; } -static void display_handle_name(void *data, struct wl_output *wl_output, const char *name) +static void handle_wl_output_name(void *data, struct wl_output *wl_output, const char *name) { SDL_DisplayData *internal = (SDL_DisplayData *)data; @@ -1115,7 +1097,7 @@ static void display_handle_name(void *data, struct wl_output *wl_output, const c internal->wl_output_name = SDL_strdup(name); } -static void display_handle_description(void *data, struct wl_output *wl_output, const char *description) +static void handle_wl_output_description(void *data, struct wl_output *wl_output, const char *description) { SDL_DisplayData *internal = (SDL_DisplayData *)data; @@ -1127,12 +1109,12 @@ static void display_handle_description(void *data, struct wl_output *wl_output, } static const struct wl_output_listener output_listener = { - display_handle_geometry, // Version 1 - display_handle_mode, // Version 1 - display_handle_done, // Version 2 - display_handle_scale, // Version 2 - display_handle_name, // Version 4 - display_handle_description // Version 4 + handle_wl_output_geometry, // Version 1 + handle_wl_output_mode, // Version 1 + handle_wl_output_done, // Version 2 + handle_wl_output_scale, // Version 2 + handle_wl_output_name, // Version 4 + handle_wl_output_description // Version 4 }; static void handle_output_image_description_changed(void *data, @@ -1247,13 +1229,13 @@ static void Wayland_InitColorManager(SDL_VideoData *d) } } -static void handle_ping_xdg_wm_base(void *data, struct xdg_wm_base *xdg, uint32_t serial) +static void handle_xdg_wm_base_ping(void *data, struct xdg_wm_base *xdg, uint32_t serial) { xdg_wm_base_pong(xdg, serial); } -static const struct xdg_wm_base_listener shell_listener_xdg = { - handle_ping_xdg_wm_base +static const struct xdg_wm_base_listener _xdg_wm_base_listener = { + handle_xdg_wm_base_ping }; #ifdef HAVE_LIBDECOR_H @@ -1265,12 +1247,12 @@ static void libdecor_error(struct libdecor *context, } static struct libdecor_interface libdecor_interface = { - libdecor_error, + libdecor_error }; #endif -static void display_handle_global(void *data, struct wl_registry *registry, uint32_t id, - const char *interface, uint32_t version) +static void handle_registry_global(void *data, struct wl_registry *registry, uint32_t id, + const char *interface, uint32_t version) { SDL_VideoData *d = data; @@ -1285,7 +1267,7 @@ static void display_handle_global(void *data, struct wl_registry *registry, uint Wayland_DisplayCreateSeat(d, seat, id); } else if (SDL_strcmp(interface, "xdg_wm_base") == 0) { d->shell.xdg = wl_registry_bind(d->registry, id, &xdg_wm_base_interface, SDL_min(version, 7)); - xdg_wm_base_add_listener(d->shell.xdg, &shell_listener_xdg, NULL); + xdg_wm_base_add_listener(d->shell.xdg, &_xdg_wm_base_listener, NULL); } else if (SDL_strcmp(interface, "wl_shm") == 0) { d->shm = wl_registry_bind(registry, id, &wl_shm_interface, SDL_min(SDL_WL_SHM_VERSION, version)); } else if (SDL_strcmp(interface, "zwp_relative_pointer_manager_v1") == 0) { @@ -1348,7 +1330,7 @@ static void display_handle_global(void *data, struct wl_registry *registry, uint #endif } -static void display_remove_global(void *data, struct wl_registry *registry, uint32_t id) +static void handle_registry_remove_global(void *data, struct wl_registry *registry, uint32_t id) { SDL_VideoData *d = data; @@ -1383,8 +1365,8 @@ static void display_remove_global(void *data, struct wl_registry *registry, uint } static const struct wl_registry_listener registry_listener = { - display_handle_global, - display_remove_global + handle_registry_global, + handle_registry_remove_global }; #ifdef HAVE_LIBDECOR_H diff --git a/src/video/wayland/SDL_waylandwindow.c b/src/video/wayland/SDL_waylandwindow.c index f22c3b624c..5917f2552c 100644 --- a/src/video/wayland/SDL_waylandwindow.c +++ b/src/video/wayland/SDL_waylandwindow.c @@ -741,7 +741,7 @@ static const struct wl_callback_listener gles_swap_frame_listener = { gles_swap_frame_done }; -static void handle_configure_xdg_shell_surface(void *data, struct xdg_surface *xdg, uint32_t serial) +static void handle_xdg_surface_configure(void *data, struct xdg_surface *xdg, uint32_t serial) { SDL_WindowData *wind = (SDL_WindowData *)data; SDL_Window *window = wind->sdlwindow; @@ -755,11 +755,11 @@ static void handle_configure_xdg_shell_surface(void *data, struct xdg_surface *x } } -static const struct xdg_surface_listener shell_surface_listener_xdg = { - handle_configure_xdg_shell_surface +static const struct xdg_surface_listener _xdg_surface_listener = { + handle_xdg_surface_configure }; -static void handle_configure_xdg_toplevel(void *data, +static void handle_xdg_toplevel_configure(void *data, struct xdg_toplevel *xdg_toplevel, int32_t width, int32_t height, @@ -984,13 +984,13 @@ static void handle_configure_xdg_toplevel(void *data, wind->resizing = resizing; } -static void handle_close_xdg_toplevel(void *data, struct xdg_toplevel *xdg_toplevel) +static void handle_xdg_toplevel_close(void *data, struct xdg_toplevel *xdg_toplevel) { SDL_WindowData *window = (SDL_WindowData *)data; SDL_SendWindowEvent(window->sdlwindow, SDL_EVENT_WINDOW_CLOSE_REQUESTED, 0, 0); } -static void handle_xdg_configure_toplevel_bounds(void *data, +static void handle_xdg_toplevel_configure_bounds(void *data, struct xdg_toplevel *xdg_toplevel, int32_t width, int32_t height) { @@ -1029,13 +1029,13 @@ static void handle_xdg_toplevel_wm_capabilities(void *data, } static const struct xdg_toplevel_listener toplevel_listener_xdg = { - handle_configure_xdg_toplevel, - handle_close_xdg_toplevel, - handle_xdg_configure_toplevel_bounds, // Version 4 + handle_xdg_toplevel_configure, + handle_xdg_toplevel_close, + handle_xdg_toplevel_configure_bounds, // Version 4 handle_xdg_toplevel_wm_capabilities // Version 5 }; -static void handle_configure_xdg_popup(void *data, +static void handle_xdg_popup_configure(void *data, struct xdg_popup *xdg_popup, int32_t x, int32_t y, @@ -1086,28 +1086,28 @@ static void handle_configure_xdg_popup(void *data, } } -static void handle_done_xdg_popup(void *data, struct xdg_popup *xdg_popup) +static void handle_xdg_popup_done(void *data, struct xdg_popup *xdg_popup) { SDL_WindowData *window = (SDL_WindowData *)data; SDL_SendWindowEvent(window->sdlwindow, SDL_EVENT_WINDOW_CLOSE_REQUESTED, 0, 0); } -static void handle_repositioned_xdg_popup(void *data, +static void handle_xdg_popup_repositioned(void *data, struct xdg_popup *xdg_popup, uint32_t token) { // No-op, configure does all the work we care about } -static const struct xdg_popup_listener popup_listener_xdg = { - handle_configure_xdg_popup, - handle_done_xdg_popup, - handle_repositioned_xdg_popup +static const struct xdg_popup_listener _xdg_popup_listener = { + handle_xdg_popup_configure, + handle_xdg_popup_done, + handle_xdg_popup_repositioned }; -static void handle_configure_zxdg_decoration(void *data, - struct zxdg_toplevel_decoration_v1 *zxdg_toplevel_decoration_v1, - uint32_t mode) +static void handle_xdg_toplevel_decoration_configure(void *data, + struct zxdg_toplevel_decoration_v1 *zxdg_toplevel_decoration_v1, + uint32_t mode) { SDL_Window *window = (SDL_Window *)data; SDL_WindowData *internal = window->internal; @@ -1135,8 +1135,8 @@ static void handle_configure_zxdg_decoration(void *data, } } -static const struct zxdg_toplevel_decoration_v1_listener decoration_listener = { - handle_configure_zxdg_decoration +static const struct zxdg_toplevel_decoration_v1_listener xdg_toplevel_decoration_listener = { + handle_xdg_toplevel_decoration_configure }; #ifdef HAVE_LIBDECOR_H @@ -1621,7 +1621,7 @@ static void handle_surface_leave(void *data, struct wl_surface *surface, struct Wayland_RemoveOutputFromWindow(window, (SDL_DisplayData *)wl_output_get_user_data(output)); } -static void handle_preferred_buffer_scale(void *data, struct wl_surface *wl_surface, int32_t factor) +static void handle_surface_preferred_buffer_scale(void *data, struct wl_surface *wl_surface, int32_t factor) { SDL_WindowData *wind = data; @@ -1634,7 +1634,7 @@ static void handle_preferred_buffer_scale(void *data, struct wl_surface *wl_surf } } -static void handle_preferred_buffer_transform(void *data, struct wl_surface *wl_surface, uint32_t transform) +static void handle_surface_preferred_buffer_transform(void *data, struct wl_surface *wl_surface, uint32_t transform) { // Nothing to do here. } @@ -1642,18 +1642,18 @@ static void handle_preferred_buffer_transform(void *data, struct wl_surface *wl_ static const struct wl_surface_listener surface_listener = { handle_surface_enter, handle_surface_leave, - handle_preferred_buffer_scale, - handle_preferred_buffer_transform + handle_surface_preferred_buffer_scale, + handle_surface_preferred_buffer_transform }; -static void handle_preferred_fractional_scale(void *data, struct wp_fractional_scale_v1 *wp_fractional_scale_v1, uint32_t scale) +static void handle_fractional_scale_preferred(void *data, struct wp_fractional_scale_v1 *wp_fractional_scale_v1, uint32_t scale) { const double factor = (double)scale / 120.; // 120 is a magic number defined in the spec as a common denominator Wayland_HandlePreferredScaleChanged(data, factor); } static const struct wp_fractional_scale_v1_listener fractional_scale_listener = { - handle_preferred_fractional_scale + handle_fractional_scale_preferred }; static void frog_preferred_metadata_handler(void *data, struct frog_color_managed_surface *frog_color_managed_surface, uint32_t transfer_function, @@ -1697,16 +1697,16 @@ static const struct frog_color_managed_surface_listener frog_surface_listener = frog_preferred_metadata_handler }; -static void feedback_surface_preferred_changed(void *data, - struct wp_color_management_surface_feedback_v1 *wp_color_management_surface_feedback_v1, - uint32_t identity) +static void handle_surface_feedback_preferred_changed(void *data, + struct wp_color_management_surface_feedback_v1 *wp_color_management_surface_feedback_v1, + uint32_t identity) { SDL_WindowData *wind = (SDL_WindowData *)data; Wayland_GetColorInfoForWindow(wind, false); } static const struct wp_color_management_surface_feedback_v1_listener color_management_surface_feedback_listener = { - feedback_surface_preferred_changed + handle_surface_feedback_preferred_changed }; static void Wayland_SetKeyboardFocus(SDL_Window *window, bool set_focus) @@ -1922,7 +1922,7 @@ void Wayland_ShowWindow(SDL_VideoDevice *_this, SDL_Window *window) if (data->shell_surface_type == WAYLAND_SHELL_SURFACE_TYPE_XDG_TOPLEVEL || data->shell_surface_type == WAYLAND_SHELL_SURFACE_TYPE_XDG_POPUP) { data->shell_surface.xdg.surface = xdg_wm_base_get_xdg_surface(c->shell.xdg, data->surface); xdg_surface_set_user_data(data->shell_surface.xdg.surface, data); - xdg_surface_add_listener(data->shell_surface.xdg.surface, &shell_surface_listener_xdg, data); + xdg_surface_add_listener(data->shell_surface.xdg.surface, &_xdg_surface_listener, data); SDL_SetPointerProperty(SDL_GetWindowProperties(window), SDL_PROP_WINDOW_WAYLAND_XDG_SURFACE_POINTER, data->shell_surface.xdg.surface); if (data->shell_surface_type == WAYLAND_SHELL_SURFACE_TYPE_XDG_POPUP) { @@ -1967,7 +1967,7 @@ void Wayland_ShowWindow(SDL_VideoDevice *_this, SDL_Window *window) data->shell_surface.xdg.popup.xdg_popup = xdg_surface_get_popup(data->shell_surface.xdg.surface, parent_xdg_surface, data->shell_surface.xdg.popup.xdg_positioner); - xdg_popup_add_listener(data->shell_surface.xdg.popup.xdg_popup, &popup_listener_xdg, data); + xdg_popup_add_listener(data->shell_surface.xdg.popup.xdg_popup, &_xdg_popup_listener, data); if (window->flags & SDL_WINDOW_TOOLTIP) { struct wl_region *region; @@ -1991,7 +1991,7 @@ void Wayland_ShowWindow(SDL_VideoDevice *_this, SDL_Window *window) // Create the window decorations if (c->decoration_manager) { data->server_decoration = zxdg_decoration_manager_v1_get_toplevel_decoration(c->decoration_manager, data->shell_surface.xdg.toplevel.xdg_toplevel); - zxdg_toplevel_decoration_v1_add_listener(data->server_decoration, &decoration_listener, window); + zxdg_toplevel_decoration_v1_add_listener(data->server_decoration, &xdg_toplevel_decoration_listener, window); const enum zxdg_toplevel_decoration_v1_mode mode = !(window->flags & SDL_WINDOW_BORDERLESS) ? ZXDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE : ZXDG_TOPLEVEL_DECORATION_V1_MODE_CLIENT_SIDE; zxdg_toplevel_decoration_v1_set_mode(data->server_decoration, mode); } @@ -2227,7 +2227,7 @@ static void handle_xdg_activation_done(void *data, } } -static const struct xdg_activation_token_v1_listener activation_listener_xdg = { +static const struct xdg_activation_token_v1_listener xdg_activation_listener = { handle_xdg_activation_done }; @@ -2273,7 +2273,7 @@ static void Wayland_activate_window(SDL_VideoData *data, SDL_WindowData *target_ target_wind->activation_token = xdg_activation_v1_get_activation_token(data->activation_manager); xdg_activation_token_v1_add_listener(target_wind->activation_token, - &activation_listener_xdg, + &xdg_activation_listener, target_wind); /* Note that we are not setting the app_id here.