wayland: Set the damage buffer size when supported

The preferred method for setting the damage region on compositor protocol versions 4 and above is to use wl_surface.damage_buffer. Use this when available and only fall back to wl_surface.damage on older versions.

Bumps the highest supported version of wl_compositor to version 4.
This commit is contained in:
Frank Praznik 2022-10-03 18:31:15 -04:00 committed by Ethan Lee
parent a8cb7bbe2f
commit ea5958009c
2 changed files with 12 additions and 4 deletions

View file

@ -849,7 +849,7 @@ display_handle_global(void *data, struct wl_registry *registry, uint32_t id,
/*printf("WAYLAND INTERFACE: %s\n", interface);*/ /*printf("WAYLAND INTERFACE: %s\n", interface);*/
if (SDL_strcmp(interface, "wl_compositor") == 0) { if (SDL_strcmp(interface, "wl_compositor") == 0) {
d->compositor = wl_registry_bind(d->registry, id, &wl_compositor_interface, SDL_min(3, version)); d->compositor = wl_registry_bind(d->registry, id, &wl_compositor_interface, SDL_min(4, version));
} else if (SDL_strcmp(interface, "wl_output") == 0) { } else if (SDL_strcmp(interface, "wl_output") == 0) {
Wayland_add_display(d, id); Wayland_add_display(d, id);
} else if (SDL_strcmp(interface, "wl_seat") == 0) { } else if (SDL_strcmp(interface, "wl_seat") == 0) {

View file

@ -522,9 +522,17 @@ surface_damage_frame_done(void *data, struct wl_callback *cb, uint32_t time)
{ {
SDL_WindowData *wind = (SDL_WindowData *)data; SDL_WindowData *wind = (SDL_WindowData *)data;
/* Set the damage region. */ /*
wl_surface_damage(wind->surface, 0, 0, * wl_surface.damage_buffer is the preferred method of setting the damage region
wind->window_width, wind->window_height); * on compositor version 4 and above.
*/
if (wl_compositor_get_version(wind->waylandData->compositor) >= 4) {
wl_surface_damage_buffer(wind->surface, 0, 0,
wind->drawable_width, wind->drawable_height);
} else {
wl_surface_damage(wind->surface, 0, 0,
wind->window_width, wind->window_height);
}
wl_callback_destroy(cb); wl_callback_destroy(cb);
wind->surface_damage_frame_callback = wl_surface_frame(wind->surface); wind->surface_damage_frame_callback = wl_surface_frame(wind->surface);