wayland: Only set the surface opaque region if EGL transparency is disabled

Check if the "SDL_VIDEO_EGL_ALLOW_TRANSPARENCY" hint is enabled and don't mark surfaces as opqaue if it is.
This commit is contained in:
Frank Praznik 2022-05-16 18:18:55 -04:00 committed by Sam Lantinga
parent a20516d4f3
commit 146ea9b0e1
1 changed files with 25 additions and 13 deletions

View File

@ -44,6 +44,12 @@
#include <libdecor.h> #include <libdecor.h>
#endif #endif
SDL_FORCE_INLINE SDL_bool
EGLTransparencyEnabled()
{
return SDL_GetHintBoolean(SDL_HINT_VIDEO_EGL_ALLOW_TRANSPARENCY, SDL_FALSE);
}
SDL_FORCE_INLINE SDL_bool SDL_FORCE_INLINE SDL_bool
FloatEqual(float a, float b) FloatEqual(float a, float b)
{ {
@ -264,11 +270,13 @@ ConfigureWindowGeometry(SDL_Window *window)
data->pointer_scale_x = (float)fs_width / (float)output->width; data->pointer_scale_x = (float)fs_width / (float)output->width;
data->pointer_scale_y = (float)fs_height / (float)output->height; data->pointer_scale_y = (float)fs_height / (float)output->height;
region = wl_compositor_create_region(viddata->compositor); if (!EGLTransparencyEnabled()) {
wl_region_add(region, data->viewport_rect.x, data->viewport_rect.y, region = wl_compositor_create_region(viddata->compositor);
data->viewport_rect.w, data->viewport_rect.h); wl_region_add(region, data->viewport_rect.x, data->viewport_rect.y,
wl_surface_set_opaque_region(data->surface, region); data->viewport_rect.w, data->viewport_rect.h);
wl_region_destroy(region); wl_surface_set_opaque_region(data->surface, region);
wl_region_destroy(region);
}
} else { } else {
if (NeedViewport(window)) { if (NeedViewport(window)) {
wl_surface_set_buffer_scale(data->surface, 1); wl_surface_set_buffer_scale(data->surface, 1);
@ -285,10 +293,12 @@ ConfigureWindowGeometry(SDL_Window *window)
data->pointer_scale_x = 1.0f; data->pointer_scale_x = 1.0f;
data->pointer_scale_y = 1.0f; data->pointer_scale_y = 1.0f;
region = wl_compositor_create_region(viddata->compositor); if (!EGLTransparencyEnabled()) {
wl_region_add(region, 0, 0, window->w, window->h); region = wl_compositor_create_region(viddata->compositor);
wl_surface_set_opaque_region(data->surface, region); wl_region_add(region, 0, 0, window->w, window->h);
wl_region_destroy(region); wl_surface_set_opaque_region(data->surface, region);
wl_region_destroy(region);
}
} }
/* Recreate the pointer confinement region when the window geometry changes. */ /* Recreate the pointer confinement region when the window geometry changes. */
@ -1869,10 +1879,12 @@ int Wayland_CreateWindow(_THIS, SDL_Window *window)
} }
#endif /* SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH */ #endif /* SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH */
region = wl_compositor_create_region(c->compositor); if (!EGLTransparencyEnabled()) {
wl_region_add(region, 0, 0, window->w, window->h); region = wl_compositor_create_region(c->compositor);
wl_surface_set_opaque_region(data->surface, region); wl_region_add(region, 0, 0, window->w, window->h);
wl_region_destroy(region); wl_surface_set_opaque_region(data->surface, region);
wl_region_destroy(region);
}
if (c->relative_mouse_mode) { if (c->relative_mouse_mode) {
Wayland_input_lock_pointer(c->input); Wayland_input_lock_pointer(c->input);