未验证 提交 66344068 编写于 作者: D Damian Wrobel 提交者: GitHub

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 <gdk/gdk.h> can be included directly."
 #endif

 #include <glib.h>

 G_BEGIN_DECLS

 #define GDK_WINDOWING_WAYLAND

 G_END_DECLS

 #endif  /* __GDKCONFIG_H__ */

Additionally headers like <gdk/gdkx.h> 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: NDamian Wrobel <dwrobel@ertelnet.rybnik.pl>
上级 d9a24814
......@@ -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
......@@ -5,6 +5,9 @@
#ifndef FLUTTER_SHELL_PLATFORM_LINUX_FL_RENDERER_X11_H_
#define FLUTTER_SHELL_PLATFORM_LINUX_FL_RENDERER_X11_H_
#include <gdk/gdk.h>
#ifdef GDK_WINDOWING_X11
#include <gdk/gdkx.h>
#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_
......@@ -5,7 +5,9 @@
#include "flutter/shell/platform/linux/public/flutter_linux/fl_view.h"
#include <gdk/gdkwayland.h>
#ifdef GDK_WINDOWING_X11
#include <gdk/gdkx.h>
#endif
#include <cstring>
#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.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册