From 5735427f192842481bc2ef71ca52a557920c55a5 Mon Sep 17 00:00:00 2001 From: yutent Date: Mon, 31 Jul 2023 20:14:01 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E8=BE=93=E5=85=A5=E6=B3=95?= =?UTF-8?q?=E5=80=99=E9=80=89=E6=A1=86=E8=B7=9F=E9=9A=8F=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/main.py b/main.py index 84ef3d4..b91f9fa 100755 --- a/main.py +++ b/main.py @@ -83,7 +83,10 @@ class WebKitWindow(Gtk.Window): # self.webview.load_uri("https://benchmark.wkit.fun") + # 解决输入法候选框跟随问题 + im.connect('preedit-started', self.on_preedit_changed) im.connect('preedit-changed', self.on_preedit_changed) + im.connect('preedit-finished', self.on_preedit_changed) @@ -94,9 +97,12 @@ class WebKitWindow(Gtk.Window): def on_preedit_changed(self, im): - print(p) + display = Gdk.Display.get_default() + p = display.get_pointer() # 光标位置 + x, y = self.get_position() # 窗口位置 + im.notify_focus_in() - im.notify_cursor_area(100, 200, 0,0) + im.notify_cursor_area(p.x - x, p.y - y, 0, 0) # 修正输入法跟随