From 0325e590babb33963dc35283cd425b39290919e5 Mon Sep 17 00:00:00 2001 From: Sam Lakerveld Date: Fri, 26 Jul 2024 18:48:05 +0200 Subject: [PATCH] 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 --- engine/src/flutter/shell/platform/linux/fl_renderer.cc | 2 +- engine/src/flutter/shell/platform/linux/fl_view.cc | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/engine/src/flutter/shell/platform/linux/fl_renderer.cc b/engine/src/flutter/shell/platform/linux/fl_renderer.cc index 80bdbea2db..e2a98753e6 100644 --- a/engine/src/flutter/shell/platform/linux/fl_renderer.cc +++ b/engine/src/flutter/shell/platform/linux/fl_renderer.cc @@ -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) { diff --git a/engine/src/flutter/shell/platform/linux/fl_view.cc b/engine/src/flutter/shell/platform/linux/fl_view.cc index 77414b07cb..0eb08e0177 100644 --- a/engine/src/flutter/shell/platform/linux/fl_view.cc +++ b/engine/src/flutter/shell/platform/linux/fl_view.cc @@ -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));