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): reset the input method focus before re-enabling it on Linux
baiyuzef0569d178ae4
diff --git a/ui/lib/picker/picker_host.dart b/ui/lib/picker/picker_host.dartindex 1414dd3..453653a 100644--- a/ui/lib/picker/picker_host.dart+++ b/ui/lib/picker/picker_host.dart@@ -37,7 +37,9 @@ class PickerHost {case 'onHotkeyChanged':onHotkeyChanged?.call('${(call.arguments as Map?)?['hotkey'] ?? ''}');case 'onFocusIn':- // 和搜索框连着输入法时 TextInputConnection.show 发的是同一条:引擎据此调用 gtk_im_context_focus_in+ // 引擎收到 TextInput.hide、TextInput.show 时调用 gtk_im_context_focus_out、focus_in。+ // 先 hide:IBus 的输入上下文自认为还有焦点时(窗口收起时没人告诉它失去了焦点),focus_in 什么都不做+ await SystemChannels.textInput.invokeMethod<void>('TextInput.hide');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 0930e9f..4f38bf2 100644--- a/ui/linux/runner/picker_application.cc+++ b/ui/linux/runner/picker_application.cc@@ -477,9 +477,10 @@ 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 上由合成器通知输入法,本来就没问题+// 窗口拿到焦点时告诉 Dart,由它重新连一次输入法(TextInput.hide 再 TextInput.show,见 picker_host.dart)。+// Flutter 只在这两条消息上调用 gtk_im_context_focus_out、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");diff --git a/ui/test/picker_test.dart b/ui/test/picker_test.dartindex 35638a1..596391e 100644--- a/ui/test/picker_test.dart+++ b/ui/test/picker_test.dart@@ -298,7 +298,7 @@ void main() {(_) {},);await tester.pump();- expect(tester.testTextInput.log.map((c) => c.method), contains('TextInput.show'));+ expect(tester.testTextInput.log.map((c) => c.method), containsAllInOrder(['TextInput.hide', 'TextInput.show']));});testWidgets('每次呼出都从「全部」、第一条、空搜索开始', (tester) async {