From 231fd4f1c235813908eda4b4812354d55ac2894e Mon Sep 17 00:00:00 2001 From: "Hans Elias B. Josephsen" Date: Tue, 18 Oct 2022 14:10:41 +0200 Subject: [PATCH 1/2] upgrade flutter engine --- subprojects/flutter_embedder/meson_options.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/subprojects/flutter_embedder/meson_options.txt b/subprojects/flutter_embedder/meson_options.txt index a2fb228..73be87a 100644 --- a/subprojects/flutter_embedder/meson_options.txt +++ b/subprojects/flutter_embedder/meson_options.txt @@ -1,2 +1,2 @@ -option('engine_commit', type: 'string', value: '890a5fca2e34db413be624fc83aeea8e61d42ce6', description: 'Commit of engine build to use') -option('engine_embedder_hash', type: 'string', value: '2ab7c40a7aef8ba4b5766a930e95e3d5bd92c70d8d8d6cc3f28bb690ec030b14', description: 'If present, sha256 hash to validate embedder build') +option('engine_commit', type: 'string', value: 'c08d7d5efc9aa6eb3c30cfb3be6dc09bca5e7631', description: 'Commit of engine build to use, c08d7d5efc9aa6eb3c30cfb3be6dc09bca5e7631 corresponding to flutter 3.3.4 by default') +option('engine_embedder_hash', type: 'string', value: 'f0b3e15746a15365d690e1f0e9d3bead6aa4e5664097e766b83a5779404cdbda', description: 'If present, sha256 hash to validate embedder build') From b1c6db2140ac6efcdcb93b097f7ce98ce9830804 Mon Sep 17 00:00:00 2001 From: "Hans Elias B. Josephsen" Date: Mon, 5 Dec 2022 15:24:35 +0100 Subject: [PATCH 2/2] fix interceptor binding and therefore keyboard input on flutter 3 --- .../lib/keyboard/platform_keyboard.dart | 1 + .../platform/interceptor_widgets_binding.dart | 23 ++++------- demo/lib/main.dart | 36 +++++++++-------- demo/linux/flutter/generated_plugins.cmake | 8 ++++ demo/pubspec.lock | 40 ++++++------------- include/platform_channel.h | 2 + src/flutter_wlroots.c | 1 + src/input.c | 6 +-- src/platform_channel.c | 8 +++- 9 files changed, 63 insertions(+), 62 deletions(-) diff --git a/compositor_dart/lib/keyboard/platform_keyboard.dart b/compositor_dart/lib/keyboard/platform_keyboard.dart index f4eb624..64eea63 100644 --- a/compositor_dart/lib/keyboard/platform_keyboard.dart +++ b/compositor_dart/lib/keyboard/platform_keyboard.dart @@ -137,6 +137,7 @@ class PlatformKeyboard { case 'TextInput.setClient': // arg: [client_id, https://api.flutter.dev/flutter/services/TextInputConfiguration-class.html] + assert(_keyboardClient == null); _keyboardClient = KeyboardClientController( connectionId: methodCall.arguments[0] as int, platformKeyboard: this, diff --git a/compositor_dart/lib/platform/interceptor_widgets_binding.dart b/compositor_dart/lib/platform/interceptor_widgets_binding.dart index f571d3a..cb610b4 100644 --- a/compositor_dart/lib/platform/interceptor_widgets_binding.dart +++ b/compositor_dart/lib/platform/interceptor_widgets_binding.dart @@ -5,27 +5,20 @@ import 'package:flutter/services.dart'; class InterceptorWidgetsBinding extends WidgetsFlutterBinding { InterceptorBinaryMessenger? _binaryMessenger; - static WidgetsBinding? instance; - - @override - void initInstances() { - super.initInstances(); - _binaryMessenger = InterceptorBinaryMessenger(super.defaultBinaryMessenger); - instance = this; - } - @override BinaryMessenger get defaultBinaryMessenger { - return _binaryMessenger == null - ? super.defaultBinaryMessenger - : _binaryMessenger!; + _binaryMessenger ??= InterceptorBinaryMessenger(super.defaultBinaryMessenger); + return _binaryMessenger!; } static WidgetsBinding ensureInitialized() { - if (InterceptorWidgetsBinding.instance == null) { - InterceptorWidgetsBinding(); + try { + return WidgetsBinding.instance; + } on FlutterError { + var constructedBinding = InterceptorWidgetsBinding(); + assert(constructedBinding == WidgetsBinding.instance); + return WidgetsBinding.instance; } - return InterceptorWidgetsBinding.instance!; } static void runApp(Widget app) { diff --git a/demo/lib/main.dart b/demo/lib/main.dart index cebcef4..bde660d 100644 --- a/demo/lib/main.dart +++ b/demo/lib/main.dart @@ -67,27 +67,31 @@ class _MyAppState extends State { KeyboardClientController? keyboardClient; bool shown = false; + void _setClient(KeyboardClientController? client) { + print("setclient"); + SchedulerBinding.instance!.addPostFrameCallback((duration) { + setState(() { + keyboardClient = client; + print(client?.inputConfiguration); + }); + }); + } + + void _setShown(bool shown) { + SchedulerBinding.instance!.addPostFrameCallback((duration) { + setState(() { + this.shown = shown; + }); + }); + } + // This widget is the root of your application. @override Widget build(BuildContext context) { return PlatformKeyboardWidget( callbacks: PlatformKeyboardCallbacks( - setClient: (client) { - print("setclient"); - SchedulerBinding.instance!.addPostFrameCallback((duration) { - setState(() { - keyboardClient = client; - print(client?.inputConfiguration); - }); - }); - }, - setShown: (shown) { - SchedulerBinding.instance!.addPostFrameCallback((duration) { - setState(() { - this.shown = shown; - }); - }); - }, + setClient: _setClient, + setShown: _setShown, ), child: Stack( textDirection: TextDirection.ltr, diff --git a/demo/linux/flutter/generated_plugins.cmake b/demo/linux/flutter/generated_plugins.cmake index 51436ae..2e1de87 100644 --- a/demo/linux/flutter/generated_plugins.cmake +++ b/demo/linux/flutter/generated_plugins.cmake @@ -5,6 +5,9 @@ list(APPEND FLUTTER_PLUGIN_LIST ) +list(APPEND FLUTTER_FFI_PLUGIN_LIST +) + set(PLUGIN_BUNDLED_LIBRARIES) foreach(plugin ${FLUTTER_PLUGIN_LIST}) @@ -13,3 +16,8 @@ foreach(plugin ${FLUTTER_PLUGIN_LIST}) list(APPEND PLUGIN_BUNDLED_LIBRARIES $) list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) endforeach(plugin) + +foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) + add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/linux plugins/${ffi_plugin}) + list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) +endforeach(ffi_plugin) diff --git a/demo/pubspec.lock b/demo/pubspec.lock index c8de885..16518de 100644 --- a/demo/pubspec.lock +++ b/demo/pubspec.lock @@ -7,7 +7,7 @@ packages: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.8.2" + version: "2.9.0" boolean_selector: dependency: transitive description: @@ -21,21 +21,14 @@ packages: name: characters url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" - charcode: - dependency: transitive - description: - name: charcode - url: "https://pub.dartlang.org" - source: hosted - version: "1.3.1" + version: "1.2.1" clock: dependency: transitive description: name: clock url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "1.1.1" collection: dependency: transitive description: @@ -63,7 +56,7 @@ packages: name: fake_async url: "https://pub.dartlang.org" source: hosted - version: "1.3.0" + version: "1.3.1" flutter: dependency: "direct main" description: flutter @@ -101,28 +94,28 @@ packages: name: matcher url: "https://pub.dartlang.org" source: hosted - version: "0.12.11" + version: "0.12.12" material_color_utilities: dependency: transitive description: name: material_color_utilities url: "https://pub.dartlang.org" source: hosted - version: "0.1.3" + version: "0.1.5" meta: dependency: transitive description: name: meta url: "https://pub.dartlang.org" source: hosted - version: "1.7.0" + version: "1.8.0" path: dependency: transitive description: name: path url: "https://pub.dartlang.org" source: hosted - version: "1.8.0" + version: "1.8.2" sky_engine: dependency: transitive description: flutter @@ -134,7 +127,7 @@ packages: name: source_span url: "https://pub.dartlang.org" source: hosted - version: "1.8.1" + version: "1.9.0" stack_trace: dependency: transitive description: @@ -155,35 +148,28 @@ packages: name: string_scanner url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "1.1.1" term_glyph: dependency: transitive description: name: term_glyph url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" + version: "1.2.1" test_api: dependency: transitive description: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.4.9" - typed_data: - dependency: transitive - description: - name: typed_data - url: "https://pub.dartlang.org" - source: hosted - version: "1.3.0" + version: "0.4.12" vector_math: dependency: transitive description: name: vector_math url: "https://pub.dartlang.org" source: hosted - version: "2.1.1" + version: "2.1.2" sdks: dart: ">=2.17.0-0 <3.0.0" flutter: ">=1.17.0" diff --git a/include/platform_channel.h b/include/platform_channel.h index c392dd9..94168fa 100644 --- a/include/platform_channel.h +++ b/include/platform_channel.h @@ -32,6 +32,7 @@ enum json_value_type { kJsonNull, kJsonTrue, kJsonFalse, + kJsonInteger, kJsonNumber, kJsonString, kJsonArray, @@ -41,6 +42,7 @@ struct json_value { enum json_value_type type; union { double number_value; + int64_t integer_value; char *string_value; struct { size_t size; diff --git a/src/flutter_wlroots.c b/src/flutter_wlroots.c index 05e2c32..45f8a2f 100644 --- a/src/flutter_wlroots.c +++ b/src/flutter_wlroots.c @@ -219,6 +219,7 @@ static void engine_cb_platform_message( error: // TODO(hansihe): Handle messages + //wlr_log(WLR_INFO, "Unhandled platform message: channel: %s %.*s", engine_message->channel, engine_message->message_size, engine_message->message); wlr_log(WLR_INFO, "Unhandled platform message: channel: %s", engine_message->channel); message_free(&name); diff --git a/src/input.c b/src/input.c index c021b48..4e73c2d 100644 --- a/src/input.c +++ b/src/input.c @@ -316,8 +316,8 @@ static void send_key_to_flutter(struct fwr_keyboard *keyboard, struct wlr_event_ | (keyboard_state_is_capslock_active(kb_state) << 1) | (keyboard_state_is_ctrl_active(kb_state) << 2) | (keyboard_state_is_alt_active(kb_state) << 3) - | (keyboard_state_is_numlock_active(kb_state) << 4) - | (keyboard_state_is_meta_active(kb_state) << 28); + | (keyboard_state_is_numlock_active(kb_state) << 4); + //| (keyboard_state_is_meta_active(kb_state) << 28); uint16_t scan_code = (uint16_t)event->keycode + 8; xkb_keysym_t key_code = xkb_state_key_get_one_sym(kb_state, scan_code); uint32_t unicode = xkb_state_key_get_utf32(kb_state, scan_code); @@ -373,7 +373,7 @@ static void send_key_to_flutter(struct fwr_keyboard *keyboard, struct wlr_event_ /* unicodeScalarValues */ {.type = kJsonNumber, .number_value = (flType == kFlutterKeyEventTypeDown ? unicode : 0x0)}, /* keyCode */ {.type = kJsonNumber, .number_value = (uint32_t) key_code}, /* scanCode */ {.type = kJsonNumber, .number_value = scan_code}, - /* modifiers */ {.type = kJsonNumber, .number_value = modifiers}, + /* modifiers */ {.type = kJsonInteger, .number_value = modifiers}, /* type */ {.type = kJsonString, .string_value = type} } } diff --git a/src/platform_channel.c b/src/platform_channel.c index e4c7feb..830a418 100644 --- a/src/platform_channel.c +++ b/src/platform_channel.c @@ -441,14 +441,17 @@ int platch_write_value_to_buffer_std(struct std_value* value, uint8_t **pbuffer) size_t platch_calc_value_size_json(struct json_value *value) { size_t size = 0; + char numBuffer[32]; + switch (value->type) { case kJsonNull: case kJsonTrue: return 4; case kJsonFalse: return 5; + case kJsonInteger: + return sprintf(numBuffer, "%ld", value->integer_value); case kJsonNumber: ; - char numBuffer[32]; return sprintf(numBuffer, "%g", value->number_value); case kJsonString: size = 2; @@ -503,6 +506,9 @@ int platch_write_value_to_buffer_json(struct json_value* value, uint8_t **pbuffe case kJsonFalse: *pbuffer += sprintf((char*) *pbuffer, "false"); break; + case kJsonInteger: + *pbuffer += sprintf((char*) *pbuffer, "%ld", value->integer_value); + break; case kJsonNumber: *pbuffer += sprintf((char*) *pbuffer, "%g", value->number_value); break;