From 66344068899635154addec16005167113b9c1e9d Mon Sep 17 00:00:00 2001 From: Damian Wrobel Date: Tue, 13 Oct 2020 04:54:44 +0200 Subject: [PATCH] Support Wayland only (without X11 support in gdk) (#21218) Adds a support for compiling flutter engine when gdk does not have X11 backend. In such a configuration the generated gdkconfig.h header file looks like the following: /* gdkconfig.h * * This is a generated file. Please modify `configure.ac' */ #ifndef __GDKCONFIG_H__ #define __GDKCONFIG_H__ #if !defined (__GDK_H_INSIDE__) && !defined (GDK_COMPILATION) #error "Only can be included directly." #endif #include G_BEGIN_DECLS #define GDK_WINDOWING_WAYLAND G_END_DECLS #endif /* __GDKCONFIG_H__ */ Additionally headers like are not available at all. Above configuration can be found on the most of the embedded systems. This patch enables compilation of X11 specific code only when gdk defines GDK_WINDOWING_X11. Signed-off-by: Damian Wrobel --- shell/platform/linux/fl_renderer_x11.cc | 4 ++++ shell/platform/linux/fl_renderer_x11.h | 5 +++++ shell/platform/linux/fl_view.cc | 26 ++++++++++++++++++------- 3 files changed, 28 insertions(+), 7 deletions(-) diff --git a/shell/platform/linux/fl_renderer_x11.cc b/shell/platform/linux/fl_renderer_x11.cc index 5fa6e5797..2c646b16c 100644 --- a/shell/platform/linux/fl_renderer_x11.cc +++ b/shell/platform/linux/fl_renderer_x11.cc @@ -3,6 +3,8 @@ // found in the LICENSE file. #include "fl_renderer_x11.h" +#ifdef GDK_WINDOWING_X11 + #include "flutter/shell/platform/linux/egl_utils.h" struct _FlRendererX11 { @@ -108,3 +110,5 @@ static void fl_renderer_x11_init(FlRendererX11* self) {} FlRendererX11* fl_renderer_x11_new() { return FL_RENDERER_X11(g_object_new(fl_renderer_x11_get_type(), nullptr)); } + +#endif // GDK_WINDOWING_X11 diff --git a/shell/platform/linux/fl_renderer_x11.h b/shell/platform/linux/fl_renderer_x11.h index 8c32dcd0b..d8d3b60f2 100644 --- a/shell/platform/linux/fl_renderer_x11.h +++ b/shell/platform/linux/fl_renderer_x11.h @@ -5,6 +5,9 @@ #ifndef FLUTTER_SHELL_PLATFORM_LINUX_FL_RENDERER_X11_H_ #define FLUTTER_SHELL_PLATFORM_LINUX_FL_RENDERER_X11_H_ +#include + +#ifdef GDK_WINDOWING_X11 #include #include "flutter/shell/platform/linux/fl_renderer.h" @@ -35,4 +38,6 @@ FlRendererX11* fl_renderer_x11_new(); G_END_DECLS +#endif // GDK_WINDOWING_X11 + #endif // FLUTTER_SHELL_PLATFORM_LINUX_FL_RENDERER_X11_H_ diff --git a/shell/platform/linux/fl_view.cc b/shell/platform/linux/fl_view.cc index d38ef5aa5..01711d125 100644 --- a/shell/platform/linux/fl_view.cc +++ b/shell/platform/linux/fl_view.cc @@ -5,7 +5,9 @@ #include "flutter/shell/platform/linux/public/flutter_linux/fl_view.h" #include +#ifdef GDK_WINDOWING_X11 #include +#endif #include #include "flutter/shell/platform/linux/fl_engine_private.h" @@ -131,17 +133,27 @@ static void fl_view_plugin_registry_iface_init( iface->get_registrar_for_plugin = fl_view_get_registrar_for_plugin; } +static FlRenderer* fl_view_get_renderer_for_display(GdkDisplay* display) { +#ifdef GDK_WINDOWING_X11 + if (GDK_IS_X11_DISPLAY(display)) { + return FL_RENDERER(fl_renderer_x11_new()); + } +#endif + + if (GDK_IS_WAYLAND_DISPLAY(display)) { + return FL_RENDERER(fl_renderer_wayland_new()); + } + + g_error("Unsupported GDK backend"); + + return nullptr; +} + static void fl_view_constructed(GObject* object) { FlView* self = FL_VIEW(object); GdkDisplay* display = gtk_widget_get_display(GTK_WIDGET(self)); - if (GDK_IS_X11_DISPLAY(display)) { - self->renderer = FL_RENDERER(fl_renderer_x11_new()); - } else if (GDK_IS_WAYLAND_DISPLAY(display)) { - self->renderer = FL_RENDERER(fl_renderer_wayland_new()); - } else { - g_error("Unsupported GDK backend"); - } + self->renderer = fl_view_get_renderer_for_display(display); self->engine = fl_engine_new(self->project, self->renderer); // Create system channel handlers. -- GitLab