try to add linux webview support

This commit is contained in:
haorendashu
2025-02-08 19:05:31 +08:00
parent 725234ce98
commit beb20091ee
20 changed files with 689 additions and 40 deletions

View File

@@ -8,6 +8,7 @@
#include <flutter_secure_storage_linux/flutter_secure_storage_linux_plugin.h>
#include <screen_retriever_linux/screen_retriever_linux_plugin.h>
#include <webview_cef/webview_cef_plugin.h>
#include <window_manager/window_manager_plugin.h>
void fl_register_plugins(FlPluginRegistry* registry) {
@@ -17,6 +18,9 @@ void fl_register_plugins(FlPluginRegistry* registry) {
g_autoptr(FlPluginRegistrar) screen_retriever_linux_registrar =
fl_plugin_registry_get_registrar_for_plugin(registry, "ScreenRetrieverLinuxPlugin");
screen_retriever_linux_plugin_register_with_registrar(screen_retriever_linux_registrar);
g_autoptr(FlPluginRegistrar) webview_cef_registrar =
fl_plugin_registry_get_registrar_for_plugin(registry, "WebviewCefPlugin");
webview_cef_plugin_register_with_registrar(webview_cef_registrar);
g_autoptr(FlPluginRegistrar) window_manager_registrar =
fl_plugin_registry_get_registrar_for_plugin(registry, "WindowManagerPlugin");
window_manager_plugin_register_with_registrar(window_manager_registrar);

View File

@@ -5,6 +5,7 @@
list(APPEND FLUTTER_PLUGIN_LIST
flutter_secure_storage_linux
screen_retriever_linux
webview_cef
window_manager
)

View File

@@ -1,6 +1,8 @@
#include <webview_cef/webview_cef_plugin.h>
#include "my_application.h"
int main(int argc, char** argv) {
initCEFProcesses(argc, argv);
g_autoptr(MyApplication) app = my_application_new();
return g_application_run(G_APPLICATION(app), argc, argv);
}

View File

@@ -6,6 +6,7 @@
#endif
#include "flutter/generated_plugin_registrant.h"
#include <webview_cef/webview_cef_plugin.h>
struct _MyApplication {
GtkApplication parent_instance;
@@ -54,6 +55,8 @@ static void my_application_activate(GApplication* application) {
fl_dart_project_set_dart_entrypoint_arguments(project, self->dart_entrypoint_arguments);
FlView* view = fl_view_new(project);
g_signal_connect(view, "key_press_event", G_CALLBACK(processKeyEventForCEF), nullptr);
g_signal_connect(view, "key_release_event", G_CALLBACK(processKeyEventForCEF), nullptr);
gtk_widget_show(GTK_WIDGET(view));
gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(view));