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) # 修正输入法跟随