PasteFerry (隔空贴): clipboard and file sync across macOS, Windows and Linux. Direct-first, end-to-end encrypted. Optional official access: no server to host. Independent self-hosting remains available.
Dart airdrop-alternativeclipboardclipboard-sharingclipboard-synccopy-pastecross-platformend-to-end-encryptionfile-syncfile-transferfluttergolanglinuxmacosnat-traversalp2pself-hostedtailscaleuniversal-clipboardwebrtcwindows
fix(ui): enable the input method in quick paste on Linux X11
baiyuze572c6b3bb6e9
diff --git a/ui/lib/picker/picker_host.dart b/ui/lib/picker/picker_host.dartindex 0718a46..1414dd3 100644--- a/ui/lib/picker/picker_host.dart+++ b/ui/lib/picker/picker_host.dart@@ -17,6 +17,7 @@ import 'package:flutter/services.dart';/// onShow 窗口刚显示出来/// onHide 窗口被收起(点了窗口外面、切到别的程序)/// onHotkeyChanged {hotkey} Wayland 上用户在系统设置里改了快捷键+/// onFocusIn Linux:窗口拿到了焦点,重新打开输入法(见 linux/runner/picker_application.cc)class PickerHost {PickerHost([MethodChannel? channel]) : _ch = channel ?? const MethodChannel('pasteferry/picker');@@ -35,6 +36,9 @@ class PickerHost {onHide?.call();case 'onHotkeyChanged':onHotkeyChanged?.call('${(call.arguments as Map?)?['hotkey'] ?? ''}');+ case 'onFocusIn':+ // 和搜索框连着输入法时 TextInputConnection.show 发的是同一条:引擎据此调用 gtk_im_context_focus_in+ await SystemChannels.textInput.invokeMethod<void>('TextInput.show');}return null;});diff --git a/ui/linux/runner/picker_application.cc b/ui/linux/runner/picker_application.ccindex b4f02a6..0930e9f 100644--- a/ui/linux/runner/picker_application.cc+++ b/ui/linux/runner/picker_application.cc@@ -477,6 +477,15 @@ static void toggle_from_portal(PickerApplication* self, const gchar* token) {toggle(self, GDK_CURRENT_TIME);}+// 窗口拿到焦点时告诉 Dart,由它重新打开输入法(TextInput.show)。Flutter 只在 TextInput.show 时+// 调用 gtk_im_context_focus_in,不管窗口焦点;搜索框的焦点在窗口隐藏时就有了、之后不再变,+// X11 上 IBus 就一直不知道该把按键交给这个窗口,打不出中文。Wayland 上由合成器通知输入法,本来就没问题+static gboolean on_focus_in(GtkWidget*, GdkEvent*, gpointer data) {+ auto* self = PICKER_APPLICATION(data);+ if (gtk_widget_get_visible(GTK_WIDGET(self->window))) invoke(self, "onFocusIn");+ return FALSE;+}+static gboolean on_focus_out(GtkWidget*, GdkEvent*, gpointer data) {// 点了窗口外面、切到别的程序:收起,什么都不粘贴hide(PICKER_APPLICATION(data), TRUE);@@ -653,6 +662,7 @@ static void create_window(PickerApplication* self) {gtk_window_set_type_hint(window, GDK_WINDOW_TYPE_HINT_DIALOG);gtk_window_set_default_size(window, kWidth, kHeight);gtk_window_set_position(window, GTK_WIN_POS_CENTER);+ g_signal_connect(window, "focus-in-event", G_CALLBACK(on_focus_in), self);g_signal_connect(window, "focus-out-event", G_CALLBACK(on_focus_out), self);g_signal_connect(window, "delete-event", G_CALLBACK(on_delete), self);diff --git a/ui/test/picker_test.dart b/ui/test/picker_test.dartindex cc1db81..35638a1 100644--- a/ui/test/picker_test.dart+++ b/ui/test/picker_test.dart@@ -288,6 +288,19 @@ void main() {await tester.pump(const Duration(milliseconds: 200));});+ testWidgets('窗口拿到焦点(Linux 外壳发 onFocusIn)时重新打开输入法', (tester) async {+ final s = await open(tester);+ s.host.listen();+ tester.testTextInput.log.clear();+ await TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger.handlePlatformMessage(+ _channel.name,+ _channel.codec.encodeMethodCall(const MethodCall('onFocusIn')),+ (_) {},+ );+ await tester.pump();+ expect(tester.testTextInput.log.map((c) => c.method), contains('TextInput.show'));+ });+testWidgets('每次呼出都从「全部」、第一条、空搜索开始', (tester) async {final s = await open(tester);await tester.sendKeyEvent(LogicalKeyboardKey.tab);