Set GLArea.has-alpha = true (flutter/engine#54053)

GLArea.has-alpha defaults to false, which makes it impossible for a Flutter app to be transparent.

The additional change to glClearColor is to prevent a black flash when the application starts, before Flutter widgets become visible. This will also affect applications that aren't transparent, by showing the default GTK background color instead of black. This will not make the window transparent, because the developer currently has to add some code to their `linux/my_application.cc` to support transparency.

Fixes flutter/flutter#152154

Transparent windows were possible before #50754. Would it be ok to add a test for this to prevent breaking transparency again in the future?

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
This commit is contained in:
Sam Lakerveld 2024-07-26 18:48:05 +02:00 committed by GitHub
parent d29d4a12b3
commit 0325e590ba
2 changed files with 2 additions and 1 deletions

View File

@ -445,7 +445,7 @@ void fl_renderer_render(FlRenderer* self, int width, int height) {
g_return_if_fail(FL_IS_RENDERER(self));
glClearColor(0.0, 0.0, 0.0, 1.0);
glClearColor(0.0, 0.0, 0.0, 0.0);
glClear(GL_COLOR_BUFFER_BIT);
if (priv->has_gl_framebuffer_blit) {

View File

@ -743,6 +743,7 @@ static void fl_view_init(FlView* self) {
self);
self->gl_area = GTK_GL_AREA(gtk_gl_area_new());
gtk_gl_area_set_has_alpha(self->gl_area, TRUE);
gtk_widget_show(GTK_WIDGET(self->gl_area));
gtk_container_add(GTK_CONTAINER(self->event_box), GTK_WIDGET(self->gl_area));